Arm Mbed OS support forum

Blocking-ish SPI/I2C API's

Please add a variant of the transfer() function which will basically appear blocking to the user, but put the calling thread into deep sleep for the duration of the transfer.

Right now, the way to do this is:

  1. Acquire bus lock
  2. Create a semaphore at 1
  3. Create a transfer with a callback that will decrement the semaphore
  4. Wait for the semaphore to reach zero
  5. Release bus lock

A convenience method inside the SPI/I2C drivers to do these steps in a single function would lead to much cleaner-looking code.

1 Like