how to manipulating of GPIOs on Pulpissino platform
#2
(09-23-2019, 02:46 PM)mapletree Wrote: Hi,
I would like to do some manipulation of the user and general purchase I/Os of the pianissimo platform, for example to light up a user LED via pressing down a pushbutton.
I found the functions in the sdk runtime doc for configuring the gpio as a bus such as rt_gpio_init and rt_gpio_pin_configure etc, but I did not find any document mentioning the exact address/pin or registers that are corresponding to the LEDs or pushbuttons. I am wondering where to get the detailed info of such so that I can light up a user LED?

Thanks,
Mapletree

Hi Mapletree,

You can use the following example:

  
Code:
/*
* This example shows how drive a GPIO as an output.
*/

#include "rt/rt_data.h"
#include <stdio.h>
#include <rt/rt_api.h>
#include <stdint.h>


#define GPIO 5 // LED0 on Genesys2 board
unsigned int __rt_iodev_uart_baudrate = 115200;
int __rt_fpga_fc_frequency = 20000000;
int __rt_fpga_periph_frequency = 10000000;

int main()
{
 // GPIO initialization
 rt_pad_set_function(GPIO, 1); //pad_func=1 means gpio functionality. pad_func=0 is default (e.g. in this case spim_csn1)
 rt_gpio_init(0, GPIO);

 // Configure GPIO as an outpout
 rt_gpio_set_dir(0, 1<<GPIO, RT_GPIO_IS_OUT);

 // Now set the output value

 rt_gpio_set_pin_value(0, GPIO, 1);

 return 0;
}


Unfortunately, the documentation on that regard is a little bit lacking. Here is a summary of the GPIO/Pad association currently in use:

 Pad Name    Assigned GPIO 
---------------------------
 spim_sdio0  GPIO 0        
 spim_sdio1  GPIO 1        
 spim_sdio2  GPIO 2        
 spim_sdio3  GPIO 3        
 spim_csn0   GPIO 4        
 spim_csn1   GPIO 5        
 spim_sck    GPIO 6        
 uart_rx     GPIO 7        
 uart_tx     GPIO 8        
 cam_pclk    GPIO 9        
 cam_hsync   GPIO 10       
 cam_data0   GPIO 11       
 cam_data1   GPIO 12       
 cam_data2   GPIO 13       
 cam_data3   GPIO 14       
 cam_data4   GPIO 15       
 cam_data5   GPIO 16       
 cam_data6   GPIO 17       
 cam_data7   GPIO 18       
 cam_vsync   GPIO 19       
 sdio_clk    GPIO 20       
 sdio_cmd    GPIO 21       
 sdio_data0  GPIO 22       
 sdio_data1  GPIO 23       
 sdio_data2  GPIO 24       
 sdio_data3  GPIO 25       
 i2c0_sda    GPIO 26       
 i2c0_scl    GPIO 27       
 i2s0_sck    GPIO 28       
 i2s0_ws     GPIO 29       
 i2s0_sdi    GPIO 30       
 i2s1_sdi    GPIO 31       



You can find this information in the pulpissimo/pad_control.sv.
I hope this helps.
Greetings,
Manuel
Reply


Messages In This Thread
RE: how to manipulating of GPIOs on Pulpissino platform - by meggiman - 09-30-2019, 09:23 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)