Merge branch 'bugfix/spi_multiple_cs_fix' into 'master'

Add missing variable initialisation to make SPI work for multiple CS

Ref https://github.com/espressif/esp-idf/pull/277
From PR: "I am not especially familiar with this platform or with esp-idf -- so review with care.

The spi-master driver would not work for me when the number of devices on a bus exceeded 1 (caused device hang). I believe this is because cur_cs is not properly set (anywhere), and yet is used. This is likely just not noticed because 0 is presumably the correct value when there's only 1 device (and I'm guessing multi-device setup is not tested as thoroughly).

Simply setting cur_cs to the correct slot value resolves the problem and multiple devices on a single bus behave correctly in my test environment."

Looks like a small oversight on my side.

See merge request !468
This commit is contained in:
Angus Gratton 2017-01-27 08:33:16 +08:00
commit a4c76671c2

View file

@ -502,6 +502,7 @@ static void IRAM_ATTR spi_intr(void *arg)
//We have a transaction. Send it.
spi_device_t *dev=host->device[i];
host->cur_trans=trans;
host->cur_cs=i;
//We should be done with the transmission.
assert(host->hw->cmd.usr == 0);
@ -510,7 +511,7 @@ static void IRAM_ATTR spi_intr(void *arg)
trans->rxlength=trans->length;
}
//Reconfigure accoding to device settings, but only if we change CSses.
//Reconfigure according to device settings, but only if we change CSses.
if (i!=prevCs) {
//Assumes a hardcoded 80MHz Fapb for now. ToDo: figure out something better once we have
//clock scaling working.