-
-
Notifications
You must be signed in to change notification settings - Fork 16
SPI.transfer16 - does not properly handle word size. #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Edit to the above: this line: Should be: And it then properly changed it from 0x100 to 0x200. However it did not change the output at all. Thought maybe MSBFIRST -> SPI_TRANSFER_MSB |
@facchinm - I figured out what the issue is, but not necessarily what the best solution for it would be. I have a version, which at least shows how it can potentially work... The issue is, with the use of the config object.
Which in spi_context.h simply does:
Which at the end of the spi_transceive function it assigns the ctx->config to the value passed in. Or in other words, My first quick and dirty hack version:
Which is mostly debug code, currently puts a spi_config structure on the stack, copies the current one to it and Like I manually did for the two 8 bit outputs:
I also want to confirm that the registers were properly updated (debug code above):
So it did update the CFG1 setting, DSIZE, the other 7 checked was the CRCSIZE, and my guess is we don't use this. How to Properly fix? b) Which I will play with: Thoughts? |
This approach seems to be more logical, at least to me. Also I believe in the KISS principle |
I have an implementation that appears to be working using b) Both appeared to work using test sketch:
|
@KurtE good catch! I almost never use |
Describe the bug
SPI.transfer16(0x2ff) - with MSBFIRST defined in the transaction, outputs the bytes in LSB, MSB order
The issue, is that the code, does not update the word size from 8 to 16 in the config.operation field.
Optional: attach the sketch
Additional context
I thought I could fix this, by simply editing the Transfer16 method to:
But running it faulted:
I probably missed something, but thought I would at least first mention this as an issue.
The text was updated successfully, but these errors were encountered: