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/>.
25 #include "drivers/accgyro/accgyro_mpu.h"
26 #include "drivers/exti.h"
27 #include "drivers/nvic.h"
28 #include "drivers/system.h"
30 void SystemClock_Config(void);
32 void enableGPIOPowerUsageAndNoiseReductions(void)
36 __HAL_RCC_BKPSRAM_CLK_ENABLE();
37 __HAL_RCC_DTCMRAMEN_CLK_ENABLE();
38 __HAL_RCC_DMA2_CLK_ENABLE();
39 __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
40 __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE();
43 __HAL_RCC_USART2_CLK_ENABLE();
44 __HAL_RCC_USART3_CLK_ENABLE();
45 __HAL_RCC_UART4_CLK_ENABLE();
46 __HAL_RCC_UART5_CLK_ENABLE();
47 __HAL_RCC_UART7_CLK_ENABLE();
48 __HAL_RCC_UART8_CLK_ENABLE();
51 __HAL_RCC_USART1_CLK_ENABLE();
52 __HAL_RCC_USART6_CLK_ENABLE();
53 __HAL_RCC_SDMMC1_CLK_ENABLE();
56 bool isMPUSoftReset(void)
58 if (RCC
->CSR
& RCC_CSR_SFTRSTF
)
64 uint32_t systemBootloaderAddress(void)
71 checkForBootLoaderRequest();
73 //Called by SystemInit from startup_stm32f7xx.s
74 //SystemClock_Config();
76 // Configure NVIC preempt/priority groups
77 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITY_GROUPING
);
79 // cache RCC->CSR value to use it in isMPUSoftreset() and others
80 cachedRccCsrValue
= RCC
->CSR
;
82 /* Accounts for OP Bootloader, set the Vector Table base address as specified in .ld file */
83 //extern void *isr_vector_table_base;
84 //NVIC_SetVectorTable((uint32_t)&isr_vector_table_base, 0x0);
85 //__HAL_RCC_USB_OTG_FS_CLK_DISABLE;
89 enableGPIOPowerUsageAndNoiseReductions();
95 //SysTick_Config(SystemCoreClock / 1000);
96 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
98 HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK
);