瀏覽代碼

More tweaks to fastio_Due.h

etagle 7 年之前
父節點
當前提交
e7e896e7d7
共有 1 個檔案被更改,包括 5 行新增8 行删除
  1. 5
    8
      Marlin/src/HAL/HAL_DUE/fastio_Due.h

+ 5
- 8
Marlin/src/HAL/HAL_DUE/fastio_Due.h 查看文件

67
 // Write to a pin
67
 // Write to a pin
68
 #define _WRITE_VAR(IO,V) do { \
68
 #define _WRITE_VAR(IO,V) do { \
69
   volatile Pio* port = digitalPinToPort(IO); \
69
   volatile Pio* port = digitalPinToPort(IO); \
70
-  uint32_t mask = g_APinDescription[IO].ulPin; \
70
+  uint32_t mask = digitalPinToBitMask(IO); \
71
   if (V) port->PIO_SODR = mask; \
71
   if (V) port->PIO_SODR = mask; \
72
   else port->PIO_CODR = mask; \
72
   else port->PIO_CODR = mask; \
73
 } while(0)
73
 } while(0)
86
 // Set pin as input
86
 // Set pin as input
87
 #define _SET_INPUT(IO) do{ \
87
 #define _SET_INPUT(IO) do{ \
88
   pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
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
 }while(0)
90
 }while(0)
91
 
91
 
92
 // Set pin as output
92
 // Set pin as output
93
 #define _SET_OUTPUT(IO) do{ \
93
 #define _SET_OUTPUT(IO) do{ \
94
   pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
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
   g_pinStatus[IO] = (g_pinStatus[IO] & 0xF0) | PIN_STATUS_DIGITAL_OUTPUT;\
96
   g_pinStatus[IO] = (g_pinStatus[IO] & 0xF0) | PIN_STATUS_DIGITAL_OUTPUT;\
97
 }while(0)
97
 }while(0)
98
 
98
 
120
 #define GET_INPUT(IO) !(digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO))
120
 #define GET_INPUT(IO) !(digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO))
121
 // Check if pin is an output
121
 // Check if pin is an output
122
 #define GET_OUTPUT(IO) !!(digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO))
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
 // Shorthand
126
 // Shorthand
130
 #define OUT_WRITE(IO,V) { SET_OUTPUT(IO); WRITE(IO,V); }
127
 #define OUT_WRITE(IO,V) { SET_OUTPUT(IO); WRITE(IO,V); }

Loading…
取消
儲存