Browse Source

More tweaks to fastio_Due.h

etagle 6 years ago
parent
commit
e7e896e7d7
1 changed files with 5 additions and 8 deletions
  1. 5
    8
      Marlin/src/HAL/HAL_DUE/fastio_Due.h

+ 5
- 8
Marlin/src/HAL/HAL_DUE/fastio_Due.h View File

@@ -67,7 +67,7 @@
67 67
 // Write to a pin
68 68
 #define _WRITE_VAR(IO,V) do { \
69 69
   volatile Pio* port = digitalPinToPort(IO); \
70
-  uint32_t mask = g_APinDescription[IO].ulPin; \
70
+  uint32_t mask = digitalPinToBitMask(IO); \
71 71
   if (V) port->PIO_SODR = mask; \
72 72
   else port->PIO_CODR = mask; \
73 73
 } while(0)
@@ -86,13 +86,13 @@
86 86
 // Set pin as input
87 87
 #define _SET_INPUT(IO) do{ \
88 88
   pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
89
-  PIO_Configure(g_APinDescription[IO].pPort, PIO_INPUT, digitalPinToBitMask(IO), 0); \
89
+  PIO_Configure(digitalPinToPort(IO), PIO_INPUT, digitalPinToBitMask(IO), 0); \
90 90
 }while(0)
91 91
 
92 92
 // Set pin as output
93 93
 #define _SET_OUTPUT(IO) do{ \
94 94
   pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
95
-  PIO_Configure(g_APinDescription[IO].pPort, _READ(IO) ? PIO_OUTPUT_1 : PIO_OUTPUT_0, digitalPinToBitMask(IO), g_APinDescription[IO].ulPinConfiguration); \
95
+  PIO_Configure(digitalPinToPort(IO), _READ(IO) ? PIO_OUTPUT_1 : PIO_OUTPUT_0, digitalPinToBitMask(IO), g_APinDescription[IO].ulPinConfiguration); \
96 96
   g_pinStatus[IO] = (g_pinStatus[IO] & 0xF0) | PIN_STATUS_DIGITAL_OUTPUT;\
97 97
 }while(0)
98 98
 
@@ -120,11 +120,8 @@
120 120
 #define GET_INPUT(IO) !(digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO))
121 121
 // Check if pin is an output
122 122
 #define GET_OUTPUT(IO) !!(digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO))
123
-// Check if pin is a timer
124
-#define GET_TIMER(IO) ( \
125
-     (g_APinDescription[IO].ulPinAttribute & PIN_ATTR_TIMER) == PIN_ATTR_TIMER \
126
-  || (g_APinDescription[IO].ulPinAttribute & PIN_ATTR_PWM) == PIN_ATTR_PWM \
127
-)
123
+// Check if pin is a timer - Must be a constexpr
124
+#define GET_TIMER(IO) ((IO) >= 2 && (IO) <= 13)
128 125
 
129 126
 // Shorthand
130 127
 #define OUT_WRITE(IO,V) { SET_OUTPUT(IO); WRITE(IO,V); }

Loading…
Cancel
Save