⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
7 posts / 0 new
Last post
Dieter Falk
Offline
Last seen:4 months 3 weeks ago
加入:2019-10-12 10:33
Uart Adapter Async

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

Device:
PM_Dialog
Offline
Last seen:15 hours 15 min ago
Staff
加入:2018-02-08 11:03
Hi Dieter,

Hi Dieter,

Let me check your question and revert back to you as soon as possible.

Thanks, PM_Dialog

PM_Dialog
Offline
Last seen:15 hours 15 min ago
Staff
加入:2018-02-08 11:03
Hi Dieter,

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

Dieter Falk
Offline
Last seen:4 months 3 weeks ago
加入:2019-10-12 10:33
Hello,

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

PM_Dialog
Offline
Last seen:15 hours 15 min ago
Staff
加入:2018-02-08 11:03
Hi 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

Dieter Falk
Offline
Last seen:4 months 3 weeks ago
加入:2019-10-12 10:33
Hello,

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

MHv_Dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2013-12-06 15:10
Hi 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