annotate OtherSources/system_stm32f4xx.c @ 929:63c340abd70e Evo_2_23 tip

Add a line to the compass heading dive menu that shows the currently set heading to enable the diver to confirm it / add it to notes. Also add a log entry every time a new compass heading is set or the heading is cleared. And add a way to add compass headings to the log without changing the currently set heading - this was added after discussion with cave divers who are interested in recording headings when mapping out caves. From mikeller
author heinrichsweikamp
date Mon, 02 Dec 2024 11:16:10 +0100
parents 4e10a3e087a1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
1 /**
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
2 ******************************************************************************
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
3 * @file system_stm32f4xx.c
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
4 * @author MCD Application Team
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
5 * @version V2.1.0
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
6 * @date 19-June-2014
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
7 * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
8 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
9 * This file provides two functions and one global variable to be called from
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
10 * user application:
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
11 * - SystemInit(): This function is called at startup just after reset and
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
12 * before branch to main program. This call is made inside
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
13 * the "startup_stm32f4xx.s" file.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
14 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
15 * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
16 * by the user application to setup the SysTick
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
17 * timer or configure other parameters.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
18 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
19 * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
20 * be called whenever the core clock is changed
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
21 * during program execution.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
22 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
23 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
24 ******************************************************************************
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
25 * @attention
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
26 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
27 * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
28 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
29 * Redistribution and use in source and binary forms, with or without modification,
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
30 * are permitted provided that the following conditions are met:
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
31 * 1. Redistributions of source code must retain the above copyright notice,
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
32 * this list of conditions and the following disclaimer.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
33 * 2. Redistributions in binary form must reproduce the above copyright notice,
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
34 * this list of conditions and the following disclaimer in the documentation
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
35 * and/or other materials provided with the distribution.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
36 * 3. Neither the name of STMicroelectronics nor the names of its contributors
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
37 * may be used to endorse or promote products derived from this software
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
38 * without specific prior written permission.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
39 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
41 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
43 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
46 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
47 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
48 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
49 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
50 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
51 ******************************************************************************
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
52 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
53
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
54 /** @addtogroup CMSIS
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
55 * @{
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
56 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
57
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
58 /** @addtogroup stm32f4xx_system
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
59 * @{
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
60 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
61
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
62 /** @addtogroup STM32F4xx_System_Private_Includes
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
63 * @{
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
64 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
65
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
66
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
67 #include "stm32f4xx.h"
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
68
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
69 #if !defined (HSE_VALUE)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
70 #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
71 #endif /* HSE_VALUE */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
72
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
73 #if !defined (HSI_VALUE)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
74 #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
75 #endif /* HSI_VALUE */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
76
869
4e10a3e087a1 Reactivate Bootloader:
Ideenmodellierer
parents: 7
diff changeset
77
4e10a3e087a1 Reactivate Bootloader:
Ideenmodellierer
parents: 7
diff changeset
78 const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4};
7
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
79 /**
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
80 * @}
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
81 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
82
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
83 /** @addtogroup STM32F4xx_System_Private_TypesDefinitions
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
84 * @{
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
85 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
86
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
87 /**
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
88 * @}
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
89 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
90
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
91 /** @addtogroup STM32F4xx_System_Private_Defines
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
92 * @{
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
93 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
94
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
95 /************************* Miscellaneous Configuration ************************/
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
96 /*!< Uncomment the following line if you need to use external SRAM or SDRAM mounted
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
97 on STM324xG_EVAL/STM324x9I_EVAL boards as data memory */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
98 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
99 /* #define DATA_IN_ExtSRAM */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
100 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
101
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
102 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
103 /* #define DATA_IN_ExtSDRAM */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
104 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
105
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
106 #if defined(DATA_IN_ExtSRAM) && defined(DATA_IN_ExtSDRAM)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
107 #error "Please select DATA_IN_ExtSRAM or DATA_IN_ExtSDRAM "
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
108 #endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
109
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
110 /*!< Uncomment the following line if you need to relocate your vector Table in
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
111 Internal SRAM. */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
112 /* #define VECT_TAB_SRAM */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
113 #define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
114 This value must be a multiple of 0x200. */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
115 /******************************************************************************/
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
116
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
117 /**
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
118 * @}
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
119 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
120
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
121 /** @addtogroup STM32F4xx_System_Private_Macros
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
122 * @{
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
123 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
124
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
125 /**
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
126 * @}
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
127 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
128
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
129 /** @addtogroup STM32F4xx_System_Private_Variables
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
130 * @{
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
131 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
132 /* This variable is updated in three ways:
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
133 1) by calling CMSIS function SystemCoreClockUpdate()
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
134 2) by calling HAL API function HAL_RCC_GetHCLKFreq()
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
135 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
136 Note: If you use this function to configure the system clock; then there
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
137 is no need to call the 2 first functions listed above, since SystemCoreClock
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
138 variable is updated automatically.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
139 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
140 uint32_t SystemCoreClock = 16000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
141 __IO const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
142
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
143 /**
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
144 * @}
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
145 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
146
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
147 /** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
148 * @{
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
149 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
150
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
151 #if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
152 static void SystemInit_ExtMemCtl(void);
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
153 #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
154
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
155 /**
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
156 * @}
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
157 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
158
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
159 /** @addtogroup STM32F4xx_System_Private_Functions
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
160 * @{
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
161 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
162
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
163 /**
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
164 * @brief Setup the microcontroller system
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
165 * Initialize the FPU setting, vector table location and External memory
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
166 * configuration.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
167 * @param None
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
168 * @retval None
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
169 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
170 void SystemInit(void)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
171 {
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
172 /* FPU settings ------------------------------------------------------------*/
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
173 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
174 SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
175 #endif
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
176 /* Reset the RCC clock configuration to the default reset state ------------*/
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
177 /* Set HSION bit */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
178 RCC->CR |= (uint32_t)0x00000001;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
179
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
180 /* Reset CFGR register */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
181 RCC->CFGR = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
182
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
183 /* Reset HSEON, CSSON and PLLON bits */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
184 RCC->CR &= (uint32_t)0xFEF6FFFF;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
185
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
186 /* Reset PLLCFGR register */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
187 RCC->PLLCFGR = 0x24003010;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
188
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
189 /* Reset HSEBYP bit */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
190 RCC->CR &= (uint32_t)0xFFFBFFFF;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
191
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
192 /* Disable all interrupts */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
193 RCC->CIR = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
194
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
195 #if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
196 SystemInit_ExtMemCtl();
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
197 #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
198
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
199 /* Configure the Vector Table location add offset address ------------------*/
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
200 #ifdef VECT_TAB_SRAM
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
201 SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
202 #else
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
203 SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
204 #endif
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
205 }
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
206
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
207 /**
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
208 * @brief Update SystemCoreClock variable according to Clock Register Values.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
209 * The SystemCoreClock variable contains the core clock (HCLK), it can
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
210 * be used by the user application to setup the SysTick timer or configure
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
211 * other parameters.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
212 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
213 * @note Each time the core clock (HCLK) changes, this function must be called
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
214 * to update SystemCoreClock variable value. Otherwise, any configuration
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
215 * based on this variable will be incorrect.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
216 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
217 * @note - The system frequency computed by this function is not the real
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
218 * frequency in the chip. It is calculated based on the predefined
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
219 * constant and the selected clock source:
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
220 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
221 * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
222 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
223 * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
224 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
225 * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
226 * or HSI_VALUE(*) multiplied/divided by the PLL factors.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
227 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
228 * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
229 * 16 MHz) but the real value may vary depending on the variations
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
230 * in voltage and temperature.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
231 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
232 * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
233 * depends on the application requirements), user has to ensure that HSE_VALUE
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
234 * is same as the real frequency of the crystal used. Otherwise, this function
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
235 * may have wrong result.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
236 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
237 * - The result of this function could be not correct when using fractional
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
238 * value for HSE crystal.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
239 *
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
240 * @param None
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
241 * @retval None
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
242 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
243 void SystemCoreClockUpdate(void)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
244 {
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
245 uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
246
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
247 /* Get SYSCLK source -------------------------------------------------------*/
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
248 tmp = RCC->CFGR & RCC_CFGR_SWS;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
249
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
250 switch (tmp)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
251 {
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
252 case 0x00: /* HSI used as system clock source */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
253 SystemCoreClock = HSI_VALUE;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
254 break;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
255 case 0x04: /* HSE used as system clock source */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
256 SystemCoreClock = HSE_VALUE;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
257 break;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
258 case 0x08: /* PLL used as system clock source */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
259
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
260 /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
261 SYSCLK = PLL_VCO / PLL_P
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
262 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
263 pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
264 pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
265
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
266 if (pllsource != 0)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
267 {
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
268 /* HSE used as PLL clock source */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
269 pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
270 }
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
271 else
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
272 {
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
273 /* HSI used as PLL clock source */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
274 pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
275 }
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
276
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
277 pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
278 SystemCoreClock = pllvco/pllp;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
279 break;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
280 default:
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
281 SystemCoreClock = HSI_VALUE;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
282 break;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
283 }
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
284 /* Compute HCLK frequency --------------------------------------------------*/
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
285 /* Get HCLK prescaler */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
286 tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
287 /* HCLK frequency */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
288 SystemCoreClock >>= tmp;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
289 }
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
290
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
291 #if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
292 /**
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
293 * @brief Setup the external memory controller.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
294 * Called in startup_stm32f4xx.s before jump to main.
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
295 * This function configures the external memories (SRAM/SDRAM)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
296 * This SRAM/SDRAM will be used as program data memory (including heap and stack).
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
297 * @param None
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
298 * @retval None
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
299 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
300 void SystemInit_ExtMemCtl(void)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
301 {
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
302 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
303 #if defined (DATA_IN_ExtSDRAM)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
304 register uint32_t tmpreg = 0, timeout = 0xFFFF;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
305 register uint32_t index;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
306
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
307 /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
308 clock */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
309 RCC->AHB1ENR |= 0x000001F8;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
310
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
311 /* Connect PDx pins to FMC Alternate function */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
312 GPIOD->AFR[0] = 0x000000CC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
313 GPIOD->AFR[1] = 0xCC000CCC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
314 /* Configure PDx pins in Alternate function mode */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
315 GPIOD->MODER = 0xA02A000A;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
316 /* Configure PDx pins speed to 50 MHz */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
317 GPIOD->OSPEEDR = 0xA02A000A;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
318 /* Configure PDx pins Output type to push-pull */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
319 GPIOD->OTYPER = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
320 /* No pull-up, pull-down for PDx pins */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
321 GPIOD->PUPDR = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
322
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
323 /* Connect PEx pins to FMC Alternate function */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
324 GPIOE->AFR[0] = 0xC00000CC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
325 GPIOE->AFR[1] = 0xCCCCCCCC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
326 /* Configure PEx pins in Alternate function mode */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
327 GPIOE->MODER = 0xAAAA800A;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
328 /* Configure PEx pins speed to 50 MHz */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
329 GPIOE->OSPEEDR = 0xAAAA800A;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
330 /* Configure PEx pins Output type to push-pull */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
331 GPIOE->OTYPER = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
332 /* No pull-up, pull-down for PEx pins */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
333 GPIOE->PUPDR = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
334
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
335 /* Connect PFx pins to FMC Alternate function */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
336 GPIOF->AFR[0] = 0xCCCCCCCC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
337 GPIOF->AFR[1] = 0xCCCCCCCC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
338 /* Configure PFx pins in Alternate function mode */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
339 GPIOF->MODER = 0xAA800AAA;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
340 /* Configure PFx pins speed to 50 MHz */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
341 GPIOF->OSPEEDR = 0xAA800AAA;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
342 /* Configure PFx pins Output type to push-pull */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
343 GPIOF->OTYPER = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
344 /* No pull-up, pull-down for PFx pins */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
345 GPIOF->PUPDR = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
346
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
347 /* Connect PGx pins to FMC Alternate function */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
348 GPIOG->AFR[0] = 0xCCCCCCCC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
349 GPIOG->AFR[1] = 0xCCCCCCCC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
350 /* Configure PGx pins in Alternate function mode */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
351 GPIOG->MODER = 0xAAAAAAAA;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
352 /* Configure PGx pins speed to 50 MHz */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
353 GPIOG->OSPEEDR = 0xAAAAAAAA;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
354 /* Configure PGx pins Output type to push-pull */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
355 GPIOG->OTYPER = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
356 /* No pull-up, pull-down for PGx pins */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
357 GPIOG->PUPDR = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
358
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
359 /* Connect PHx pins to FMC Alternate function */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
360 GPIOH->AFR[0] = 0x00C0CC00;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
361 GPIOH->AFR[1] = 0xCCCCCCCC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
362 /* Configure PHx pins in Alternate function mode */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
363 GPIOH->MODER = 0xAAAA08A0;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
364 /* Configure PHx pins speed to 50 MHz */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
365 GPIOH->OSPEEDR = 0xAAAA08A0;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
366 /* Configure PHx pins Output type to push-pull */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
367 GPIOH->OTYPER = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
368 /* No pull-up, pull-down for PHx pins */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
369 GPIOH->PUPDR = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
370
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
371 /* Connect PIx pins to FMC Alternate function */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
372 GPIOI->AFR[0] = 0xCCCCCCCC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
373 GPIOI->AFR[1] = 0x00000CC0;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
374 /* Configure PIx pins in Alternate function mode */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
375 GPIOI->MODER = 0x0028AAAA;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
376 /* Configure PIx pins speed to 50 MHz */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
377 GPIOI->OSPEEDR = 0x0028AAAA;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
378 /* Configure PIx pins Output type to push-pull */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
379 GPIOI->OTYPER = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
380 /* No pull-up, pull-down for PIx pins */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
381 GPIOI->PUPDR = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
382
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
383 /*-- FMC Configuration ------------------------------------------------------*/
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
384 /* Enable the FMC interface clock */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
385 RCC->AHB3ENR |= 0x00000001;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
386
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
387 /* Configure and enable SDRAM bank1 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
388 FMC_Bank5_6->SDCR[0] = 0x000019E0;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
389 FMC_Bank5_6->SDTR[0] = 0x01115351;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
390
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
391 /* SDRAM initialization sequence */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
392 /* Clock enable command */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
393 FMC_Bank5_6->SDCMR = 0x00000011;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
394 tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
395 while((tmpreg != 0) && (timeout-- > 0))
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
396 {
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
397 tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
398 }
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
399
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
400 /* Delay */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
401 for (index = 0; index<1000; index++);
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
402
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
403 /* PALL command */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
404 FMC_Bank5_6->SDCMR = 0x00000012;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
405 timeout = 0xFFFF;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
406 while((tmpreg != 0) && (timeout-- > 0))
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
407 {
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
408 tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
409 }
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
410
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
411 /* Auto refresh command */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
412 FMC_Bank5_6->SDCMR = 0x00000073;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
413 timeout = 0xFFFF;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
414 while((tmpreg != 0) && (timeout-- > 0))
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
415 {
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
416 tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
417 }
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
418
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
419 /* MRD register program */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
420 FMC_Bank5_6->SDCMR = 0x00046014;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
421 timeout = 0xFFFF;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
422 while((tmpreg != 0) && (timeout-- > 0))
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
423 {
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
424 tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
425 }
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
426
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
427 /* Set refresh count */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
428 tmpreg = FMC_Bank5_6->SDRTR;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
429 FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
430
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
431 /* Disable write protection */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
432 tmpreg = FMC_Bank5_6->SDCR[0];
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
433 FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
434 #endif /* DATA_IN_ExtSDRAM */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
435 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
436
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
437 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
438 #if defined(DATA_IN_ExtSRAM)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
439 /*-- GPIOs Configuration -----------------------------------------------------*/
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
440 /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
441 RCC->AHB1ENR |= 0x00000078;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
442
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
443 /* Connect PDx pins to FMC Alternate function */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
444 GPIOD->AFR[0] = 0x00CCC0CC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
445 GPIOD->AFR[1] = 0xCCCCCCCC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
446 /* Configure PDx pins in Alternate function mode */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
447 GPIOD->MODER = 0xAAAA0A8A;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
448 /* Configure PDx pins speed to 100 MHz */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
449 GPIOD->OSPEEDR = 0xFFFF0FCF;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
450 /* Configure PDx pins Output type to push-pull */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
451 GPIOD->OTYPER = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
452 /* No pull-up, pull-down for PDx pins */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
453 GPIOD->PUPDR = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
454
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
455 /* Connect PEx pins to FMC Alternate function */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
456 GPIOE->AFR[0] = 0xC00CC0CC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
457 GPIOE->AFR[1] = 0xCCCCCCCC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
458 /* Configure PEx pins in Alternate function mode */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
459 GPIOE->MODER = 0xAAAA828A;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
460 /* Configure PEx pins speed to 100 MHz */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
461 GPIOE->OSPEEDR = 0xFFFFC3CF;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
462 /* Configure PEx pins Output type to push-pull */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
463 GPIOE->OTYPER = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
464 /* No pull-up, pull-down for PEx pins */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
465 GPIOE->PUPDR = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
466
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
467 /* Connect PFx pins to FMC Alternate function */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
468 GPIOF->AFR[0] = 0x00CCCCCC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
469 GPIOF->AFR[1] = 0xCCCC0000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
470 /* Configure PFx pins in Alternate function mode */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
471 GPIOF->MODER = 0xAA000AAA;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
472 /* Configure PFx pins speed to 100 MHz */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
473 GPIOF->OSPEEDR = 0xFF000FFF;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
474 /* Configure PFx pins Output type to push-pull */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
475 GPIOF->OTYPER = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
476 /* No pull-up, pull-down for PFx pins */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
477 GPIOF->PUPDR = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
478
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
479 /* Connect PGx pins to FMC Alternate function */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
480 GPIOG->AFR[0] = 0x00CCCCCC;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
481 GPIOG->AFR[1] = 0x000000C0;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
482 /* Configure PGx pins in Alternate function mode */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
483 GPIOG->MODER = 0x00085AAA;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
484 /* Configure PGx pins speed to 100 MHz */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
485 GPIOG->OSPEEDR = 0x000CAFFF;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
486 /* Configure PGx pins Output type to push-pull */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
487 GPIOG->OTYPER = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
488 /* No pull-up, pull-down for PGx pins */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
489 GPIOG->PUPDR = 0x00000000;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
490
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
491 /*-- FMC/FSMC Configuration --------------------------------------------------*/
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
492 /* Enable the FMC/FSMC interface clock */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
493 RCC->AHB3ENR |= 0x00000001;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
494
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
495 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
496 /* Configure and enable Bank1_SRAM2 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
497 FMC_Bank1->BTCR[2] = 0x00001011;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
498 FMC_Bank1->BTCR[3] = 0x00000201;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
499 FMC_Bank1E->BWTR[2] = 0x0fffffff;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
500 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
501
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
502 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
503 /* Configure and enable Bank1_SRAM2 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
504 FSMC_Bank1->BTCR[2] = 0x00001011;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
505 FSMC_Bank1->BTCR[3] = 0x00000201;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
506 FSMC_Bank1E->BWTR[2] = 0x0FFFFFFF;
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
507 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
508
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
509 #endif /* DATA_IN_ExtSRAM */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
510 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
511 }
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
512 #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
513 /**
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
514 * @}
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
515 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
516
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
517 /**
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
518 * @}
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
519 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
520
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
521 /**
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
522 * @}
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
523 */
2de06b1abed3 CLEAN retrieve original startup code. reset linker script.
jDG
parents:
diff changeset
524 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/