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

How to add app_fifo with LIBUARTE ?

Hi All,

I used app_uart_fifo.c and it worked however RX is not good so I switched to LIBUARTE.

The RX part is good with LIBUARTE however when TX traffic is high nrf_libuarte_async_tx might skip data I need.

Any good idea to integrate app_fifo with LIBUARTE for TX and is there blocking API of nrf_libuarte_async_tx ?

BR,

Sam

Parents
  • Hi,

    It is not possible to run two different libraries on a single UART instance, this would require you to run libUARTE on UARTE0 for TX on GPIO P0.06 and app_uart_fifo on UARTE1 for RX on GPIO P0.08 or similar.

    What baudrate are you running at, and are you using HW flow control pins? I'm not sure that running two different libraries is the best solution to your issues. Are you checking error codes when calling nrf_libuarte_async_tx? This function should return NRF_ERROR_BUSY if a transfer is ongoing. You can then buffer the message in your application and start a new transfer as soon as you receive the NRF_LIBUARTE_ASYNC_EVT_TX_DONE event.

    Best regards,
    Jørgen

  • Hi,

    My idea is to port this stuff with nrf_libuarte_async_tx

    uint32_t app_uart_put(uint8_t byte)
    {
        uint32_t err_code;
    
        err_code = app_fifo_put(&m_tx_fifo, byte);
        if (err_code == NRF_SUCCESS)
        {
            // The new byte has been added to FIFO. It will be picked up from there
            // (in 'uart_event_handler') when all preceding bytes are transmitted.
            // But if UART is not transmitting anything at the moment, we must start
            // a new transmission here.
            if (!nrf_drv_uart_tx_in_progress())
            {
                // This operation should be almost always successful, since we've
                // just added a byte to FIFO, but if some bigger delay occurred
                // (some heavy interrupt handler routine has been executed) since
                // that time, FIFO might be empty already.
                if (app_fifo_get(&m_tx_fifo, tx_buffer) == NRF_SUCCESS)
                {
                    err_code = nrf_drv_uart_tx(tx_buffer, 1);
                }
            }
        }
    
        return err_code;
    }

    However I need equivalent nrf_drv_uart_tx_in_progress() API in libuarte however it's not available.

    BR,

    Sam 

Reply
  • Hi,

    My idea is to port this stuff with nrf_libuarte_async_tx

    uint32_t app_uart_put(uint8_t byte)
    {
        uint32_t err_code;
    
        err_code = app_fifo_put(&m_tx_fifo, byte);
        if (err_code == NRF_SUCCESS)
        {
            // The new byte has been added to FIFO. It will be picked up from there
            // (in 'uart_event_handler') when all preceding bytes are transmitted.
            // But if UART is not transmitting anything at the moment, we must start
            // a new transmission here.
            if (!nrf_drv_uart_tx_in_progress())
            {
                // This operation should be almost always successful, since we've
                // just added a byte to FIFO, but if some bigger delay occurred
                // (some heavy interrupt handler routine has been executed) since
                // that time, FIFO might be empty already.
                if (app_fifo_get(&m_tx_fifo, tx_buffer) == NRF_SUCCESS)
                {
                    err_code = nrf_drv_uart_tx(tx_buffer, 1);
                }
            }
        }
    
        return err_code;
    }

    However I need equivalent nrf_drv_uart_tx_in_progress() API in libuarte however it's not available.

    BR,

    Sam 

Children
No Data
Related