Mbed-os: Handling multiple SPI slaves idiomatically

Created on 28 Jun 2018  路  4Comments  路  Source: ARMmbed/mbed-os

Description

In a multi slave setting, it is not clear how the API is supposed to work, since only one SS line can be passed on at a time.
The only solution I see right now, is handling the slave selection process manually.

Issue request type

[X] Question
[ ] Enhancement
[ ] Bug

closed_in_jira drivers mirrored

Most helpful comment

It would be nice if this could be added to the documentation as an example and explicitly stating that this logic is already part of the SPI class rather than to expect people to dig through the SPI implementation details (if it already exists, I did not find it, so this might be a good point in making it more prominent).

All 4 comments

ARM Internal Ref: MBOTRIAGE-958

My understanding of the intent is that you use multiple SPI objects, one for each slave. Those would specify the same MOSI/MISO pins, but different SSEL pins.

If you look at SPI.cpp, you'll see that it tracks the previous SPI object that accessed the HAL, and does reconfiguration of bus frequency/format as required when you switch between objects. So each SPI object and hence slave can have a different configuration.

It would be nice if this could be added to the documentation as an example and explicitly stating that this logic is already part of the SPI class rather than to expect people to dig through the SPI implementation details (if it already exists, I did not find it, so this might be a good point in making it more prominent).

Thanks @drahnr for pointing this out and we will be updating the documentation to capture this. - https://github.com/ARMmbed/mbed-os-5-docs/pull/632
Let us know if you have more questions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ccchang12 picture ccchang12  路  4Comments

neilt6 picture neilt6  路  4Comments

drahnr picture drahnr  路  4Comments

sarahmarshy picture sarahmarshy  路  4Comments

ashok-rao picture ashok-rao  路  4Comments