Skip to main content

Module tca8418

Module tca8418 

Source
Expand description

TI TCA8418 I²C keypad scanner.

The chip scans a key matrix of up to 8 rows × 10 columns on its own and queues press/release events in a 10-deep FIFO, pulling INT low while events are pending. The host only has to drain the FIFO, so a keyboard costs nothing until a key actually changes.

ⓘ
let mut kp = Tca8418::new(i2c, DEFAULT_ADDRESS);
kp.configure(Matrix::new(7, 8)).await?;
loop {
    int.wait_for_low().await?;
    let mut fifo = [0; FIFO_DEPTH];
    for raw in kp.drain(&mut fifo).await? {
        if let Some(Event::Key(k)) = Event::decode(*raw) { /* ... */ }
    }
    kp.clear_interrupts().await?;
}

Structs§

KeyEvent
A key press or release at a position in the scan matrix.
Matrix
The rows × columns window of the chip’s pins used as a key matrix.
Tca8418
TCA8418 driver.

Enums§

Event
One entry popped from the event FIFO.

Constants§

DEFAULT_ADDRESS
Factory-fixed 7-bit I²C address.
FIFO_DEPTH
Depth of the on-chip event FIFO.