10 years, 10 months ago.

MBED Asynchronous APIs

Hello,

According to following link Async APIs can "allow me to set up a transfer, send it to the peripheral for execution, and get a callback when the transfer is finished. This way, i can do something else, such as more number crunching, or even go to sleep......."

https://developer.mbed.org/teams/SiliconLabs/wiki/Using-the-mbed-asynchronous-APIs

Hmm very nice.... Let's try... First updated to mbed library version 100, even though async api's were already introduced in version 98.

Then I found the sample application for Sserial communication: https://developer.mbed.org/teams/SiliconLabs/code/Serial-LowPower-Demo/file/f911d11682f3/main.cpp

Since I can't find any way to use "LowPowerTicker" i change line 50 to "Ticker" and removed line 43,45,46 and 47, cos I got error message (At that moment I sensed that the async api's are not compatible with my platform NUCLEO F401RE??)..And later on while compiling I got errors from lines 91, 94 and 105...

So, shortly, why can't I use async serial api functions, especially;

Quote:

int read (uint8_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_RX_COMPLETE, unsigned char char_match=SERIAL_RESERVED_CHAR_MATCH) Begin asynchronous reading using 8bit buffer. int read (uint16_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_RX_COMPLETE, unsigned char char_match=SERIAL_RESERVED_CHAR_MATCH) Begin asynchronous reading using 16bit buffer.

int write (uint8_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE) Begin asynchronous write using 8bit buffer. int write (uint16_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE) Begin asynchronous write using 16bit buffer.

If I can, can you give some example codes?

Regards...

1 Answer

10 years, 10 months ago.

Async APIs are currently not yet available for anything except SiliconLabs boards. In the meantime what should work for your board to have async serial: https://developer.mbed.org/users/sam_grove/code/BufferedSerial/

Accepted Answer