Posted: 29 Mar 2012, 16:03
Thanks to the LPC Expresso support in the LPC1114 codebase, I am using the codebase now!
I note that the API to set/clear GPIO bits uses read/modify/write to the GPIO data register at 0x500x3ffc, with a clever use of the ternary operator to avoid an if statement.
write(bit, state):
state ? (*(uint32_t*)0x500x3ffc |= (1 << bit)) : (*(uint32_t*)0x500x3ffc &= ~(1 << bit))
Since this register is bit banded across the lower 12 bits of the address range, why not do
*((uint32_t*)0x500x0000 + (1<<bit)) = state ? 0x03ff : 0
This avoids the read of the GPIODATA register, which can flip bits if the corresponding pin is set to input.