From 8767a8a0a987c7d181530a7fb0afd9b2cf2d001c Mon Sep 17 00:00:00 2001 From: lilian Date: Mon, 5 Dec 2016 12:45:40 +0100 Subject: [PATCH] Readable option --- core/esp_spi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/esp_spi.c b/core/esp_spi.c index 878b574..0bda9d2 100644 --- a/core/esp_spi.c +++ b/core/esp_spi.c @@ -224,20 +224,20 @@ uint32_t spi_transfer_32(uint8_t bus, uint32_t data) static void _rearm_extras_bit(uint8_t bus, bool arm) { if(!_minimal_pins[bus]) return ; - static uint8_t status = 0 ; + static uint8_t status[2] ; if (arm) { - if (status & (0x01<<(4*bus))) SPI(bus).USER0 |= (SPI_USER0_ADDR) ; - if (status & (0x02<<(4*bus))) SPI(bus).USER0 |= (SPI_USER0_COMMAND) ; - if (status & (0x04<<(4*bus))) SPI(bus).USER0 |= (SPI_USER0_DUMMY | SPI_USER0_MISO); - status &= ~(0x0F<<(4*bus)); + if (status[bus] & 0x01) SPI(bus).USER0 |= (SPI_USER0_ADDR) ; + if (status[bus] & 0x02) SPI(bus).USER0 |= (SPI_USER0_COMMAND) ; + if (status[bus] & 0x04) SPI(bus).USER0 |= (SPI_USER0_DUMMY | SPI_USER0_MISO); + status[bus] = 0; } else { - if (SPI(bus).USER0 & SPI_USER0_ADDR) { SPI(bus).USER0 &= ~(SPI_USER0_ADDR) ; status |= 0x01<<(4*bus) ; } - if (SPI(bus).USER0 & SPI_USER0_COMMAND) { SPI(bus).USER0 &= ~(SPI_USER0_COMMAND) ; status |= 0x02<<(4*bus) ; } - if (SPI(bus).USER0 & SPI_USER0_DUMMY) { SPI(bus).USER0 &= ~(SPI_USER0_DUMMY | SPI_USER0_MISO); status |= 0x04<<(4*bus) ; } + if (SPI(bus).USER0 & SPI_USER0_ADDR) { SPI(bus).USER0 &= ~(SPI_USER0_ADDR) ; status[bus] |= 0x01 ; } + if (SPI(bus).USER0 & SPI_USER0_COMMAND) { SPI(bus).USER0 &= ~(SPI_USER0_COMMAND) ; status[bus] |= 0x02 ; } + if (SPI(bus).USER0 & SPI_USER0_DUMMY) { SPI(bus).USER0 &= ~(SPI_USER0_DUMMY | SPI_USER0_MISO); status[bus] |= 0x04 ; } } }