Looking at the code in ad_uart.c I can see the following:
void ad_uart_write_async(uart_device dev, const char *wbuf, size_t wlen, ad_uart_user_cb cb,
void *user_data)
{
uart_device_config *device = (uart_device_config *) dev;
uart_bus_dynamic_data *data = device->bus_data;
if ((device->flags & AD_UART_DEVICE_FLAGS_LOCKING_ASYNC)) {
ad_uart_bus_acquire_ex(dev, AD_UART_RES_TYPE_WRITE);
}
data->write_cb = cb;
data->write_cb_data = user_data;
hw_uart_send(设备- > bus_id (const uint8_t *) wbuf, wlen, ad_uart_write_callback, dev);
}
It seems that the "ad_uart_bus_acquire_ex(..)" function is called, when the AD_UART_DEVICE_FLAGS_LOCKING_ASYNC is set.
My interpretation of this code snippet is, that I do not have to call the ad_uart_bus_acquire_ex(..) by myself when using the async call function in case the device flag is set.
How to configure the UART or the adapter, that this flag is set?
Best regards
Dieter
Hi Dieter,
Let me check your question and revert back to you as soon as possible.
Thanks, PM_Dialog
Hi Dieter,
Can you please clarify your question and share more inputs about what you are trying to accomplish? Generally, I would strongly recommend you to not modify the adapters and the SDK files. The adapters should be used at they are provided by the SDK. If you do any modifications, there is not guarantee they will work as expected.
Thanks, PM_Dialog
Hello,
I want to know how to use the uart adapter in case of async. transfer modes. The example in you documentation just shows the nomal (blocking) mode.
And therefore I had a look in the adapter code (which I do not want to change for sure) and it was not clear for me how to use this code correctly. This can be either a sequence of code like in the example or as I said some hint how to configure the UART correctly when the intended use is asyncchronous transfer.
I hope this clarify my question for you. If you need more details for answering my question, please let me know.
Best regards
Dieter
Hi Dieter,
Can I ask in which example you are referring to? You should open the adapter with the desired UART configurations, The ad_uart_open() should be used in order to open the adapter. Then you should execute the ad_uart_write_async() for the asynchronous UART write. At the end, you should use until all the UART transactions are finished and close the adapter (ad_uart_close).
Thanks, PM_Dialog
Hello,
the example I was taking about is in your documentation: DA1468x Software Platform Reference
The sequence you described in your answer was exactly that what I implemented. So this did not really help. Therefore I had a closer look to the definition of AD_UART_DEVICE_FLAGS_LOCKING_ASYNC. This flag is checked in ad_uart_write_async (..) function to do the necessary call to ad_uart_bus_acquire_ex(dev, AD_UART_RES_TYPE_WRITE);
My initial question was how to configure the UART that this flag is set. Now I found it out by myself, and my application runs now as expected.
The answer for the problem:
Instead of using the macro "UART_BUS(..)" in the platform_devices.h file, the macro UART_DEV(..) must be used, because this macro will also take the "_flags" parameter, where I can put the AD_UART_DEVICE_FLAGS_LOCKING_ASYNC definition.
It would be a good idea to add this hint as a remark to your documentation in case the user wants to use the _async - functions of the UART.
Best regards
Dieter
Hi Dieter,
Thanks for sharing your solution. I have requested that your proposed addition to the documentation be implemented in the next document release.
/MHv