diff options
author | William Chang <william@factual.com> | 2019-11-20 22:17:07 -0800 |
---|---|---|
committer | William Chang <william@factual.com> | 2019-11-20 22:17:07 -0800 |
commit | e7f4d56592b3975c38af329e77b4efd9108495e8 (patch) | |
tree | 0a416bccbf70bfdbdb9ffcdb3bf136b47378c014 /quantum/pincontrol.h | |
parent | 71493b2f9bbd5f3d18373c518fa14ccafcbf48fc (diff) | |
parent | 8416a94ad27b3ff058576f09f35f0704a8b39ff3 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'quantum/pincontrol.h')
-rw-r--r-- | quantum/pincontrol.h | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/quantum/pincontrol.h b/quantum/pincontrol.h index d77977ebe2..204fddf30c 100644 --- a/quantum/pincontrol.h +++ b/quantum/pincontrol.h @@ -18,35 +18,33 @@ #include <avr/io.h> enum { - PinDirectionInput = 0, - PinDirectionOutput = 1, - PinLevelHigh = 1, - PinLevelLow = 0, + PinDirectionInput = 0, + PinDirectionOutput = 1, + PinLevelHigh = 1, + PinLevelLow = 0, }; // ex: pinMode(B0, PinDirectionOutput); static inline void pinMode(uint8_t pin, int mode) { - uint8_t bv = _BV(pin & 0xf); - if (mode == PinDirectionOutput) { - _SFR_IO8((pin >> 4) + 1) |= bv; - } else { - _SFR_IO8((pin >> 4) + 1) &= ~bv; - _SFR_IO8((pin >> 4) + 2) &= ~bv; - } + uint8_t bv = _BV(pin & 0xf); + if (mode == PinDirectionOutput) { + _SFR_IO8((pin >> 4) + 1) |= bv; + } else { + _SFR_IO8((pin >> 4) + 1) &= ~bv; + _SFR_IO8((pin >> 4) + 2) &= ~bv; + } } // ex: digitalWrite(B0, PinLevelHigh); static inline void digitalWrite(uint8_t pin, int mode) { - uint8_t bv = _BV(pin & 0xf); - if (mode == PinLevelHigh) { - _SFR_IO8((pin >> 4) + 2) |= bv; - } else { - _SFR_IO8((pin >> 4) + 2) &= ~bv; - } + uint8_t bv = _BV(pin & 0xf); + if (mode == PinLevelHigh) { + _SFR_IO8((pin >> 4) + 2) |= bv; + } else { + _SFR_IO8((pin >> 4) + 2) &= ~bv; + } } // Return true if the pin is HIGH // digitalRead(B0) -static inline bool digitalRead(uint8_t pin) { - return _SFR_IO8(pin >> 4) & _BV(pin & 0xf); -} +static inline bool digitalRead(uint8_t pin) { return _SFR_IO8(pin >> 4) & _BV(pin & 0xf); } |