Hi all,
Am trying to make the GPIO work on RZ/A2M, such that I can map it to a physical pin to observe it on an oscilloscope.
I am using the led code as a reference and trying to make the PORT_D_PIN_3 work as a GPIO to observe.
static uint32_t gs_main_gpio_flg; /* Flag to toggle the signal on and off */ static int_t gs_my_gpio_handle; static st_r_drv_gpio_pin_rw_t gs_pd3_hi = { GPIO_PORT_D_PIN_3, GPIO_LEVEL_HIGH, GPIO_SUCCESS }; static st_r_drv_gpio_pin_rw_t gs_pd3_lo = { GPIO_PORT_D_PIN_3, GPIO_LEVEL_LOW, GPIO_SUCCESS }; static const r_gpio_port_pin_t gs_led_pin_list[] = { GPIO_PORT_D_PIN_3, }; /********************************************************************************************************************** * Function Name: GPIO Toggle * Description : This function is executed when the OSTM0 interrupt is received. * : In this sample code, the processing to toggle the GPIOs on the CPU board. * Arguments : uint32_t int_sense : Interrupt detection * : : INTC_LEVEL_SENSITIVE : Level sense * : : INTC_EDGE_TRIGGER : Edge trigger * Return Value : none *********************************************************************************************************************/ void GPIO_Toggle() { /* ==== Toggle GPIO ==== */ gs_main_gpio_flg ^= 1; if (MAIN_PRV_GPIO_ON == gs_main_gpio_flg) { direct_control(gs_my_gpio_handle, CTL_GPIO_PIN_WRITE, &gs_pd3_hi); } else { direct_control(gs_my_gpio_handle, CTL_GPIO_PIN_WRITE, &gs_pd3_lo); } } /********************************************************************************************************************** * End of function GPIO Toggle function ***********************************************************************************************************************/ int_t main(void) { /* GPIO initialization */ int_t err; st_r_drv_gpio_pin_list_t pin_gpio; /************************************************** * Initialise pins **************************************************/ gs_my_gpio_handle = direct_open("gpio", 0); if (gs_my_gpio_handle < 0) { /* stop execution */ while (true) { /* Spin here forever.. */ R_COMPILER_Nop(); } } /************************************************** * Initialise PD_3 pin parameterised in GPIO_SC_TABLE_MANUAL **************************************************/ pin_gpio.p_pin_list = gs_gpio_pin_list; pin_gpio.count = (sizeof(gs_gpio_pin_list)) / (sizeof(gs_gpio_pin_list[0])); err = direct_control(gs_my_gpio_handle, CTL_GPIO_INIT_BY_PIN_LIST, &pin_gpio); if (err < 0) { /* stop execution */ while (true) { /* Spin here forever.. */ R_COMPILER_Nop(); } } }
The code gets stuck in lines 77-85, kindly could you please help me with this?
Thanks!
Hope to hear from you soon.
Thanks!