Skip to content

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

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions cpp/arduino/SPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@

class SPISettings {
public:
SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode){};
uint8_t bitOrder;
SPISettings(uint32_t clock, uint8_t bitOrder = MSBFIRST, uint8_t dataMode = SPI_MODE0){
this->bitOrder = bitOrder;
};
SPISettings(){};
};

Expand Down Expand Up @@ -68,6 +71,7 @@ class SPIClass: public ObservableDataStream {
// and configure the correct settings.
void beginTransaction(SPISettings settings)
{
this->bitOrder = settings.bitOrder;
#ifdef SPI_TRANSACTION_MISMATCH_LED
if (inTransactionFlag) {
pinMode(SPI_TRANSACTION_MISMATCH_LED, OUTPUT);
Expand All @@ -94,10 +98,7 @@ class SPIClass: public ObservableDataStream {
uint16_t transfer16(uint16_t data) {
union { uint16_t val; struct { uint8_t lsb; uint8_t msb; }; } in, out;
in.val = data;
// Changes in the definition of _SFR_IO8() cause this to break.
// This horible hack allows the tests to pass but is done
// without any understanding at all of what is going on here!
if (false && !(SPCR & (1 << DORD))) {
if (bitOrder == MSBFIRST) {
out.msb = transfer(in.msb);
out.lsb = transfer(in.lsb);
} else {
Expand Down Expand Up @@ -146,6 +147,7 @@ class SPIClass: public ObservableDataStream {
#endif

bool isStarted = false;
uint8_t bitOrder;
String* dataIn;
String* dataOut;
};
Expand Down