1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2026-01-01 01:41:18 +01:00

cpu/esp32: fix CS handling in spi_transfer_bytes

If `SPI_CS_UNDEF` is given as the `cs` parameter, CS pin must not be handled by the driver. Furthermore, if `cont` parameter is true, CS pin must not be disabled at the end of one transfer.
This commit is contained in:
Gunar Schorcht 2019-10-22 08:11:25 +02:00
parent 855ef72202
commit db945bdd86

View File

@ -456,7 +456,9 @@ void IRAM_ATTR spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont,
}
#endif
gpio_clear (cs != SPI_CS_UNDEF ? cs : spi_config[bus].cs);
if (cs != SPI_CS_UNDEF) {
gpio_clear(cs);
}
size_t blocks = len / SPI_BLOCK_SIZE;
uint8_t tail = len % SPI_BLOCK_SIZE;
@ -474,8 +476,9 @@ void IRAM_ATTR spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont,
out ? (const uint8_t *)out + blocks * SPI_BLOCK_SIZE : 0,
in ? (uint8_t *)in + blocks * SPI_BLOCK_SIZE : NULL, tail);
}
if (!cont) {
gpio_set (cs != SPI_CS_UNDEF ? cs : spi_config[bus].cs);
if (!cont && (cs != SPI_CS_UNDEF)) {
gpio_set (cs);
}
#if ENABLE_DEBUG