diff --git a/core/embed/trezorhal/stm32f4/touch/stmpe811.c b/core/embed/trezorhal/stm32f4/touch/stmpe811.c index 05a6f55727..8fc25092b1 100644 --- a/core/embed/trezorhal/stm32f4/touch/stmpe811.c +++ b/core/embed/trezorhal/stm32f4/touch/stmpe811.c @@ -25,7 +25,7 @@ #include "common.h" #include "secbool.h" -#include "i2c.h" +#include "i2c_bus.h" #include "stmpe811.h" #include "touch.h" @@ -157,8 +157,6 @@ #define STMPE811_TS_CTRL_ENABLE 0x01 #define STMPE811_TS_CTRL_STATUS 0x80 -#define TOUCH_ADDRESS \ - (0x38U << 1) // the HAL requires the 7-bit address to be shifted by one bit #define TOUCH_PACKET_SIZE 7U #define EVENT_PRESS_DOWN 0x00U #define EVENT_CONTACT 0x80U @@ -173,17 +171,14 @@ #define EVENT_OLD_TIMEOUT_MS 50 #define EVENT_MISSING_TIMEOUT_MS 50 -#define TS_I2C_ADDRESS 0x82 +#define TS_I2C_ADDRESS (0x82 >> 1) #define I2Cx_TIMEOUT_MAX \ 0x3000 /*initialized != sectrue) { + i2c_bus = i2c_bus_open(TOUCH_I2C_INSTANCE); + if (i2c_bus == NULL) { + return secfalse; + } + stmpe811_Reset(); touch_set_mode(); @@ -589,6 +635,7 @@ void touch_deinit(void) { if (driver->initialized == sectrue) { // Not implemented properly + i2c_bus_close(i2c_bus); memset(driver, 0, sizeof(touch_driver_t)); } }