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