File tree Expand file tree Collapse file tree 4 files changed +20
-4
lines changed
SampleProjects/TestSomething/test Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ unittest(SFR_IO8)
1616 // error like: cannot take the address of an rvalue of type 'int'
1717 //
1818 // this tests that directly
19- &DDRE;
19+ auto foo = &DDRE; // avoid compiler warning by using the result of an expression
2020}
2121
2222unittest_main ()
Original file line number Diff line number Diff line change @@ -118,3 +118,5 @@ TwoWire Wire = TwoWire();
118118 #include < EEPROM.h>
119119 EEPROMClass EEPROM;
120120#endif
121+
122+ volatile long long __ARDUINO_CI_SFR_MOCK[1024 ];
Original file line number Diff line number Diff line change 4040
4141class SPISettings {
4242public:
43- SPISettings (uint32_t clock, uint8_t bitOrder, uint8_t dataMode){};
43+ uint8_t bitOrder;
44+
45+ SPISettings (uint32_t clock, uint8_t bitOrder = MSBFIRST, uint8_t dataMode = SPI_MODE0) {
46+ this ->bitOrder = bitOrder;
47+ };
4448 SPISettings (){};
4549};
4650
@@ -68,6 +72,7 @@ class SPIClass: public ObservableDataStream {
6872 // and configure the correct settings.
6973 void beginTransaction (SPISettings settings)
7074 {
75+ this ->bitOrder = settings.bitOrder ;
7176 #ifdef SPI_TRANSACTION_MISMATCH_LED
7277 if (inTransactionFlag) {
7378 pinMode (SPI_TRANSACTION_MISMATCH_LED, OUTPUT);
@@ -95,7 +100,7 @@ class SPIClass: public ObservableDataStream {
95100 union { uint16_t val; struct { uint8_t lsb; uint8_t msb; }; } in, out;
96101 in.val = data;
97102 #if defined(SPCR) && defined(DORD)
98- if (!(SPCR & ( 1 << DORD)) ) {
103+ if (bitOrder == MSBFIRST ) {
99104 out.msb = transfer (in.msb );
100105 out.lsb = transfer (in.lsb );
101106 }
@@ -147,6 +152,7 @@ class SPIClass: public ObservableDataStream {
147152 #endif
148153
149154 bool isStarted = false ;
155+ uint8_t bitOrder;
150156 String* dataIn;
151157 String* dataOut;
152158};
Original file line number Diff line number Diff line change 9696#ifndef _AVR_IO_H_
9797#define _AVR_IO_H_
9898
99- #define _SFR_IO8 (io_addr ) (*(volatile uint8_t *)(io_addr)) // this macro is all we need from the sfr file
99+ // hardware mocks
100+
101+ // this set of macros is all we need from the sfr file
102+ extern volatile long long __ARDUINO_CI_SFR_MOCK [1024 ];
103+ #define _SFR_IO8 (io_addr ) (*(volatile uint8_t *)(__ARDUINO_CI_SFR_MOCK + io_addr))
104+ #define _SFR_IO16 (io_addr ) (*(volatile uint16_t *)(__ARDUINO_CI_SFR_MOCK + io_addr))
105+ #define _SFR_MEM8 (io_addr ) (*(volatile uint8_t *)(__ARDUINO_CI_SFR_MOCK + io_addr))
106+ #define _SFR_MEM16 (io_addr ) (*(volatile uint16_t *)(__ARDUINO_CI_SFR_MOCK + io_addr))
107+ #define _SFR_MEM32 (io_addr ) (*(volatile uint32_t *)(__ARDUINO_CI_SFR_MOCK + io_addr))
100108
101109#if defined (__AVR_AT94K__ )
102110# include "ioat94k.h"
You can’t perform that action at this time.
0 commit comments