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

Zephyr + Argon (nRF52840) + UART with interrupts

Howdy,

I'm trying to get Zypher up and running with the Particle Argon board using the nRF52840 chipset. The goal is to get both Bluetooth and UART working, but for now the question is, "How do I enable UART0 with interrupts".

Background: I'm using using PlatformIO as the IDE, a J-Link for debugging / programming, and Zephyr as the RTOS. PlatformIO is configured and able to write and debug to the board. Zephyr has the call uart_callback_set that let's a user register a callback. However, the compiler report back: undefined reference to `uart_callback_set'. In the uart.h file, uart_callback_set relies on a #define called CONFIG_UART_ASYNC_API. After reading around, this should be unlockable through the project.conf file. I've configured mine based on the Zephyr docs and this post, though it is a different chipset. Here is the config file:

CONFIG_DEBUG_OPTIMIZATIONS=y
CONFIG_EXCEPTION_STACK_TRACE=y
CONFIG_DEBUG_INFO=y

BOARD_ADAFRUIT_FEATHER_NRF52840=n

#UART Config
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=n
CONFIG_SERIAL_SUPPORT_ASYNC=y
CONFIG_SERIAL_SUPPORT_INTERRUPT=y

CONFIG_UART_ASYNC_API=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_0_INTERRUPT_DRIVEN=y
CONFIG_UART_0_NRFE_UART=y
CONFIG_UART_ASYNC_API=y
CONFIG_UART_NRF=y

Extra: I can find the device using the device tree label:

struct device *uart_device = device_get_binding("UART_0");

Edit 1 - uart_poll_out and uart_poll_in work, but pretty much none of the other uart_ calls will compile. Checked via a loop back wire and a logic analyzer.

Parents
  • Ok, so I figured it out. After reading the PlatformIO docs on Zephyr, they require the prj.conf file in the Zephyr folder along with the CMakeLists.txt file. This is different than the Zephyr docs, as they request the prj.conf to be at the top level. 

    Secondly, any change to the prj.conf requires a Clean -> Build under PlatformIO. Not sure if this is a feature or a bug.

    The final prj.cong file UART settings that work are:

     

    CONFIG_SERIAL=y
    # CONFIG_UART_CONSOLE=n
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_UART_ASYNC_API=y

    This unlocks all the uart functions as documented by Zephyr. 

    The clue was that the .config file compiled by Zephyr was not matching the prj.conf settings.

    Sorry for the trouble and hope this helps someone in the future.

    Austin

    Edit 1 - Thanks to Simon for confirming that the code worked on his end!

Reply
  • Ok, so I figured it out. After reading the PlatformIO docs on Zephyr, they require the prj.conf file in the Zephyr folder along with the CMakeLists.txt file. This is different than the Zephyr docs, as they request the prj.conf to be at the top level. 

    Secondly, any change to the prj.conf requires a Clean -> Build under PlatformIO. Not sure if this is a feature or a bug.

    The final prj.cong file UART settings that work are:

     

    CONFIG_SERIAL=y
    # CONFIG_UART_CONSOLE=n
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_UART_ASYNC_API=y

    This unlocks all the uart functions as documented by Zephyr. 

    The clue was that the .config file compiled by Zephyr was not matching the prj.conf settings.

    Sorry for the trouble and hope this helps someone in the future.

    Austin

    Edit 1 - Thanks to Simon for confirming that the code worked on his end!

Children
No Data
Related