6 years, 7 months ago.

Which Platform supports which function of asynchronous api?

Hello all! At the moment i am trying to set up i2c to work on a callback-scheme ( "asynchronous" operation). Board is bluepill/nucleo f103rb. Whatever i try wont compile. So is this not supported yet on all plattforms or is it my fault? Before i put more days into this subject:are there any examples apart from the sparse documentation? What is the status on this important frature?

Thanks!

1 Answer

6 years, 7 months ago.

Which board supports what is declared in targets.json. You're looking for SPI_ASYNCH feature. That should be supported on all STM32 boards.

Are you on the latest version of Mbed OS?

This also compiles fine for me against Mbed OS 5.6:

#include "mbed.h"

SPI device(SPI_MOSI, SPI_MISO, SPI_SCK);

uint8_t rxbuff[100];

void done(int) {
    printf("done\n");
}

// main() runs in its own thread in the OS
int main() {
    const uint8_t txbuff[] = { 0x13, 0x24 };
    device.transfer(txbuff, sizeof(txbuff), rxbuff, sizeof(rxbuff), callback(done), SPI_EVENT_COMPLETE);

    wait(osWaitForever);
}

(there does seem to be an issue with pins and SPI on F103RB, see here, but probably does not apply on Bluepill board)