Fix SET_OUTPUT glitch - LPC1768 & DUE

This commit is contained in:
Bob-the-Kuhn 2017-12-22 11:03:22 -06:00 committed by Scott Lahteine
parent 869c89d83f
commit 1a948cbd93
2 changed files with 12 additions and 10 deletions

View File

@ -78,14 +78,17 @@
#define _TOGGLE(IO) _WRITE(IO, !READ(IO)) #define _TOGGLE(IO) _WRITE(IO, !READ(IO))
/// set pin as input /// set pin as input
#define _SET_INPUT(IO) pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \ #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) 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) PIO_Configure(g_APinDescription[IO].pPort, PIO_OUTPUT_1, \ #define _SET_OUTPUT(IO) do{ pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
g_APinDescription[IO].ulPin, g_APinDescription[IO].ulPinConfiguration) PIO_Configure(g_APinDescription[IO].pPort, _READ(IO) ? PIO_OUTPUT_1 : PIO_OUTPUT_0, \
g_APinDescription[IO].ulPin, g_APinDescription[IO].ulPinConfiguration); \
}while(0)
/// set pin as input with pullup mode /// set pin as input with pullup mode
#define _PULLUP(IO, v) { pinMode(IO, (v!=LOW ? INPUT_PULLUP : INPUT)); } #define _PULLUP(IO, v) { pinMode(IO, v != LOW ? INPUT_PULLUP : INPUT); }
/// check if pin is an input /// check if pin is an input
#define _GET_INPUT(IO) #define _GET_INPUT(IO)
@ -109,9 +112,8 @@
#define SET_INPUT(IO) _SET_INPUT(IO) #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) #define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
/// set pin as output wrapper /// set pin as output wrapper - reads the pin and sets the output to that value
#define SET_OUTPUT(IO) do{ _SET_OUTPUT(IO); _WRITE(IO, LOW); }while(0) #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) #define GET_INPUT(IO) _GET_INPUT(IO)
/// check if pin is an output wrapper /// check if pin is an output wrapper

View File

@ -119,8 +119,8 @@ bool useable_hardware_PWM(pin_t pin);
#define SET_INPUT(IO) _SET_INPUT(IO) #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) #define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
/// set pin as output wrapper /// set pin as output wrapper - reads the pin and sets the output to that value
#define SET_OUTPUT(IO) do{ _SET_OUTPUT(IO); _WRITE(IO, LOW); }while(0) #define SET_OUTPUT(IO) do{ _WRITE(IO, _READ(IO)); _SET_OUTPUT(IO); }while(0)
/// check if pin is an input wrapper /// check if pin is an input wrapper
#define GET_INPUT(IO) _GET_INPUT(IO) #define GET_INPUT(IO) _GET_INPUT(IO)