1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 23:08:14 +00:00
trezor-firmware/micropython/trezorhal/flash.c

24 lines
712 B
C
Raw Normal View History

2017-03-07 13:50:09 +00:00
#include STM32_HAL_H
2017-03-07 14:52:19 +00:00
int flash_init(void) {
2017-03-07 13:50:09 +00:00
// Enable the flash IRQ, which is used to also call our storage IRQ handler
// It needs to go at a higher priority than all those components that rely on
// the flash storage (eg higher than USB MSC).
HAL_NVIC_SetPriority(FLASH_IRQn, 2, 0);
HAL_NVIC_EnableIRQ(FLASH_IRQn);
2017-03-07 14:52:19 +00:00
return 0;
2017-03-07 13:50:09 +00:00
}
void FLASH_IRQHandler(void) {
// This calls the real flash IRQ handler, if needed
/*
uint32_t flash_cr = FLASH->CR;
if ((flash_cr & FLASH_IT_EOP) || (flash_cr & FLASH_IT_ERR)) {
HAL_FLASH_IRQHandler();
}
*/
// This call the storage IRQ handler, to check if the flash cache needs flushing
// storage_irq_handler();
}