lpcware

[sampleCode] GPIO Macro Definitions

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by behzat_c on Wed May 18 13:36:30 MST 2011
Hey everyone!

I just wrote those macros for pin input/output assignments and high/low functions. I hope someone can use them.

Any bug reports or comments will be wellcomed!


// GPIO Macro Definitions.

#define p0_high(pin) (LPC_GPIO0->FIOSET = (1 << pin))
#define p0_low(pin) (LPC_GPIO0->FIOCLR = (1 << pin))
#define p0_input(pin) (LPC_GPIO0->FIODIR &= ~(1 << pin))
#define p0_output(pin) (LPC_GPIO0->FIODIR |= (1 << pin))

#define p1_high(pin) (LPC_GPIO1->FIOSET = (1 << pin))
#define p1_low(pin) (LPC_GPIO1->FIOCLR = (1 << pin))
#define p1_input(pin) (LPC_GPIO1->FIODIR &= ~(1 << pin))
#define p1_output(pin) (LPC_GPIO1->FIODIR |= (1 << pin))

#define p2_high(pin) (LPC_GPIO2->FIOSET = (1 << pin))
#define p2_low(pin) (LPC_GPIO2->FIOCLR = (1 << pin))
#define p2_input(pin) (LPC_GPIO2->FIODIR &= ~(1 << pin))
#define p2_output(pin) (LPC_GPIO2->FIODIR |= (1 << pin))

#define p3_high(pin) (LPC_GPIO3->FIOSET = (1 << pin))
#define p3_low(pin) (LPC_GPIO3->FIOCLR = (1 << pin))
#define p3_input(pin) (LPC_GPIO3->FIODIR &= ~(1 << pin))
#define p3_output(pin) (LPC_GPIO3->FIODIR |= (1 << pin))

#define p4_high(pin) (LPC_GPIO4->FIOSET = (1 << pin))
#define p4_low(pin) (LPC_GPIO4->FIOCLR = (1 << pin))
#define p4_input(pin) (LPC_GPIO4->FIODIR &= ~(1 << pin))
#define p4_output(pin) (LPC_GPIO4->FIODIR |= (1 << pin))


--------------------------

I forgot to write, those macros written specially for LPC1769

Outcomes