1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Manually manage FIFO volatility

Replace volatile with properly placed __sync_synchronize

SPI1W0 is volatile, but when writing multiple words
to the FIFO (which is really just a piece of SRAM),
we don't need to worry about write ordering. We only
need worry about write ordering such that all FIFO
words are written completely before HSPI is told to
use FIFO by setting SPI1CMD |= SPIBUSY;
This commit is contained in:
Richard Allen 2017-06-03 00:48:51 -05:00 committed by Ivan Grokhotkov
parent c07c8dc88e
commit 00815f2db4

View File

@ -398,7 +398,7 @@ void SPIClass::writeBytes_(uint8_t * data, uint8_t size) {
// Set Bits to transfer // Set Bits to transfer
setDataBits(size * 8); setDataBits(size * 8);
volatile uint32_t * fifoPtr = &SPI1W0; uint32_t * fifoPtr = (uint32_t*)&SPI1W0;
uint32_t * dataPtr = (uint32_t*) data; uint32_t * dataPtr = (uint32_t*) data;
uint8_t dataSize = ((size + 3) / 4); uint8_t dataSize = ((size + 3) / 4);
@ -408,6 +408,7 @@ void SPIClass::writeBytes_(uint8_t * data, uint8_t size) {
fifoPtr++; fifoPtr++;
} }
__sync_synchronize();
SPI1CMD |= SPIBUSY; SPI1CMD |= SPIBUSY;
while(SPI1CMD & SPIBUSY) {} while(SPI1CMD & SPIBUSY) {}
} }