File tree 4 files changed +20
-4
lines changed
SampleProjects/TestSomething/test
4 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ unittest(SFR_IO8)
16
16
// error like: cannot take the address of an rvalue of type 'int'
17
17
//
18
18
// this tests that directly
19
- &DDRE;
19
+ auto foo = &DDRE; // avoid compiler warning by using the result of an expression
20
20
}
21
21
22
22
unittest_main ()
Original file line number Diff line number Diff line change @@ -118,3 +118,5 @@ TwoWire Wire = TwoWire();
118
118
#include < EEPROM.h>
119
119
EEPROMClass EEPROM;
120
120
#endif
121
+
122
+ volatile long long __ARDUINO_CI_SFR_MOCK[1024 ];
Original file line number Diff line number Diff line change 40
40
41
41
class SPISettings {
42
42
public:
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
+ };
44
48
SPISettings (){};
45
49
};
46
50
@@ -68,6 +72,7 @@ class SPIClass: public ObservableDataStream {
68
72
// and configure the correct settings.
69
73
void beginTransaction (SPISettings settings)
70
74
{
75
+ this ->bitOrder = settings.bitOrder ;
71
76
#ifdef SPI_TRANSACTION_MISMATCH_LED
72
77
if (inTransactionFlag) {
73
78
pinMode (SPI_TRANSACTION_MISMATCH_LED, OUTPUT);
@@ -95,7 +100,7 @@ class SPIClass: public ObservableDataStream {
95
100
union { uint16_t val; struct { uint8_t lsb; uint8_t msb; }; } in, out;
96
101
in.val = data;
97
102
#if defined(SPCR) && defined(DORD)
98
- if (!(SPCR & ( 1 << DORD)) ) {
103
+ if (bitOrder == MSBFIRST ) {
99
104
out.msb = transfer (in.msb );
100
105
out.lsb = transfer (in.lsb );
101
106
}
@@ -147,6 +152,7 @@ class SPIClass: public ObservableDataStream {
147
152
#endif
148
153
149
154
bool isStarted = false ;
155
+ uint8_t bitOrder;
150
156
String* dataIn;
151
157
String* dataOut;
152
158
};
Original file line number Diff line number Diff line change 96
96
#ifndef _AVR_IO_H_
97
97
#define _AVR_IO_H_
98
98
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))
100
108
101
109
#if defined (__AVR_AT94K__ )
102
110
# include "ioat94k.h"
You can’t perform that action at this time.
0 commit comments