5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
23 #define SDRAM_MEMORY_WIDTH FMC_SDMemory_Width_16b
25 #define SDRAM_CAS_LATENCY FMC_CAS_Latency_3
27 #define SDCLOCK_PERIOD FMC_SDClock_Period_2
29 #define SDRAM_TIMEOUT ((uint32_t)0xFFFF)
32 * @brief FMC SDRAM Mode definition register defines
34 #define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000)
35 #define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001)
36 #define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002)
37 #define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0004)
38 #define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000)
39 #define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008)
40 #define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020)
41 #define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030)
42 #define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000)
43 #define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000)
44 #define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200)
47 * @brief FMC SDRAM Memory Read Burst feature
49 #define SDRAM_READBURST FMC_Read_Burst_Disable
51 static void __Delay(__IO
uint32_t nCount
)
53 __IO
uint32_t index
= 0;
54 for(index
= (100000 * nCount
); index
!= 0; index
--)
60 * @brief Configures all SDRAM memory I/Os pins.
64 void SDRAM_GPIOConfig(void)
66 GPIO_InitTypeDef GPIO_InitStructure
;
68 /* Enable GPIOs clock */
69 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB
| RCC_AHB1Periph_GPIOC
| RCC_AHB1Periph_GPIOD
|
70 RCC_AHB1Periph_GPIOE
| RCC_AHB1Periph_GPIOF
| RCC_AHB1Periph_GPIOG
|RCC_AHB1Periph_GPIOH
, ENABLE
);
72 /*-- GPIOs Configuration -----------------------------------------------------*/
74 +-------------------+--------------------+--------------------+--------------------+
75 + SDRAM pins assignment +
76 +-------------------+--------------------+--------------------+--------------------+
77 | PD0 <-> FMC_D2 | PE0 <-> FMC_NBL0 | PF0 <-> FMC_A0 | PG0 <-> FMC_A10 |
78 | PD1 <-> FMC_D3 | PE1 <-> FMC_NBL1 | PF1 <-> FMC_A1 | PG1 <-> FMC_A11 |
79 | PD8 <-> FMC_D13 | PE7 <-> FMC_D4 | PF2 <-> FMC_A2 | PG8 <-> FMC_SDCLK |
80 | PD9 <-> FMC_D14 | PE8 <-> FMC_D5 | PF3 <-> FMC_A3 | PG15 <-> FMC_NCAS |
81 | PD10 <-> FMC_D15 | PE9 <-> FMC_D6 | PF4 <-> FMC_A4 |--------------------+
82 | PD14 <-> FMC_D0 | PE10 <-> FMC_D7 | PF5 <-> FMC_A5 |
83 | PD15 <-> FMC_D1 | PE11 <-> FMC_D8 | PF11 <-> FMC_NRAS |
84 +-------------------| PE12 <-> FMC_D9 | PF12 <-> FMC_A6 |
85 | PE13 <-> FMC_D10 | PF13 <-> FMC_A7 |
86 | PE14 <-> FMC_D11 | PF14 <-> FMC_A8 |
87 | PE15 <-> FMC_D12 | PF15 <-> FMC_A9 |
88 +-------------------+--------------------+--------------------+
91 | PH5 <-> FMC_SDNWE |///////
96 /* Common GPIO configuration */
97 GPIO_InitStructure
.GPIO_Mode
= GPIO_Mode_AF
;
98 GPIO_InitStructure
.GPIO_Speed
= GPIO_Speed_50MHz
;
99 GPIO_InitStructure
.GPIO_OType
= GPIO_OType_PP
;
100 GPIO_InitStructure
.GPIO_PuPd
= GPIO_PuPd_NOPULL
;
102 /* GPIOB configuration */
103 GPIO_PinAFConfig(GPIOB
, GPIO_PinSource5
, GPIO_AF_FMC
);
105 GPIO_InitStructure
.GPIO_Pin
= GPIO_Pin_5
;
107 GPIO_Init(GPIOB
, &GPIO_InitStructure
);
109 /* GPIOC configuration */
110 GPIO_PinAFConfig(GPIOH
, GPIO_PinSource5
, GPIO_AF_FMC
);
112 GPIO_PinAFConfig(GPIOH
, GPIO_PinSource6
, GPIO_AF_FMC
);
114 GPIO_InitStructure
.GPIO_Pin
= GPIO_Pin_5
| GPIO_Pin_6
;
116 GPIO_Init(GPIOH
, &GPIO_InitStructure
);
118 /* GPIOD configuration */
119 GPIO_PinAFConfig(GPIOD
, GPIO_PinSource0
, GPIO_AF_FMC
);
120 GPIO_PinAFConfig(GPIOD
, GPIO_PinSource1
, GPIO_AF_FMC
);
121 GPIO_PinAFConfig(GPIOD
, GPIO_PinSource8
, GPIO_AF_FMC
);
122 GPIO_PinAFConfig(GPIOD
, GPIO_PinSource9
, GPIO_AF_FMC
);
123 GPIO_PinAFConfig(GPIOD
, GPIO_PinSource10
, GPIO_AF_FMC
);
124 GPIO_PinAFConfig(GPIOD
, GPIO_PinSource14
, GPIO_AF_FMC
);
125 GPIO_PinAFConfig(GPIOD
, GPIO_PinSource15
, GPIO_AF_FMC
);
127 GPIO_InitStructure
.GPIO_Pin
= GPIO_Pin_0
| GPIO_Pin_1
| GPIO_Pin_8
|
128 GPIO_Pin_9
| GPIO_Pin_10
| GPIO_Pin_14
|
131 GPIO_Init(GPIOD
, &GPIO_InitStructure
);
133 /* GPIOE configuration */
134 GPIO_PinAFConfig(GPIOE
, GPIO_PinSource0
, GPIO_AF_FMC
);
135 GPIO_PinAFConfig(GPIOE
, GPIO_PinSource1
, GPIO_AF_FMC
);
136 GPIO_PinAFConfig(GPIOE
, GPIO_PinSource7
, GPIO_AF_FMC
);
137 GPIO_PinAFConfig(GPIOE
, GPIO_PinSource8
, GPIO_AF_FMC
);
138 GPIO_PinAFConfig(GPIOE
, GPIO_PinSource9
, GPIO_AF_FMC
);
139 GPIO_PinAFConfig(GPIOE
, GPIO_PinSource10
, GPIO_AF_FMC
);
140 GPIO_PinAFConfig(GPIOE
, GPIO_PinSource11
, GPIO_AF_FMC
);
141 GPIO_PinAFConfig(GPIOE
, GPIO_PinSource12
, GPIO_AF_FMC
);
142 GPIO_PinAFConfig(GPIOE
, GPIO_PinSource13
, GPIO_AF_FMC
);
143 GPIO_PinAFConfig(GPIOE
, GPIO_PinSource14
, GPIO_AF_FMC
);
144 GPIO_PinAFConfig(GPIOE
, GPIO_PinSource15
, GPIO_AF_FMC
);
146 GPIO_InitStructure
.GPIO_Pin
= GPIO_Pin_0
| GPIO_Pin_1
| GPIO_Pin_7
|
147 GPIO_Pin_8
| GPIO_Pin_9
| GPIO_Pin_10
|
148 GPIO_Pin_11
| GPIO_Pin_12
| GPIO_Pin_13
|
149 GPIO_Pin_14
| GPIO_Pin_15
;
151 GPIO_Init(GPIOE
, &GPIO_InitStructure
);
153 /* GPIOF configuration */
154 GPIO_PinAFConfig(GPIOF
, GPIO_PinSource0
, GPIO_AF_FMC
);
155 GPIO_PinAFConfig(GPIOF
, GPIO_PinSource1
, GPIO_AF_FMC
);
156 GPIO_PinAFConfig(GPIOF
, GPIO_PinSource2
, GPIO_AF_FMC
);
157 GPIO_PinAFConfig(GPIOF
, GPIO_PinSource3
, GPIO_AF_FMC
);
158 GPIO_PinAFConfig(GPIOF
, GPIO_PinSource4
, GPIO_AF_FMC
);
159 GPIO_PinAFConfig(GPIOF
, GPIO_PinSource5
, GPIO_AF_FMC
);
160 GPIO_PinAFConfig(GPIOF
, GPIO_PinSource11
, GPIO_AF_FMC
);
161 GPIO_PinAFConfig(GPIOF
, GPIO_PinSource12
, GPIO_AF_FMC
);
162 GPIO_PinAFConfig(GPIOF
, GPIO_PinSource13
, GPIO_AF_FMC
);
163 GPIO_PinAFConfig(GPIOF
, GPIO_PinSource14
, GPIO_AF_FMC
);
164 GPIO_PinAFConfig(GPIOF
, GPIO_PinSource15
, GPIO_AF_FMC
);
166 GPIO_InitStructure
.GPIO_Pin
= GPIO_Pin_0
| GPIO_Pin_1
| GPIO_Pin_2
|
167 GPIO_Pin_3
| GPIO_Pin_4
| GPIO_Pin_5
|
168 GPIO_Pin_11
| GPIO_Pin_12
| GPIO_Pin_13
|
169 GPIO_Pin_14
| GPIO_Pin_15
;
171 GPIO_Init(GPIOF
, &GPIO_InitStructure
);
173 /* GPIOG configuration */
174 GPIO_PinAFConfig(GPIOG
, GPIO_PinSource0
, GPIO_AF_FMC
);
175 GPIO_PinAFConfig(GPIOG
, GPIO_PinSource1
, GPIO_AF_FMC
);
176 GPIO_PinAFConfig(GPIOG
, GPIO_PinSource4
, GPIO_AF_FMC
);
177 GPIO_PinAFConfig(GPIOG
, GPIO_PinSource5
, GPIO_AF_FMC
);
178 GPIO_PinAFConfig(GPIOG
, GPIO_PinSource8
, GPIO_AF_FMC
);
179 GPIO_PinAFConfig(GPIOG
, GPIO_PinSource15
, GPIO_AF_FMC
);
182 GPIO_InitStructure
.GPIO_Pin
= GPIO_Pin_0
| GPIO_Pin_1
| GPIO_Pin_4
|
183 GPIO_Pin_5
| GPIO_Pin_8
| GPIO_Pin_15
;
185 GPIO_Init(GPIOG
, &GPIO_InitStructure
);
189 * @brief Executes the SDRAM memory initialization sequence.
193 void SDRAM_InitSequence(void)
195 FMC_SDRAMCommandTypeDef FMC_SDRAMCommandStructure
;
197 uint32_t timeout
= SDRAM_TIMEOUT
;
199 /* Step 3 --------------------------------------------------------------------*/
200 /* Configure a clock configuration enable command */
201 FMC_SDRAMCommandStructure
.FMC_CommandMode
= FMC_Command_Mode_CLK_Enabled
;
202 FMC_SDRAMCommandStructure
.FMC_CommandTarget
= FMC_Command_Target_bank1
;
203 FMC_SDRAMCommandStructure
.FMC_AutoRefreshNumber
= 1;
204 FMC_SDRAMCommandStructure
.FMC_ModeRegisterDefinition
= 0;
205 /* Wait until the SDRAM controller is ready */
206 while((FMC_GetFlagStatus(FMC_Bank1_SDRAM
, FMC_FLAG_Busy
) != RESET
) && (timeout
> 0))
210 /* Send the command */
211 FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure
);
213 /* Step 4 --------------------------------------------------------------------*/
214 /* Insert 100 ms delay */
217 /* Step 5 --------------------------------------------------------------------*/
218 /* Configure a PALL (precharge all) command */
219 FMC_SDRAMCommandStructure
.FMC_CommandMode
= FMC_Command_Mode_PALL
;
220 FMC_SDRAMCommandStructure
.FMC_CommandTarget
= FMC_Command_Target_bank1
;
221 FMC_SDRAMCommandStructure
.FMC_AutoRefreshNumber
= 1;
222 FMC_SDRAMCommandStructure
.FMC_ModeRegisterDefinition
= 0;
224 /* Wait until the SDRAM controller is ready */
225 timeout
= SDRAM_TIMEOUT
;
226 while((FMC_GetFlagStatus(FMC_Bank1_SDRAM
, FMC_FLAG_Busy
) != RESET
) && (timeout
> 0))
230 /* Send the command */
231 FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure
);
233 /* Step 6 --------------------------------------------------------------------*/
234 /* Configure a Auto-Refresh command */
235 FMC_SDRAMCommandStructure
.FMC_CommandMode
= FMC_Command_Mode_AutoRefresh
;
236 FMC_SDRAMCommandStructure
.FMC_CommandTarget
= FMC_Command_Target_bank1
;
237 FMC_SDRAMCommandStructure
.FMC_AutoRefreshNumber
= 8;
238 FMC_SDRAMCommandStructure
.FMC_ModeRegisterDefinition
= 0;
240 /* Wait until the SDRAM controller is ready */
241 timeout
= SDRAM_TIMEOUT
;
242 while((FMC_GetFlagStatus(FMC_Bank1_SDRAM
, FMC_FLAG_Busy
) != RESET
) && (timeout
> 0))
246 /* Send the command */
247 FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure
);
249 /* Step 7 --------------------------------------------------------------------*/
250 /* Program the external memory mode register */
251 tmpr
= (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1
|
252 SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL
|
253 SDRAM_MODEREG_CAS_LATENCY_3
|
254 SDRAM_MODEREG_OPERATING_MODE_STANDARD
|
255 SDRAM_MODEREG_WRITEBURST_MODE_SINGLE
;
257 /* Configure a load Mode register command*/
258 FMC_SDRAMCommandStructure
.FMC_CommandMode
= FMC_Command_Mode_LoadMode
;
259 FMC_SDRAMCommandStructure
.FMC_CommandTarget
= FMC_Command_Target_bank1
;
260 FMC_SDRAMCommandStructure
.FMC_AutoRefreshNumber
= 1;
261 FMC_SDRAMCommandStructure
.FMC_ModeRegisterDefinition
= tmpr
;
263 /* Wait until the SDRAM controller is ready */
264 timeout
= SDRAM_TIMEOUT
;
265 while((FMC_GetFlagStatus(FMC_Bank1_SDRAM
, FMC_FLAG_Busy
) != RESET
) && (timeout
> 0))
269 /* Send the command */
270 FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure
);
272 /* Step 8 --------------------------------------------------------------------*/
274 /* Set the refresh rate counter */
275 /* (15.62 us x Freq) - 20 */
276 /* Set the device refresh counter */
277 FMC_SetRefreshCount(1385);
279 /* Wait until the SDRAM controller is ready */
280 timeout
= SDRAM_TIMEOUT
;
281 while((FMC_GetFlagStatus(FMC_Bank1_SDRAM
, FMC_FLAG_Busy
) != RESET
) && (timeout
> 0))
288 * @brief Executes the SDRAM memory initialization sequence.
292 void SDRAMTest_InitSequence(void)
294 FMC_SDRAMCommandTypeDef FMC_SDRAMCommandStructure
;
297 /* Step 3 --------------------------------------------------------------------*/
298 /* Configure a clock configuration enable command */
299 FMC_SDRAMCommandStructure
.FMC_CommandMode
= FMC_Command_Mode_CLK_Enabled
;
300 FMC_SDRAMCommandStructure
.FMC_CommandTarget
= FMC_Command_Target_bank2
;
301 FMC_SDRAMCommandStructure
.FMC_AutoRefreshNumber
= 1;
302 FMC_SDRAMCommandStructure
.FMC_ModeRegisterDefinition
= 0;
303 /* Wait until the SDRAM controller is ready */
304 while(FMC_GetFlagStatus(FMC_Bank2_SDRAM
, FMC_FLAG_Busy
) != RESET
)
307 /* Send the command */
308 FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure
);
310 /* Step 4 --------------------------------------------------------------------*/
311 /* Insert 100 ms delay */
314 /* Step 5 --------------------------------------------------------------------*/
315 /* Configure a PALL (precharge all) command */
316 FMC_SDRAMCommandStructure
.FMC_CommandMode
= FMC_Command_Mode_PALL
;
317 FMC_SDRAMCommandStructure
.FMC_CommandTarget
= FMC_Command_Target_bank2
;
318 FMC_SDRAMCommandStructure
.FMC_AutoRefreshNumber
= 1;
319 FMC_SDRAMCommandStructure
.FMC_ModeRegisterDefinition
= 0;
320 /* Wait until the SDRAM controller is ready */
321 while(FMC_GetFlagStatus(FMC_Bank2_SDRAM
, FMC_FLAG_Busy
) != RESET
)
324 /* Send the command */
325 FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure
);
327 /* Step 6 --------------------------------------------------------------------*/
328 /* Configure a Auto-Refresh command */
329 FMC_SDRAMCommandStructure
.FMC_CommandMode
= FMC_Command_Mode_AutoRefresh
;
330 FMC_SDRAMCommandStructure
.FMC_CommandTarget
= FMC_Command_Target_bank2
;
331 FMC_SDRAMCommandStructure
.FMC_AutoRefreshNumber
= 4;
332 FMC_SDRAMCommandStructure
.FMC_ModeRegisterDefinition
= 0;
333 /* Wait until the SDRAM controller is ready */
334 while(FMC_GetFlagStatus(FMC_Bank2_SDRAM
, FMC_FLAG_Busy
) != RESET
)
337 /* Send the first command */
338 FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure
);
340 /* Wait until the SDRAM controller is ready */
341 while(FMC_GetFlagStatus(FMC_Bank2_SDRAM
, FMC_FLAG_Busy
) != RESET
)
344 /* Send the second command */
345 FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure
);
347 /* Step 7 --------------------------------------------------------------------*/
348 /* Program the external memory mode register */
349 tmpr
= (uint32_t)SDRAM_MODEREG_BURST_LENGTH_2
|
350 SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL
|
351 SDRAM_MODEREG_CAS_LATENCY_3
|
352 SDRAM_MODEREG_OPERATING_MODE_STANDARD
|
353 SDRAM_MODEREG_WRITEBURST_MODE_SINGLE
;
355 /* Configure a load Mode register command*/
356 FMC_SDRAMCommandStructure
.FMC_CommandMode
= FMC_Command_Mode_LoadMode
;
357 FMC_SDRAMCommandStructure
.FMC_CommandTarget
= FMC_Command_Target_bank2
;
358 FMC_SDRAMCommandStructure
.FMC_AutoRefreshNumber
= 1;
359 FMC_SDRAMCommandStructure
.FMC_ModeRegisterDefinition
= tmpr
;
360 /* Wait until the SDRAM controller is ready */
361 while(FMC_GetFlagStatus(FMC_Bank2_SDRAM
, FMC_FLAG_Busy
) != RESET
)
364 /* Send the command */
365 FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure
);
367 /* Step 8 --------------------------------------------------------------------*/
369 /* Set the refresh rate counter */
370 /* (15.62 us x Freq) - 20 */
371 /* Set the device refresh counter */
372 FMC_SetRefreshCount(1386);
373 /* Wait until the SDRAM controller is ready */
374 while(FMC_GetFlagStatus(FMC_Bank2_SDRAM
, FMC_FLAG_Busy
) != RESET
)
379 void SDRAM_Init(void)
381 FMC_SDRAMInitTypeDef FMC_SDRAMInitStructure
;
382 FMC_SDRAMTimingInitTypeDef FMC_SDRAMTimingInitStructure
;
384 /* GPIO configuration for FMC SDRAM bank */
387 /* Enable FMC clock */
388 RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FMC
, ENABLE
);
390 /* FMC Configuration ---------------------------------------------------------*/
391 /* FMC SDRAM Bank configuration */
392 /* Timing configuration for 90 Mhz of SD clock frequency (168Mhz/2) */
393 /* TMRD: 2 Clock cycles */
394 FMC_SDRAMTimingInitStructure
.FMC_LoadToActiveDelay
= 2;
395 /* TXSR: min=70ns (7x11.11ns) */
396 FMC_SDRAMTimingInitStructure
.FMC_ExitSelfRefreshDelay
= 7;
397 /* TRAS: min=42ns (4x11.11ns) max=120k (ns) */
398 FMC_SDRAMTimingInitStructure
.FMC_SelfRefreshTime
= 4;
399 /* TRC: min=70 (7x11.11ns) */
400 FMC_SDRAMTimingInitStructure
.FMC_RowCycleDelay
= 7;
401 /* TWR: min=1+ 7ns (1+1x11.11ns) */
402 FMC_SDRAMTimingInitStructure
.FMC_WriteRecoveryTime
= 2;
403 /* TRP: 20ns => 2x11.11ns */
404 FMC_SDRAMTimingInitStructure
.FMC_RPDelay
= 2;
405 /* TRCD: 20ns => 2x11.11ns */
406 FMC_SDRAMTimingInitStructure
.FMC_RCDDelay
= 2;
408 /* FMC SDRAM control configuration */
409 FMC_SDRAMInitStructure
.FMC_Bank
= FMC_Bank2_SDRAM
;
410 /* Row addressing: [7:0] */
411 FMC_SDRAMInitStructure
.FMC_ColumnBitsNumber
= FMC_ColumnBits_Number_8b
;
412 /* Column addressing: [11:0] */
413 FMC_SDRAMInitStructure
.FMC_RowBitsNumber
= FMC_RowBits_Number_12b
;
414 FMC_SDRAMInitStructure
.FMC_SDMemoryDataWidth
= SDRAM_MEMORY_WIDTH
;
415 FMC_SDRAMInitStructure
.FMC_InternalBankNumber
= FMC_InternalBank_Number_4
;
416 FMC_SDRAMInitStructure
.FMC_CASLatency
= SDRAM_CAS_LATENCY
;
417 FMC_SDRAMInitStructure
.FMC_WriteProtection
= FMC_Write_Protection_Disable
;
418 FMC_SDRAMInitStructure
.FMC_SDClockPeriod
= SDCLOCK_PERIOD
;
419 FMC_SDRAMInitStructure
.FMC_ReadBurst
= SDRAM_READBURST
;
420 FMC_SDRAMInitStructure
.FMC_ReadPipeDelay
= FMC_ReadPipe_Delay_0
;
421 FMC_SDRAMInitStructure
.FMC_SDRAMTimingStruct
= &FMC_SDRAMTimingInitStructure
;
423 /* FMC SDRAM bank initialization */
424 FMC_SDRAMInit(&FMC_SDRAMInitStructure
);
426 /* FMC SDRAM device initialization sequence */
427 SDRAMTest_InitSequence();
431 void SDRAM_WriteBuffer(uint32_t* pBuffer
, uint32_t uwWriteAddress
, uint32_t uwBufferSize
)
433 __IO
uint32_t write_pointer
= (uint32_t)uwWriteAddress
;
435 FMC_SDRAMWriteProtectionConfig(FMC_Bank1_SDRAM
, DISABLE
);
437 while(FMC_GetFlagStatus(FMC_Bank1_SDRAM
, FMC_FLAG_Busy
) != RESET
)
441 for (; uwBufferSize
!= 0; uwBufferSize
--)
444 *(uint32_t *) (SDRAM_BANK_ADDR
+ write_pointer
) = *pBuffer
++;
451 void SDRAM_ReadBuffer(uint32_t* pBuffer
, uint32_t uwReadAddress
, uint32_t uwBufferSize
)
453 __IO
uint32_t write_pointer
= (uint32_t)uwReadAddress
;
455 while(FMC_GetFlagStatus(FMC_Bank1_SDRAM
, FMC_FLAG_Busy
) != RESET
)
459 for(; uwBufferSize
!= 0x00; uwBufferSize
--)
461 *pBuffer
++ = *(__IO
uint32_t *)(SDRAM_BANK_ADDR
+ write_pointer
);