|
|
|
@ -55,7 +55,7 @@ bool useable_hardware_PWM(pin_t pin);
|
|
|
|
|
#define WRITE_PIN_CLR(IO) (LPC_GPIO(LPC1768_PIN_PORT(IO))->FIOCLR = LPC_PIN(LPC1768_PIN_PIN(IO)))
|
|
|
|
|
|
|
|
|
|
#define READ_PIN(IO) ((LPC_GPIO(LPC1768_PIN_PORT(IO))->FIOPIN & LPC_PIN(LPC1768_PIN_PIN(IO))) ? 1 : 0)
|
|
|
|
|
#define WRITE_PIN(IO, v) ((v) ? WRITE_PIN_SET(IO) : WRITE_PIN_CLR(IO))
|
|
|
|
|
#define WRITE_PIN(IO,V) ((V) ? WRITE_PIN_SET(IO) : WRITE_PIN_CLR(IO))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Magic I/O routines
|
|
|
|
@ -69,9 +69,9 @@ bool useable_hardware_PWM(pin_t pin);
|
|
|
|
|
#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))
|
|
|
|
@ -83,10 +83,10 @@ bool useable_hardware_PWM(pin_t pin);
|
|
|
|
|
#define _SET_OUTPUT(IO) SET_DIR_OUTPUT(IO)
|
|
|
|
|
|
|
|
|
|
/// 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) ? INPUT_PULLUP : INPUT)
|
|
|
|
|
|
|
|
|
|
/// set pin as input with pulldown mode
|
|
|
|
|
#define _PULLDOWN(IO, v) (pinMode(IO, (v!=LOW ? 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)
|
|
|
|
@ -112,8 +112,8 @@ bool useable_hardware_PWM(pin_t pin);
|
|
|
|
|
#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)
|
|
|
|
@ -136,6 +136,6 @@ bool useable_hardware_PWM(pin_t pin);
|
|
|
|
|
#define GET_TIMER(IO) _GET_TIMER(IO)
|
|
|
|
|
|
|
|
|
|
// Shorthand
|
|
|
|
|
#define OUT_WRITE(IO, v) { SET_OUTPUT(IO); WRITE(IO, v); }
|
|
|
|
|
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
|
|
|
|
|
|
|
|
|
#endif // _FASTIO_LPC1768_H
|
|
|
|
|