Multiple devices on a single SPI bus

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
User avatar
part1zan_
Posts: 44
Joined: Sun Sep 08, 2013 9:04 pm

Multiple devices on a single SPI bus

Post by part1zan_ »

What's the most common and convenient way of using two or more SPI devices on a single SPI bus? The point is that I can use the same MISO/MOSI/SCK pins, and the only thing that really differs is the CS (ChibSelect) pin.
I see only one: reconfigure SPI (spiStart) with the appropriate ChipSelect pin every time I use another device. That sounds kludgy, doesn't that? Are there other ways of doing that? Maybe, some statements in spiConfig?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Multiple devices on a single SPI bus

Post by Giovanni »

The mode is to do spiStart() each time you need to address a different device. The internal code path is quite simple.

If all devices have the same settings (CPOL, CPHA, speed etc) then you can simply use PAL functions to control CS lines without need to reconfigure.

Giovanni
Post Reply