File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,22 @@ byte SPIClass::transfer(uint8_t data)
194194 return _p_sercom->readDataSPI () & 0xFF ;
195195}
196196
197+ uint16_t SPIClass::transfer16 (uint16_t data) {
198+ union { uint16_t val; struct { uint8_t lsb; uint8_t msb; }; } t;
199+
200+ t.val = data;
201+
202+ if (_p_sercom->getDataOrderSPI () == LSB_FIRST) {
203+ t.lsb = transfer (t.lsb );
204+ t.msb = transfer (t.msb );
205+ } else {
206+ t.msb = transfer (t.msb );
207+ t.lsb = transfer (t.lsb );
208+ }
209+
210+ return t.val ;
211+ }
212+
197213void SPIClass::attachInterrupt () {
198214 // Should be enableInterrupt()
199215}
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ class SPIClass {
9696
9797
9898 byte transfer (uint8_t data);
99+ uint16_t transfer16 (uint16_t data);
99100 inline void transfer (void *buf, size_t count);
100101
101102 // Transaction Functions
You can’t perform that action at this time.
0 commit comments