diff --git a/cpu/esp32/periph/spi.c b/cpu/esp32/periph/spi.c index 284afb7ebd..2af333f6d1 100644 --- a/cpu/esp32/periph/spi.c +++ b/cpu/esp32/periph/spi.c @@ -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