mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-19 14:08:11 +00:00
fix(core): improve robustness of touch driver
[no changelog]
This commit is contained in:
parent
5bda9a89d9
commit
638ebbc0df
@ -98,9 +98,15 @@ void touch_set_mode(void) {
|
|||||||
// set register 0xA4 G_MODE to interrupt trigger mode (0x01). basically, CTPM
|
// set register 0xA4 G_MODE to interrupt trigger mode (0x01). basically, CTPM
|
||||||
// generates a pulse when new data is available
|
// generates a pulse when new data is available
|
||||||
uint8_t touch_panel_config[] = {0xA4, 0x01};
|
uint8_t touch_panel_config[] = {0xA4, 0x01};
|
||||||
ensure(sectrue * (HAL_OK == i2c_transmit(TOUCH_ADDRESS, touch_panel_config,
|
for (int i = 0; i < 3; i++) {
|
||||||
sizeof(touch_panel_config), 10)),
|
if (HAL_OK == i2c_transmit(TOUCH_ADDRESS, touch_panel_config,
|
||||||
"Touch screen panel was not loaded properly.");
|
sizeof(touch_panel_config), 10)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
i2c_cycle();
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure(secfalse, "Touch screen panel was not loaded properly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void touch_power_on(void) {
|
void touch_power_on(void) {
|
||||||
@ -135,9 +141,15 @@ void touch_init(void) {
|
|||||||
void touch_sensitivity(uint8_t value) {
|
void touch_sensitivity(uint8_t value) {
|
||||||
// set panel threshold (TH_GROUP) - default value is 0x12
|
// set panel threshold (TH_GROUP) - default value is 0x12
|
||||||
uint8_t touch_panel_threshold[] = {0x80, value};
|
uint8_t touch_panel_threshold[] = {0x80, value};
|
||||||
ensure(sectrue * (HAL_OK == i2c_transmit(TOUCH_ADDRESS, touch_panel_threshold,
|
for (int i = 0; i < 3; i++) {
|
||||||
sizeof(touch_panel_threshold), 10)),
|
if (HAL_OK == i2c_transmit(TOUCH_ADDRESS, touch_panel_threshold,
|
||||||
NULL);
|
sizeof(touch_panel_threshold), 10)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
i2c_cycle();
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure(secfalse, "Touch screen panel was not loaded properly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t touch_is_detected(void) {
|
uint32_t touch_is_detected(void) {
|
||||||
|
Loading…
Reference in New Issue
Block a user