mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 13:38:12 +00:00
chore(core): unify i2c instances numbering
[no changelog]
This commit is contained in:
parent
834693a115
commit
7d7ccc9dde
@ -16,18 +16,18 @@
|
||||
#include "displays/ltdc.h"
|
||||
|
||||
#define I2C_COUNT 1
|
||||
#define I2C_INSTANCE_1 I2C3
|
||||
#define I2C_INSTANCE_1_CLK_EN __HAL_RCC_I2C3_CLK_ENABLE
|
||||
#define I2C_INSTANCE_1_CLK_DIS __HAL_RCC_I2C3_CLK_DISABLE
|
||||
#define I2C_INSTANCE_1_PIN_AF GPIO_AF4_I2C3
|
||||
#define I2C_INSTANCE_1_SDA_PORT GPIOC
|
||||
#define I2C_INSTANCE_1_SDA_PIN GPIO_PIN_9
|
||||
#define I2C_INSTANCE_1_SDA_CLK_EN __HAL_RCC_GPIOC_CLK_ENABLE
|
||||
#define I2C_INSTANCE_1_SCL_PORT GPIOA
|
||||
#define I2C_INSTANCE_1_SCL_PIN GPIO_PIN_8
|
||||
#define I2C_INSTANCE_1_SCL_CLK_EN __HAL_RCC_GPIOA_CLK_ENABLE
|
||||
#define I2C_INSTANCE_1_RESET_FLG RCC_APB1RSTR_I2C3RST
|
||||
#define I2C_INSTANCE_0 I2C3
|
||||
#define I2C_INSTANCE_0_CLK_EN __HAL_RCC_I2C3_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_CLK_DIS __HAL_RCC_I2C3_CLK_DISABLE
|
||||
#define I2C_INSTANCE_0_PIN_AF GPIO_AF4_I2C3
|
||||
#define I2C_INSTANCE_0_SDA_PORT GPIOC
|
||||
#define I2C_INSTANCE_0_SDA_PIN GPIO_PIN_9
|
||||
#define I2C_INSTANCE_0_SDA_CLK_EN __HAL_RCC_GPIOC_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_SCL_PORT GPIOA
|
||||
#define I2C_INSTANCE_0_SCL_PIN GPIO_PIN_8
|
||||
#define I2C_INSTANCE_0_SCL_CLK_EN __HAL_RCC_GPIOA_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_RESET_FLG RCC_APB1RSTR_I2C3RST
|
||||
|
||||
#define TOUCH_I2C_NUM 0
|
||||
#define TOUCH_I2C_INSTANCE 0
|
||||
|
||||
#endif //_STM32F429I_DISC1_H
|
||||
|
@ -13,19 +13,19 @@
|
||||
#include "displays/dsi.h"
|
||||
|
||||
#define I2C_COUNT 1
|
||||
#define I2C_INSTANCE_1 I2C5
|
||||
#define I2C_INSTANCE_1_CLK_EN __HAL_RCC_I2C5_CLK_ENABLE
|
||||
#define I2C_INSTANCE_1_CLK_DIS __HAL_RCC_I2C5_CLK_DISABLE
|
||||
#define I2C_INSTANCE_1_PIN_AF GPIO_AF2_I2C5
|
||||
#define I2C_INSTANCE_1_SDA_PORT GPIOH
|
||||
#define I2C_INSTANCE_1_SDA_PIN GPIO_PIN_4
|
||||
#define I2C_INSTANCE_1_SDA_CLK_EN __HAL_RCC_GPIOH_CLK_ENABLE
|
||||
#define I2C_INSTANCE_1_SCL_PORT GPIOH
|
||||
#define I2C_INSTANCE_1_SCL_PIN GPIO_PIN_5
|
||||
#define I2C_INSTANCE_1_SCL_CLK_EN __HAL_RCC_GPIOH_CLK_ENABLE
|
||||
#define I2C_INSTANCE_1_RESET_REG &RCC->APB1RSTR2
|
||||
#define I2C_INSTANCE_1_RESET_BIT RCC_APB1RSTR2_I2C5RST
|
||||
#define I2C_INSTANCE_0 I2C5
|
||||
#define I2C_INSTANCE_0_CLK_EN __HAL_RCC_I2C5_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_CLK_DIS __HAL_RCC_I2C5_CLK_DISABLE
|
||||
#define I2C_INSTANCE_0_PIN_AF GPIO_AF2_I2C5
|
||||
#define I2C_INSTANCE_0_SDA_PORT GPIOH
|
||||
#define I2C_INSTANCE_0_SDA_PIN GPIO_PIN_4
|
||||
#define I2C_INSTANCE_0_SDA_CLK_EN __HAL_RCC_GPIOH_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_SCL_PORT GPIOH
|
||||
#define I2C_INSTANCE_0_SCL_PIN GPIO_PIN_5
|
||||
#define I2C_INSTANCE_0_SCL_CLK_EN __HAL_RCC_GPIOH_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_RESET_REG &RCC->APB1RSTR2
|
||||
#define I2C_INSTANCE_0_RESET_BIT RCC_APB1RSTR2_I2C5RST
|
||||
|
||||
#define TOUCH_I2C_NUM 0
|
||||
#define TOUCH_I2C_INSTANCE 0
|
||||
|
||||
#endif // STM32U5A9J_DK_H_
|
||||
|
@ -38,17 +38,17 @@
|
||||
#define OLED_SPI_MOSI_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE
|
||||
|
||||
#define I2C_COUNT 1
|
||||
#define I2C_INSTANCE_1 I2C2
|
||||
#define I2C_INSTANCE_1_CLK_EN __HAL_RCC_I2C2_CLK_ENABLE
|
||||
#define I2C_INSTANCE_1_CLK_DIS __HAL_RCC_I2C2_CLK_DISABLE
|
||||
#define I2C_INSTANCE_1_PIN_AF GPIO_AF4_I2C2
|
||||
#define I2C_INSTANCE_1_SDA_PORT GPIOB
|
||||
#define I2C_INSTANCE_1_SDA_PIN GPIO_PIN_11
|
||||
#define I2C_INSTANCE_1_SDA_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
|
||||
#define I2C_INSTANCE_1_SCL_PORT GPIOB
|
||||
#define I2C_INSTANCE_1_SCL_PIN GPIO_PIN_10
|
||||
#define I2C_INSTANCE_1_SCL_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
|
||||
#define I2C_INSTANCE_1_RESET_FLG RCC_APB1RSTR_I2C2RST
|
||||
#define I2C_INSTANCE_0 I2C2
|
||||
#define I2C_INSTANCE_0_CLK_EN __HAL_RCC_I2C2_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_CLK_DIS __HAL_RCC_I2C2_CLK_DISABLE
|
||||
#define I2C_INSTANCE_0_PIN_AF GPIO_AF4_I2C2
|
||||
#define I2C_INSTANCE_0_SDA_PORT GPIOB
|
||||
#define I2C_INSTANCE_0_SDA_PIN GPIO_PIN_11
|
||||
#define I2C_INSTANCE_0_SDA_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_SCL_PORT GPIOB
|
||||
#define I2C_INSTANCE_0_SCL_PIN GPIO_PIN_10
|
||||
#define I2C_INSTANCE_0_SCL_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_RESET_FLG RCC_APB1RSTR_I2C2RST
|
||||
|
||||
#define OPTIGA_I2C_INSTANCE 0
|
||||
|
||||
|
@ -33,20 +33,20 @@
|
||||
#define BACKLIGHT_PWM_PORT_CLK_EN __HAL_RCC_GPIOA_CLK_ENABLE
|
||||
|
||||
#define I2C_COUNT 1
|
||||
#define I2C_INSTANCE_1 I2C1
|
||||
#define I2C_INSTANCE_1_CLK_EN __HAL_RCC_I2C1_CLK_ENABLE
|
||||
#define I2C_INSTANCE_1_CLK_DIS __HAL_RCC_I2C1_CLK_DISABLE
|
||||
#define I2C_INSTANCE_1_PIN_AF GPIO_AF4_I2C1
|
||||
#define I2C_INSTANCE_1_SDA_PORT GPIOB
|
||||
#define I2C_INSTANCE_1_SDA_PIN GPIO_PIN_7
|
||||
#define I2C_INSTANCE_1_SDA_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
|
||||
#define I2C_INSTANCE_1_SCL_PORT GPIOB
|
||||
#define I2C_INSTANCE_1_SCL_PIN GPIO_PIN_6
|
||||
#define I2C_INSTANCE_1_SCL_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
|
||||
#define I2C_INSTANCE_1_RESET_FLG RCC_APB1RSTR_I2C1RST
|
||||
#define I2C_INSTANCE_0 I2C1
|
||||
#define I2C_INSTANCE_0_CLK_EN __HAL_RCC_I2C1_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_CLK_DIS __HAL_RCC_I2C1_CLK_DISABLE
|
||||
#define I2C_INSTANCE_0_PIN_AF GPIO_AF4_I2C1
|
||||
#define I2C_INSTANCE_0_SDA_PORT GPIOB
|
||||
#define I2C_INSTANCE_0_SDA_PIN GPIO_PIN_7
|
||||
#define I2C_INSTANCE_0_SDA_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_SCL_PORT GPIOB
|
||||
#define I2C_INSTANCE_0_SCL_PIN GPIO_PIN_6
|
||||
#define I2C_INSTANCE_0_SCL_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_RESET_FLG RCC_APB1RSTR_I2C1RST
|
||||
|
||||
#define TOUCH_SENSITIVITY 0x06
|
||||
#define TOUCH_I2C_NUM 0
|
||||
#define TOUCH_I2C_INSTANCE 0
|
||||
#define TOUCH_RST_PORT GPIOC
|
||||
#define TOUCH_RST_PIN GPIO_PIN_5
|
||||
#define TOUCH_INT_PORT GPIOC
|
||||
|
0
core/embed/trezorhal/boards/trezor_t3t1_v4.h
Normal file
0
core/embed/trezorhal/boards/trezor_t3t1_v4.h
Normal file
@ -18,6 +18,16 @@ typedef struct {
|
||||
} i2c_instance_t;
|
||||
|
||||
i2c_instance_t i2c_defs[I2C_COUNT] = {
|
||||
{
|
||||
.Instance = I2C_INSTANCE_0,
|
||||
.SclPort = I2C_INSTANCE_0_SCL_PORT,
|
||||
.SdaPort = I2C_INSTANCE_0_SDA_PORT,
|
||||
.SclPin = I2C_INSTANCE_0_SCL_PIN,
|
||||
.SdaPin = I2C_INSTANCE_0_SDA_PIN,
|
||||
.PinAF = I2C_INSTANCE_0_PIN_AF,
|
||||
.Reset = I2C_INSTANCE_0_RESET_FLG,
|
||||
},
|
||||
#ifdef I2C_INSTANCE_1
|
||||
{
|
||||
.Instance = I2C_INSTANCE_1,
|
||||
.SclPort = I2C_INSTANCE_1_SCL_PORT,
|
||||
@ -27,16 +37,6 @@ i2c_instance_t i2c_defs[I2C_COUNT] = {
|
||||
.PinAF = I2C_INSTANCE_1_PIN_AF,
|
||||
.Reset = I2C_INSTANCE_1_RESET_FLG,
|
||||
},
|
||||
#ifdef I2C_INSTANCE_2
|
||||
{
|
||||
.Instance = I2C_INSTANCE_2,
|
||||
.SclPort = I2C_INSTANCE_2_SCL_PORT,
|
||||
.SdaPort = I2C_INSTANCE_2_SDA_PORT,
|
||||
.SclPin = I2C_INSTANCE_2_SCL_PIN,
|
||||
.SdaPin = I2C_INSTANCE_2_SDA_PIN,
|
||||
.PinAF = I2C_INSTANCE_2_PIN_AF,
|
||||
.Reset = I2C_INSTANCE_2_RESET_FLG,
|
||||
},
|
||||
#endif
|
||||
|
||||
};
|
||||
@ -60,7 +60,6 @@ void i2c_init_instance(uint16_t idx, i2c_instance_t *instance) {
|
||||
HAL_GPIO_Init(instance->SclPort, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.Alternate = instance->PinAF;
|
||||
;
|
||||
GPIO_InitStructure.Pin = instance->SdaPin;
|
||||
HAL_GPIO_Init(instance->SdaPort, &GPIO_InitStructure);
|
||||
|
||||
@ -82,16 +81,16 @@ void i2c_init_instance(uint16_t idx, i2c_instance_t *instance) {
|
||||
|
||||
void i2c_init(void) {
|
||||
// enable I2C clock
|
||||
I2C_INSTANCE_1_CLK_EN();
|
||||
I2C_INSTANCE_1_SCL_CLK_EN();
|
||||
I2C_INSTANCE_1_SDA_CLK_EN();
|
||||
I2C_INSTANCE_0_CLK_EN();
|
||||
I2C_INSTANCE_0_SCL_CLK_EN();
|
||||
I2C_INSTANCE_0_SDA_CLK_EN();
|
||||
|
||||
i2c_init_instance(0, &i2c_defs[0]);
|
||||
|
||||
#ifdef I2C_INSTANCE_2
|
||||
I2C_INSTANCE_2_CLK_EN();
|
||||
I2C_INSTANCE_2_SCL_CLK_EN();
|
||||
I2C_INSTANCE_2_SDA_CLK_EN();
|
||||
#ifdef I2C_INSTANCE_1
|
||||
I2C_INSTANCE_1_CLK_EN();
|
||||
I2C_INSTANCE_1_SCL_CLK_EN();
|
||||
I2C_INSTANCE_1_SDA_CLK_EN();
|
||||
i2c_init_instance(1, &i2c_defs[1]);
|
||||
#endif
|
||||
}
|
||||
|
@ -102,11 +102,12 @@ void touch_set_mode(void) {
|
||||
// generates a pulse when new data is available
|
||||
uint8_t touch_panel_config[] = {0xA4, 0x01};
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (HAL_OK == i2c_transmit(TOUCH_I2C_NUM, TOUCH_ADDRESS, touch_panel_config,
|
||||
sizeof(touch_panel_config), 10)) {
|
||||
if (HAL_OK == i2c_transmit(TOUCH_I2C_INSTANCE, TOUCH_ADDRESS,
|
||||
touch_panel_config, sizeof(touch_panel_config),
|
||||
10)) {
|
||||
return;
|
||||
}
|
||||
i2c_cycle(TOUCH_I2C_NUM);
|
||||
i2c_cycle(TOUCH_I2C_INSTANCE);
|
||||
}
|
||||
|
||||
ensure(secfalse, "Touch screen panel was not loaded properly.");
|
||||
@ -146,12 +147,12 @@ void touch_sensitivity(uint8_t value) {
|
||||
// set panel threshold (TH_GROUP) - default value is 0x12
|
||||
uint8_t touch_panel_threshold[] = {0x80, value};
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (HAL_OK == i2c_transmit(TOUCH_I2C_NUM, TOUCH_ADDRESS,
|
||||
if (HAL_OK == i2c_transmit(TOUCH_I2C_INSTANCE, TOUCH_ADDRESS,
|
||||
touch_panel_threshold,
|
||||
sizeof(touch_panel_threshold), 10)) {
|
||||
return;
|
||||
}
|
||||
i2c_cycle(TOUCH_I2C_NUM);
|
||||
i2c_cycle(TOUCH_I2C_INSTANCE);
|
||||
}
|
||||
|
||||
ensure(secfalse, "Touch screen panel was not loaded properly.");
|
||||
@ -217,14 +218,14 @@ uint32_t touch_read(void) {
|
||||
last_check_time = hal_ticks_ms();
|
||||
|
||||
uint8_t outgoing[] = {0x00}; // start reading from address 0x00
|
||||
int result =
|
||||
i2c_transmit(TOUCH_I2C_NUM, TOUCH_ADDRESS, outgoing, sizeof(outgoing), 1);
|
||||
int result = i2c_transmit(TOUCH_I2C_INSTANCE, TOUCH_ADDRESS, outgoing,
|
||||
sizeof(outgoing), 1);
|
||||
if (result != HAL_OK) {
|
||||
if (result == HAL_BUSY) i2c_cycle(TOUCH_I2C_NUM);
|
||||
if (result == HAL_BUSY) i2c_cycle(TOUCH_I2C_INSTANCE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (HAL_OK != i2c_receive(TOUCH_I2C_NUM, TOUCH_ADDRESS, touch_data,
|
||||
if (HAL_OK != i2c_receive(TOUCH_I2C_INSTANCE, TOUCH_ADDRESS, touch_data,
|
||||
TOUCH_PACKET_SIZE, 1)) {
|
||||
return 0; // read failure
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ uint32_t I2cxTimeout =
|
||||
/**
|
||||
* @brief I2Cx error treatment function
|
||||
*/
|
||||
static void I2Cx_Error(void) { i2c_cycle(TOUCH_I2C_NUM); }
|
||||
static void I2Cx_Error(void) { i2c_cycle(TOUCH_I2C_INSTANCE); }
|
||||
|
||||
/**
|
||||
* @brief Writes a value in a register of the device through BUS.
|
||||
@ -194,7 +194,7 @@ static void I2Cx_Error(void) { i2c_cycle(TOUCH_I2C_NUM); }
|
||||
static void I2Cx_WriteData(uint8_t Addr, uint8_t Reg, uint8_t Value) {
|
||||
HAL_StatusTypeDef status = HAL_OK;
|
||||
|
||||
status = i2c_mem_write(TOUCH_I2C_NUM, Addr, (uint16_t)Reg,
|
||||
status = i2c_mem_write(TOUCH_I2C_INSTANCE, Addr, (uint16_t)Reg,
|
||||
I2C_MEMADD_SIZE_8BIT, &Value, 1, I2cxTimeout);
|
||||
|
||||
/* Check the communication status */
|
||||
@ -215,7 +215,7 @@ static void I2Cx_WriteBuffer(uint8_t Addr, uint8_t Reg, uint8_t *pBuffer,
|
||||
uint16_t Length) {
|
||||
HAL_StatusTypeDef status = HAL_OK;
|
||||
|
||||
status = i2c_mem_write(TOUCH_I2C_NUM, Addr, (uint16_t)Reg,
|
||||
status = i2c_mem_write(TOUCH_I2C_INSTANCE, Addr, (uint16_t)Reg,
|
||||
I2C_MEMADD_SIZE_8BIT, pBuffer, Length, I2cxTimeout);
|
||||
|
||||
/* Check the communication status */
|
||||
@ -235,8 +235,8 @@ static uint8_t I2Cx_ReadData(uint8_t Addr, uint8_t Reg) {
|
||||
HAL_StatusTypeDef status = HAL_OK;
|
||||
uint8_t value = 0;
|
||||
|
||||
status = i2c_mem_read(TOUCH_I2C_NUM, Addr, Reg, I2C_MEMADD_SIZE_8BIT, &value,
|
||||
1, I2cxTimeout);
|
||||
status = i2c_mem_read(TOUCH_I2C_INSTANCE, Addr, Reg, I2C_MEMADD_SIZE_8BIT,
|
||||
&value, 1, I2cxTimeout);
|
||||
|
||||
/* Check the communication status */
|
||||
if (status != HAL_OK) {
|
||||
@ -258,7 +258,7 @@ static uint8_t I2Cx_ReadBuffer(uint8_t Addr, uint8_t Reg, uint8_t *pBuffer,
|
||||
uint16_t Length) {
|
||||
HAL_StatusTypeDef status = HAL_OK;
|
||||
|
||||
status = i2c_mem_read(TOUCH_I2C_NUM, Addr, (uint16_t)Reg,
|
||||
status = i2c_mem_read(TOUCH_I2C_INSTANCE, Addr, (uint16_t)Reg,
|
||||
I2C_MEMADD_SIZE_8BIT, pBuffer, Length, I2cxTimeout);
|
||||
|
||||
/* Check the communication status */
|
||||
|
@ -19,6 +19,17 @@ typedef struct {
|
||||
} i2c_instance_t;
|
||||
|
||||
i2c_instance_t i2c_defs[I2C_COUNT] = {
|
||||
{
|
||||
.Instance = I2C_INSTANCE_0,
|
||||
.SclPort = I2C_INSTANCE_0_SCL_PORT,
|
||||
.SdaPort = I2C_INSTANCE_0_SDA_PORT,
|
||||
.SclPin = I2C_INSTANCE_0_SCL_PIN,
|
||||
.SdaPin = I2C_INSTANCE_0_SDA_PIN,
|
||||
.PinAF = I2C_INSTANCE_0_PIN_AF,
|
||||
.ResetReg = I2C_INSTANCE_0_RESET_REG,
|
||||
.ResetBit = I2C_INSTANCE_0_RESET_BIT,
|
||||
},
|
||||
#ifdef I2C_INSTANCE_1
|
||||
{
|
||||
.Instance = I2C_INSTANCE_1,
|
||||
.SclPort = I2C_INSTANCE_1_SCL_PORT,
|
||||
@ -29,17 +40,6 @@ i2c_instance_t i2c_defs[I2C_COUNT] = {
|
||||
.ResetReg = I2C_INSTANCE_1_RESET_REG,
|
||||
.ResetBit = I2C_INSTANCE_1_RESET_BIT,
|
||||
},
|
||||
#ifdef I2C_INSTANCE_2
|
||||
{
|
||||
.Instance = I2C_INSTANCE_2,
|
||||
.SclPort = I2C_INSTANCE_2_SCL_PORT,
|
||||
.SdaPort = I2C_INSTANCE_2_SDA_PORT,
|
||||
.SclPin = I2C_INSTANCE_2_SCL_PIN,
|
||||
.SdaPin = I2C_INSTANCE_2_SDA_PIN,
|
||||
.PinAF = I2C_INSTANCE_2_PIN_AF,
|
||||
.ResetReg = I2C_INSTANCE_2_RESET_REG,
|
||||
.ResetBit = I2C_INSTANCE_2_RESET_BIT,
|
||||
},
|
||||
#endif
|
||||
|
||||
};
|
||||
@ -374,21 +374,20 @@ void i2c_init_instance(uint16_t idx, i2c_instance_t *instance) {
|
||||
|
||||
void i2c_init(void) {
|
||||
// enable I2C clock
|
||||
I2C_INSTANCE_0_CLK_EN();
|
||||
I2C_INSTANCE_0_SCL_CLK_EN();
|
||||
I2C_INSTANCE_0_SDA_CLK_EN();
|
||||
i2c_init_instance(0, &i2c_defs[0]);
|
||||
|
||||
#ifdef I2C_INSTANCE_1
|
||||
I2C_INSTANCE_1_CLK_EN();
|
||||
I2C_INSTANCE_1_SCL_CLK_EN();
|
||||
I2C_INSTANCE_1_SDA_CLK_EN();
|
||||
i2c_init_instance(0, &i2c_defs[0]);
|
||||
|
||||
#ifdef I2C_INSTANCE_2
|
||||
I2C_INSTANCE_2_CLK_EN();
|
||||
I2C_INSTANCE_2_SCL_CLK_EN();
|
||||
I2C_INSTANCE_2_SDA_CLK_EN();
|
||||
i2c_init_instance(1, &i2c_defs[1]);
|
||||
#endif
|
||||
}
|
||||
|
||||
void i2c_deinit(uint16_t idx) {
|
||||
__HAL_RCC_I2C5_FORCE_RESET();
|
||||
if (i2c_handle[idx].Instance) {
|
||||
HAL_I2C_DeInit(&i2c_handle[idx]);
|
||||
i2c_handle[idx].Instance = NULL;
|
||||
|
@ -58,8 +58,8 @@
|
||||
* Output : pdata Read
|
||||
*******************************************************************************/
|
||||
int32_t sitronix_read_reg(uint8_t reg, uint8_t *pdata, uint16_t length) {
|
||||
return i2c_mem_read(TOUCH_I2C_NUM, TS_I2C_ADDRESS, reg, length, pdata, length,
|
||||
1000);
|
||||
return i2c_mem_read(TOUCH_I2C_INSTANCE, TS_I2C_ADDRESS, reg, length, pdata,
|
||||
length, 1000);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -70,7 +70,7 @@ int32_t sitronix_read_reg(uint8_t reg, uint8_t *pdata, uint16_t length) {
|
||||
* Output : None
|
||||
*******************************************************************************/
|
||||
int32_t sitronix_write_reg(uint8_t reg, uint8_t *pdata, uint16_t length) {
|
||||
return i2c_mem_write(TOUCH_I2C_NUM, TS_I2C_ADDRESS, reg, length, pdata,
|
||||
return i2c_mem_write(TOUCH_I2C_INSTANCE, TS_I2C_ADDRESS, reg, length, pdata,
|
||||
length, 1000);
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ int32_t sitronix_write_reg(uint8_t reg, uint8_t *pdata, uint16_t length) {
|
||||
* Output : pdata Read
|
||||
*******************************************************************************/
|
||||
int32_t sitronix_read_data(uint8_t *pdata, uint16_t length) {
|
||||
return i2c_receive(TOUCH_I2C_NUM, TS_I2C_ADDRESS, pdata, length, 1000);
|
||||
return i2c_receive(TOUCH_I2C_INSTANCE, TS_I2C_ADDRESS, pdata, length, 1000);
|
||||
}
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
@ -513,7 +513,7 @@ __attribute__((optimize("-O0"))) int32_t SITRONIX_DetectTouch(
|
||||
// */
|
||||
// static int32_t ReadRegWrap(void *handle, uint8_t Reg, uint8_t *pData,
|
||||
// uint16_t Length) {
|
||||
// return i2c_mem_read(TOUCH_I2C_NUM, TS_I2C_ADDRESS, Reg, Length, pData,
|
||||
// return i2c_mem_read(TOUCH_I2C_INSTANCE, TS_I2C_ADDRESS, Reg, Length, pData,
|
||||
// Length, 1000);
|
||||
//}
|
||||
//
|
||||
@ -527,7 +527,7 @@ __attribute__((optimize("-O0"))) int32_t SITRONIX_DetectTouch(
|
||||
// */
|
||||
// static int32_t WriteRegWrap(void *handle, uint8_t Reg, uint8_t *pData,
|
||||
// uint16_t Length) {
|
||||
// return i2c_mem_write(TOUCH_I2C_NUM, TS_I2C_ADDRESS, Reg, Length, pData,
|
||||
// return i2c_mem_write(TOUCH_I2C_INSTANCE, TS_I2C_ADDRESS, Reg, Length, pData,
|
||||
// Length, 1000);
|
||||
//}
|
||||
//
|
||||
@ -539,7 +539,7 @@ __attribute__((optimize("-O0"))) int32_t SITRONIX_DetectTouch(
|
||||
// * @retval Component status.
|
||||
// */
|
||||
// static int32_t ReadDataWrap(void *handle, uint8_t *pData, uint16_t Length) {
|
||||
// return i2c_receive(TOUCH_I2C_NUM, TS_I2C_ADDRESS, pData, Length, 1000);
|
||||
// return i2c_receive(TOUCH_I2C_INSTANCE, TS_I2C_ADDRESS, pData, Length, 1000);
|
||||
//}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user