Tweaks to fastio_Due.h

This commit is contained in:
Scott Lahteine 2018-06-30 00:12:48 -05:00
parent 05518d6add
commit fc10101b06

View File

@ -78,55 +78,54 @@
else port->PIO_CODR = mask; \
} while(0)
// toggle a pin
// Toggle a pin
#define _TOGGLE(IO) _WRITE(IO, !READ(IO))
// set pin as input
// Set pin as input
#define _SET_INPUT(IO) do{ \
pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
PIO_Configure(g_APinDescription[IO].pPort, PIO_INPUT, g_APinDescription[IO].ulPin, 0); \
}while(0)
// set pin as output
// Set pin as output
#define _SET_OUTPUT(IO) do{ \
pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
PIO_Configure(g_APinDescription[IO].pPort, _READ(IO) ? PIO_OUTPUT_1 : PIO_OUTPUT_0, g_APinDescription[IO].ulPin, g_APinDescription[IO].ulPinConfiguration); \
g_pinStatus[IO] = (g_pinStatus[IO] & 0xF0) | PIN_STATUS_DIGITAL_OUTPUT;\
}while(0)
// set pin as input with pullup mode
// Set pin as input with pullup mode
#define _PULLUP(IO,V) pinMode(IO, (V) ? INPUT_PULLUP : INPUT)
// check if pin is an input
// Check if pin is an input
#define _GET_INPUT(IO)
// check if pin is an output
// Check if pin is an output
#define _GET_OUTPUT(IO)
// check if pin is a timer
// Check if pin is a timer
#define _GET_TIMER(IO)
// Read a pin wrapper
// Read a pin (wrapper)
#define READ(IO) _READ(IO)
// Write to a pin wrapper
// Write to a pin (wrapper)
#define WRITE_VAR(IO,V) _WRITE_VAR(IO,V)
#define WRITE(IO,V) _WRITE(IO,V)
// toggle a pin wrapper
// Toggle a pin (wrapper)
#define TOGGLE(IO) _TOGGLE(IO)
// set pin as input wrapper
// Set pin as input (wrapper)
#define SET_INPUT(IO) _SET_INPUT(IO)
// set pin as input with pullup wrapper
// Set pin as input with pullup (wrapper)
#define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
// set pin as output wrapper - reads the pin and sets the output to that value
// Set pin as output (wrapper) - reads the pin and sets the output to that value
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
// check if pin is an input wrapper
// Check if pin is an input (wrapper)
#define GET_INPUT(IO) _GET_INPUT(IO)
// check if pin is an output wrapper
// Check if pin is an output (wrapper)
#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
// check if pin is a timer (wrapper)
// Check if pin is a timer (wrapper)
#define GET_TIMER(IO) _GET_TIMER(IO)
// Shorthand