#ifndef __TCA6416_H #define __TCA6416_H #include "stm32f1xx_hal.h" /* TCA6416 I2C地址 */ #define TCA6416_ADDR 0x20 // 基础地址 (A0=A1=A2=GND) /* 寄存器地址定义 */ #define TCA6416_INPUT_PORT0 0x00 // 输入端口0 #define TCA6416_INPUT_PORT1 0x01 // 输入端口1 #define TCA6416_OUTPUT_PORT0 0x02 // 输出端口0 #define TCA6416_OUTPUT_PORT1 0x03 // 输出端口1 #define TCA6416_CONFIG_PORT0 0x06 // 配置端口0 #define TCA6416_CONFIG_PORT1 0x07 // 配置端口1 #define TCA6416_POL_INV_PORT0 0x04 // 极性反转端口0 #define TCA6416_POL_INV_PORT1 0x05 // 极性反转端口1 /* 函数声明 */ HAL_StatusTypeDef TCA6416_Init(I2C_HandleTypeDef *hi2c); HAL_StatusTypeDef TCA6416_WritePort(I2C_HandleTypeDef *hi2c, uint8_t port, uint8_t data); HAL_StatusTypeDef TCA6416_ReadPort(I2C_HandleTypeDef *hi2c, uint8_t port, uint8_t *data); HAL_StatusTypeDef TCA6416_SetPortDirection(I2C_HandleTypeDef *hi2c, uint8_t port, uint8_t direction); HAL_StatusTypeDef TCA6416_SetPortPolarity(I2C_HandleTypeDef *hi2c, uint8_t port, uint8_t polarity); HAL_StatusTypeDef TCA6416_WritePin(I2C_HandleTypeDef *hi2c, uint8_t port, uint8_t pin, uint8_t state); HAL_StatusTypeDef TCA6416_ReadPin(I2C_HandleTypeDef *hi2c, uint8_t port, uint8_t pin, uint8_t *state); #endif /* __TCA6416_H */