|
@@ -78,55 +78,54 @@
|
78
|
78
|
else port->PIO_CODR = mask; \
|
79
|
79
|
} while(0)
|
80
|
80
|
|
81
|
|
-// toggle a pin
|
|
81
|
+// Toggle a pin
|
82
|
82
|
#define _TOGGLE(IO) _WRITE(IO, !READ(IO))
|
83
|
83
|
|
84
|
|
-// set pin as input
|
|
84
|
+// Set pin as input
|
85
|
85
|
#define _SET_INPUT(IO) do{ \
|
86
|
86
|
pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
|
87
|
87
|
PIO_Configure(g_APinDescription[IO].pPort, PIO_INPUT, g_APinDescription[IO].ulPin, 0); \
|
88
|
88
|
}while(0)
|
89
|
89
|
|
90
|
|
-// set pin as output
|
|
90
|
+// Set pin as output
|
91
|
91
|
#define _SET_OUTPUT(IO) do{ \
|
92
|
92
|
pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
|
93
|
93
|
PIO_Configure(g_APinDescription[IO].pPort, _READ(IO) ? PIO_OUTPUT_1 : PIO_OUTPUT_0, g_APinDescription[IO].ulPin, g_APinDescription[IO].ulPinConfiguration); \
|
94
|
94
|
g_pinStatus[IO] = (g_pinStatus[IO] & 0xF0) | PIN_STATUS_DIGITAL_OUTPUT;\
|
95
|
95
|
}while(0)
|
96
|
96
|
|
97
|
|
-// set pin as input with pullup mode
|
|
97
|
+// Set pin as input with pullup mode
|
98
|
98
|
#define _PULLUP(IO,V) pinMode(IO, (V) ? INPUT_PULLUP : INPUT)
|
99
|
99
|
|
100
|
|
-// check if pin is an input
|
|
100
|
+// Check if pin is an input
|
101
|
101
|
#define _GET_INPUT(IO)
|
102
|
|
-// check if pin is an output
|
|
102
|
+// Check if pin is an output
|
103
|
103
|
#define _GET_OUTPUT(IO)
|
104
|
|
-
|
105
|
|
-// check if pin is a timer
|
|
104
|
+// Check if pin is a timer
|
106
|
105
|
#define _GET_TIMER(IO)
|
107
|
106
|
|
108
|
|
-// Read a pin wrapper
|
|
107
|
+// Read a pin (wrapper)
|
109
|
108
|
#define READ(IO) _READ(IO)
|
110
|
109
|
|
111
|
|
-// Write to a pin wrapper
|
|
110
|
+// Write to a pin (wrapper)
|
112
|
111
|
#define WRITE_VAR(IO,V) _WRITE_VAR(IO,V)
|
113
|
112
|
#define WRITE(IO,V) _WRITE(IO,V)
|
114
|
113
|
|
115
|
|
-// toggle a pin wrapper
|
|
114
|
+// Toggle a pin (wrapper)
|
116
|
115
|
#define TOGGLE(IO) _TOGGLE(IO)
|
117
|
116
|
|
118
|
|
-// set pin as input wrapper
|
|
117
|
+// Set pin as input (wrapper)
|
119
|
118
|
#define SET_INPUT(IO) _SET_INPUT(IO)
|
120
|
|
-// set pin as input with pullup wrapper
|
|
119
|
+// Set pin as input with pullup (wrapper)
|
121
|
120
|
#define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
|
122
|
|
-// set pin as output wrapper - reads the pin and sets the output to that value
|
|
121
|
+// Set pin as output (wrapper) - reads the pin and sets the output to that value
|
123
|
122
|
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
|
124
|
|
-// check if pin is an input wrapper
|
|
123
|
+// Check if pin is an input (wrapper)
|
125
|
124
|
#define GET_INPUT(IO) _GET_INPUT(IO)
|
126
|
|
-// check if pin is an output wrapper
|
|
125
|
+// Check if pin is an output (wrapper)
|
127
|
126
|
#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
|
128
|
127
|
|
129
|
|
-// check if pin is a timer (wrapper)
|
|
128
|
+// Check if pin is a timer (wrapper)
|
130
|
129
|
#define GET_TIMER(IO) _GET_TIMER(IO)
|
131
|
130
|
|
132
|
131
|
// Shorthand
|