|
@@ -78,14 +78,17 @@
|
78
|
78
|
#define _TOGGLE(IO) _WRITE(IO, !READ(IO))
|
79
|
79
|
|
80
|
80
|
/// set pin as input
|
81
|
|
-#define _SET_INPUT(IO) pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
|
82
|
|
- PIO_Configure(g_APinDescription[IO].pPort, PIO_INPUT, g_APinDescription[IO].ulPin, 0)
|
|
81
|
+#define _SET_INPUT(IO) do{ pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
|
|
82
|
+ PIO_Configure(g_APinDescription[IO].pPort, PIO_INPUT, g_APinDescription[IO].ulPin, 0); \
|
|
83
|
+ }while(0)
|
83
|
84
|
/// set pin as output
|
84
|
|
-#define _SET_OUTPUT(IO) PIO_Configure(g_APinDescription[IO].pPort, PIO_OUTPUT_1, \
|
85
|
|
- g_APinDescription[IO].ulPin, g_APinDescription[IO].ulPinConfiguration)
|
|
85
|
+#define _SET_OUTPUT(IO) do{ pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
|
|
86
|
+ PIO_Configure(g_APinDescription[IO].pPort, _READ(IO) ? PIO_OUTPUT_1 : PIO_OUTPUT_0, \
|
|
87
|
+ g_APinDescription[IO].ulPin, g_APinDescription[IO].ulPinConfiguration); \
|
|
88
|
+ }while(0)
|
86
|
89
|
|
87
|
90
|
/// set pin as input with pullup mode
|
88
|
|
-#define _PULLUP(IO, v) { pinMode(IO, (v!=LOW ? INPUT_PULLUP : INPUT)); }
|
|
91
|
+#define _PULLUP(IO, v) { pinMode(IO, v != LOW ? INPUT_PULLUP : INPUT); }
|
89
|
92
|
|
90
|
93
|
/// check if pin is an input
|
91
|
94
|
#define _GET_INPUT(IO)
|
|
@@ -109,9 +112,8 @@
|
109
|
112
|
#define SET_INPUT(IO) _SET_INPUT(IO)
|
110
|
113
|
/// set pin as input with pullup wrapper
|
111
|
114
|
#define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
|
112
|
|
-/// set pin as output wrapper
|
113
|
|
-#define SET_OUTPUT(IO) do{ _SET_OUTPUT(IO); _WRITE(IO, LOW); }while(0)
|
114
|
|
-
|
|
115
|
+/// set pin as output wrapper - reads the pin and sets the output to that value
|
|
116
|
+#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
|
115
|
117
|
/// check if pin is an input wrapper
|
116
|
118
|
#define GET_INPUT(IO) _GET_INPUT(IO)
|
117
|
119
|
/// check if pin is an output wrapper
|