-
Notifications
You must be signed in to change notification settings - Fork 34
Possible direction for __ARDUINO_CI_SFR_MOCK
#201
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
Conversation
(but only because of a horrible hack by someone who doesn't understand what is happening!).
For the SPI thing, see the related commit 90dc747 from #144. I suspect that:
If the above is correct, I think a correct fix could be to set a meaningful value for |
If we rebase this off master (which should now have the |
…er16()` does the right thing.
I've taken a bit of a different approach than suggested by @matthijskooijman above. Instead of using Another area that should be considered is the But, from what I have, I'm satisfied with this PR and I think it is an improvement on the previous situation. Advice, as always, is welcome. |
As do I... my round of edits on this all ended in some segfaulting unit tests. I've squashed this into #183 and we'll see where it takes us |
Good point about alignment. Maybe the AVR registers happen to be aligned, but I wouldn't really expect so (and if so, probably only 16-bit, not 32-bit). I was thinking reading registers could be more explicit, e.g.:
But that no longer allows assigning values to the register, so that won't fly... I'm not actually sure how to handle this in a way that:
Mostly alignment is a problem, anyone know what the rules are for that? IIRC on some platforms misaligned access is a fatal problem, on a lot of others it's just slower. Can you somehow tell the compiler that you're not sure a pointer is aligned so it can generate slower but safe byte-by-byte accesses automatically maybe? |
It appears that x86 allows misaligned memory accesses (see this stackoverflow question), so I think that changing this to a byte would be safe and accurate. I'll update this PR. |
* Set bit order based on `SPISettings` in `beginTransaction()` and use `SPCR` and `DORD` to test it.
@matthijskooijman, This time I've taken the approach you suggested above (I appreciate your patience and explanations). Further review and comments are welcome. @ianfixes, I've added tests for bit/byte order and for misaligned memory accesses. I think this a further improvement and invite you to merge it with the previous code. |
I think I have this all picked in again |
It's failing here: I'm not sure whether that's because a separate patch in #if defined(SPCR) && defined(DORD)
if (bitOrder == MSBFIRST) { Is |
Yes, the failing tests are related to confirming that the two bit-order configs each work. When the code used |
Agreed, the changes from this PR make the guard obsolete. You can just drop my commit 7d7d810 completely. |
A squashed version of this was merged with #183 |
This seems to hint at a direction to take for #187. Before merging please see
SPI.h:100
where a change was made in order to get thespi
test ingodmode.cpp
to pass. It is almost certainly wrong, but I don't know enough to fix it.This is also related to discussions in #183.