We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 18a1d60 commit a15e621Copy full SHA for a15e621
libraries/SPI/SPI.cpp
@@ -32,9 +32,18 @@ uint8_t arduino::MbedSPI::transfer(uint8_t data) {
32
}
33
34
uint16_t arduino::MbedSPI::transfer16(uint16_t data) {
35
- uint8_t ret[2];
36
- dev->write((const char*)&data, 2, (char*)ret, 2);
37
- return ret[0] << 8 | ret[1];
+
+ union { uint16_t val; struct { uint8_t lsb; uint8_t msb; }; } t;
+ t.val = data;
38
39
+ if (settings.getBitOrder() == LSBFIRST) {
40
+ t.lsb = transfer(t.lsb);
41
+ t.msb = transfer(t.msb);
42
+ } else {
43
44
45
+ }
46
+ return t.val;
47
48
49
void arduino::MbedSPI::transfer(void *buf, size_t count) {
0 commit comments