aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/wiring_shift.c
diff options
context:
space:
mode:
authorDave Madison <dmadison@users.noreply.github.com>2020-02-01 05:46:15 -0500
committerGitHub <noreply@github.com>2020-02-01 05:46:15 -0500
commit924299c159b619852d4c5eb1fc106db8a459d661 (patch)
tree39aad14af9ba55cc9f26f2920f6ff873552f4c62 /cores/arduino/wiring_shift.c
parent59dd6085ec8ec0a5438c1019e982fefb77f485d3 (diff)
parent923b4441fed740c5ff1e42bb8f2f58ea87d4eaf7 (diff)
Merge pull request #6 from dmadison/upstream-updatesv1.0.1
Arduino Core 1.8.2
Diffstat (limited to 'cores/arduino/wiring_shift.c')
-rw-r--r--cores/arduino/wiring_shift.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/cores/arduino/wiring_shift.c b/cores/arduino/wiring_shift.c
index 2b6f7a8..a9b3be5 100644
--- a/cores/arduino/wiring_shift.c
+++ b/cores/arduino/wiring_shift.c
@@ -42,10 +42,13 @@ void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
uint8_t i;
for (i = 0; i < 8; i++) {
- if (bitOrder == LSBFIRST)
- digitalWrite(dataPin, !!(val & (1 << i)));
- else
- digitalWrite(dataPin, !!(val & (1 << (7 - i))));
+ if (bitOrder == LSBFIRST) {
+ digitalWrite(dataPin, val & 1);
+ val >>= 1;
+ } else {
+ digitalWrite(dataPin, (val & 128) != 0);
+ val <<= 1;
+ }
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);