TB2026-YDS Firmware
Loading...
Searching...
No Matches
gpio_expander.c File Reference
#include "gpio_expander.h"
#include "i2c_bus.h"
#include "board_pins.h"

Macros

#define EXPANDER_ADDR   0x38
#define EXP_I2C_TIMEOUT   100 /* ms; fail loud rather than block forever */
#define REG_INPUT   0x00 /* read-only */
#define REG_OUTPUT   0x01
#define REG_CONFIG   0x03 /* direction: 1 = input, 0 = output */
#define EXP_OUTPUTS   ((1u << EXP_DAC_MUTE) | (1u << EXP_AMP_SHDN))
#define CONFIG_DIR   ((uint8_t)~EXP_OUTPUTS)

Functions

esp_err_t gpio_expander_init (i2c_master_bus_handle_t bus)
 Attach the expander to the shared I2C bus and set pin directions.
esp_err_t gpio_expander_set (uint8_t channel, bool level)
 Drive one output channel (read-modify-write of the cached output port).
esp_err_t gpio_expander_get (uint8_t channel, bool *level)
 Read one input channel's logic level.
esp_err_t gpio_expander_read_all (uint8_t *inputs)
 Read all 8 input-port levels in one transaction.

Detailed Description

Note
Développé avec l'assistance de Claude Opus 4.8 (Anthropic), sous la direction de Y. Dos Santos : spécification, revue et validation sur cible par l'auteur.

Macro Definition Documentation

◆ CONFIG_DIR

#define CONFIG_DIR   ((uint8_t)~EXP_OUTPUTS)

◆ EXP_I2C_TIMEOUT

#define EXP_I2C_TIMEOUT   100 /* ms; fail loud rather than block forever */

◆ EXP_OUTPUTS

#define EXP_OUTPUTS   ((1u << EXP_DAC_MUTE) | (1u << EXP_AMP_SHDN))

◆ EXPANDER_ADDR

#define EXPANDER_ADDR   0x38

◆ REG_CONFIG

#define REG_CONFIG   0x03 /* direction: 1 = input, 0 = output */

◆ REG_INPUT

#define REG_INPUT   0x00 /* read-only */

◆ REG_OUTPUT

#define REG_OUTPUT   0x01