Skip to content

Commit 2eaf846

Browse files
mcgillanme-no-dev
authored andcommitted
Spi pattern fix (espressif#502)
* Add files via upload Calls to writePattern() don't send the desired number of bytes when the pattern size doesn't divide evenly into the hardware FIFO size (e.g. sending 18-bit RGB data, 11 patterns take 63 bytes, so 1/64th of the data is never sent). * Add files via upload Remove white space changes.
1 parent b3fdfda commit 2eaf846

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

libraries/SPI/src/SPI.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,12 @@ void SPIClass::writePattern(uint8_t * data, uint8_t size, uint32_t repeat)
242242

243243
uint32_t byte = (size * repeat);
244244
uint8_t r = (64 / size);
245+
const uint8_t max_bytes_FIFO = r * size; // Max number of whole patterns (in bytes) that can fit into the hardware FIFO
245246

246247
while(byte) {
247-
if(byte > 64) {
248+
if(byte > max_bytes_FIFO) {
248249
writePattern_(data, size, r);
249-
byte -= 64;
250+
byte -= max_bytes_FIFO;
250251
} else {
251252
writePattern_(data, size, (byte / size));
252253
byte = 0;

0 commit comments

Comments
 (0)