1
0
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:
Pavol Rusnak 2017-10-17 11:44:53 +02:00
parent 45a4a944d0
commit 4a14fb6c4d
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
5 changed files with 26 additions and 30 deletions

View File

@ -43,3 +43,28 @@ bool flash_check_option_bytes(void)
((FLASH->OPTCR & FLASH_OPTCR_RDP) == FLASH_OPTCR_RDP_2) && ((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)); ((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
}

View File

@ -5,5 +5,6 @@
void flash_set_option_bytes(void); void flash_set_option_bytes(void);
bool flash_check_option_bytes(void); bool flash_check_option_bytes(void);
void periph_init(void);
#endif #endif

View File

@ -1,5 +1,3 @@
#include STM32_HAL_H
#include <string.h> #include <string.h>
#include "common.h" #include "common.h"
@ -149,34 +147,8 @@ static const uint8_t * const BOARDLOADER_KEYS[] = {
#endif #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) int main(void)
{ {
#if PRODUCTION #if PRODUCTION
flash_set_option_bytes(); flash_set_option_bytes();
if (!flash_check_option_bytes()) { if (!flash_check_option_bytes()) {

View File

@ -207,7 +207,6 @@ void check_bootloader_version(void)
int main(void) int main(void)
{ {
#if PRODUCTION #if PRODUCTION
check_bootloader_version(); check_bootloader_version();
#endif #endif

View File

@ -23,7 +23,6 @@
int main(void) int main(void)
{ {
pendsv_init(); pendsv_init();
display_orientation(0); display_orientation(0);