This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

the question of the ble_app_uart in nRF52_SDK_0.9.2_dbc28c9

HI,ALL

there are two 'uart_event_handler' function in the project.

one in main, and the another in the app_uart_fifo.c

with the source code, i think when i input a character through uart, the 'uart_event_handler' in the app_uart_fifo.c call first,and call the 'uart_event_handler in main.

am i right?

thank you very much!!

  • Yes, you are right.

    A function pointer to your application's event handler (called uart_event_handle() in the example) is registered by the call to app_uart_init() (via APP_UART_FIFO_INIT()). There it is copied to m_event_handler in app_uart_fifo.c. In the same file there is a function called uart_event_handler(), which obviously is a completely different function, though it has almost the same name. This function is registered as the callback function in the driver.

    Now, when the driver makes a callback, it is to the uart_event_handler() in app_uart_fifo.c. There you will see, that the events are forwarded to your application by call to m_event_handler, which is a function pointer to the application's event handler.

Related