SPI API slave select functionality Topic is solved

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
awygle
Posts: 32
Joined: Sun Apr 03, 2016 8:39 pm
Has thanked: 6 times
Been thanked: 4 times

SPI API slave select functionality

Post by awygle »

I've been working with the SPI API for a while now and I had a couple of questions about slave select functionality.

First, it seems inefficient to reload all driver configuration just to select a new device. In my experience it's not at all uncommon to have multiple SPI devices on the same bus all using identical data rates, CPOL/CPHA, etc., with different slave selects. Calling spiStart works fine, but seems like overkill - is there another way?

Second, different devices expect different kinds of slave select framing - some expect it to be toggled per frame (which works fine with the current architecture) but some expect it to be toggled per byte. I can't see a way to achieve that behavior with the current API, short of calling spiPolledExchange over and over, which is pretty inefficient. Is there a way to make that happen?

Thanks!
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: SPI API slave select functionality

Post by Giovanni »

Hi,

spiStart() has a short path internally when called in the SPI_READY state, so it is not overkill, it just makes few basic initializations, not the full initialization.

Per-frame toggling can only effectively done using an HW slave select, if the underlying SPI unit supports it.

Giovanni
Post Reply