]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M7_STM32F7_STM32756G-EVAL_IAR_Keil/ST_Library/stm32f7xx_hal_nor.c
Final V8.2.1 release ready for tagging:
[freertos] / FreeRTOS / Demo / CORTEX_M7_STM32F7_STM32756G-EVAL_IAR_Keil / ST_Library / stm32f7xx_hal_nor.c
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32f7xx_hal_nor.c\r
4   * @author  MCD Application Team\r
5   * @version V1.0.0RC1\r
6   * @date    24-March-2015\r
7   * @brief   NOR HAL module driver.\r
8   *          This file provides a generic firmware to drive NOR memories mounted \r
9   *          as external device.\r
10   *         \r
11   @verbatim\r
12   ==============================================================================\r
13                      ##### How to use this driver #####\r
14   ==============================================================================       \r
15     [..]\r
16       This driver is a generic layered driver which contains a set of APIs used to \r
17       control NOR flash memories. It uses the FMC layer functions to interface \r
18       with NOR devices. This driver is used as follows:\r
19     \r
20       (+) NOR flash memory configuration sequence using the function HAL_NOR_Init() \r
21           with control and timing parameters for both normal and extended mode.\r
22             \r
23       (+) Read NOR flash memory manufacturer code and device IDs using the function\r
24           HAL_NOR_Read_ID(). The read information is stored in the NOR_ID_TypeDef \r
25           structure declared by the function caller. \r
26         \r
27       (+) Access NOR flash memory by read/write data unit operations using the functions\r
28           HAL_NOR_Read(), HAL_NOR_Program().\r
29         \r
30       (+) Perform NOR flash erase block/chip operations using the functions \r
31           HAL_NOR_Erase_Block() and HAL_NOR_Erase_Chip().\r
32         \r
33       (+) Read the NOR flash CFI (common flash interface) IDs using the function\r
34           HAL_NOR_Read_CFI(). The read information is stored in the NOR_CFI_TypeDef\r
35           structure declared by the function caller.\r
36         \r
37       (+) You can also control the NOR device by calling the control APIs HAL_NOR_WriteOperation_Enable()/\r
38           HAL_NOR_WriteOperation_Disable() to respectively enable/disable the NOR write operation  \r
39        \r
40       (+) You can monitor the NOR device HAL state by calling the function\r
41           HAL_NOR_GetState() \r
42     [..]\r
43      (@) This driver is a set of generic APIs which handle standard NOR flash operations.\r
44          If a NOR flash device contains different operations and/or implementations, \r
45          it should be implemented separately.\r
46 \r
47      *** NOR HAL driver macros list ***\r
48      ============================================= \r
49      [..]\r
50        Below the list of most used macros in NOR HAL driver.\r
51        \r
52       (+) NOR_WRITE : NOR memory write data to specified address\r
53 \r
54   @endverbatim\r
55   ******************************************************************************\r
56   * @attention\r
57   *\r
58   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>\r
59   *\r
60   * Redistribution and use in source and binary forms, with or without modification,\r
61   * are permitted provided that the following conditions are met:\r
62   *   1. Redistributions of source code must retain the above copyright notice,\r
63   *      this list of conditions and the following disclaimer.\r
64   *   2. Redistributions in binary form must reproduce the above copyright notice,\r
65   *      this list of conditions and the following disclaimer in the documentation\r
66   *      and/or other materials provided with the distribution.\r
67   *   3. Neither the name of STMicroelectronics nor the names of its contributors\r
68   *      may be used to endorse or promote products derived from this software\r
69   *      without specific prior written permission.\r
70   *\r
71   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
72   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
73   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
74   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
75   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
76   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
77   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
78   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
79   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
80   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
81   *\r
82   ******************************************************************************\r
83   */ \r
84 \r
85 /* Includes ------------------------------------------------------------------*/\r
86 #include "stm32f7xx_hal.h"\r
87 \r
88 /** @addtogroup STM32F7xx_HAL_Driver\r
89   * @{\r
90   */\r
91 \r
92 /** @defgroup NOR NOR\r
93   * @brief NOR driver modules\r
94   * @{\r
95   */\r
96 #ifdef HAL_NOR_MODULE_ENABLED\r
97 #if defined(STM32F756xx) || defined(STM32F746xx)\r
98 \r
99 /* Private typedef -----------------------------------------------------------*/\r
100 /* Private define ------------------------------------------------------------*/\r
101       \r
102 /** @defgroup NOR_Private_Defines NOR Private Defines\r
103   * @{\r
104   */\r
105 \r
106 /* Constants to define address to set to write a command */\r
107 #define NOR_CMD_ADDRESS_FIRST                 (uint16_t)0x0555\r
108 #define NOR_CMD_ADDRESS_FIRST_CFI             (uint16_t)0x0055\r
109 #define NOR_CMD_ADDRESS_SECOND                (uint16_t)0x02AA\r
110 #define NOR_CMD_ADDRESS_THIRD                 (uint16_t)0x0555\r
111 #define NOR_CMD_ADDRESS_FOURTH                (uint16_t)0x0555\r
112 #define NOR_CMD_ADDRESS_FIFTH                 (uint16_t)0x02AA\r
113 #define NOR_CMD_ADDRESS_SIXTH                 (uint16_t)0x0555\r
114 \r
115 /* Constants to define data to program a command */\r
116 #define NOR_CMD_DATA_READ_RESET               (uint16_t)0x00F0\r
117 #define NOR_CMD_DATA_FIRST                    (uint16_t)0x00AA\r
118 #define NOR_CMD_DATA_SECOND                   (uint16_t)0x0055\r
119 #define NOR_CMD_DATA_AUTO_SELECT              (uint16_t)0x0090\r
120 #define NOR_CMD_DATA_PROGRAM                  (uint16_t)0x00A0\r
121 #define NOR_CMD_DATA_CHIP_BLOCK_ERASE_THIRD   (uint16_t)0x0080\r
122 #define NOR_CMD_DATA_CHIP_BLOCK_ERASE_FOURTH  (uint16_t)0x00AA\r
123 #define NOR_CMD_DATA_CHIP_BLOCK_ERASE_FIFTH   (uint16_t)0x0055\r
124 #define NOR_CMD_DATA_CHIP_ERASE               (uint16_t)0x0010\r
125 #define NOR_CMD_DATA_CFI                      (uint16_t)0x0098\r
126 \r
127 #define NOR_CMD_DATA_BUFFER_AND_PROG          (uint8_t)0x25\r
128 #define NOR_CMD_DATA_BUFFER_AND_PROG_CONFIRM  (uint8_t)0x29\r
129 #define NOR_CMD_DATA_BLOCK_ERASE              (uint8_t)0x30\r
130 \r
131 /* Mask on NOR STATUS REGISTER */\r
132 #define NOR_MASK_STATUS_DQ5                   (uint16_t)0x0020\r
133 #define NOR_MASK_STATUS_DQ6                   (uint16_t)0x0040\r
134 \r
135 /**\r
136   * @}\r
137   */\r
138       \r
139 /* Private macro -------------------------------------------------------------*/\r
140 /* Private variables ---------------------------------------------------------*/\r
141 /* Private functions ---------------------------------------------------------*/\r
142 /* Exported functions --------------------------------------------------------*/\r
143 /** @defgroup NOR_Exported_Functions NOR Exported Functions\r
144   * @{\r
145   */\r
146 \r
147 /** @defgroup NOR_Exported_Functions_Group1 Initialization and de-initialization functions \r
148   * @brief    Initialization and Configuration functions \r
149   *\r
150   @verbatim    \r
151   ==============================================================================\r
152            ##### NOR Initialization and de_initialization functions #####\r
153   ==============================================================================\r
154   [..]  \r
155     This section provides functions allowing to initialize/de-initialize\r
156     the NOR memory\r
157   \r
158 @endverbatim\r
159   * @{\r
160   */\r
161     \r
162 /**\r
163   * @brief  Perform the NOR memory Initialization sequence\r
164   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
165   *                the configuration information for NOR module.\r
166   * @param  Timing: pointer to NOR control timing structure \r
167   * @param  ExtTiming: pointer to NOR extended mode timing structure    \r
168   * @retval HAL status\r
169   */\r
170 HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming)\r
171 {\r
172   /* Check the NOR handle parameter */\r
173   if(hnor == NULL)\r
174   {\r
175      return HAL_ERROR;\r
176   }\r
177   \r
178   if(hnor->State == HAL_NOR_STATE_RESET)\r
179   {\r
180     /* Allocate lock resource and initialize it */\r
181     hnor->Lock = HAL_UNLOCKED;\r
182     /* Initialize the low level hardware (MSP) */\r
183     HAL_NOR_MspInit(hnor);\r
184   }\r
185   \r
186   /* Initialize NOR control Interface */\r
187   FMC_NORSRAM_Init(hnor->Instance, &(hnor->Init));\r
188 \r
189   /* Initialize NOR timing Interface */\r
190   FMC_NORSRAM_Timing_Init(hnor->Instance, Timing, hnor->Init.NSBank); \r
191 \r
192   /* Initialize NOR extended mode timing Interface */\r
193   FMC_NORSRAM_Extended_Timing_Init(hnor->Extended, ExtTiming, hnor->Init.NSBank, hnor->Init.ExtendedMode);\r
194 \r
195   /* Enable the NORSRAM device */\r
196   __FMC_NORSRAM_ENABLE(hnor->Instance, hnor->Init.NSBank);\r
197 \r
198   /* Check the NOR controller state */\r
199   hnor->State = HAL_NOR_STATE_READY; \r
200   \r
201   return HAL_OK;\r
202 }\r
203 \r
204 /**\r
205   * @brief  Perform NOR memory De-Initialization sequence\r
206   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
207   *                the configuration information for NOR module.\r
208   * @retval HAL status\r
209   */\r
210 HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor)  \r
211 {\r
212   /* De-Initialize the low level hardware (MSP) */\r
213   HAL_NOR_MspDeInit(hnor);\r
214  \r
215   /* Configure the NOR registers with their reset values */\r
216   FMC_NORSRAM_DeInit(hnor->Instance, hnor->Extended, hnor->Init.NSBank);\r
217   \r
218   /* Update the NOR controller state */\r
219   hnor->State = HAL_NOR_STATE_RESET;\r
220 \r
221   /* Release Lock */\r
222   __HAL_UNLOCK(hnor);\r
223 \r
224   return HAL_OK;\r
225 }\r
226 \r
227 /**\r
228   * @brief  NOR MSP Init\r
229   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
230   *                the configuration information for NOR module.\r
231   * @retval None\r
232   */\r
233 __weak void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor)\r
234 {\r
235   /* NOTE : This function Should not be modified, when the callback is needed,\r
236             the HAL_NOR_MspInit could be implemented in the user file\r
237    */ \r
238 }\r
239 \r
240 /**\r
241   * @brief  NOR MSP DeInit\r
242   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
243   *                the configuration information for NOR module.\r
244   * @retval None\r
245   */\r
246 __weak void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor)\r
247 {\r
248   /* NOTE : This function Should not be modified, when the callback is needed,\r
249             the HAL_NOR_MspDeInit could be implemented in the user file\r
250    */ \r
251 }\r
252 \r
253 /**\r
254   * @brief  NOR MSP Wait for Ready/Busy signal\r
255   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
256   *                the configuration information for NOR module.\r
257   * @param  Timeout: Maximum timeout value\r
258   * @retval None\r
259   */\r
260 __weak void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout)\r
261 {\r
262   /* NOTE : This function Should not be modified, when the callback is needed,\r
263             the HAL_NOR_MspWait could be implemented in the user file\r
264    */ \r
265 }\r
266   \r
267 /**\r
268   * @}\r
269   */\r
270 \r
271 /** @defgroup NOR_Exported_Functions_Group2 Input and Output functions \r
272   * @brief    Input Output and memory control functions \r
273   *\r
274   @verbatim    \r
275   ==============================================================================\r
276                 ##### NOR Input and Output functions #####\r
277   ==============================================================================\r
278   [..]  \r
279     This section provides functions allowing to use and control the NOR memory\r
280   \r
281 @endverbatim\r
282   * @{\r
283   */\r
284   \r
285 /**\r
286   * @brief  Read NOR flash IDs\r
287   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
288   *                the configuration information for NOR module.\r
289   * @param  pNOR_ID : pointer to NOR ID structure\r
290   * @retval HAL status\r
291   */\r
292 HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID)\r
293 {\r
294   uint32_t deviceaddress = 0;\r
295   \r
296   /* Process Locked */\r
297   __HAL_LOCK(hnor);\r
298   \r
299   /* Check the NOR controller state */\r
300   if(hnor->State == HAL_NOR_STATE_BUSY)\r
301   {\r
302      return HAL_BUSY;\r
303   }\r
304   \r
305   /* Select the NOR device address */\r
306   if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)\r
307   {\r
308     deviceaddress = NOR_MEMORY_ADRESS1;\r
309   }\r
310   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)\r
311   {\r
312     deviceaddress = NOR_MEMORY_ADRESS2;\r
313   }\r
314   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)\r
315   {\r
316     deviceaddress = NOR_MEMORY_ADRESS3;\r
317   }\r
318   else /* FMC_NORSRAM_BANK4 */\r
319   {\r
320     deviceaddress = NOR_MEMORY_ADRESS4;\r
321   }  \r
322     \r
323   /* Update the NOR controller state */\r
324   hnor->State = HAL_NOR_STATE_BUSY;\r
325   \r
326   /* Send read ID command */\r
327   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);\r
328   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);\r
329   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_AUTO_SELECT);\r
330 \r
331   /* Read the NOR IDs */\r
332   pNOR_ID->Manufacturer_Code = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, MC_ADDRESS);\r
333   pNOR_ID->Device_Code1      = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, DEVICE_CODE1_ADDR);\r
334   pNOR_ID->Device_Code2      = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, DEVICE_CODE2_ADDR);\r
335   pNOR_ID->Device_Code3      = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, DEVICE_CODE3_ADDR);\r
336   \r
337   /* Check the NOR controller state */\r
338   hnor->State = HAL_NOR_STATE_READY;\r
339   \r
340   /* Process unlocked */\r
341   __HAL_UNLOCK(hnor);   \r
342   \r
343   return HAL_OK;\r
344 }\r
345 \r
346 /**\r
347   * @brief  Returns the NOR memory to Read mode.\r
348   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
349   *                the configuration information for NOR module.\r
350   * @retval HAL status\r
351   */\r
352 HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor)\r
353 {\r
354   uint32_t deviceaddress = 0;  \r
355   \r
356   /* Process Locked */\r
357   __HAL_LOCK(hnor);\r
358   \r
359   /* Check the NOR controller state */\r
360   if(hnor->State == HAL_NOR_STATE_BUSY)\r
361   {\r
362      return HAL_BUSY;\r
363   }\r
364   \r
365   /* Select the NOR device address */\r
366   if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)\r
367   {\r
368     deviceaddress = NOR_MEMORY_ADRESS1;\r
369   }\r
370   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)\r
371   {\r
372     deviceaddress = NOR_MEMORY_ADRESS2;\r
373   }\r
374   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)\r
375   {\r
376     deviceaddress = NOR_MEMORY_ADRESS3;\r
377   }\r
378   else /* FMC_NORSRAM_BANK4 */\r
379   {\r
380     deviceaddress = NOR_MEMORY_ADRESS4;\r
381   }  \r
382   \r
383   NOR_WRITE(deviceaddress, NOR_CMD_DATA_READ_RESET);\r
384 \r
385   /* Check the NOR controller state */\r
386   hnor->State = HAL_NOR_STATE_READY;\r
387   \r
388   /* Process unlocked */\r
389   __HAL_UNLOCK(hnor);   \r
390   \r
391   return HAL_OK;\r
392 }\r
393 \r
394 /**\r
395   * @brief  Read data from NOR memory \r
396   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
397   *                the configuration information for NOR module.\r
398   * @param  pAddress: pointer to Device address\r
399   * @param  pData : pointer to read data  \r
400   * @retval HAL status\r
401   */\r
402 HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData)\r
403 {\r
404   uint32_t deviceaddress = 0;\r
405   \r
406   /* Process Locked */\r
407   __HAL_LOCK(hnor);\r
408   \r
409   /* Check the NOR controller state */\r
410   if(hnor->State == HAL_NOR_STATE_BUSY)\r
411   {\r
412      return HAL_BUSY;\r
413   }\r
414   \r
415   /* Select the NOR device address */\r
416   if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)\r
417   {\r
418     deviceaddress = NOR_MEMORY_ADRESS1;\r
419   }\r
420   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)\r
421   {\r
422     deviceaddress = NOR_MEMORY_ADRESS2;\r
423   }\r
424   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)\r
425   {\r
426     deviceaddress = NOR_MEMORY_ADRESS3;\r
427   }\r
428   else /* FMC_NORSRAM_BANK4 */\r
429   {\r
430     deviceaddress = NOR_MEMORY_ADRESS4;\r
431   } \r
432     \r
433   /* Update the NOR controller state */\r
434   hnor->State = HAL_NOR_STATE_BUSY;\r
435   \r
436   /* Send read data command */\r
437   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST); \r
438   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);  \r
439   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_READ_RESET);\r
440 \r
441   /* Read the data */\r
442   *pData = *(__IO uint32_t *)(uint32_t)pAddress;\r
443   \r
444   /* Check the NOR controller state */\r
445   hnor->State = HAL_NOR_STATE_READY;\r
446   \r
447   /* Process unlocked */\r
448   __HAL_UNLOCK(hnor);\r
449   \r
450   return HAL_OK;  \r
451 }\r
452 \r
453 /**\r
454   * @brief  Program data to NOR memory \r
455   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
456   *                the configuration information for NOR module.\r
457   * @param  pAddress: Device address\r
458   * @param  pData : pointer to the data to write   \r
459   * @retval HAL status\r
460   */\r
461 HAL_StatusTypeDef HAL_NOR_Program(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData)\r
462 {\r
463   uint32_t deviceaddress = 0;\r
464   \r
465   /* Process Locked */\r
466   __HAL_LOCK(hnor);\r
467   \r
468   /* Check the NOR controller state */\r
469   if(hnor->State == HAL_NOR_STATE_BUSY)\r
470   {\r
471      return HAL_BUSY;\r
472   }\r
473   \r
474   /* Select the NOR device address */\r
475   if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)\r
476   {\r
477     deviceaddress = NOR_MEMORY_ADRESS1;\r
478   }\r
479   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)\r
480   {\r
481     deviceaddress = NOR_MEMORY_ADRESS2;\r
482   }\r
483   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)\r
484   {\r
485     deviceaddress = NOR_MEMORY_ADRESS3;\r
486   }\r
487   else /* FMC_NORSRAM_BANK4 */\r
488   {\r
489     deviceaddress = NOR_MEMORY_ADRESS4;\r
490   } \r
491     \r
492   /* Update the NOR controller state */\r
493   hnor->State = HAL_NOR_STATE_BUSY;\r
494   \r
495   /* Send program data command */\r
496   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);\r
497   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);\r
498   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_PROGRAM);\r
499 \r
500   /* Write the data */\r
501   NOR_WRITE(pAddress, *pData);\r
502   \r
503   /* Check the NOR controller state */\r
504   hnor->State = HAL_NOR_STATE_READY;\r
505   \r
506   /* Process unlocked */\r
507   __HAL_UNLOCK(hnor);\r
508   \r
509   return HAL_OK;  \r
510 }\r
511 \r
512 /**\r
513   * @brief  Reads a half-word buffer from the NOR memory.\r
514   * @param  hnor: pointer to the NOR handle\r
515   * @param  uwAddress: NOR memory internal address to read from.\r
516   * @param  pData: pointer to the buffer that receives the data read from the \r
517   *         NOR memory.\r
518   * @param  uwBufferSize : number of Half word to read.\r
519   * @retval HAL status\r
520   */\r
521 HAL_StatusTypeDef HAL_NOR_ReadBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize)\r
522 {\r
523   uint32_t deviceaddress = 0;\r
524   \r
525   /* Process Locked */\r
526   __HAL_LOCK(hnor);\r
527   \r
528   /* Check the NOR controller state */\r
529   if(hnor->State == HAL_NOR_STATE_BUSY)\r
530   {\r
531      return HAL_BUSY;\r
532   }\r
533   \r
534   /* Select the NOR device address */\r
535   if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)\r
536   {\r
537     deviceaddress = NOR_MEMORY_ADRESS1;\r
538   }\r
539   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)\r
540   {\r
541     deviceaddress = NOR_MEMORY_ADRESS2;\r
542   }\r
543   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)\r
544   {\r
545     deviceaddress = NOR_MEMORY_ADRESS3;\r
546   }\r
547   else /* FMC_NORSRAM_BANK4 */\r
548   {\r
549     deviceaddress = NOR_MEMORY_ADRESS4;\r
550   }  \r
551     \r
552   /* Update the NOR controller state */\r
553   hnor->State = HAL_NOR_STATE_BUSY;\r
554   \r
555   /* Send read data command */\r
556   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST); \r
557   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);  \r
558   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_READ_RESET);\r
559   \r
560   /* Read buffer */\r
561   while( uwBufferSize > 0) \r
562   {\r
563     *pData++ = *(__IO uint16_t *)uwAddress;\r
564     uwAddress += 2;\r
565     uwBufferSize--;\r
566   } \r
567   \r
568   /* Check the NOR controller state */\r
569   hnor->State = HAL_NOR_STATE_READY;\r
570   \r
571   /* Process unlocked */\r
572   __HAL_UNLOCK(hnor);\r
573   \r
574   return HAL_OK;  \r
575 }\r
576 \r
577 /**\r
578   * @brief  Writes a half-word buffer to the NOR memory. This function must be used \r
579             only with S29GL128P NOR memory. \r
580   * @param  hnor: pointer to the NOR handle\r
581   * @param  uwAddress: NOR memory internal start write address \r
582   * @param  pData: pointer to source data buffer. \r
583   * @param  uwBufferSize: Size of the buffer to write\r
584   * @retval HAL status\r
585   */ \r
586 HAL_StatusTypeDef HAL_NOR_ProgramBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize)\r
587 {\r
588   uint16_t * p_currentaddress = (uint16_t *)NULL;\r
589   uint16_t * p_endaddress = (uint16_t *)NULL;\r
590   uint32_t lastloadedaddress = 0, deviceaddress = 0;\r
591   \r
592   /* Process Locked */\r
593   __HAL_LOCK(hnor);\r
594   \r
595   /* Check the NOR controller state */\r
596   if(hnor->State == HAL_NOR_STATE_BUSY)\r
597   {\r
598      return HAL_BUSY;\r
599   }\r
600   \r
601   /* Select the NOR device address */\r
602   if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)\r
603   {\r
604     deviceaddress = NOR_MEMORY_ADRESS1;\r
605   }\r
606   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)\r
607   {\r
608     deviceaddress = NOR_MEMORY_ADRESS2;\r
609   }\r
610   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)\r
611   {\r
612     deviceaddress = NOR_MEMORY_ADRESS3;\r
613   }\r
614   else /* FMC_NORSRAM_BANK4 */\r
615   {\r
616     deviceaddress = NOR_MEMORY_ADRESS4;\r
617   }  \r
618     \r
619   /* Update the NOR controller state */\r
620   hnor->State = HAL_NOR_STATE_BUSY;\r
621   \r
622   /* Initialize variables */\r
623   p_currentaddress  = (uint16_t*)((uint32_t)(uwAddress));\r
624   p_endaddress      = p_currentaddress + (uwBufferSize-1);\r
625   lastloadedaddress = (uint32_t)(uwAddress);\r
626 \r
627   /* Issue unlock command sequence */\r
628   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);\r
629   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND); \r
630 \r
631   /* Write Buffer Load Command */\r
632   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, uwAddress), NOR_CMD_DATA_BUFFER_AND_PROG); \r
633   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, uwAddress), (uwBufferSize - 1)); \r
634 \r
635   /* Load Data into NOR Buffer */\r
636   while(p_currentaddress <= p_endaddress)\r
637   {\r
638     /* Store last loaded address & data value (for polling) */\r
639      lastloadedaddress = (uint32_t)p_currentaddress;\r
640  \r
641     NOR_WRITE(p_currentaddress, *pData++);\r
642     \r
643     p_currentaddress ++; \r
644   }\r
645 \r
646   NOR_WRITE((uint32_t)(lastloadedaddress), NOR_CMD_DATA_BUFFER_AND_PROG_CONFIRM);\r
647   \r
648   /* Check the NOR controller state */\r
649   hnor->State = HAL_NOR_STATE_READY;\r
650   \r
651   /* Process unlocked */\r
652   __HAL_UNLOCK(hnor);\r
653   \r
654   return HAL_OK; \r
655   \r
656 }\r
657 \r
658 /**\r
659   * @brief  Erase the specified block of the NOR memory \r
660   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
661   *                the configuration information for NOR module.\r
662   * @param  BlockAddress : Block to erase address \r
663   * @param  Address: Device address\r
664   * @retval HAL status\r
665   */\r
666 HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAddress, uint32_t Address)\r
667 {\r
668   uint32_t deviceaddress = 0;\r
669 \r
670   /* Process Locked */\r
671   __HAL_LOCK(hnor);\r
672   \r
673   /* Check the NOR controller state */\r
674   if(hnor->State == HAL_NOR_STATE_BUSY)\r
675   {\r
676      return HAL_BUSY;\r
677   }\r
678   \r
679   /* Select the NOR device address */\r
680   if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)\r
681   {\r
682     deviceaddress = NOR_MEMORY_ADRESS1;\r
683   }\r
684   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)\r
685   {\r
686     deviceaddress = NOR_MEMORY_ADRESS2;\r
687   }\r
688   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)\r
689   {\r
690     deviceaddress = NOR_MEMORY_ADRESS3;\r
691   }\r
692   else /* FMC_NORSRAM_BANK4 */\r
693   {\r
694     deviceaddress = NOR_MEMORY_ADRESS4;\r
695   }\r
696     \r
697   /* Update the NOR controller state */\r
698   hnor->State = HAL_NOR_STATE_BUSY;\r
699   \r
700   /* Send block erase command sequence */\r
701   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);\r
702   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);\r
703   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_CHIP_BLOCK_ERASE_THIRD);\r
704   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_FOURTH), NOR_CMD_DATA_CHIP_BLOCK_ERASE_FOURTH);\r
705   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_FIFTH), NOR_CMD_DATA_CHIP_BLOCK_ERASE_FIFTH);\r
706   NOR_WRITE((uint32_t)(BlockAddress + Address), NOR_CMD_DATA_BLOCK_ERASE);\r
707 \r
708   /* Check the NOR memory status and update the controller state */\r
709   hnor->State = HAL_NOR_STATE_READY;\r
710     \r
711   /* Process unlocked */\r
712   __HAL_UNLOCK(hnor);\r
713   \r
714   return HAL_OK;\r
715  \r
716 }\r
717 \r
718 /**\r
719   * @brief  Erase the entire NOR chip.\r
720   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
721   *                the configuration information for NOR module.\r
722   * @param  Address : Device address  \r
723   * @retval HAL status\r
724   */\r
725 HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address)\r
726 {\r
727   uint32_t deviceaddress = 0;\r
728   \r
729   /* Process Locked */\r
730   __HAL_LOCK(hnor);\r
731   \r
732   /* Check the NOR controller state */\r
733   if(hnor->State == HAL_NOR_STATE_BUSY)\r
734   {\r
735      return HAL_BUSY;\r
736   }\r
737   \r
738   /* Select the NOR device address */\r
739   if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)\r
740   {\r
741     deviceaddress = NOR_MEMORY_ADRESS1;\r
742   }\r
743   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)\r
744   {\r
745     deviceaddress = NOR_MEMORY_ADRESS2;\r
746   }\r
747   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)\r
748   {\r
749     deviceaddress = NOR_MEMORY_ADRESS3;\r
750   }\r
751   else /* FMC_NORSRAM_BANK4 */\r
752   {\r
753     deviceaddress = NOR_MEMORY_ADRESS4;\r
754   }\r
755     \r
756   /* Update the NOR controller state */\r
757   hnor->State = HAL_NOR_STATE_BUSY;  \r
758     \r
759   /* Send NOR chip erase command sequence */\r
760   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_FIRST), NOR_CMD_DATA_FIRST);\r
761   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_SECOND), NOR_CMD_DATA_SECOND);\r
762   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_THIRD), NOR_CMD_DATA_CHIP_BLOCK_ERASE_THIRD);\r
763   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_FOURTH), NOR_CMD_DATA_CHIP_BLOCK_ERASE_FOURTH);\r
764   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_FIFTH), NOR_CMD_DATA_CHIP_BLOCK_ERASE_FIFTH);  \r
765   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_SIXTH), NOR_CMD_DATA_CHIP_ERASE);\r
766   \r
767   /* Check the NOR memory status and update the controller state */\r
768   hnor->State = HAL_NOR_STATE_READY;\r
769     \r
770   /* Process unlocked */\r
771   __HAL_UNLOCK(hnor);\r
772   \r
773   return HAL_OK;  \r
774 }\r
775 \r
776 /**\r
777   * @brief  Read NOR flash CFI IDs\r
778   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
779   *                the configuration information for NOR module.\r
780   * @param  pNOR_CFI : pointer to NOR CFI IDs structure  \r
781   * @retval HAL status\r
782   */\r
783 HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR_CFI)\r
784 {\r
785   uint32_t deviceaddress = 0;\r
786   \r
787   /* Process Locked */\r
788   __HAL_LOCK(hnor);\r
789   \r
790   /* Check the NOR controller state */\r
791   if(hnor->State == HAL_NOR_STATE_BUSY)\r
792   {\r
793      return HAL_BUSY;\r
794   }\r
795   \r
796   /* Select the NOR device address */\r
797   if (hnor->Init.NSBank == FMC_NORSRAM_BANK1)\r
798   {\r
799     deviceaddress = NOR_MEMORY_ADRESS1;\r
800   }\r
801   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK2)\r
802   {\r
803     deviceaddress = NOR_MEMORY_ADRESS2;\r
804   }\r
805   else if (hnor->Init.NSBank == FMC_NORSRAM_BANK3)\r
806   {\r
807     deviceaddress = NOR_MEMORY_ADRESS3;\r
808   }\r
809   else /* FMC_NORSRAM_BANK4 */\r
810   {\r
811     deviceaddress = NOR_MEMORY_ADRESS4;\r
812   }  \r
813     \r
814   /* Update the NOR controller state */\r
815   hnor->State = HAL_NOR_STATE_BUSY;\r
816   \r
817   /* Send read CFI query command */\r
818   NOR_WRITE(NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, NOR_CMD_ADDRESS_FIRST_CFI), NOR_CMD_DATA_CFI);\r
819 \r
820   /* read the NOR CFI information */\r
821   pNOR_CFI->CFI_1 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, CFI1_ADDRESS);\r
822   pNOR_CFI->CFI_2 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, CFI2_ADDRESS);\r
823   pNOR_CFI->CFI_3 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, CFI3_ADDRESS);\r
824   pNOR_CFI->CFI_4 = *(__IO uint16_t *) NOR_ADDR_SHIFT(deviceaddress, NOR_MEMORY_8B, CFI4_ADDRESS);\r
825 \r
826   /* Check the NOR controller state */\r
827   hnor->State = HAL_NOR_STATE_READY;\r
828   \r
829   /* Process unlocked */\r
830   __HAL_UNLOCK(hnor);\r
831   \r
832   return HAL_OK;\r
833 }\r
834 \r
835 /**\r
836   * @}\r
837   */\r
838   \r
839 /** @defgroup NOR_Exported_Functions_Group3 Control functions \r
840  *  @brief   management functions \r
841  *\r
842 @verbatim   \r
843   ==============================================================================\r
844                         ##### NOR Control functions #####\r
845   ==============================================================================\r
846   [..]\r
847     This subsection provides a set of functions allowing to control dynamically\r
848     the NOR interface.\r
849 \r
850 @endverbatim\r
851   * @{\r
852   */\r
853     \r
854 /**\r
855   * @brief  Enables dynamically NOR write operation.\r
856   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
857   *                the configuration information for NOR module.\r
858   * @retval HAL status\r
859   */\r
860 HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor)\r
861 {\r
862   /* Process Locked */\r
863   __HAL_LOCK(hnor);\r
864 \r
865   /* Enable write operation */\r
866   FMC_NORSRAM_WriteOperation_Enable(hnor->Instance, hnor->Init.NSBank); \r
867   \r
868   /* Update the NOR controller state */\r
869   hnor->State = HAL_NOR_STATE_READY;\r
870   \r
871   /* Process unlocked */\r
872   __HAL_UNLOCK(hnor); \r
873   \r
874   return HAL_OK;  \r
875 }\r
876 \r
877 /**\r
878   * @brief  Disables dynamically NOR write operation.\r
879   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
880   *                the configuration information for NOR module.\r
881   * @retval HAL status\r
882   */\r
883 HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor)\r
884 {\r
885   /* Process Locked */\r
886   __HAL_LOCK(hnor);\r
887 \r
888   /* Update the SRAM controller state */\r
889   hnor->State = HAL_NOR_STATE_BUSY;\r
890     \r
891   /* Disable write operation */\r
892   FMC_NORSRAM_WriteOperation_Disable(hnor->Instance, hnor->Init.NSBank); \r
893   \r
894   /* Update the NOR controller state */\r
895   hnor->State = HAL_NOR_STATE_PROTECTED;\r
896   \r
897   /* Process unlocked */\r
898   __HAL_UNLOCK(hnor); \r
899   \r
900   return HAL_OK;  \r
901 }\r
902 \r
903 /**\r
904   * @}\r
905   */  \r
906   \r
907 /** @defgroup NOR_Exported_Functions_Group4 State functions \r
908  *  @brief   Peripheral State functions \r
909  *\r
910 @verbatim   \r
911   ==============================================================================\r
912                       ##### NOR State functions #####\r
913   ==============================================================================  \r
914   [..]\r
915     This subsection permits to get in run-time the status of the NOR controller \r
916     and the data flow.\r
917 \r
918 @endverbatim\r
919   * @{\r
920   */\r
921   \r
922 /**\r
923   * @brief  return the NOR controller state\r
924   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
925   *                the configuration information for NOR module.\r
926   * @retval NOR controller state\r
927   */\r
928 HAL_NOR_StateTypeDef HAL_NOR_GetState(NOR_HandleTypeDef *hnor)\r
929 {\r
930   return hnor->State;\r
931 }\r
932 \r
933 /**\r
934   * @brief  Returns the NOR operation status.\r
935   * @param  hnor: pointer to a NOR_HandleTypeDef structure that contains\r
936   *                the configuration information for NOR module.   \r
937   * @param  Address: Device address\r
938   * @param  Timeout: NOR programming Timeout\r
939   * @retval NOR_Status: The returned value can be: HAL_NOR_STATUS_SUCCESS, HAL_NOR_STATUS_ERROR\r
940   *         or HAL_NOR_STATUS_TIMEOUT\r
941   */\r
942 HAL_NOR_StatusTypeDef HAL_NOR_GetStatus(NOR_HandleTypeDef *hnor, uint32_t Address, uint32_t Timeout)\r
943\r
944   HAL_NOR_StatusTypeDef status = HAL_NOR_STATUS_ONGOING;\r
945   uint16_t tmpSR1 = 0, tmpSR2 = 0;\r
946   uint32_t tickstart = 0;\r
947 \r
948   /* Poll on NOR memory Ready/Busy signal ------------------------------------*/\r
949   HAL_NOR_MspWait(hnor, Timeout);\r
950   \r
951   /* Get the NOR memory operation status -------------------------------------*/\r
952   \r
953   /* Get tick */\r
954   tickstart = HAL_GetTick();\r
955   while((status != HAL_NOR_STATUS_SUCCESS ) && (status != HAL_NOR_STATUS_TIMEOUT))\r
956   {\r
957     /* Check for the Timeout */\r
958     if(Timeout != HAL_MAX_DELAY)\r
959     {\r
960       if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))\r
961       {\r
962         status = HAL_NOR_STATUS_TIMEOUT; \r
963       } \r
964     } \r
965 \r
966     /* Read NOR status register (DQ6 and DQ5) */\r
967     tmpSR1 = *(__IO uint16_t *)Address;\r
968     tmpSR2 = *(__IO uint16_t *)Address;\r
969 \r
970     /* If DQ6 did not toggle between the two reads then return HAL_NOR_STATUS_SUCCESS  */\r
971     if((tmpSR1 & NOR_MASK_STATUS_DQ6) == (tmpSR2 & NOR_MASK_STATUS_DQ6)) \r
972     {\r
973       return HAL_NOR_STATUS_SUCCESS ;\r
974     }\r
975     \r
976     if((tmpSR1 & NOR_MASK_STATUS_DQ5) == NOR_MASK_STATUS_DQ5)\r
977     {\r
978       status = HAL_NOR_STATUS_ONGOING;\r
979     }\r
980     \r
981     tmpSR1 = *(__IO uint16_t *)Address;\r
982     tmpSR2 = *(__IO uint16_t *)Address;\r
983 \r
984     /* If DQ6 did not toggle between the two reads then return HAL_NOR_STATUS_SUCCESS  */\r
985     if((tmpSR1 & NOR_MASK_STATUS_DQ6) == (tmpSR2 & NOR_MASK_STATUS_DQ6)) \r
986     {\r
987       return HAL_NOR_STATUS_SUCCESS;\r
988     }\r
989     if((tmpSR1 & NOR_MASK_STATUS_DQ5) == NOR_MASK_STATUS_DQ5)\r
990     {\r
991       return HAL_NOR_STATUS_ERROR;\r
992     } \r
993   }\r
994 \r
995   /* Return the operation status */\r
996   return status;\r
997 }\r
998 \r
999 /**\r
1000   * @}\r
1001   */\r
1002 \r
1003 /**\r
1004   * @}\r
1005   */\r
1006 #endif /* STM32F756xx || STM32F746xx */\r
1007 #endif /* HAL_NOR_MODULE_ENABLED */\r
1008 /**\r
1009   * @}\r
1010   */\r
1011 \r
1012 /**\r
1013   * @}\r
1014   */\r
1015 \r
1016 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r