Content originally posted in LPCWare by mohsin on Fri Jun 03 09:29:04 MST 2011
Hi All,
I am using LPC1114 in my project. In my project, I am using PIO2_7 pin as an digital output and also as digital input. I need to periodically change the pin direction to input, read the value and then change it back to output.
/*
** Make pin 2_7 an input
*/
GIO_set_direction_for_pin_2_7(LOGIC_0);
delay_for_pin_dir(); // delay before reading
busy_status = GIO_get_pin_2_7(); // [B]read the pin[/B]
/*
** Make pin 2_7 an output as busy status has been checked.
*/
GIO_set_direction_for_pin_2_7(LOGIC_1);
delay_for_pin_dir();
Can anyone please let me know if the above method is correct or are there any other precautions that need to be taken when changing the [B]pin direction from output to input[/B] ?
[B]void
GIO_set_direction_for[/B]_[B]pin_2_7[/B][B](
bool direction
) [/B]{
if(direction) {
LPC_IOCON->PIO2_7 = 0x00;
/*
** Output
*/
LPC_GPIO2->DIR |= 1 << HDW_OP_LCD_DB7_BIT;
}
else {
/*
** Input
*/
LPC_GPIO2->DIR &= ~(1 << HDW_OP_LCD_DB7_BIT);
}
}