Clean up fastIO ahead of PWM patch
This commit is contained in:
@ -30,16 +30,16 @@
|
||||
|
||||
#define USEABLE_HARDWARE_PWM(pin) false
|
||||
|
||||
#define SET_DIR_INPUT(IO) Gpio::setDir(IO, 1)
|
||||
#define SET_DIR_OUTPUT(IO) Gpio::setDir(IO, 0)
|
||||
#define SET_DIR_INPUT(IO) Gpio::setDir(IO, 1)
|
||||
#define SET_DIR_OUTPUT(IO) Gpio::setDir(IO, 0)
|
||||
|
||||
#define SET_MODE(IO, mode) Gpio::setMode(IO, mode)
|
||||
#define SET_MODE(IO, mode) Gpio::setMode(IO, mode)
|
||||
|
||||
#define WRITE_PIN_SET(IO) Gpio::set(IO)
|
||||
#define WRITE_PIN_CLR(IO) Gpio::clear(IO)
|
||||
#define WRITE_PIN_SET(IO) Gpio::set(IO)
|
||||
#define WRITE_PIN_CLR(IO) Gpio::clear(IO)
|
||||
|
||||
#define READ_PIN(IO) Gpio::get(IO)
|
||||
#define WRITE_PIN(IO,V) Gpio::set(IO, V)
|
||||
#define READ_PIN(IO) Gpio::get(IO)
|
||||
#define WRITE_PIN(IO,V) Gpio::set(IO, V)
|
||||
|
||||
/**
|
||||
* Magic I/O routines
|
||||
@ -50,77 +50,77 @@
|
||||
*/
|
||||
|
||||
/// Read a pin
|
||||
#define _READ(IO) READ_PIN(IO)
|
||||
#define _READ(IO) READ_PIN(IO)
|
||||
|
||||
/// Write to a pin
|
||||
#define _WRITE_VAR(IO,V) digitalWrite(IO,V)
|
||||
#define _WRITE_VAR(IO,V) digitalWrite(IO,V)
|
||||
|
||||
#define _WRITE(IO,V) WRITE_PIN(IO,V)
|
||||
#define _WRITE(IO,V) WRITE_PIN(IO,V)
|
||||
|
||||
/// toggle a pin
|
||||
#define _TOGGLE(IO) _WRITE(IO, !READ(IO))
|
||||
#define _TOGGLE(IO) _WRITE(IO, !READ(IO))
|
||||
|
||||
/// set pin as input
|
||||
#define _SET_INPUT(IO) SET_DIR_INPUT(IO)
|
||||
#define _SET_INPUT(IO) SET_DIR_INPUT(IO)
|
||||
|
||||
/// set pin as output
|
||||
#define _SET_OUTPUT(IO) SET_DIR_OUTPUT(IO)
|
||||
#define _SET_OUTPUT(IO) SET_DIR_OUTPUT(IO)
|
||||
|
||||
/// set pin as input with pullup mode
|
||||
#define _PULLUP(IO,V) pinMode(IO, (V) ? INPUT_PULLUP : INPUT)
|
||||
#define _PULLUP(IO,V) pinMode(IO, (V) ? INPUT_PULLUP : INPUT)
|
||||
|
||||
/// set pin as input with pulldown mode
|
||||
#define _PULLDOWN(IO,V) pinMode(IO, (V) ? INPUT_PULLDOWN : INPUT)
|
||||
#define _PULLDOWN(IO,V) pinMode(IO, (V) ? INPUT_PULLDOWN : INPUT)
|
||||
|
||||
// hg42: all pins can be input or output (I hope)
|
||||
// hg42: undefined pins create compile error (IO, is no pin)
|
||||
// hg42: currently not used, but was used by pinsDebug
|
||||
|
||||
/// check if pin is an input
|
||||
#define _GET_INPUT(IO) (LPC1768_PIN_PIN(IO) >= 0)
|
||||
#define _GET_INPUT(IO) (LPC1768_PIN_PIN(IO) >= 0)
|
||||
|
||||
/// check if pin is an output
|
||||
#define _GET_OUTPUT(IO) (LPC1768_PIN_PIN(IO) >= 0)
|
||||
#define _GET_OUTPUT(IO) (LPC1768_PIN_PIN(IO) >= 0)
|
||||
|
||||
// hg42: GET_TIMER is used only to check if it's a PWM pin
|
||||
// hg42: we cannot use USEABLE_HARDWARE_PWM because it uses a function that cannot be used statically
|
||||
// hg42: instead use PWM bit from the #define
|
||||
|
||||
/// check if pin is a timer
|
||||
#define _GET_TIMER(IO) TRUE // could be LPC1768_PIN_PWM(IO), but there
|
||||
#define _GET_TIMER(IO) true // could be LPC1768_PIN_PWM(IO), but there
|
||||
// hg42: could be this:
|
||||
// #define _GET_TIMER(IO) LPC1768_PIN_PWM(IO)
|
||||
// but this is an incomplete check (12 pins are PWMable, but only 6 can be used at the same time)
|
||||
|
||||
/// Read a pin wrapper
|
||||
#define READ(IO) _READ(IO)
|
||||
#define READ(IO) _READ(IO)
|
||||
|
||||
/// Write to a pin wrapper
|
||||
#define WRITE_VAR(IO,V) _WRITE_VAR(IO,V)
|
||||
#define WRITE(IO,V) _WRITE(IO,V)
|
||||
#define WRITE_VAR(IO,V) _WRITE_VAR(IO,V)
|
||||
#define WRITE(IO,V) _WRITE(IO,V)
|
||||
|
||||
/// toggle a pin wrapper
|
||||
#define TOGGLE(IO) _TOGGLE(IO)
|
||||
#define TOGGLE(IO) _TOGGLE(IO)
|
||||
|
||||
/// set pin as input wrapper
|
||||
#define SET_INPUT(IO) _SET_INPUT(IO)
|
||||
#define SET_INPUT(IO) _SET_INPUT(IO)
|
||||
/// 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 input with pulldown wrapper
|
||||
#define SET_INPUT_PULLDOWN(IO) do{ _SET_INPUT(IO); _PULLDOWN(IO, HIGH); }while(0)
|
||||
#define SET_INPUT_PULLDOWN(IO) do{ _SET_INPUT(IO); _PULLDOWN(IO, HIGH); }while(0)
|
||||
/// set pin as output wrapper - reads the pin and sets the output to that value
|
||||
#define SET_OUTPUT(IO) do{ _WRITE(IO, _READ(IO)); _SET_OUTPUT(IO); }while(0)
|
||||
#define SET_OUTPUT(IO) do{ _WRITE(IO, _READ(IO)); _SET_OUTPUT(IO); }while(0)
|
||||
|
||||
/// 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
|
||||
#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
|
||||
#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
|
||||
|
||||
/// check if pin is a timer (wrapper)
|
||||
#define GET_TIMER(IO) _GET_TIMER(IO)
|
||||
#define GET_TIMER(IO) _GET_TIMER(IO)
|
||||
|
||||
// Shorthand
|
||||
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||
|
||||
// digitalRead/Write wrappers
|
||||
#define extDigitalRead(IO) digitalRead(IO)
|
||||
|
Reference in New Issue
Block a user