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

app_uart_put and app_uart_get mechanisms

Hi,

I'm writing a driver for a Ublox cellular module, which will be communicating with the nRF5240 using UART. After going back and forth, I decided to go with the app_uart implementation, as the nrf_serial might be a little overkill for my application.

I'd like to clarify exactly how the app_uart_get and app_uart_put functions work.

I understand there's an  event handler that can be assigned to the driver:

1. Regarding the APP_UART_DATA_READY event, is this event received when all bytes from the DCE are received, or is the event generated "per byte" received?

2. Same for the APP_UART_TX_EMPTY.. is this event generated when all bytes are transmitted or is it generated "per byte" transmitted.

3. What would be  the best way to use app_uart_get and app_uart_put to send a string? A while loop?

Parents
  • Hello,

    Looking at the ble_app_uart example, you can see the use of these events.

    1. APP_UART_DATA_READY is received "per byte", not when all bytes are received. However, the byte is stored in the FIFO module. You can use app_uart_get(uint8_t * p_byte) to get the next byte from this buffer. If it returns NRF_SUCCESS, it means that the byte was received and copied to the pointer, p_byte. If no byte was found, it will return NRF_ERROR_NOT_FOUND. This is described in app_uart.h on lines 212-223.

    2: APP_UART_TX_EMPTY means that all the data that you have pushed into the FIFO buffer using app_uart_put(uint8_t byte). app_uart_put() is described in app_uart.h on line 225-237. APP_UART_TX_EMPTY is described in app_uart.h on line 103:

    APP_UART_TX_EMPTY,            /**< An event indicating that UART has completed transmission of all available data in the TX FIFO. */

    I hope that clears things up. I recommend you study how this is used in the ble_app_uart example in the "normal" SDK found here:

    https://www.nordicsemi.com/Software-and-Tools/Software/nRF5-SDK

    Best regards,

    Edvin

  • Hi, Edvin 

    i want to mechanism like printf and scanf ,where the scanf will read the data from input interface. how can i do this in nordic . i want to read the data from input interface.

Reply Children
No Data
Related