I'm working with a design that has several GPIO inputs and outputs connected to a TCA8418. After looking through the datasheet, I have a few questions, and I'd also like to confirm that I'm not misunderstanding anything.
Outputs
Here's my understanding of how to configure/use a GPIO output after a POR:
- Write to the GPIO_DIR# registers to configure pins as outputs
- Write to the GPIO_DAT_OUT# registers to toggle outputs on/off
That's all I can glean from the datasheet. After POR, every pin defaults to GPIO mode (as per the KP_GPIO# registers), so I don't think there's anything else to do.
Inputs
I'm trying to configure the inputs as simply as possible — no FIFO, no interrupts, no debounce, nothing like that. Here's what the process seems to be:
- Write to the GPIO_PULL# registers to configure pull-ups
- Read the GPIO_DAT_STAT# registers to poll input status
Again, this seems simple enough. Pins default to GPIO mode (KP_GPIO#) and interrupts are disabled (GPIO_INT_EN#) on POR, so this seems to be sufficient.
I'm also curious how to read from the GPIO_DAT_STAT# registers. The datasheet says the following:
These registers show the GPIO state when read for inputs and outputs. Read these twice to clear them.
The last sentence doesn't make sense to me. What does it mean to "clear" this register? To me, this implies that these values latch when set, but I can't find this mentioned anywhere in the datasheet. Do these registers reflect the current state of GPIO inputs? Or do they need to be read twice (cleared) to get the current status?
Thanks!