2 ******************************************************************************
4 * Description : This file provides code for the configuration
5 * of the FMC peripheral.
6 ******************************************************************************
9 * <h2><center>© Copyright (c) 2021 STMicroelectronics.
10 * All rights reserved.</center></h2>
12 * This software component is licensed by ST under Ultimate Liberty license
13 * SLA0044, the "License"; You may not use this file except in compliance with
14 * the License. You may obtain a copy of the License at:
17 ******************************************************************************
20 /* Includes ------------------------------------------------------------------*/
23 /* USER CODE BEGIN 0 */
27 SRAM_HandleTypeDef hsram1;
29 /* FMC initialization function */
30 void MX_FMC_Init(void)
32 FMC_NORSRAM_TimingTypeDef Timing = {0};
34 /** Perform the SRAM1 memory initialization sequence
36 hsram1.Instance = FMC_NORSRAM_DEVICE;
37 hsram1.Extended = FMC_NORSRAM_EXTENDED_DEVICE;
39 hsram1.Init.NSBank = FMC_NORSRAM_BANK1;
40 hsram1.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_ENABLE;
41 hsram1.Init.MemoryType = FMC_MEMORY_TYPE_PSRAM;
42 hsram1.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_16;
43 hsram1.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE;
44 hsram1.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW;
45 hsram1.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS;
46 hsram1.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE;
47 hsram1.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE;
48 hsram1.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE;
49 hsram1.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE;
50 hsram1.Init.WriteBurst = FMC_WRITE_BURST_DISABLE;
51 hsram1.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ONLY;
52 hsram1.Init.WriteFifo = FMC_WRITE_FIFO_ENABLE;
53 hsram1.Init.PageSize = FMC_PAGE_SIZE_NONE;
55 Timing.AddressSetupTime = 2;
56 Timing.AddressHoldTime = 1;
57 Timing.DataSetupTime = 4;
58 Timing.BusTurnAroundDuration = 1;
59 Timing.CLKDivision = 16;
60 Timing.DataLatency = 17;
61 Timing.AccessMode = FMC_ACCESS_MODE_A;
64 if (HAL_SRAM_Init(&hsram1, &Timing, NULL) != HAL_OK)
71 static uint32_t FMC_Initialized = 0;
73 static void HAL_FMC_MspInit(void){
74 /* USER CODE BEGIN FMC_MspInit 0 */
76 /* USER CODE END FMC_MspInit 0 */
77 GPIO_InitTypeDef GPIO_InitStruct = {0};
78 if (FMC_Initialized) {
83 /* Peripheral clock enable */
84 __HAL_RCC_FMC_CLK_ENABLE();
86 /** FMC GPIO Configuration
110 /* GPIO_InitStruct */
111 GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
112 |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
113 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
114 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
115 GPIO_InitStruct.Pull = GPIO_NOPULL;
116 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
117 GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
119 HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
121 /* GPIO_InitStruct */
122 GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14
123 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4
124 |GPIO_PIN_5|GPIO_PIN_7;
125 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
126 GPIO_InitStruct.Pull = GPIO_NOPULL;
127 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
128 GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
130 HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
132 /* GPIO_InitStruct */
133 GPIO_InitStruct.Pin = GPIO_PIN_7;
134 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
135 GPIO_InitStruct.Pull = GPIO_NOPULL;
136 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
137 GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
139 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
141 /* USER CODE BEGIN FMC_MspInit 1 */
143 /* USER CODE END FMC_MspInit 1 */
146 void HAL_SRAM_MspInit(SRAM_HandleTypeDef* sramHandle){
147 /* USER CODE BEGIN SRAM_MspInit 0 */
149 /* USER CODE END SRAM_MspInit 0 */
151 /* USER CODE BEGIN SRAM_MspInit 1 */
153 /* USER CODE END SRAM_MspInit 1 */
156 static uint32_t FMC_DeInitialized = 0;
158 static void HAL_FMC_MspDeInit(void){
159 /* USER CODE BEGIN FMC_MspDeInit 0 */
161 /* USER CODE END FMC_MspDeInit 0 */
162 if (FMC_DeInitialized) {
165 FMC_DeInitialized = 1;
166 /* Peripheral clock enable */
167 __HAL_RCC_FMC_CLK_DISABLE();
169 /** FMC GPIO Configuration
176 PE13 ------> FMC_DA10
177 PE14 ------> FMC_DA11
178 PE15 ------> FMC_DA12
181 PD10 ------> FMC_DA15
194 HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
195 |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
196 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1);
198 HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14
199 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4
200 |GPIO_PIN_5|GPIO_PIN_7);
202 HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7);
204 /* USER CODE BEGIN FMC_MspDeInit 1 */
206 /* USER CODE END FMC_MspDeInit 1 */
209 void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef* sramHandle){
210 /* USER CODE BEGIN SRAM_MspDeInit 0 */
212 /* USER CODE END SRAM_MspDeInit 0 */
214 /* USER CODE BEGIN SRAM_MspDeInit 1 */
216 /* USER CODE END SRAM_MspDeInit 1 */
226 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/