mbed library sources

Dependents:   Marvino mbot

Fork of mbed-src by mbed official

Committer:
jaerts
Date:
Tue Dec 22 13:22:16 2015 +0000
Revision:
637:ed69428d4850
Parent:
610:813dcc80987e
Add very shady LPC1768 CAN Filter implementation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 610:813dcc80987e 1 /**
mbed_official 610:813dcc80987e 2 ******************************************************************************
mbed_official 610:813dcc80987e 3 * @file stm32l4xx_hal_nor.h
mbed_official 610:813dcc80987e 4 * @author MCD Application Team
mbed_official 610:813dcc80987e 5 * @version V1.0.0
mbed_official 610:813dcc80987e 6 * @date 26-June-2015
mbed_official 610:813dcc80987e 7 * @brief Header file of NOR HAL module.
mbed_official 610:813dcc80987e 8 ******************************************************************************
mbed_official 610:813dcc80987e 9 * @attention
mbed_official 610:813dcc80987e 10 *
mbed_official 610:813dcc80987e 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
mbed_official 610:813dcc80987e 12 *
mbed_official 610:813dcc80987e 13 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 610:813dcc80987e 14 * are permitted provided that the following conditions are met:
mbed_official 610:813dcc80987e 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 610:813dcc80987e 16 * this list of conditions and the following disclaimer.
mbed_official 610:813dcc80987e 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 610:813dcc80987e 18 * this list of conditions and the following disclaimer in the documentation
mbed_official 610:813dcc80987e 19 * and/or other materials provided with the distribution.
mbed_official 610:813dcc80987e 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 610:813dcc80987e 21 * may be used to endorse or promote products derived from this software
mbed_official 610:813dcc80987e 22 * without specific prior written permission.
mbed_official 610:813dcc80987e 23 *
mbed_official 610:813dcc80987e 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 610:813dcc80987e 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 610:813dcc80987e 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 610:813dcc80987e 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 610:813dcc80987e 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 610:813dcc80987e 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 610:813dcc80987e 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 610:813dcc80987e 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 610:813dcc80987e 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 610:813dcc80987e 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 610:813dcc80987e 34 *
mbed_official 610:813dcc80987e 35 ******************************************************************************
mbed_official 610:813dcc80987e 36 */
mbed_official 610:813dcc80987e 37
mbed_official 610:813dcc80987e 38 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 610:813dcc80987e 39 #ifndef __STM32L4xx_HAL_NOR_H
mbed_official 610:813dcc80987e 40 #define __STM32L4xx_HAL_NOR_H
mbed_official 610:813dcc80987e 41
mbed_official 610:813dcc80987e 42 #ifdef __cplusplus
mbed_official 610:813dcc80987e 43 extern "C" {
mbed_official 610:813dcc80987e 44 #endif
mbed_official 610:813dcc80987e 45
mbed_official 610:813dcc80987e 46 /* Includes ------------------------------------------------------------------*/
mbed_official 610:813dcc80987e 47 #include "stm32l4xx_ll_fmc.h"
mbed_official 610:813dcc80987e 48
mbed_official 610:813dcc80987e 49
mbed_official 610:813dcc80987e 50 /** @addtogroup STM32L4xx_HAL_Driver
mbed_official 610:813dcc80987e 51 * @{
mbed_official 610:813dcc80987e 52 */
mbed_official 610:813dcc80987e 53
mbed_official 610:813dcc80987e 54 /** @addtogroup NOR
mbed_official 610:813dcc80987e 55 * @{
mbed_official 610:813dcc80987e 56 */
mbed_official 610:813dcc80987e 57
mbed_official 610:813dcc80987e 58 /** @addtogroup NOR_Private_Constants
mbed_official 610:813dcc80987e 59 * @{
mbed_official 610:813dcc80987e 60 */
mbed_official 610:813dcc80987e 61
mbed_official 610:813dcc80987e 62 /* NOR device IDs addresses */
mbed_official 610:813dcc80987e 63 #define MC_ADDRESS ((uint16_t)0x0000)
mbed_official 610:813dcc80987e 64 #define DEVICE_CODE1_ADDR ((uint16_t)0x0001)
mbed_official 610:813dcc80987e 65 #define DEVICE_CODE2_ADDR ((uint16_t)0x000E)
mbed_official 610:813dcc80987e 66 #define DEVICE_CODE3_ADDR ((uint16_t)0x000F)
mbed_official 610:813dcc80987e 67
mbed_official 610:813dcc80987e 68 /* NOR CFI IDs addresses */
mbed_official 610:813dcc80987e 69 #define CFI1_ADDRESS ((uint16_t)0x10)
mbed_official 610:813dcc80987e 70 #define CFI2_ADDRESS ((uint16_t)0x11)
mbed_official 610:813dcc80987e 71 #define CFI3_ADDRESS ((uint16_t)0x12)
mbed_official 610:813dcc80987e 72 #define CFI4_ADDRESS ((uint16_t)0x13)
mbed_official 610:813dcc80987e 73
mbed_official 610:813dcc80987e 74 /* NOR memory data width */
mbed_official 610:813dcc80987e 75 #define NOR_MEMORY_8B ((uint8_t)0x0)
mbed_official 610:813dcc80987e 76 #define NOR_MEMORY_16B ((uint8_t)0x1)
mbed_official 610:813dcc80987e 77
mbed_official 610:813dcc80987e 78 /* NOR memory device read/write start address */
mbed_official 610:813dcc80987e 79 #define NOR_MEMORY_ADRESS1 FMC_BANK1_1
mbed_official 610:813dcc80987e 80 #define NOR_MEMORY_ADRESS2 FMC_BANK1_2
mbed_official 610:813dcc80987e 81 #define NOR_MEMORY_ADRESS3 FMC_BANK1_3
mbed_official 610:813dcc80987e 82 #define NOR_MEMORY_ADRESS4 FMC_BANK1_4
mbed_official 610:813dcc80987e 83
mbed_official 610:813dcc80987e 84 /**
mbed_official 610:813dcc80987e 85 * @}
mbed_official 610:813dcc80987e 86 */
mbed_official 610:813dcc80987e 87
mbed_official 610:813dcc80987e 88 /** @addtogroup NOR_Private_Macros
mbed_official 610:813dcc80987e 89 * @{
mbed_official 610:813dcc80987e 90 */
mbed_official 610:813dcc80987e 91
mbed_official 610:813dcc80987e 92 /**
mbed_official 610:813dcc80987e 93 * @brief NOR memory address shifting.
mbed_official 610:813dcc80987e 94 * @param __NOR_ADDRESS: NOR base address
mbed_official 610:813dcc80987e 95 * @param __NOR_MEMORY_WIDTH_: NOR memory width
mbed_official 610:813dcc80987e 96 * @param __ADDRESS__: NOR memory address
mbed_official 610:813dcc80987e 97 * @retval NOR shifted address value
mbed_official 610:813dcc80987e 98 */
mbed_official 610:813dcc80987e 99 #define NOR_ADDR_SHIFT(__NOR_ADDRESS, __NOR_MEMORY_WIDTH_, __ADDRESS__) \
mbed_official 610:813dcc80987e 100 ((uint32_t)(((__NOR_MEMORY_WIDTH_) == NOR_MEMORY_16B)? \
mbed_official 610:813dcc80987e 101 ((uint32_t)((__NOR_ADDRESS) + (2 * (__ADDRESS__)))): \
mbed_official 610:813dcc80987e 102 ((uint32_t)((__NOR_ADDRESS) + (__ADDRESS__)))))
mbed_official 610:813dcc80987e 103
mbed_official 610:813dcc80987e 104 /**
mbed_official 610:813dcc80987e 105 * @brief NOR memory write data to specified address.
mbed_official 610:813dcc80987e 106 * @param __ADDRESS__: NOR memory address
mbed_official 610:813dcc80987e 107 * @param __DATA__: Data to write
mbed_official 610:813dcc80987e 108 * @retval None
mbed_official 610:813dcc80987e 109 */
mbed_official 610:813dcc80987e 110 #define NOR_WRITE(__ADDRESS__, __DATA__) (*(__IO uint16_t *)((uint32_t)(__ADDRESS__)) = (__DATA__))
mbed_official 610:813dcc80987e 111
mbed_official 610:813dcc80987e 112 /**
mbed_official 610:813dcc80987e 113 * @}
mbed_official 610:813dcc80987e 114 */
mbed_official 610:813dcc80987e 115
mbed_official 610:813dcc80987e 116 /* Exported typedef ----------------------------------------------------------*/
mbed_official 610:813dcc80987e 117 /** @defgroup NOR_Exported_Types NOR Exported Types
mbed_official 610:813dcc80987e 118 * @{
mbed_official 610:813dcc80987e 119 */
mbed_official 610:813dcc80987e 120
mbed_official 610:813dcc80987e 121 /**
mbed_official 610:813dcc80987e 122 * @brief HAL SRAM State structures definition
mbed_official 610:813dcc80987e 123 */
mbed_official 610:813dcc80987e 124 typedef enum
mbed_official 610:813dcc80987e 125 {
mbed_official 610:813dcc80987e 126 HAL_NOR_STATE_RESET = 0x00, /*!< NOR not yet initialized or disabled */
mbed_official 610:813dcc80987e 127 HAL_NOR_STATE_READY = 0x01, /*!< NOR initialized and ready for use */
mbed_official 610:813dcc80987e 128 HAL_NOR_STATE_BUSY = 0x02, /*!< NOR internal processing is ongoing */
mbed_official 610:813dcc80987e 129 HAL_NOR_STATE_ERROR = 0x03, /*!< NOR error state */
mbed_official 610:813dcc80987e 130 HAL_NOR_STATE_PROTECTED = 0x04 /*!< NOR NORSRAM device write protected */
mbed_official 610:813dcc80987e 131 }HAL_NOR_StateTypeDef;
mbed_official 610:813dcc80987e 132
mbed_official 610:813dcc80987e 133 /**
mbed_official 610:813dcc80987e 134 * @brief FMC NOR Status typedef
mbed_official 610:813dcc80987e 135 */
mbed_official 610:813dcc80987e 136 typedef enum
mbed_official 610:813dcc80987e 137 {
mbed_official 610:813dcc80987e 138 HAL_NOR_STATUS_SUCCESS = 0,
mbed_official 610:813dcc80987e 139 HAL_NOR_STATUS_ONGOING,
mbed_official 610:813dcc80987e 140 HAL_NOR_STATUS_ERROR,
mbed_official 610:813dcc80987e 141 HAL_NOR_STATUS_TIMEOUT
mbed_official 610:813dcc80987e 142 }HAL_NOR_StatusTypeDef;
mbed_official 610:813dcc80987e 143
mbed_official 610:813dcc80987e 144 /**
mbed_official 610:813dcc80987e 145 * @brief FMC NOR ID typedef
mbed_official 610:813dcc80987e 146 */
mbed_official 610:813dcc80987e 147 typedef struct
mbed_official 610:813dcc80987e 148 {
mbed_official 610:813dcc80987e 149 uint16_t Manufacturer_Code; /*!< Defines the device's manufacturer code used to identify the memory */
mbed_official 610:813dcc80987e 150
mbed_official 610:813dcc80987e 151 uint16_t Device_Code1;
mbed_official 610:813dcc80987e 152
mbed_official 610:813dcc80987e 153 uint16_t Device_Code2;
mbed_official 610:813dcc80987e 154
mbed_official 610:813dcc80987e 155 uint16_t Device_Code3; /*!< Defines the device's codes used to identify the memory.
mbed_official 610:813dcc80987e 156 These codes can be accessed by performing read operations with specific
mbed_official 610:813dcc80987e 157 control signals and addresses set.They can also be accessed by issuing
mbed_official 610:813dcc80987e 158 an Auto Select command. */
mbed_official 610:813dcc80987e 159 }NOR_IDTypeDef;
mbed_official 610:813dcc80987e 160
mbed_official 610:813dcc80987e 161 /**
mbed_official 610:813dcc80987e 162 * @brief FMC NOR CFI typedef
mbed_official 610:813dcc80987e 163 */
mbed_official 610:813dcc80987e 164 typedef struct
mbed_official 610:813dcc80987e 165 {
mbed_official 610:813dcc80987e 166 uint16_t CFI_1;
mbed_official 610:813dcc80987e 167
mbed_official 610:813dcc80987e 168 uint16_t CFI_2;
mbed_official 610:813dcc80987e 169
mbed_official 610:813dcc80987e 170 uint16_t CFI_3;
mbed_official 610:813dcc80987e 171
mbed_official 610:813dcc80987e 172 uint16_t CFI_4; /*!< Defines the information stored in the memory's Common flash interface
mbed_official 610:813dcc80987e 173 which contains a description of various electrical and timing parameters,
mbed_official 610:813dcc80987e 174 density information and functions supported by the memory. */
mbed_official 610:813dcc80987e 175 }NOR_CFITypeDef;
mbed_official 610:813dcc80987e 176
mbed_official 610:813dcc80987e 177 /**
mbed_official 610:813dcc80987e 178 * @brief NOR handle Structure definition
mbed_official 610:813dcc80987e 179 */
mbed_official 610:813dcc80987e 180 typedef struct
mbed_official 610:813dcc80987e 181 {
mbed_official 610:813dcc80987e 182 FMC_NORSRAM_TypeDef *Instance; /*!< Register base address */
mbed_official 610:813dcc80987e 183
mbed_official 610:813dcc80987e 184 FMC_NORSRAM_EXTENDED_TypeDef *Extended; /*!< Extended mode register base address */
mbed_official 610:813dcc80987e 185
mbed_official 610:813dcc80987e 186 FMC_NORSRAM_InitTypeDef Init; /*!< NOR device control configuration parameters */
mbed_official 610:813dcc80987e 187
mbed_official 610:813dcc80987e 188 HAL_LockTypeDef Lock; /*!< NOR locking object */
mbed_official 610:813dcc80987e 189
mbed_official 610:813dcc80987e 190 __IO HAL_NOR_StateTypeDef State; /*!< NOR device access state */
mbed_official 610:813dcc80987e 191
mbed_official 610:813dcc80987e 192 }NOR_HandleTypeDef;
mbed_official 610:813dcc80987e 193
mbed_official 610:813dcc80987e 194 /**
mbed_official 610:813dcc80987e 195 * @}
mbed_official 610:813dcc80987e 196 */
mbed_official 610:813dcc80987e 197
mbed_official 610:813dcc80987e 198 /* Exported constants --------------------------------------------------------*/
mbed_official 610:813dcc80987e 199 /* Exported macro ------------------------------------------------------------*/
mbed_official 610:813dcc80987e 200 /** @defgroup NOR_Exported_Macros NOR Exported Macros
mbed_official 610:813dcc80987e 201 * @{
mbed_official 610:813dcc80987e 202 */
mbed_official 610:813dcc80987e 203
mbed_official 610:813dcc80987e 204 /** @brief Reset NOR handle state.
mbed_official 610:813dcc80987e 205 * @param __HANDLE__: NOR handle
mbed_official 610:813dcc80987e 206 * @retval None
mbed_official 610:813dcc80987e 207 */
mbed_official 610:813dcc80987e 208 #define __HAL_NOR_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_NOR_STATE_RESET)
mbed_official 610:813dcc80987e 209
mbed_official 610:813dcc80987e 210 /**
mbed_official 610:813dcc80987e 211 * @}
mbed_official 610:813dcc80987e 212 */
mbed_official 610:813dcc80987e 213
mbed_official 610:813dcc80987e 214 /* Exported functions --------------------------------------------------------*/
mbed_official 610:813dcc80987e 215 /** @addtogroup NOR_Exported_Functions NOR Exported Functions
mbed_official 610:813dcc80987e 216 * @{
mbed_official 610:813dcc80987e 217 */
mbed_official 610:813dcc80987e 218
mbed_official 610:813dcc80987e 219 /** @addtogroup NOR_Exported_Functions_Group1 Initialization and de-initialization functions
mbed_official 610:813dcc80987e 220 * @{
mbed_official 610:813dcc80987e 221 */
mbed_official 610:813dcc80987e 222
mbed_official 610:813dcc80987e 223 /* Initialization/de-initialization functions ********************************/
mbed_official 610:813dcc80987e 224 HAL_StatusTypeDef HAL_NOR_Init(NOR_HandleTypeDef *hnor, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming);
mbed_official 610:813dcc80987e 225 HAL_StatusTypeDef HAL_NOR_DeInit(NOR_HandleTypeDef *hnor);
mbed_official 610:813dcc80987e 226 void HAL_NOR_MspInit(NOR_HandleTypeDef *hnor);
mbed_official 610:813dcc80987e 227 void HAL_NOR_MspDeInit(NOR_HandleTypeDef *hnor);
mbed_official 610:813dcc80987e 228 void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout);
mbed_official 610:813dcc80987e 229
mbed_official 610:813dcc80987e 230 /**
mbed_official 610:813dcc80987e 231 * @}
mbed_official 610:813dcc80987e 232 */
mbed_official 610:813dcc80987e 233
mbed_official 610:813dcc80987e 234 /** @addtogroup NOR_Exported_Functions_Group2 Input and Output functions
mbed_official 610:813dcc80987e 235 * @{
mbed_official 610:813dcc80987e 236 */
mbed_official 610:813dcc80987e 237
mbed_official 610:813dcc80987e 238 /* I/O operation functions ***************************************************/
mbed_official 610:813dcc80987e 239 HAL_StatusTypeDef HAL_NOR_Read_ID(NOR_HandleTypeDef *hnor, NOR_IDTypeDef *pNOR_ID);
mbed_official 610:813dcc80987e 240 HAL_StatusTypeDef HAL_NOR_ReturnToReadMode(NOR_HandleTypeDef *hnor);
mbed_official 610:813dcc80987e 241 HAL_StatusTypeDef HAL_NOR_Read(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData);
mbed_official 610:813dcc80987e 242 HAL_StatusTypeDef HAL_NOR_Program(NOR_HandleTypeDef *hnor, uint32_t *pAddress, uint16_t *pData);
mbed_official 610:813dcc80987e 243
mbed_official 610:813dcc80987e 244 HAL_StatusTypeDef HAL_NOR_ReadBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize);
mbed_official 610:813dcc80987e 245 HAL_StatusTypeDef HAL_NOR_ProgramBuffer(NOR_HandleTypeDef *hnor, uint32_t uwAddress, uint16_t *pData, uint32_t uwBufferSize);
mbed_official 610:813dcc80987e 246
mbed_official 610:813dcc80987e 247 HAL_StatusTypeDef HAL_NOR_Erase_Block(NOR_HandleTypeDef *hnor, uint32_t BlockAddress, uint32_t Address);
mbed_official 610:813dcc80987e 248 HAL_StatusTypeDef HAL_NOR_Erase_Chip(NOR_HandleTypeDef *hnor, uint32_t Address);
mbed_official 610:813dcc80987e 249 HAL_StatusTypeDef HAL_NOR_Read_CFI(NOR_HandleTypeDef *hnor, NOR_CFITypeDef *pNOR_CFI);
mbed_official 610:813dcc80987e 250
mbed_official 610:813dcc80987e 251 /**
mbed_official 610:813dcc80987e 252 * @}
mbed_official 610:813dcc80987e 253 */
mbed_official 610:813dcc80987e 254
mbed_official 610:813dcc80987e 255 /** @addtogroup NOR_Exported_Functions_Group3 Peripheral Control functions
mbed_official 610:813dcc80987e 256 * @{
mbed_official 610:813dcc80987e 257 */
mbed_official 610:813dcc80987e 258
mbed_official 610:813dcc80987e 259 /* NOR Control functions *****************************************************/
mbed_official 610:813dcc80987e 260 HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable(NOR_HandleTypeDef *hnor);
mbed_official 610:813dcc80987e 261 HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable(NOR_HandleTypeDef *hnor);
mbed_official 610:813dcc80987e 262
mbed_official 610:813dcc80987e 263 /**
mbed_official 610:813dcc80987e 264 * @}
mbed_official 610:813dcc80987e 265 */
mbed_official 610:813dcc80987e 266
mbed_official 610:813dcc80987e 267 /** @addtogroup NOR_Exported_Functions_Group4 Peripheral State functions
mbed_official 610:813dcc80987e 268 * @{
mbed_official 610:813dcc80987e 269 */
mbed_official 610:813dcc80987e 270
mbed_official 610:813dcc80987e 271 /* NOR State functions ********************************************************/
mbed_official 610:813dcc80987e 272 HAL_NOR_StateTypeDef HAL_NOR_GetState(NOR_HandleTypeDef *hnor);
mbed_official 610:813dcc80987e 273 HAL_NOR_StatusTypeDef HAL_NOR_GetStatus(NOR_HandleTypeDef *hnor, uint32_t Address, uint32_t Timeout);
mbed_official 610:813dcc80987e 274
mbed_official 610:813dcc80987e 275 /**
mbed_official 610:813dcc80987e 276 * @}
mbed_official 610:813dcc80987e 277 */
mbed_official 610:813dcc80987e 278
mbed_official 610:813dcc80987e 279 /**
mbed_official 610:813dcc80987e 280 * @}
mbed_official 610:813dcc80987e 281 */
mbed_official 610:813dcc80987e 282
mbed_official 610:813dcc80987e 283 /**
mbed_official 610:813dcc80987e 284 * @}
mbed_official 610:813dcc80987e 285 */
mbed_official 610:813dcc80987e 286
mbed_official 610:813dcc80987e 287 /**
mbed_official 610:813dcc80987e 288 * @}
mbed_official 610:813dcc80987e 289 */
mbed_official 610:813dcc80987e 290
mbed_official 610:813dcc80987e 291 #ifdef __cplusplus
mbed_official 610:813dcc80987e 292 }
mbed_official 610:813dcc80987e 293 #endif
mbed_official 610:813dcc80987e 294
mbed_official 610:813dcc80987e 295 #endif /* __STM32L4xx_HAL_NOR_H */
mbed_official 610:813dcc80987e 296
mbed_official 610:813dcc80987e 297 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/