mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-09 15:00:58 +00:00
boardloader: enable PVD programmable voltage detector and interrupt
This commit is contained in:
parent
f93316bebd
commit
b1eea5a434
@ -64,6 +64,19 @@ void periph_init(void)
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
|
||||
// enable the PVD (programmable voltage detector).
|
||||
// select the "2.7V" threshold (level 5). the typical electrical
|
||||
// characteristic values are similar to BOR level 3.
|
||||
// this detector will be active regardless of the
|
||||
// flash option byte BOR setting.
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
PWR_PVDTypeDef pvd_config;
|
||||
pvd_config.PVDLevel = PWR_PVDLEVEL_5;
|
||||
pvd_config.Mode = PWR_PVD_MODE_IT_RISING_FALLING;
|
||||
HAL_PWR_ConfigPVD(&pvd_config);
|
||||
HAL_PWR_EnablePVD();
|
||||
NVIC_EnableIRQ(PVD_IRQn);
|
||||
|
||||
// Clear the reset flags
|
||||
PWR->CR |= PWR_CR_CSBF;
|
||||
RCC->CSR |= RCC_CSR_RMVF;
|
||||
|
Loading…
Reference in New Issue
Block a user