1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

fix(core): reintroduce touch controller initialization without power down/up in firmware, fix model R firmware initialization

This commit is contained in:
TychoVrahe 2022-07-26 15:09:43 +02:00 committed by GitHub
parent 4d3d9f5d7e
commit a762e75fee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 23 deletions

View File

@ -0,0 +1 @@
Remove power-down power-up cycle from touch controller initialization in firmware

View File

@ -1 +0,0 @@
Don't initialize touch controller in firmware

View File

@ -250,8 +250,8 @@ int main(void) {
random_delays_init(); random_delays_init();
// display_init_seq(); // display_init_seq();
#if defined TREZOR_MODEL_T #if defined TREZOR_MODEL_T
touch_init();
touch_power_on(); touch_power_on();
touch_init();
#endif #endif
#if defined TREZOR_MODEL_R #if defined TREZOR_MODEL_R

View File

@ -73,7 +73,7 @@ int main(void) {
#endif #endif
// reinitialize HAL for Trezor One // reinitialize HAL for Trezor One
#if defined TREZOR_MODEL_1 || defined TREZOR_MODEL_R #if defined TREZOR_MODEL_1
HAL_Init(); HAL_Init();
#endif #endif
@ -85,9 +85,7 @@ int main(void) {
#if !defined TREZOR_MODEL_1 #if !defined TREZOR_MODEL_1
parse_boardloader_capabilities(); parse_boardloader_capabilities();
#endif
#if defined TREZOR_MODEL_T
#if PRODUCTION #if PRODUCTION
check_and_replace_bootloader(); check_and_replace_bootloader();
#endif #endif
@ -98,7 +96,7 @@ int main(void) {
// Init peripherals // Init peripherals
pendsv_init(); pendsv_init();
#if defined TREZOR_MODEL_1 || defined TREZOR_MODEL_R #if defined TREZOR_MODEL_1
display_init(); display_init();
button_init(); button_init();
#endif #endif
@ -110,15 +108,17 @@ int main(void) {
#endif #endif
#if defined TREZOR_MODEL_T #if defined TREZOR_MODEL_T
touch_init();
// display_init_seq(); // display_init_seq();
sdcard_init(); sdcard_init();
display_clear();
#endif
#if !defined TREZOR_MODEL_1
// jump to unprivileged mode // jump to unprivileged mode
// http://infocenter.arm.com/help/topic/com.arm.doc.dui0552a/CHDBIBGJ.html // http://infocenter.arm.com/help/topic/com.arm.doc.dui0552a/CHDBIBGJ.html
__asm__ volatile("msr control, %0" ::"r"(0x1)); __asm__ volatile("msr control, %0" ::"r"(0x1));
__asm__ volatile("isb"); __asm__ volatile("isb");
display_clear();
#endif #endif
#ifdef USE_SECP256K1_ZKP #ifdef USE_SECP256K1_ZKP

View File

@ -102,8 +102,6 @@ static void touch_active_pin_state(void) {
// 300ms, giving an extra 10ms // 300ms, giving an extra 10ms
} }
void touch_init(void) { touch_default_pin_state(); }
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c) { void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c) {
// enable I2C clock // enable I2C clock
__HAL_RCC_I2C1_CLK_ENABLE(); __HAL_RCC_I2C1_CLK_ENABLE();
@ -200,18 +198,7 @@ static void _i2c_cycle(void) {
HAL_Delay(10); HAL_Delay(10);
} }
void touch_power_on(void) { void touch_set_mode(void) {
if (i2c_handle.Instance) {
return;
}
// turn on CTP circuitry
touch_active_pin_state();
HAL_Delay(50);
// I2C device interface configuration
_i2c_init();
// set register 0xA4 G_MODE to interrupt polling mode (0x00). basically, CTPM // set register 0xA4 G_MODE to interrupt polling mode (0x00). basically, CTPM
// keeps this input line (to PC4) low while a finger is on the screen. // keeps this input line (to PC4) low while a finger is on the screen.
uint8_t touch_panel_config[] = {0xA4, 0x00}; uint8_t touch_panel_config[] = {0xA4, 0x00};
@ -220,8 +207,18 @@ void touch_power_on(void) {
&i2c_handle, TOUCH_ADDRESS, touch_panel_config, &i2c_handle, TOUCH_ADDRESS, touch_panel_config,
sizeof(touch_panel_config), 10)), sizeof(touch_panel_config), 10)),
NULL); NULL);
}
touch_sensitivity(0x06); void touch_power_on(void) {
if (i2c_handle.Instance) {
return;
}
touch_default_pin_state();
// turn on CTP circuitry
touch_active_pin_state();
HAL_Delay(50);
} }
void touch_power_off(void) { void touch_power_off(void) {
@ -231,6 +228,14 @@ void touch_power_off(void) {
touch_default_pin_state(); touch_default_pin_state();
} }
void touch_init(void) {
// I2C device interface configuration
_i2c_init();
touch_set_mode();
touch_sensitivity(0x06);
}
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};