diff options
| author | Ryan <fauxpark@gmail.com> | 2020-04-30 16:24:47 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-30 16:24:47 +1000 |
| commit | 16a15c1cfcbfd0feb2c2cf1383676747e2f97d73 (patch) | |
| tree | aaa3c9f5a23207861d05c37ed4860af8efd40f85 /quantum | |
| parent | 37a4b53c4f51b66992e687b5012c83df9cc6b138 (diff) | |
| download | qmk_firmware-16a15c1cfcbfd0feb2c2cf1383676747e2f97d73.tar.gz qmk_firmware-16a15c1cfcbfd0feb2c2cf1383676747e2f97d73.zip | |
QMK-ify some GPIO macros (#8315)
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/pincontrol.h | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/quantum/pincontrol.h b/quantum/pincontrol.h deleted file mode 100644 index 204fddf30..000000000 --- a/quantum/pincontrol.h +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | /* Copyright 2016 Wez Furlong | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | // Some helpers for controlling gpio pins | ||
| 18 | #include <avr/io.h> | ||
| 19 | |||
| 20 | enum { | ||
| 21 | PinDirectionInput = 0, | ||
| 22 | PinDirectionOutput = 1, | ||
| 23 | PinLevelHigh = 1, | ||
| 24 | PinLevelLow = 0, | ||
| 25 | }; | ||
| 26 | |||
| 27 | // ex: pinMode(B0, PinDirectionOutput); | ||
| 28 | static inline void pinMode(uint8_t pin, int mode) { | ||
| 29 | uint8_t bv = _BV(pin & 0xf); | ||
| 30 | if (mode == PinDirectionOutput) { | ||
| 31 | _SFR_IO8((pin >> 4) + 1) |= bv; | ||
| 32 | } else { | ||
| 33 | _SFR_IO8((pin >> 4) + 1) &= ~bv; | ||
| 34 | _SFR_IO8((pin >> 4) + 2) &= ~bv; | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | // ex: digitalWrite(B0, PinLevelHigh); | ||
| 39 | static inline void digitalWrite(uint8_t pin, int mode) { | ||
| 40 | uint8_t bv = _BV(pin & 0xf); | ||
| 41 | if (mode == PinLevelHigh) { | ||
| 42 | _SFR_IO8((pin >> 4) + 2) |= bv; | ||
| 43 | } else { | ||
| 44 | _SFR_IO8((pin >> 4) + 2) &= ~bv; | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | // Return true if the pin is HIGH | ||
| 49 | // digitalRead(B0) | ||
| 50 | static inline bool digitalRead(uint8_t pin) { return _SFR_IO8(pin >> 4) & _BV(pin & 0xf); } | ||
