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

drv_uart vs uart_app functions

Hi,

Are the functions implemented in drv_uart and uart_app even related to each other? I noticed that uart_app implements only some simple functions. Can someone please explain to me the differences between these implementations? Can I freely call the functions from either of them? Are they any different from the blocking point of view?

-vala

Parents
  • App_uart or app_uart_fifo uses nrf_drv_uart. The FIFO (or buffer, not to be confused with the uart peripheral FIFO) in app_uart_fifo is implemented with the app_fifo module.

    You should not used app_uart functions and nrf_drv_uart functions in the same project unless you know exactly what you are doing.

  • I am also very confused by these two implementations. I am trying to port an application using s110 6 with SDK 8 to the latest SoftDevice and SDK that can be supported by the nRF51822. Boy have there been changes!

    In the original project there was only need for initialization, simple_uart_put, and an interrupt handler. The interrupt hander was defined in the arm_startup asm file. The original project used that interrupt handler in its main.c. Now it seems that the nrf_driver_uart uses that same damn interrupt, causing a conflict. I took an example thermometer from the latest version and am moving that to my health device implementation (a pulse ox). It has that nrf_driver_uart along for the ride. Can I just get rid of it and use the app_uart methods?

    How does one come to terms with this confusion? The documentation is all over the place and is no help at all.

Reply
  • I am also very confused by these two implementations. I am trying to port an application using s110 6 with SDK 8 to the latest SoftDevice and SDK that can be supported by the nRF51822. Boy have there been changes!

    In the original project there was only need for initialization, simple_uart_put, and an interrupt handler. The interrupt hander was defined in the arm_startup asm file. The original project used that interrupt handler in its main.c. Now it seems that the nrf_driver_uart uses that same damn interrupt, causing a conflict. I took an example thermometer from the latest version and am moving that to my health device implementation (a pulse ox). It has that nrf_driver_uart along for the ride. Can I just get rid of it and use the app_uart methods?

    How does one come to terms with this confusion? The documentation is all over the place and is no help at all.

Children
  • Hi,

    You are free to use whatever way you want for interaction with the UART peripheral. Writing to the registers and defining your own interrupt handler works well, but for those that does not want to implement that on their own, we provide drivers and libraries that handle lower layer operations through a higher level API, linke app_uart. As you noticed, only one interrupt handler can be defined in the project, if not you will get multiple definitions error and the interrupt would not know which interrupt handler to call.

    Which path suits your application best is not easy for us to answer, you need to look at your own requirements and make a decision. 

    brianreinhold said:
    I took an example thermometer from the latest version and am moving that to my health device implementation (a pulse ox). It has that nrf_driver_uart along for the ride. Can I just get rid of it and use the app_uart methods?

    What is the "latest version"? What is the nrf_drv_uart used for in that example? You cannot "get rid of it and use app_uart methods", as app_uart uses nrf_drv_uart internally, but you could possibly remove API calls directly to nrf_drv_uart in an application and replace it with app_uart calls, but this depends on the application.

    Best regards,
    Jørgen

  • I changed the name of the interrupt handler that I used to something else since the NRF driver was using that name. In the s110 sdk 8 I guess the NRF driver did not use that name. But SDK 12.3.1 for s130 does. Wont be able to test my solution until I deploy it on a production device. But at least it builds.

  • The interrupt handler name should be UART0_IRQHandler() if the handler should be called when an interrupt is triggered. If this was the name of your handler and you changed it, the UART handling in your old application will/may not work anymore.

  • If I use that name the linker fails as the name is also defined in nrf_driver_uart.c here

    #if UART0_ENABLED
    void UART0_IRQHandler(void)
    {
        CODE_FOR_UARTE_INT
        (
            UART0_INSTANCE_INDEX,
            uarte_irq_handler(NRF_UARTE0, &m_cb[UART0_INSTANCE_INDEX]);
        )
        CODE_FOR_UART
        (
            uart_irq_handler(NRF_UART0, &m_cb[UART0_INSTANCE_INDEX]);
        )
    }
    #endif

    How should I deal with that? Turn off UART0?

  • Do you need to use the UART driver for anything, or are you fine with how the UART implementation you already have works?

    If it works, there is no need to change it. You can then disable/remove the UART driver from the project.

Related