UART with openThread

Hello Everyone, 

I'm developing an application which makes use of UART in open thread sdk. 

Now, libopenthread-nrf52840-sdk.a library already makes use of UART0, when I enable UART in sdk_config.h - it gives compilation error. 

As described here , I don't want to make use of USB or SPI libraries as I'm using them as well in my application. 

So, finally I want to use libopenthread-nrf52840-sdk.a library with one UART enabled for my application. 

Please suggest what settings are required to achieve that ? 

Thanks. 

 

 

Parents
  • Hi

    In this case, the easiest alternative could just be to use UART1 instead of UART0.

    This depends on how you control the UART. But if you use the same method as in the UART sample, it should be the following settings:

    #ifndef UART0_ENABLED
    #define UART0_ENABLED 0
    #endif
    
    #ifndef UART1_ENABLED
    #define UART1_ENABLED 1
    #endif
    
    #ifndef APP_UART_ENABLED
    #define APP_UART_ENABLED 1
    #endif
    
    #ifndef APP_UART_DRIVER_INSTANCE
    #define APP_UART_DRIVER_INSTANCE 1
    #endif
    

    Does this fix your issue?

    Regards,
    Sigurd Hellesvik

  • Hi, 

    Thanks for your quick reply. 

    I'm using serial_uartes example within peripheral examples. Can you please suggest settings when UART is controlled by nrf_serial library ? 

  • ashish_shukla said:
    To reproduce the issue, you can apply above settings to serial_uartes example.

    Can you post the settings you refer to, here?

    Regards,
    Sigurd Hellesvik

  • yes - the one shared by you. 

    #ifndef UART0_ENABLED
    #define UART0_ENABLED 0
    #endif

    #ifndef UART1_ENABLED
    #define UART1_ENABLED 1
    #endif

    #ifndef APP_UART_ENABLED
    #define APP_UART_ENABLED 1
    #endif

    #ifndef APP_UART_DRIVER_INSTANCE
    #define APP_UART_DRIVER_INSTANCE 1
    #endif

  • Hi

    Aha, now I have reproduced this issue, thank you for clarifying.

    I have not been able to fix it yet, but it is related to this answer.

    To find a solution, I will talk to some of my colleagues, and return tomorrow.

    Regards,
    Sigurd Hellesvik

  • Hi, 

    Do you have any update on this issue? 

    Regards, 

    Ashish Shukla

  • Hi,

    The issue is the pre-processor check in serial nrf_serial_init() - it should check if the legacy driver is actually enabled, not just if the legacy UART peripheral is present on the device.

    The fix is to use the same check as in the nrf_drv_uart_config_t struct:

    diff --git a/components/libraries/serial/nrf_serial.c b/components/libraries/serial/nrf_serial.c
    index 730f4e74..c2e6f6bb 100644
    --- a/components/libraries/serial/nrf_serial.c
    +++ b/components/libraries/serial/nrf_serial.c
    @@ -207,7 +207,7 @@ ret_code_t nrf_serial_init(nrf_serial_t const * p_serial,
         nrf_drv_uart_config_t drv_config;
         memcpy(&drv_config, p_drv_uart_config, sizeof(nrf_drv_uart_config_t));
         drv_config.p_context = (void *)p_serial;
    -#if defined(UARTE_PRESENT) && defined(UART_PRESENT)
    +#if defined(NRF_DRV_UART_WITH_UARTE) && defined(NRF_DRV_UART_WITH_UART)
         drv_config.use_easy_dma = (p_config->mode == NRF_SERIAL_MODE_DMA);
     #endif
         ret = nrf_drv_uart_init(&p_serial->instance,

    I tested it with the following configuration:

    // <q> UART_EASY_DMA_SUPPORT  - Driver supporting EasyDMA
     
    
    #ifndef UART_EASY_DMA_SUPPORT
    #define UART_EASY_DMA_SUPPORT 1
    #endif
    
    // <q> UART_LEGACY_SUPPORT  - Driver supporting Legacy mode
     
    
    #ifndef UART_LEGACY_SUPPORT
    #define UART_LEGACY_SUPPORT 0
    #endif
    
    // <e> UART0_ENABLED - Enable UART0 instance
    //==========================================================
    #ifndef UART0_ENABLED
    #define UART0_ENABLED 0
    #endif
    // <q> UART0_CONFIG_USE_EASY_DMA  - Default setting for using EasyDMA
     
    
    #ifndef UART0_CONFIG_USE_EASY_DMA
    #define UART0_CONFIG_USE_EASY_DMA 0
    #endif
    
    // </e>
    
    // <e> UART1_ENABLED - Enable UART1 instance
    //==========================================================
    #ifndef UART1_ENABLED
    #define UART1_ENABLED 1
    #endif
    // </e>
    
    // </e>
    
    // </h> 

    Regards,

    Vidar

Reply
  • Hi,

    The issue is the pre-processor check in serial nrf_serial_init() - it should check if the legacy driver is actually enabled, not just if the legacy UART peripheral is present on the device.

    The fix is to use the same check as in the nrf_drv_uart_config_t struct:

    diff --git a/components/libraries/serial/nrf_serial.c b/components/libraries/serial/nrf_serial.c
    index 730f4e74..c2e6f6bb 100644
    --- a/components/libraries/serial/nrf_serial.c
    +++ b/components/libraries/serial/nrf_serial.c
    @@ -207,7 +207,7 @@ ret_code_t nrf_serial_init(nrf_serial_t const * p_serial,
         nrf_drv_uart_config_t drv_config;
         memcpy(&drv_config, p_drv_uart_config, sizeof(nrf_drv_uart_config_t));
         drv_config.p_context = (void *)p_serial;
    -#if defined(UARTE_PRESENT) && defined(UART_PRESENT)
    +#if defined(NRF_DRV_UART_WITH_UARTE) && defined(NRF_DRV_UART_WITH_UART)
         drv_config.use_easy_dma = (p_config->mode == NRF_SERIAL_MODE_DMA);
     #endif
         ret = nrf_drv_uart_init(&p_serial->instance,

    I tested it with the following configuration:

    // <q> UART_EASY_DMA_SUPPORT  - Driver supporting EasyDMA
     
    
    #ifndef UART_EASY_DMA_SUPPORT
    #define UART_EASY_DMA_SUPPORT 1
    #endif
    
    // <q> UART_LEGACY_SUPPORT  - Driver supporting Legacy mode
     
    
    #ifndef UART_LEGACY_SUPPORT
    #define UART_LEGACY_SUPPORT 0
    #endif
    
    // <e> UART0_ENABLED - Enable UART0 instance
    //==========================================================
    #ifndef UART0_ENABLED
    #define UART0_ENABLED 0
    #endif
    // <q> UART0_CONFIG_USE_EASY_DMA  - Default setting for using EasyDMA
     
    
    #ifndef UART0_CONFIG_USE_EASY_DMA
    #define UART0_CONFIG_USE_EASY_DMA 0
    #endif
    
    // </e>
    
    // <e> UART1_ENABLED - Enable UART1 instance
    //==========================================================
    #ifndef UART1_ENABLED
    #define UART1_ENABLED 1
    #endif
    // </e>
    
    // </e>
    
    // </h> 

    Regards,

    Vidar

Children
No Data
Related