diff --git a/drivers/avr/apa102.c b/drivers/avr/apa102.c index f4d97a15891e..b174b39b8f22 100644 --- a/drivers/avr/apa102.c +++ b/drivers/avr/apa102.c @@ -30,8 +30,8 @@ void inline apa102_setleds(LED_TYPE *ledarray, uint16_t leds) { apa102_setleds_pin(ledarray, leds, _BV(RGB_DI_PIN & 0xF), _BV(RGB_CLK_PIN & 0xF)); } void static inline apa102_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask_DI, uint8_t pinmask_CLK) { - pinMode(RGB_DI_PIN, PinDirectionOutput); - pinMode(RGB_CLK_PIN, PinDirectionOutput); + setPinOutput(RGB_DI_PIN); + setPinOutput(RGB_CLK_PIN); apa102_send_array((uint8_t *)ledarray, leds) } @@ -90,7 +90,7 @@ void apa102_end_frame(uint16_t leds) { void apa102_send_byte(uint8_t byte) { uint8_t i; for (i = 0; i < 8; i++) { - digitalWrite(RGB_DI_PIN, !!(byte & (1 << (7-i))); - digitalWrite(RGB_CLK_PIN, PinLevelHigh); + writePin(RGB_DI_PIN, !!(byte & (1 << (7 - i)))); + writePinHigh(RGB_CLK_PIN); } } diff --git a/drivers/avr/ssd1306.h b/drivers/avr/ssd1306.h index 825b0d7d5b67..9669d1b7e77e 100644 --- a/drivers/avr/ssd1306.h +++ b/drivers/avr/ssd1306.h @@ -3,7 +3,6 @@ #include #include -#include "pincontrol.h" #include "config.h" enum ssd1306_cmds { diff --git a/quantum/pincontrol.h b/quantum/pincontrol.h deleted file mode 100644 index 204fddf30c5c..000000000000 --- a/quantum/pincontrol.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright 2016 Wez Furlong - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -// Some helpers for controlling gpio pins -#include - -enum { - 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; - } -} - -// 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; - } -} - -// Return true if the pin is HIGH -// digitalRead(B0) -static inline bool digitalRead(uint8_t pin) { return _SFR_IO8(pin >> 4) & _BV(pin & 0xf); } diff --git a/users/mtdjr/solenoid.h b/users/mtdjr/solenoid.h index a911bf794fee..4ef329b4adb6 100644 --- a/users/mtdjr/solenoid.h +++ b/users/mtdjr/solenoid.h @@ -2,7 +2,6 @@ #define SOLENOID_H #include -#include "pincontrol.h" #define SOLENOID_DEFAULT_DWELL 12 @@ -45,7 +44,7 @@ void solenoid_toggle(void) { } void solenoid_stop(void) { - digitalWrite(SOLENOID_PIN, PinLevelLow); + writePinLow(SOLENOID_PIN); solenoid_on = false; solenoid_buzzing = false; } @@ -59,7 +58,7 @@ void solenoid_fire(void) { solenoid_on = true; solenoid_buzzing = true; solenoid_start = timer_read(); - digitalWrite(SOLENOID_PIN, PinLevelHigh); + writePinHigh(SOLENOID_PIN); } void solenoid_check(void) { @@ -80,20 +79,20 @@ void solenoid_check(void) { if (elapsed / SOLENOID_MIN_DWELL % 2 == 0){ if (!solenoid_buzzing) { solenoid_buzzing = true; - digitalWrite(SOLENOID_PIN, PinLevelHigh); + writePinHigh(SOLENOID_PIN); } } else { if (solenoid_buzzing) { solenoid_buzzing = false; - digitalWrite(SOLENOID_PIN, PinLevelLow); + writePinLow(SOLENOID_PIN); } } } } void solenoid_setup(void) { - pinMode(SOLENOID_PIN, PinDirectionOutput); + setPinOutput(SOLENOID_PIN); } #endif