Rev 196 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
196 | killagreg | 1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** |
1 | ingob | 2 | * File Name : 91x_fmi.c |
3 | * Author : MCD Application Team |
||
196 | killagreg | 4 | * Version : V2.1 |
5 | * Date : 12/22/2008 |
||
6 | * Description : This file provides all the FMI firmware functions. |
||
1 | ingob | 7 | ******************************************************************************** |
8 | * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH |
||
9 | * CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS |
||
10 | * A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT |
||
11 | * OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT |
||
12 | * OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION |
||
13 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
||
14 | *******************************************************************************/ |
||
15 | |||
16 | |||
17 | /* Standard include ----------------------------------------------------------*/ |
||
18 | #include "91x_fmi.h" |
||
19 | |||
20 | /* Include of other module interface headers ---------------------------------*/ |
||
21 | /* Local includes ------------------------------------------------------------*/ |
||
22 | /* Private typedef -----------------------------------------------------------*/ |
||
23 | /* Private define ------------------------------------------------------------*/ |
||
24 | |||
25 | #define TIMEOUT 0xFFFFFF /* Timeout value */ |
||
26 | |||
27 | /* Private macro -------------------------------------------------------------*/ |
||
28 | /* Private variables ---------------------------------------------------------*/ |
||
29 | /* Private function prototypes -----------------------------------------------*/ |
||
30 | /* Interface functions -------------------------------------------------------*/ |
||
31 | /* Private functions ---------------------------------------------------------*/ |
||
32 | |||
33 | |||
34 | /******************************************************************************* |
||
35 | * Function Name : FMI_BankRemapConfig |
||
36 | * Description : Configure the addresses and sizes of bank 0 and bank 1. |
||
37 | * Input1 : FMI_BootBankSize: specifies the boot bank size. |
||
38 | * This parameter can be one of the following values: |
||
39 | * - 0x0: 32KBytes. |
||
40 | * - 0x1: 64KBytes. |
||
41 | * - 0x2: 128KBytes. |
||
42 | * - 0x3: 256KBytes. |
||
43 | * - 0x4: 512KBytes. |
||
44 | * .... |
||
45 | * - 0xB: 64MBytes. |
||
46 | * Input2 : FMI_NonBootBankSize: specifies the non boot bank size. |
||
47 | * This parameter can be one of the following values: |
||
48 | * - 0x0: 8KBytes. |
||
49 | * - 0x1: 16KBytes. |
||
50 | * - 0x2: 32KBytes. |
||
51 | * - 0x3: 64KBytes. |
||
52 | * .... |
||
53 | * - 0xD: 64MBytes. |
||
54 | * Input3 : FMI_BootBankAddress: specifies the address of the boot bank. |
||
55 | * Input4 : FMI_NonBootBankAddress: specifies the address of the non |
||
56 | * boot bank. |
||
57 | * Output : None |
||
58 | * Return : None |
||
59 | *******************************************************************************/ |
||
60 | void FMI_BankRemapConfig(u8 FMI_BootBankSize, u8 FMI_NonBootBankSize, \ |
||
61 | u32 FMI_BootBankAddress, u32 FMI_NonBootBankAddress) |
||
62 | { |
||
63 | FMI->BBSR = FMI_BootBankSize; |
||
64 | FMI->NBBSR = FMI_NonBootBankSize; |
||
65 | FMI->BBADR = (FMI_BootBankAddress >> 2); |
||
66 | FMI->NBBADR = (FMI_NonBootBankAddress >> 2); |
||
67 | FMI->CR |= 0x18; /* Enable bank 1 */ |
||
68 | } |
||
69 | |||
70 | /******************************************************************************* |
||
71 | * Function Name : FMI_Config |
||
72 | * Description : Configure the FMI. |
||
73 | * Input1 : FMI_ReadWaitState: specifies the needed read wait states. |
||
74 | * This parameter can be one of the following values: |
||
75 | * - FMI_READ_WAIT_STATE_1: One read wait state. |
||
76 | * - FMI_READ_WAIT_STATE_2: Two read wait states. |
||
77 | * - FMI_READ_WAIT_STATE_3: Three read wait states. |
||
78 | * Input2 : FMI_WriteWaitState: specifies the needed write wait states. |
||
79 | * This parameter can be one of the following values: |
||
80 | * - FMI_WRITE_WAIT_STATE_1: One write wait state. |
||
81 | * - FMI_WRITE_WAIT_STATE_2: Two write wait states. |
||
82 | * Input3 : FMI_PWD: specifies the power down mode status. |
||
83 | * This parameter can be one of the following values: |
||
84 | * - FMI_PWD_ENABLE: Enable the PWD. |
||
85 | * - FMI_PWD_DISABLE: Disable the PWD. |
||
86 | * Input4 : FMI_LVDEN: specifies the low voltage detector status. |
||
87 | * This parameter can be one of the following values: |
||
88 | * - FMI_LVD_ENABLE: Enable the LVD. |
||
89 | * - FMI_LVD_DISABLE: Disable the LVD. |
||
90 | * Input5 : FMI_FreqRange: specifies the working frequency range. |
||
91 | * This parameter can be one of the following values: |
||
92 | * - FMI_FREQ_LOW: Low working frequency (up to 66MHz). |
||
93 | * - FMI_FREQ_HIGH: High working frequency (above 66MHz) . |
||
94 | * Output : None |
||
95 | * Return : None |
||
196 | killagreg | 96 | * |
97 | *NOTE: |
||
98 | *This function should be executed from SRAM when booting from bank1 |
||
99 | *to avoid any conflicts(reading and writing at the same time in bank1) |
||
100 | * |
||
1 | ingob | 101 | *******************************************************************************/ |
102 | void FMI_Config(u16 FMI_ReadWaitState, u32 FMI_WriteWaitState, u16 FMI_PWD,\ |
||
103 | u16 FMI_LVDEN, u16 FMI_FreqRange) |
||
104 | { |
||
105 | /* Configure the write wait state value */ |
||
106 | if (FMI_WriteWaitState == FMI_WRITE_WAIT_STATE_1) |
||
107 | { |
||
108 | FMI->CR |= FMI_WRITE_WAIT_STATE_1; |
||
109 | } |
||
110 | else |
||
111 | { |
||
112 | FMI->CR &= FMI_WRITE_WAIT_STATE_0; |
||
113 | } |
||
114 | |||
115 | /* Write a write flash configuration register command */ |
||
116 | *(vu16 *)FMI_BANK_1 = 0x60; |
||
117 | |||
118 | /* Configure the flash configuration register */ |
||
119 | *(vu16 *)(FMI_BANK_1|FMI_ReadWaitState|FMI_PWD|FMI_LVDEN|FMI_FreqRange) = 0x03; |
||
120 | } |
||
121 | |||
122 | /******************************************************************************* |
||
123 | * Function Name : FMI_EraseSector |
||
124 | * Description : Erase the needed sector. |
||
125 | * Input : FMI_Sector: specifies the sector to be erased. |
||
126 | * This parameter can be one of the following values: |
||
127 | * - FMI_B0S0: FMI bank 0 sector 0. |
||
196 | killagreg | 128 | * ... |
129 | * - FMI_B0S31: FMI bank 0 sector 31. |
||
130 | * |
||
131 | * |
||
1 | ingob | 132 | * - FMI_B1S0: FMI bank 1 sector 0. |
196 | killagreg | 133 | * ... |
134 | * - FMI_B1S7: FMI bank 1 sector 7. |
||
1 | ingob | 135 | * Output : None |
136 | * Return : None |
||
137 | *******************************************************************************/ |
||
138 | void FMI_EraseSector(vu32 FMI_Sector) |
||
139 | { |
||
140 | /* Write an erase set-up command to the sector */ |
||
141 | *(vu16 *)FMI_Sector = 0x20; |
||
142 | |||
143 | /* Write an erase confirm command to the sector */ |
||
144 | *(vu16 *)FMI_Sector = 0xD0; |
||
145 | } |
||
146 | |||
147 | /******************************************************************************* |
||
148 | * Function Name : FMI_EraseBank |
||
149 | * Description : Erase the needed bank. |
||
150 | * Input : FMI_Bank: specifies the bank to be erased. |
||
151 | * This parameter can be one of the following values: |
||
152 | * - FMI_BANK_0: FMI bank 0. |
||
153 | * - FMI_BANK_1: FMI bank 1. |
||
154 | * Output : None |
||
155 | * Return : None |
||
156 | *******************************************************************************/ |
||
157 | void FMI_EraseBank(vu32 FMI_Bank) |
||
158 | { |
||
159 | /* Write a bank erase set-up command to the bank */ |
||
160 | *(vu16 *)FMI_Bank = 0x80; |
||
161 | |||
162 | /* Write an erase confirm command to the sector */ |
||
163 | *(vu16 *)FMI_Bank = 0xD0; |
||
164 | } |
||
165 | |||
166 | /******************************************************************************* |
||
167 | * Function Name : FMI_WriteHalfWord |
||
168 | * Description : Write a halfword to the needed Flash memory address. |
||
169 | * Input 1 : FMI_Address: specifies the address offset where the data will |
||
170 | * be written. |
||
171 | * Input 2 : FMI_Data: the needed data. |
||
172 | * Output : None |
||
173 | * Return : None |
||
174 | *******************************************************************************/ |
||
175 | void FMI_WriteHalfWord(u32 FMI_Address, u16 FMI_Data) |
||
176 | { |
||
177 | /* Write a program command to the sector to be written */ |
||
178 | *(vu16 *)(FMI_Address & 0xFFFFFFFC) = 0x40; |
||
179 | |||
180 | /* Write the halfword to the destination address */ |
||
181 | *(vu16 *)FMI_Address = FMI_Data; |
||
182 | } |
||
183 | |||
184 | /******************************************************************************* |
||
185 | * Function Name : FMI_WriteOTPHalfWord |
||
186 | * Description : Write a halfword to the needed OTP sector address. |
||
187 | * Input 1 : FMI_OTPHWAddress: specifies the halfword address offset |
||
188 | * where the data will be written. |
||
189 | * This parameter can be one of the following values: |
||
190 | * - FMI_OTP_LOW_HALFWORD_0: OTP Low halfword 0. |
||
191 | * - FMI_OTP_HIGH_HALFWORD_0: OTP High halfword 0. |
||
192 | * - FMI_OTP_LOW_HALFWORD_1: OTP Low halfword 1. |
||
193 | * - FMI_OTP_HIGH_HALFWORD_1: OTP High halfword 1. |
||
194 | * - FMI_OTP_LOW_HALFWORD_2: OTP Low halfword 2. |
||
195 | * - FMI_OTP_HIGH_HALFWORD_2: OTP High halfword 2. |
||
196 | * - FMI_OTP_LOW_HALFWORD_3: OTP Low halfword 3. |
||
197 | * - FMI_OTP_HIGH_HALFWORD_3: OTP High halfword 3. |
||
198 | * - FMI_OTP_LOW_HALFWORD_4: OTP Low halfword 4. |
||
199 | * - FMI_OTP_HIGH_HALFWORD_4: OTP High halfword 4. |
||
200 | * - FMI_OTP_LOW_HALFWORD_5: OTP Low halfword 5. |
||
201 | * - FMI_OTP_HIGH_HALFWORD_5: OTP High halfword 5. |
||
202 | * - FMI_OTP_LOW_HALFWORD_6: OTP Low halfword 6. |
||
203 | * - FMI_OTP_HIGH_HALFWORD_6: OTP High halfword 6. |
||
204 | * - FMI_OTP_LOW_HALFWORD_7: OTP Low halfword 7. |
||
205 | * - FMI_OTP_HIGH_HALFWORD_7: OTP High halfword 7. |
||
206 | * Input 2 : FMI_OTPData: The needed OTP data. |
||
207 | * Output : None |
||
208 | * Return : None |
||
209 | *******************************************************************************/ |
||
210 | void FMI_WriteOTPHalfWord(u8 FMI_OTPHWAddress, u16 FMI_OTPData) |
||
211 | { |
||
212 | /* Write a write OTP command to the needed address */ |
||
213 | *(vu16 *)(FMI_BANK_1) = 0xC0; |
||
214 | |||
215 | /* Write the halfword to the destination address */ |
||
216 | *(vu16 *)(FMI_BANK_1 + FMI_OTPHWAddress) = FMI_OTPData; |
||
217 | } |
||
218 | |||
219 | /******************************************************************************* |
||
220 | * Function Name : FMI_ReadWord |
||
221 | * Description : Read the correspondent data. |
||
222 | * Input : FMI_Address: specifies the needed address. |
||
223 | * Output : None |
||
224 | * Return : The data contained in the specified address. |
||
225 | *******************************************************************************/ |
||
226 | u32 FMI_ReadWord(u32 FMI_Address) |
||
227 | { |
||
228 | return(*(u32*)FMI_Address); |
||
229 | } |
||
230 | |||
231 | /******************************************************************************* |
||
232 | * Function Name : FMI_ReadOTPData |
||
233 | * Description : Read data from the OTP sector. |
||
234 | * Input : FMI_OTPAddress: specifies the address of the data to be read. |
||
235 | * This parameter can be one of the following values: |
||
196 | killagreg | 236 | * - FMI_OTP_WORD_0: OTP word 0 . |
237 | * - FMI_OTP_WORD_1: OTP word 1 . |
||
238 | * - FMI_OTP_WORD_2: OTP word 2 . |
||
239 | * - FMI_OTP_WORD_3: OTP word 3 . |
||
240 | * - FMI_OTP_WORD_4: OTP word 4 . |
||
241 | * - FMI_OTP_WORD_5: OTP word 5 . |
||
242 | * - FMI_OTP_WORD_6: OTP word 6 . |
||
243 | * - FMI_OTP_WORD_7: OTP word 7 . |
||
1 | ingob | 244 | * Output : None |
245 | * Return : The needed OTP words. |
||
246 | *******************************************************************************/ |
||
247 | u32 FMI_ReadOTPData(u8 FMI_OTPAddress) |
||
248 | { |
||
249 | u32 OTP_Data = 0x0; |
||
250 | /* write a read OTP sector command */ |
||
251 | *(vu16 *)(FMI_BANK_1) = 0x98; |
||
252 | |||
253 | /* Read the correspondent data */ |
||
254 | OTP_Data = (*(vu32*)(FMI_BANK_1 + FMI_OTPAddress)); |
||
255 | |||
256 | /* Write a read array command */ |
||
257 | *(vu16 *)(FMI_BANK_1) = 0xFF; |
||
258 | |||
259 | return OTP_Data; |
||
260 | } |
||
261 | |||
262 | /******************************************************************************* |
||
263 | * Function Name : FMI_GetFlagStatus |
||
264 | * Description : Check whether the specified FMI flag is set or not. |
||
265 | * Input1 : FMI_Flag: flag to check. |
||
266 | * This parameter can be one of the following values: |
||
267 | * - FMI_FLAG_SPS: Sector Protection Status Flag. |
||
268 | * - FMI_FLAG_PSS: Program Suspend Status Flag. |
||
269 | * - FMI_FLAG_PS: Program Status Flag. |
||
270 | * - FMI_FLAG_ES: Erase Status Flag. |
||
271 | * - FMI_FLAG_ESS: Erase Suspend Status Flag. |
||
272 | * - FMI_FLAG_PECS: FPEC Status Flag. |
||
273 | * Input2 : FMI_Bank: specifies the needed bank. |
||
274 | * This parameter can be one of the following values: |
||
275 | * - FMI_BANK_0: FMI bank 0. |
||
276 | * - FMI_BANK_1: FMI bank 1. |
||
277 | * Output : None |
||
278 | * Return : None |
||
279 | *******************************************************************************/ |
||
280 | FlagStatus FMI_GetFlagStatus(u8 FMI_Flag, vu32 FMI_Bank) |
||
281 | { |
||
282 | u16 FMI_Status_Register = 0; |
||
283 | |||
284 | /* Write a read status register command */ |
||
285 | *(vu16 *)FMI_Bank = 0x70; |
||
286 | |||
287 | /* Wait until operation completion */ |
||
288 | while(!((*(vu16 *)FMI_Bank) & 0x80)); |
||
289 | |||
290 | /* Read the status register */ |
||
291 | FMI_Status_Register = *(vu16 *)FMI_Bank; |
||
292 | |||
293 | /* Write a read array command */ |
||
294 | *(vu16 *)FMI_Bank = 0xFF; |
||
295 | |||
296 | if((FMI_Status_Register & FMI_Flag) != RESET) |
||
297 | { |
||
298 | return SET; |
||
299 | } |
||
300 | else |
||
301 | { |
||
302 | return RESET; |
||
303 | } |
||
304 | } |
||
305 | |||
306 | /******************************************************************************* |
||
307 | * Function Name : FMI_GetReadWaitStateValue |
||
308 | * Description : Get the current Read wait state value. |
||
309 | * Input : None |
||
310 | * Output : None |
||
311 | * Return : The current read wait states value. |
||
312 | *******************************************************************************/ |
||
313 | u16 FMI_GetReadWaitStateValue(void) |
||
314 | { |
||
315 | u16 FMI_Configuration_Register = 0; |
||
196 | killagreg | 316 | /*Write a read RSIG command to any word address in Bank1*/ |
1 | ingob | 317 | *(vu16 *)FMI_BANK_1 = 0x90; |
196 | killagreg | 318 | |
1 | ingob | 319 | /* Read the flash configuration register */ |
196 | killagreg | 320 | #ifdef Flash_512KB_256KB |
1 | ingob | 321 | FMI_Configuration_Register = *(vu16 *)(FMI_BANK_1 + 0x14); |
196 | killagreg | 322 | #endif |
323 | |||
324 | #ifdef Flash_2MB_1MB |
||
325 | FMI_Configuration_Register = *(vu16 *)(FMI_BANK_1 + 0x1C); |
||
326 | #endif |
||
1 | ingob | 327 | /* Write a read array command */ |
328 | *(vu16 *)FMI_BANK_1 = 0xFF; |
||
329 | |||
196 | killagreg | 330 | FMI_Configuration_Register = ((FMI_Configuration_Register >> 11) + 1) & 0x3; |
331 | |||
1 | ingob | 332 | /* Return the wait states value */ |
333 | return FMI_Configuration_Register; |
||
334 | } |
||
335 | |||
336 | /******************************************************************************* |
||
337 | * Function Name : FMI_GetWriteWaitStateValue |
||
338 | * Description : Get the current write wait state value. |
||
339 | * Input : None |
||
340 | * Output : None |
||
341 | * Return : The current write wait states value. |
||
342 | *******************************************************************************/ |
||
343 | u16 FMI_GetWriteWaitStateValue(void) |
||
344 | { |
||
345 | return ((u16)((FMI->CR & 0x100) >> 8)); |
||
346 | } |
||
347 | |||
348 | /******************************************************************************* |
||
349 | * Function Name : FMI_SuspendEnable |
||
350 | * Description : Suspend command enable. |
||
351 | * Input : FMI_Bank: specifies the bank to be suspended. |
||
352 | * This parameter can be one of the following values: |
||
353 | * - FMI_BANK_0: FMI bank 0. |
||
354 | * - FMI_BANK_1: FMI bank 1. |
||
355 | * Output : None |
||
356 | * Return : None |
||
357 | *******************************************************************************/ |
||
358 | void FMI_SuspendEnable(vu32 FMI_Bank) |
||
359 | { |
||
360 | /* Write a suspend command to the bank */ |
||
361 | *(vu16 *)FMI_Bank = 0xB0; |
||
362 | } |
||
363 | |||
364 | /******************************************************************************* |
||
365 | * Function Name : FMI_ResumeEnable |
||
366 | * Description : Resume the suspended command. |
||
367 | * Input : FMI_Bank: specifies the suspended bank. |
||
368 | * This parameter can be one of the following values: |
||
369 | * - FMI_BANK_0: FMI bank 0. |
||
370 | * - FMI_BANK_1: FMI bank 1. |
||
371 | * Output : None |
||
372 | * Return : None |
||
373 | *******************************************************************************/ |
||
374 | void FMI_ResumeEnable(vu32 FMI_Bank) |
||
375 | { |
||
376 | /* Write a resume command to the bank */ |
||
377 | *(vu16 *)FMI_Bank = 0xD0; |
||
378 | } |
||
379 | |||
380 | /******************************************************************************* |
||
381 | * Function Name : FMI_ClearFlag |
||
382 | * Description : Clear the FMI Flags on the correspondent bank. |
||
383 | * Input : FMI_Bank: specifies the needed bank. |
||
384 | * This parameter can be one of the following values: |
||
385 | * - FMI_BANK_0: FMI bank 0. |
||
386 | * - FMI_BANK_1: FMI bank 1. |
||
387 | * Output : None |
||
388 | * Return : None |
||
389 | *******************************************************************************/ |
||
390 | void FMI_ClearFlag(vu32 FMI_Bank) |
||
391 | { |
||
392 | /* Write a clear status register command */ |
||
393 | *(vu16 *)FMI_Bank = 0x50; |
||
394 | } |
||
395 | |||
396 | /******************************************************************************* |
||
397 | * Function Name : FMI_WriteProtectionCmd |
||
398 | * Description : Enable or disable the write protection for the needed sector. |
||
399 | * Input1 : FMI_Sector: specifies the sector to be protected or |
||
400 | * unprotected. |
||
401 | * This parameter can be one of the following values: |
||
196 | killagreg | 402 | * |
403 | * - FMI_B0S0: FMI bank 0 sector 0. |
||
404 | * ... |
||
405 | * - FMI_B0S31: FMI bank 0 sector 31. |
||
406 | * |
||
407 | * |
||
1 | ingob | 408 | * - FMI_B1S0: FMI bank 1 sector 0. |
196 | killagreg | 409 | * ... |
410 | * - FMI_B1S7: FMI bank 1 sector 7. |
||
411 | * |
||
1 | ingob | 412 | * Input2 : FMI_NewState: specifies the protection status. |
413 | * This parameter can be one of the following values: |
||
414 | * - ENABLE: Enable the protection. |
||
415 | * - DISABLE: Disable the protection. |
||
416 | * Output : None |
||
417 | * Return : None |
||
418 | *******************************************************************************/ |
||
419 | void FMI_WriteProtectionCmd(vu32 FMI_Sector, FunctionalState FMI_NewState) |
||
420 | { |
||
421 | if (FMI_NewState == ENABLE) |
||
422 | { |
||
423 | *(vu16*)FMI_Sector = 0x60; |
||
424 | *(vu16*)FMI_Sector = 0x01; |
||
425 | *(vu16*)FMI_Sector = 0xFF; |
||
426 | } |
||
427 | else /* DISABLE */ |
||
428 | { |
||
429 | *(vu16*)FMI_Sector = 0x60; |
||
430 | *(vu16*)FMI_Sector = 0xD0; |
||
431 | *(vu16*)FMI_Sector = 0xFF; |
||
432 | } |
||
433 | } |
||
434 | |||
435 | |||
436 | /******************************************************************************* |
||
437 | * Function Name : FMI_WaitForLastOperation |
||
438 | * Description : Wait until the last operation (Write halfword, Write OTP |
||
439 | * halfword, Erase sector and Erase bank) completion. |
||
440 | * Input : FMI_Bank: specifies the bank where the operation is on going. |
||
441 | * This parameter can be one of the following values: |
||
442 | * - FMI_BANK_0: FMI bank 0. |
||
443 | * - FMI_BANK_1: FMI bank 1. |
||
444 | * Output : None |
||
445 | * Return : The timeout status. |
||
446 | * This parameter can be one of the following values: |
||
447 | * - FMI_TIME_OUT_ERROR: Timeout error occurred. |
||
448 | * - FMI_NO_TIME_OUT_ERROR: No timeout error. |
||
449 | *******************************************************************************/ |
||
450 | u8 FMI_WaitForLastOperation(vu32 FMI_Bank) |
||
451 | { |
||
452 | u32 Time_Out = 0; |
||
453 | |||
454 | /* Write a read status register command */ |
||
455 | *(vu16 *)(FMI_Bank) = 0x70; |
||
456 | |||
457 | /* Wait until operation compeletion */ |
||
458 | while((!((*(vu16 *)FMI_Bank) & 0x80))&&(Time_Out < TIMEOUT )) |
||
459 | { |
||
460 | Time_Out ++; /* Time Out */ |
||
461 | } |
||
462 | |||
463 | /* Write a read array command */ |
||
464 | *(vu16 *)FMI_Bank = 0xFF; |
||
465 | |||
466 | if (Time_Out == TIMEOUT) |
||
467 | { |
||
468 | return FMI_TIME_OUT_ERROR; |
||
469 | } |
||
470 | else |
||
471 | { |
||
472 | return FMI_NO_TIME_OUT_ERROR; |
||
473 | } |
||
474 | } |
||
475 | |||
196 | killagreg | 476 | /******************************************************************************* |
477 | * Function Name : FMI_ReadRSIGData |
||
478 | * Description : Read the Electronic Signature stored in the user configuration |
||
479 | * sector of Bank 1. |
||
480 | * Input : FMI_LSB_RSIGAddress: specifies the low byte of the address |
||
481 | * to select the register. |
||
482 | * This parameter can be one of the following values: |
||
483 | * - FMI_ReadRSIGData_0. |
||
484 | * - FMI_ReadRSIGData_1. |
||
485 | * - FMI_ReadRSIGData_2. |
||
486 | * - FMI_ReadRSIGData_3. |
||
487 | * - FMI_ReadRSIGData_4. |
||
488 | * - FMI_ReadRSIGData_5. |
||
489 | * - FMI_ReadRSIGData_6. |
||
490 | * - FMI_ReadRSIGData_7. |
||
491 | * |
||
492 | * Output : None |
||
493 | * Return : The needed RSIG data. |
||
494 | *******************************************************************************/ |
||
1 | ingob | 495 | |
196 | killagreg | 496 | u32 FMI_ReadRSIGData(u8 FMI_LSB_RSIGAddress) |
497 | { |
||
498 | u32 RSIG_Data = 0x0; |
||
499 | |||
500 | /*Write a read RSIG command to any word address in Bank1*/ |
||
501 | *(vu16 *)(FMI_BANK_1) = 0x90; |
||
502 | |||
503 | /*Read any RSIG register from any address in Bank1*/ |
||
504 | RSIG_Data = (*(vu32*)(FMI_BANK_1 + (FMI_LSB_RSIGAddress<<2))); |
||
505 | |||
506 | /*write a Read Array command (FFh) to any word address in Bank 1 to*/ |
||
507 | /*return it to Read Array mode.*/ |
||
508 | *(vu16 *)FMI_BANK_1 = 0xFF; |
||
509 | |||
510 | return RSIG_Data; |
||
511 | } |
||
512 | |||
513 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ |