42 #if USE_HARD_FAULT_RECOVERY
44 #if defined STM32F4 || defined STM32F7
45 #define BCKP_SECTION ".ram5"
46 #define IN_BCKP_SECTION(var) var __attribute__ ((section(BCKP_SECTION), aligned(8)))
48 #error "No backup ram available"
50 IN_BCKP_SECTION(
volatile bool hard_fault);
57 CH_IRQ_HANDLER(HardFault_Handler)
63 CH_IRQ_HANDLER(NMI_Handler)
69 CH_IRQ_HANDLER(MemManage_Handler)
75 CH_IRQ_HANDLER(BusFault_Handler)
81 CH_IRQ_HANDLER(UsageFault_Handler)
87 bool recovering_from_hard_fault;
91 #define __PWR_CSR PWR->CSR
92 #define __PWR_CSR_BRE PWR_CSR_BRE
93 #define __PWR_CSR_BRR PWR_CSR_BRR
95 #define __PWR_CSR PWR->CSR1
96 #define __PWR_CSR_BRE PWR_CSR1_BRE
97 #define __PWR_CSR_BRR PWR_CSR1_BRR
99 #error Hard fault recovery not supported
112 PRINT_CONFIG_MSG(
"We are running luftboot, the interrupt vector is being relocated.")
126 #if USE_HARD_FAULT_RECOVERY
128 #if defined STM32F4 || defined STM32F7
129 RCC->AHB1ENR |= RCC_AHB1ENR_BKPSRAMEN;
130 __PWR_CSR |= __PWR_CSR_BRE;
131 while ((__PWR_CSR & __PWR_CSR_BRR) == 0) ;
135 recovering_from_hard_fault =
false;
136 if (!(RCC->CSR & RCC_CSR_SFTRSTF)) {
139 }
else if ((RCC->CSR & RCC_CSR_SFTRSTF) && !hard_fault) {
144 recovering_from_hard_fault =
true;
148 RCC->CSR = RCC_CSR_RMVF;
void WEAK mcu_periph_energy_save(void)
Call board specific energy saving Can be necessary for closing on power off.
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
Arch independent mcu ( Micro Controller Unit ) utilities.