mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
boardloader: move periph_init to lowlevel.c
This commit is contained in:
parent
45a4a944d0
commit
4a14fb6c4d
@ -43,3 +43,28 @@ bool flash_check_option_bytes(void)
|
||||
((FLASH->OPTCR & FLASH_OPTCR_RDP) == FLASH_OPTCR_RDP_2) &&
|
||||
((FLASH->OPTCR & FLASH_OPTCR_BOR_LEV) == (FLASH_OPTCR_BOR_LEV_0 | FLASH_OPTCR_BOR_LEV_1));
|
||||
}
|
||||
|
||||
void periph_init(void)
|
||||
{
|
||||
// STM32F4xx HAL library initialization:
|
||||
// - configure the Flash prefetch, instruction and data caches
|
||||
// - configure the Systick to generate an interrupt each 1 msec
|
||||
// - set NVIC Group Priority to 4
|
||||
// - global MSP (MCU Support Package) initialization
|
||||
HAL_Init();
|
||||
|
||||
// Enable GPIO clocks
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
|
||||
// Clear the reset flags
|
||||
PWR->CR |= PWR_CR_CSBF;
|
||||
RCC->CSR |= RCC_CSR_RMVF;
|
||||
|
||||
// Enable CPU ticks
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; // Enable DWT
|
||||
DWT->CYCCNT = 0; // Reset Cycle Count Register
|
||||
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; // Enable Cycle Count Register
|
||||
}
|
||||
|
@ -5,5 +5,6 @@
|
||||
|
||||
void flash_set_option_bytes(void);
|
||||
bool flash_check_option_bytes(void);
|
||||
void periph_init(void);
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,3 @@
|
||||
#include STM32_HAL_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
@ -149,34 +147,8 @@ static const uint8_t * const BOARDLOADER_KEYS[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
void periph_init(void)
|
||||
{
|
||||
// STM32F4xx HAL library initialization:
|
||||
// - configure the Flash prefetch, instruction and data caches
|
||||
// - configure the Systick to generate an interrupt each 1 msec
|
||||
// - set NVIC Group Priority to 4
|
||||
// - global MSP (MCU Support Package) initialization
|
||||
HAL_Init();
|
||||
|
||||
// Enable GPIO clocks
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
|
||||
// Clear the reset flags
|
||||
PWR->CR |= PWR_CR_CSBF;
|
||||
RCC->CSR |= RCC_CSR_RMVF;
|
||||
|
||||
// Enable CPU ticks
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; // Enable DWT
|
||||
DWT->CYCCNT = 0; // Reset Cycle Count Register
|
||||
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; // Enable Cycle Count Register
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
#if PRODUCTION
|
||||
flash_set_option_bytes();
|
||||
if (!flash_check_option_bytes()) {
|
||||
|
@ -207,7 +207,6 @@ void check_bootloader_version(void)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
#if PRODUCTION
|
||||
check_bootloader_version();
|
||||
#endif
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
pendsv_init();
|
||||
|
||||
display_orientation(0);
|
||||
|
Loading…
Reference in New Issue
Block a user