Hi,
I am using WiRa 10.440.8.6 SDK on the Dialog 14695. I am implementing a UART solution with FreeRTOS. I am trying to find a good way to receive UART messages from another device.
I am using hw_uart_receive(HW_UART3, &var, 1, uart_data_cb, &var) from a main task. Once I receive 1 byte in the callback uart_data_cb, I am notifying the main task which then issues another hw_uart_receive(HW_UART3, &var, 1, uart_data_cb, &var). I am trying to get 1 byte at a time since I dont know the number of bytes that I can receive.
I am using the callback so that the Interrupt Handler can be used. Otherwise, the hw_uart_receive just blocks and spins.
Is there a good way to implement the UART receive handler using the Dialog UART APIs which will help get the UART data reliably. I dont know how many bytes I will receive, so I think it needs to be interrupt based.
Any help will be appreciated.
Thanks and Regards,
Subramanyan
Hi,
Rephrasing the same question, is there any way to do interrupt based UART receive for multiple bytes. The only reqirement is that I don't know the number of bytes that I will receive. So, I need to receive the data whenever the UART receives it.
Hi Subramanyan,
Thanks for your question online. Generally, we strongly recommend the usage of the adapters instead of Low Level Drivers(LLD) for accessing hardware peripherals because not only provide access to the peripheral, but also make sure that other tasks which are currently accessing it, suspend their operation until the peripheral is once again released. So you don't have to worry if another task tries accessing the same peripheral at the same time. Also, in sleep mode all the peripheral blocks are powered down.
The adapters start with “ad_” and the LLD with “hw_”
To do so, for accessing the UART peripheral block, I’d suggest to use the UART adapter. Please take a look at theDA1469x UART adapter examplefrom our support page.
The ad_uart_read() calls the hw_uart_receive(). If you go through the suggested example code, you will see that the application waits for one char synchronously and if there is a successful read, then it writes back the char to UART (echo).
Please also check the comments of the ad_uart_read() function in ad_uart.h – the rlen parameter sets the number of bytes to be read.
Thanks, PM_Dialog
Thanks, PM_Dialog. I saw the adapter implemenation and saw that it was also calling the LLD only. So, I did not think of using it.
I will check this.