Parcourir la source

move shortcuts around

Jack Humbert il y a 8 ans
Parent
commit
b653791d21
4 fichiers modifiés avec 22 ajouts et 17 suppressions
  1. 0 15
      quantum/config_common.h
  2. 1 1
      quantum/matrix.c
  3. 20 1
      quantum/pincontrol.h
  4. 1 0
      quantum/quantum.h

+ 0 - 15
quantum/config_common.h

@@ -36,21 +36,6 @@
 // #define PINDEF(port, pin) (uint8_t)((((uint16_t)&PIN##port) << 4) + PIN##port##pin)
 #define PINDEF(port, pin) ((pin_t)(((((uint16_t)&PIN##port) - __SFR_OFFSET)<< 4) + PIN##port##pin))
 
-static inline uint8_t* helper(pin_t p, uint8_t offset) {
-    return (uint8_t*)((p >> 4) + offset + __SFR_OFFSET);
-}
-
-#define PIN(p) *helper(p, 0)
-#define PIN_VALUE(p) (PIN(p) & _BV(p & 0xF))
-
-#define DDR(p) *helper(p, 1)
-#define DDR_OUTPUT(p) (DDR(p) |= _BV(p & 0xF))
-#define DDR_INPUT(p) (DDR(p) &= ~_BV(p & 0xF))
-
-#define PORT(p) *helper(p, 2)
-#define PORT_HIGH(p) (PORT(p) |= _BV(p & 0xF))
-#define PORT_LOW(p) (PORT(p) &= ~_BV(p & 0xF))
-
 #ifdef PORTA
     #define A0 PINDEF(A, 0)
     #define A1 PINDEF(A, 1)

+ 1 - 1
quantum/matrix.c

@@ -25,7 +25,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "util.h"
 #include "matrix.h"
 #include "timer.h"
-
+#include "quantum.h"
 
 /* Set 0 if debouncing isn't needed */
 

+ 20 - 1
quantum/pincontrol.h

@@ -15,7 +15,26 @@
  */
 #pragma once
 // Some helpers for controlling gpio pins
-#include <avr/io.h>
+#if defined(__AVR__)
+    #include <avr/io.h>
+#endif
+
+static inline volatile uint8_t* helper(pin_t p, uint8_t offset) {
+    return (volatile uint8_t*)((p >> 4) + offset + __SFR_OFFSET);
+}
+
+#define PIN(p) *helper(p, 0)
+#define PIN_VALUE(p) (PIN(p) & _BV(p & 0xF))
+
+#define DDR(p) *helper(p, 1)
+#define DDR_OUTPUT(p) (DDR(p) |= _BV(p & 0xF))
+#define DDR_INPUT(p) (DDR(p) &= ~_BV(p & 0xF))
+
+#define PORT(p) *helper(p, 2)
+#define PORT_HIGH(p) (PORT(p) |= _BV(p & 0xF))
+#define PORT_LOW(p) (PORT(p) &= ~_BV(p & 0xF))
+
+// Arduino shortcuts
 
 enum {
   PinDirectionInput = 0,

+ 1 - 0
quantum/quantum.h

@@ -41,6 +41,7 @@
 #include <stdlib.h>
 #include "print.h"
 #include "send_string_keycodes.h"
+#include "pincontrol.h"
 
 extern uint32_t default_layer_state;