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

fix(core): fix systick frequency computation by utilizing HSE_VALUE properly

[no changelog]
This commit is contained in:
tychovrahe 2024-11-15 09:44:48 +01:00 committed by TychoVrahe
parent 10687e8fa0
commit b4c95f4c16
12 changed files with 21 additions and 22 deletions

View File

@ -1,8 +1,6 @@
#ifndef _STM32F429I_DISC1_H #ifndef _STM32F429I_DISC1_H
#define _STM32F429I_DISC1_H #define _STM32F429I_DISC1_H
#define HSE_8MHZ
#define DISPLAY_COLOR_MODE DMA2D_OUTPUT_RGB565 #define DISPLAY_COLOR_MODE DMA2D_OUTPUT_RGB565
#define I2C_COUNT 1 #define I2C_COUNT 1

View File

@ -1,7 +1,6 @@
#ifndef STM32U5A9J_DK_H_ #ifndef STM32U5A9J_DK_H_
#define STM32U5A9J_DK_H_ #define STM32U5A9J_DK_H_
#define HSE_16MHZ
#define VDD_1V8 1 #define VDD_1V8 1
#define DISPLAY_COLOR_MODE DMA2D_OUTPUT_ARGB8888 #define DISPLAY_COLOR_MODE DMA2D_OUTPUT_ARGB8888

View File

@ -1,8 +1,6 @@
#ifndef _TREZOR_R_V10_H #ifndef _TREZOR_R_V10_H
#define _TREZOR_R_V10_H #define _TREZOR_R_V10_H
#define HSE_8MHZ
#define BTN_LEFT_PIN GPIO_PIN_10 #define BTN_LEFT_PIN GPIO_PIN_10
#define BTN_LEFT_PORT GPIOC #define BTN_LEFT_PORT GPIOC
#define BTN_LEFT_CLK_ENA __HAL_RCC_GPIOC_CLK_ENABLE #define BTN_LEFT_CLK_ENA __HAL_RCC_GPIOC_CLK_ENABLE

View File

@ -1,8 +1,6 @@
#ifndef _TREZOR_T_H #ifndef _TREZOR_T_H
#define _TREZOR_T_H #define _TREZOR_T_H
#define HSE_8MHZ
#define DISPLAY_COLOR_MODE DMA2D_OUTPUT_RGB565 #define DISPLAY_COLOR_MODE DMA2D_OUTPUT_RGB565
#define DISPLAY_IDENTIFY 1 #define DISPLAY_IDENTIFY 1

View File

@ -1,7 +1,6 @@
#ifndef TREZOR_T3W1_REVA_H_ #ifndef TREZOR_T3W1_REVA_H_
#define TREZOR_T3W1_REVA_H_ #define TREZOR_T3W1_REVA_H_
#define HSE_32MHZ
#define VDD_1V8 1 #define VDD_1V8 1
#define BTN_POWER_PIN GPIO_PIN_5 #define BTN_POWER_PIN GPIO_PIN_5

View File

@ -39,13 +39,17 @@ typedef struct {
uint32_t plln; uint32_t plln;
} clock_conf_t; } clock_conf_t;
#ifdef HSE_16MHZ #ifdef USE_HSE
#if HSE_VALUE == 16000000
#define PLLM_COEF 2U #define PLLM_COEF 2U
#elif defined HSE_8MHZ #elif HSE_VALUE == 8000000
#define PLLM_COEF 1U #define PLLM_COEF 1U
#else #else
#error Unsupported HSE frequency #error Unsupported HSE frequency
#endif #endif
#else
#error HSE is required
#endif
#if defined STM32F427xx || defined STM32F429xx #if defined STM32F427xx || defined STM32F429xx
#ifdef TREZOR_MODEL_T #ifdef TREZOR_MODEL_T

View File

