Tool/software: Code Composer Studio
Hello
I want to control the GPIO output on AM65x EVM IDK. I survey the RTOS template application to understand the GPIO API.
I have serveal questions about GPIO API.
1. What is the usage of GPIO_socGetInitCfg() & GPIO_socSetInitCfg()? What happens if we don't call it before calling function like GPIO_write()?
// in main.c
void Board_initGPIO(void)
{
GPIO_v0_HwAttrs gpio_cfg;
/* Get the default SPI init configurations */
GPIO_socGetInitCfg(GPIO_LED0_PORT_NUM, &gpio_cfg);
/* Modify the default GPIO configurations if necessary */
GPIO_configIntRouter(GPIO_LED0_PORT_NUM, GPIO_LED0_PIN_NUM, 0, &gpio_cfg);
/* Set the default GPIO init configurations */
GPIO_socSetInitCfg(GPIO_LED0_PORT_NUM, &gpio_cfg);
}
2. The argument of most GPIO API only contains index information, no domain information. How these function help us to set a specific gpio pin.
Furthermore, in app.c it pass a enumerator - USER_LED0 to GPIO_toggle(). Why doesn't it pass the gpio index of target LED?
// in GPIO_board.h
typedef enum GPIO_LED {
USER_LED0 = 0,
USER_LED1
}GPIO_LED;
// in app.h
#define TEST_LED_GPIO_INDEX USER_LED0
// in app.c
void gpio_toggle_led_task(UArg arg0, UArg arg1)
{
appPrint("\n gpio_toggle_led task started");
while(1) {
/* Toggle test GPIO connected to LED */
GPIO_toggle(TEST_LED_GPIO_INDEX);
/* Delay to set period of pulse */
Task_sleep(LED_BLINK_DELAY_VALUE);
/* If end Test is triggered, then exit
* Note: The end test can be triggered through commands through uart
*/
if (g_endTestTriggered)
break;
};
appPrint("\n gpio_toggle_led task ended");
Task_exit();
}
3. There are some macro like "GPIO_LED0_PORT_NUM" in template. What is the definition of term "Port".
I couldn't find it (or I miss it) in the AM65x technical reference. Is the "Port" related to "Bank"?
Best regards.
ChingWei