nodemcu-firmware
nodemcu-firmware copied to clipboard
Support sending strings with multi-byte-wide SPI
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.
- [x] This PR is for the
devbranch rather than for thereleasebranch. - [x] This PR is compliant with the other contributing guidelines as well (if not, please describe why).
- [ ] I haven't thoroughly tested my contribution - it's a simple enough change that, if it compiles and passes existing tests, it works (it only fixes behavior that was previously broken).
- [x] The code changes are reflected in the documentation at
docs/*. (This only fixes the function to more closely match the expected documented behavior.)
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).
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?