aboutsummaryrefslogtreecommitdiffstats
path: root/system_stm32l4xx.c
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2017-12-30 12:27:06 -0500
committerClyne Sullivan <tullivan99@gmail.com>2017-12-30 12:27:06 -0500
commitf0f7ae0abcf0ab73a75bd111c3e036e0722d1daa (patch)
treed6bdb9f9adf3d82175d6cfc8545f187ca12d2d32 /system_stm32l4xx.c
parent8217c76e2255119fadba76daed3b3e1ec960285a (diff)
uploaded code
Diffstat (limited to 'system_stm32l4xx.c')
-rw-r--r--system_stm32l4xx.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/system_stm32l4xx.c b/system_stm32l4xx.c
new file mode 100644
index 0000000..4c22bfe
--- /dev/null
+++ b/system_stm32l4xx.c
@@ -0,0 +1,44 @@
+#include "stm32l476xx.h"
+
+/************************* Miscellaneous Configuration ************************/
+/*!< Uncomment the following line if you need to relocate your vector Table in
+ Internal SRAM. */
+/* #define VECT_TAB_SRAM */
+#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
+ This value must be a multiple of 0x200. */
+/******************************************************************************/
+
+void SystemInit(void)
+{
+ /* FPU settings ------------------------------------------------------------*/
+ #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
+ SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
+ #endif
+
+ /* Reset the RCC clock configuration to the default reset state ------------*/
+ /* Set MSION bit */
+ RCC->CR |= RCC_CR_MSION;
+
+ /* Reset CFGR register */
+ RCC->CFGR = 0x00000000U;
+
+ /* Reset HSEON, CSSON , HSION, and PLLON bits */
+ RCC->CR &= 0xEAF6FFFFU;
+
+ /* Reset PLLCFGR register */
+ RCC->PLLCFGR = 0x00001000U;
+
+ /* Reset HSEBYP bit */
+ RCC->CR &= 0xFFFBFFFFU;
+
+ /* Disable all interrupts */
+ RCC->CIER = 0x00000000U;
+
+ /* Configure the Vector Table location add offset address ------------------*/
+#ifdef VECT_TAB_SRAM
+ SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
+#else
+ SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
+#endif
+}
+