nodemcu / nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32
https://nodemcu.readthedocs.io
MIT License
7.64k stars 3.12k forks source link

Support sending strings with multi-byte-wide SPI #3529

Open stuartpb opened 2 years ago

stuartpb commented 2 years ago

The iteration in the loop in the prior version of spi.send assumes that the value of databits is the width of char when sending any string value.

stuartpb commented 2 years ago

There should probably be further tests with this to ensure that multi-char values from strings get read and sent properly - there could be endianness issues with the string layout.

Alternately, trying to send a string value with a databits value of anything other than 8 could be an error, or ignore the databits value and always use a width of 8 for strings, transmitted character-by-character (this override should probably be documented in that case).

jmattsson commented 2 years ago

I don't see how platform_spi_send( id, spi_databits[id], pdata[ i ] ); would work with >8 bits? The pdata[i] would only pass 8 bits of data through to the function, given that pdata is of const char * type. Am I missing something?