Blackbox device type 'file' (SITL) considered working when file handler is available
[inav.git] / src / main / drivers / system_stm32h7xx.c
blobaf3ea72e2a2eac4b52cd293b4e3d8a786bc42cd5
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #include <string.h>
19 #include <stdbool.h>
20 #include <stdint.h>
21 #include <stdlib.h>
23 #include "platform.h"
25 #include "drivers/accgyro/accgyro_mpu.h"
26 #include "drivers/persistent.h"
27 #include "drivers/exti.h"
28 #include "drivers/nvic.h"
29 #include "drivers/system.h"
31 void forcedSystemResetWithoutDisablingCaches(void)
33 persistentObjectWrite(PERSISTENT_OBJECT_RESET_REASON, RESET_NONE);
34 __disable_irq();
35 NVIC_SystemReset();
38 void enableGPIOPowerUsageAndNoiseReductions(void)
40 __HAL_RCC_SYSCFG_CLK_ENABLE();
41 __HAL_RCC_D2SRAM1_CLK_ENABLE();
42 __HAL_RCC_D2SRAM2_CLK_ENABLE();
43 __HAL_RCC_D2SRAM3_CLK_ENABLE();
46 bool isMPUSoftReset(void)
48 if (cachedRccCsrValue & RCC_RSR_SFTRSTF)
49 return true;
50 else
51 return false;
54 uint32_t systemBootloaderAddress(void)
56 #if defined(STM32H743xx) || defined(STM32H750xx) || defined(STM32H723xx) || defined(STM32H725xx)
57 return 0x1ff09800;
58 #else
59 #error Unknown MCU
60 #endif
63 void systemInit(void)
65 checkForBootLoaderRequest();
67 // Configure NVIC preempt/priority groups
68 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITY_GROUPING);
70 // cache RCC->CSR value to use it in isMPUSoftreset() and others
71 cachedRccCsrValue = RCC->CSR;
73 enableGPIOPowerUsageAndNoiseReductions();
75 // Init cycle counter
76 cycleCounterInit();
78 // SysTick
79 HAL_SYSTICK_Config(SystemCoreClock / 1000);
80 HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);