@ -33,15 +33,19 @@ const uint32_t MSIRangeTable[16] = {48000000U, 24000000U, 16000000U, 12000000U,
400000U, 200000U, 133000U, 100000U}; 400000U, 200000U, 133000U, 100000U};
// PLLCLK = ((HSE / PLLM) * PLLN) / PLLR // PLLCLK = ((HSE / PLLM) * PLLN) / PLLR
#ifdef HSE_32MHZ #ifdef USE_HSE
#if HSE_VALUE == 32000000
#define PLLM_COEF 2U #define PLLM_COEF 2U
#define PLLN_COEF 2U #define PLLN_COEF 2U
#elif defined HSE_16MHZ #elif HSE_VALUE == 16000000
#define PLLM_COEF 1U #define PLLM_COEF 1U
#define PLLN_COEF 2U #define PLLN_COEF 2U
#elif defined HSE_8MHZ #elif HSE_VALUE == 8000000
#define PLLM_COEF 1U #define PLLM_COEF 1U
#define PLLN_COEF 4U #define PLLN_COEF 4U
#elif defined HSE_VALUE
#error Unsupported HSE frequency
#endif
#else #else
// no HSE available, use 16MHz HSI // no HSE available, use 16MHz HSI
#define HSI_ONLY #define HSI_ONLY

View File

@ -32,6 +32,7 @@ def configure(
defines += [f'TREZOR_BOARD=\\"{board}\\"'] defines += [f'TREZOR_BOARD=\\"{board}\\"']
defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_MODEL={hw_model}"]
defines += [f"HW_REVISION={hw_revision}"] defines += [f"HW_REVISION={hw_revision}"]
defines += ["HSE_VALUE=8000000", "USE_HSE=1"]
sources += [ sources += [
"embed/io/display/stm32f429i-disc1/display_driver.c", "embed/io/display/stm32f429i-disc1/display_driver.c",

View File

@ -30,15 +30,10 @@ def configure(
env.get("ENV")["RUST_TARGET"] = "thumbv8m.main-none-eabihf" env.get("ENV")["RUST_TARGET"] = "thumbv8m.main-none-eabihf"
defines += [mcu] defines += [mcu]
defines += [ defines += [f'TREZOR_BOARD=\\"{board}\\"']
f'TREZOR_BOARD=\\"{board}\\"', defines += [f"HW_MODEL={hw_model}"]
] defines += [f"HW_REVISION={hw_revision}"]
defines += [ defines += ["HSE_VALUE=16000000", "USE_HSE=1"]
f"HW_MODEL={hw_model}",
]
defines += [
f"HW_REVISION={hw_revision}",
]
sources += [ sources += [
"embed/io/display/stm32u5a9j-dk/display_driver.c", "embed/io/display/stm32u5a9j-dk/display_driver.c",

View File

@ -36,6 +36,7 @@ def configure(
defines += [f'TREZOR_BOARD=\\"{board}\\"'] defines += [f'TREZOR_BOARD=\\"{board}\\"']
defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_MODEL={hw_model}"]
defines += [f"HW_REVISION={hw_revision}"] defines += [f"HW_REVISION={hw_revision}"]
defines += ["HSE_VALUE=8000000", "USE_HSE=1"]
sources += ["embed/io/display/vg-2864/display_driver.c"] sources += ["embed/io/display/vg-2864/display_driver.c"]
paths += ["embed/io/display/inc"] paths += ["embed/io/display/inc"]

View File

@ -36,6 +36,7 @@ def configure(
defines += [f'TREZOR_BOARD=\\"{board}\\"'] defines += [f'TREZOR_BOARD=\\"{board}\\"']
defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_MODEL={hw_model}"]
defines += [f"HW_REVISION={hw_revision}"] defines += [f"HW_REVISION={hw_revision}"]
defines += ["HSE_VALUE=8000000", "USE_HSE=1"]
sources += ["embed/io/display/st-7789/display_nofb.c"] sources += ["embed/io/display/st-7789/display_nofb.c"]
sources += ["embed/io/display/st-7789/display_driver.c"] sources += ["embed/io/display/st-7789/display_driver.c"]

View File

@ -33,6 +33,7 @@ def configure(
defines += [f'TREZOR_BOARD=\\"{board}\\"'] defines += [f'TREZOR_BOARD=\\"{board}\\"']
defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_MODEL={hw_model}"]
defines += [f"HW_REVISION={hw_revision}"] defines += [f"HW_REVISION={hw_revision}"]
defines += ["HSE_VALUE=32000000", "USE_HSE=1"]
sources += [ sources += [
"embed/io/display/st7785ma/display_driver.c", "embed/io/display/st7785ma/display_driver.c",