Simple UART using DK nrf52832

I am new to Zephyr and I have been trying to get hold of a tutorial or a sample app that would indicate how I can use the UART on the nRF52832 for communications with another device.

I am using v1.9.99 nRF Connect SDK. 

I have been looking at the KConfig file in VSCode and have manged to tick the right boxes (Hello World app), but getting the APIs to work is where I am stuck,

Any help will be appreciated.

Cheers

Parents Reply
  • Thanks for the detailed reply. I have been looking into Zephyr documentation and it has information I am after.

    As a follow up question, how does the UART definition in the DTS/Overlay map to the UART APIs? I see in the documentation there are configuration APIs for pin mapping and strucutures for configuration of the UART itself, which duplicates the DTS configurations

    In the Simple UART example the call to device_get_binding() passes a string to a UART, I am guessing it then uses the UART configuration in the DTS file.

Children
  • Hi,

    When using UART, one of the APIs needs to be chosen. For example, choosing async API requires CONFIG_UART_ASYNC_API=y configuration option (in addition to CONFIG_SERIAL=y). An UART peripheral is defined using struct device
    const struct device *uart= device_get_binding(DT_LABEL(DT_NODELABEL(uart0)));

    In this example uart is the pointer which interacts with UART API. In the devicetree, uart0 would be the name of the devicetree node used which represents UART hardware controller on the chip. You can read more about the devicetree here.

    Best regards,
    Dejan

Related