tca8418 0.2.0

Platform-agnostic Rust driver for the TCA8418 I²C keypad scan IC
Documentation

tca8418

Crates.io docs.rs CI License

Platform-agnostic Rust driver for the Texas Instruments TCA8418 I²C keypad scan IC, built on embedded-hal traits.

The TCA8418 supports up to 80 keys (8 rows × 10 columns), with a 10-event FIFO, configurable GPIO pins, hardware debounce, and interrupt output. It operates from 1.65V to 3.6V and communicates over I²C at up to 1 MHz.

Features

  • no_std compatible — works on any microcontroller
  • Keypad matrix configuration with flexible row/column selection
  • 10-event FIFO with iterator-based draining
  • GPIO input/output on unused pins
  • Interrupt status reading and clearing
  • Keypad lock/unlock with configurable timers
  • Pull-up resistor and debounce control per pin

Quick Start

This is a simple example using active polling. See the docs for more examples.

use tca8418::{Tca8418, PinMask, InterruptFlags};
 
// Create the driver
let mut keypad = Tca8418::new(i2c);
 
// Configure rows 0–6 and columns 0–8 as the keypad matrix
let pins = PinMask::rows(0b0111_1111) | PinMask::cols(0b0001_1111_1111);
keypad.configure_keypad(pins).unwrap();
 
// Poll for events
loop {
    for event in keypad.events() {
        if let Some(key) = event.pressed_keypad() {
            // key.row, key.col
        }
    }
}