PebbleOS v4.47.0-1219-g7c542d7a9
Loading...
Searching...
No Matches
TCA8418

TI TCA8418 key matrix scanner. More...

Data Structures

struct  pbl_tca8418
 TCA8418. More...
 

Macros

#define PBL_TCA8418_NUM_PINS   18U
 Pins, ROW0-7 then COL0-9.
 
#define PBL_TCA8418_DEFINE(sym, _bus, _addr, _irq, _num_rows, _num_cols, ...)
 Define and register a TCA8418, the GPIO port sym _gpio of its other pins and their interrupt controller sym _intc.
 

Detailed Description

TI TCA8418 key matrix scanner.

Every key event is reported as a PBL_INPUT_MSC_SCAN of (row << 8) | column, then as a PBL_INPUT_EV_KEY with its code in the keymap, or PBL_INPUT_KEY_UNKNOWN.

The pins outside the matrix are GPIOs, ROW0-7 as 0-7 and COL0-9 as 8-17, whose inputs interrupt on both edges, e.g. for keys wired to ground with gpio-keys. Their calls may block.


Data Structure Documentation

◆ pbl_tca8418

struct pbl_tca8418

TCA8418.

Data Fields
struct pbl_device dev Device, child of the I2C bus.
struct pbl_i2c_dev i2c I2C device.
const struct pbl_intc * intc Interrupt controller of the GPIOs.
struct pbl_irq_spec irq Interrupt.
const uint32_t * keymap Keymap, linux,keymap entries from MATRIX_KEY().
uint8_t keymap_len Keymap entries.
uint8_t num_cols Columns, keypad,num-columns.
uint8_t num_rows Rows, keypad,num-rows.
struct pbl_tca8418_state * state Runtime state.

Macro Definition Documentation

◆ PBL_TCA8418_DEFINE

#define PBL_TCA8418_DEFINE (   sym,
  _bus,
  _addr,
  _irq,
  _num_rows,
  _num_cols,
  ... 
)
Value:
extern const struct pbl_intc sym##_intc; \
static const uint32_t sym##_keymap[] = {__VA_ARGS__ __VA_OPT__(, ) 0U}; \
static struct pbl_tca8418_state sym##_tca8418_state = {.lock = PBL_MUTEX_INITIALIZER}; \
PBL_DEVICE_STATE_DEFINE(sym); \
PBL_DEVICE_STATE_DEFINE(sym##_gpio); \
PBL_INTC_STATE_DEFINE(sym##_intc, PBL_TCA8418_NUM_PINS); \
PBL_DEVICE_INSTANCE_DEV(sym, struct pbl_tca8418){ \
.dev = PBL_DEVICE_INIT(sym, "tca8418", pbl_tca8418_init, &(_bus)->dev), \
.i2c = PBL_I2C_DEV(_bus, _addr), \
.irq = _irq, \
.num_rows = (_num_rows), \
.num_cols = (_num_cols), \
.keymap = sym##_keymap, \
.keymap_len = PBL_ARRAY_SIZE(sym##_keymap) - 1U, \
.intc = &sym##_intc, \
.state = &sym##_tca8418_state, \
}; \
PBL_DEVICE_INSTANCE(sym##_gpio, struct pbl_tca8418_gpio, struct pbl_gpio_port, port){ \
.port = PBL_GPIO_PORT_INIT(sym##_gpio, "tca8418_gpio", nullptr, &sym##_inst.dev, \
&pbl_tca8418_gpio_ops, PBL_TCA8418_NUM_PINS, &sym##_intc), \
.tca = &sym##_inst, \
}; \
PBL_DEVICE_INSTANCE(sym##_intc, struct pbl_tca8418_intc, struct pbl_intc, intc) { \
.intc = PBL_INTC_INIT(sym##_intc, "tca8418_intc", nullptr, &sym##_inst.dev, \
&pbl_tca8418_intc_ops), \
.tca = &sym##_inst, \
}
#define PBL_DEVICE_INIT(sym, _name, _init, _parent)
Initializer for the struct pbl_device of device instance sym.
Definition device.h:169
A GPIO controller.
Definition gpio.h:119
#define PBL_GPIO_PORT_INIT(sym, _name, _init, _parent, _ops, _num_pins, _intc)
Initializer for a struct pbl_gpio_port.
Definition gpio.h:157
#define PBL_I2C_DEV(_bus, _addr)
Initializer for a struct pbl_i2c_dev.
Definition i2c.h:136
TCA8418.
Definition tca8418.h:45
#define PBL_TCA8418_NUM_PINS
Pins, ROW0-7 then COL0-9.
Definition tca8418.h:30
An interrupt controller.
Definition intc.h:92
#define PBL_INTC_INIT(sym, _name, _init, _parent, _ops)
Initializer for the struct pbl_intc of controller sym.
Definition intc.h:126
#define PBL_MUTEX_INITIALIZER
Static initializer for an unlocked mutex.
Definition mutex.h:50
#define PBL_ARRAY_SIZE(array)
Get the number of elements of an array.
Definition size.h:40

Define and register a TCA8418, the GPIO port sym _gpio of its other pins and their interrupt controller sym _intc.

Parameters
symSymbol of the struct pbl_tca8418.
_busI2C bus.
_addr7-bit I2C address.
_irqInterrupt, a struct pbl_irq_spec.
_num_rowsRows.
_num_colsColumns.
...Keymap entries, from MATRIX_KEY(), if any.

◆ PBL_TCA8418_NUM_PINS

#define PBL_TCA8418_NUM_PINS   18U

Pins, ROW0-7 then COL0-9.