annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_nor.c @ 38:5f11787b4f42

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