1 /** 2 ****************************************************************************** 3 * @file stm32h5xx_hal_ramcfg.h 4 * @author MCD Application Team 5 * @brief Header file of RAMCFG HAL module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2023 STMicroelectronics. 10 * All rights reserved. 11 * 12 * This software component is licensed by ST under BSD 3-Clause license, 13 * the "License"; You may not use this file except in compliance with the 14 * License. You may obtain a copy of the License at: 15 * opensource.org/licenses/BSD-3-Clause 16 * 17 ****************************************************************************** 18 */ 19 20 /* Define to prevent recursive inclusion -------------------------------------*/ 21 #ifndef STM32H5xx_HAL_RAMCFG_H 22 #define STM32H5xx_HAL_RAMCFG_H 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /* Includes ------------------------------------------------------------------*/ 29 #include "stm32h5xx_hal_def.h" 30 31 /** @addtogroup STM32H5xx_HAL_Driver 32 * @{ 33 */ 34 35 /** @addtogroup RAMCFG 36 * @{ 37 */ 38 39 40 /* Exported types ------------------------------------------------------------*/ 41 42 /** @defgroup RAMCFG_Exported_Types RAMCFG Exported Types 43 * @brief RAMCFG Exported Types 44 * @{ 45 */ 46 47 /** 48 * @brief HAL RAMCFG State Enumeration Definition 49 */ 50 typedef enum 51 { 52 HAL_RAMCFG_STATE_RESET = 0x00U, /*!< RAMCFG not yet initialized or disabled */ 53 HAL_RAMCFG_STATE_READY = 0x01U, /*!< RAMCFG initialized and ready for use */ 54 HAL_RAMCFG_STATE_BUSY = 0x02U, /*!< RAMCFG process is ongoing */ 55 HAL_RAMCFG_STATE_ERROR = 0x03U, /*!< RAMCFG error state */ 56 } HAL_RAMCFG_StateTypeDef; 57 58 #if (USE_HAL_RAMCFG_REGISTER_CALLBACKS == 1) 59 /** 60 * @brief HAL RAMCFG Callbacks IDs Enumeration Definition 61 */ 62 typedef enum 63 { 64 HAL_RAMCFG_MSPINIT_CB_ID = 0x00U, /*!< RAMCFG MSP Init Callback ID */ 65 HAL_RAMCFG_MSPDEINIT_CB_ID = 0x01U, /*!< RAMCFG MSP DeInit Callback ID */ 66 HAL_RAMCFG_SE_DETECT_CB_ID = 0x02U, /*!< RAMCFG Single Error Detect Callback ID */ 67 HAL_RAMCFG_DE_DETECT_CB_ID = 0x03U, /*!< RAMCFG Double Error Detect Callback ID */ 68 HAL_RAMCFG_ALL_CB_ID = 0x04U, /*!< RAMCFG All callback ID */ 69 } HAL_RAMCFG_CallbackIDTypeDef; 70 #endif /* USE_HAL_RAMCFG_REGISTER_CALLBACKS */ 71 72 /** 73 * @brief RAMCFG Handle Structure Definition 74 */ 75 #if (USE_HAL_RAMCFG_REGISTER_CALLBACKS == 1) 76 typedef struct __RAMCFG_HandleTypeDef 77 #else 78 typedef struct 79 #endif /* (USE_HAL_RAMCFG_REGISTER_CALLBACKS) */ 80 { 81 RAMCFG_TypeDef *Instance; /*!< RAMCFG Register Base Address */ 82 __IO HAL_RAMCFG_StateTypeDef State; /*!< RAMCFG State */ 83 __IO uint32_t ErrorCode; /*!< RAMCFG Error Code */ 84 #if (USE_HAL_RAMCFG_REGISTER_CALLBACKS == 1) 85 void (* MspInitCallback)(struct __RAMCFG_HandleTypeDef *hramcfg); /*!< RAMCFG MSP Init Callback */ 86 void (* MspDeInitCallback)(struct __RAMCFG_HandleTypeDef *hramcfg); /*!< RAMCFG MSP DeInit Callback */ 87 void (* DetectSingleErrorCallback)(struct __RAMCFG_HandleTypeDef *hramcfg);/*!< RAMCFG Single Error Detect Callback */ 88 void (* DetectDoubleErrorCallback)(struct __RAMCFG_HandleTypeDef *hramcfg);/*!< RAMCFG Double Error Detect Callback */ 89 #endif /* USE_HAL_RAMCFG_REGISTER_CALLBACKS */ 90 } RAMCFG_HandleTypeDef; 91 92 /** 93 * @} 94 */ 95 96 97 /* Exported constants --------------------------------------------------------*/ 98 99 /** @defgroup RAMCFG_Exported_Constants RAMCFG Exported Constants 100 * @brief RAMCFG Exported Constants 101 * @{ 102 */ 103 104 /** @defgroup RAMCFG_Error_Codes RAMCFG Error Codes 105 * @brief RAMCFG Error Codes 106 * @{ 107 */ 108 #define HAL_RAMCFG_ERROR_NONE 0x00000000U /*!< RAMCFG No Error */ 109 #define HAL_RAMCFG_ERROR_TIMEOUT 0x00000001U /*!< RAMCFG Timeout Error */ 110 #define HAL_RAMCFG_ERROR_BUSY 0x00000002U /*!< RAMCFG Busy Error */ 111 #if (USE_HAL_RAMCFG_REGISTER_CALLBACKS == 1) 112 #define HAL_RAMCFG_ERROR_INVALID_CALLBACK 0x00000003U /*!< Invalid Callback error */ 113 #endif /* USE_HAL_RAMCFG_REGISTER_CALLBACKS */ 114 /** 115 * @} 116 */ 117 118 /** @defgroup RAMCFG_Interrupt RAMCFG Interrupts 119 * @brief RAMCFG Interrupts 120 * @{ 121 */ 122 #define RAMCFG_IT_SINGLEERR RAMCFG_IER_SEIE /*!< RAMCFG Single Error Interrupt */ 123 #define RAMCFG_IT_DOUBLEERR RAMCFG_IER_DEIE /*!< RAMCFG Double Error Interrupt */ 124 #define RAMCFG_IT_NMIERR RAMCFG_IER_ECCNMI /*!< RAMCFG Double Error redirected to NMI Interrupt */ 125 #define RAMCFG_IT_ALL \ 126 (RAMCFG_IER_SEIE | RAMCFG_IER_DEIE |RAMCFG_IER_ECCNMI) /*!< RAMCFG All RAMCFG interrupt */ 127 /** 128 * @} 129 */ 130 131 /** @defgroup RAMCFG_FLAG RAMCFG Monitor Flags 132 * @brief RAMCFG Monitor Flags 133 * @{ 134 */ 135 #define RAMCFG_FLAG_SINGLEERR RAMCFG_ISR_SEDC /*!< RAMCFG Single Error Detected and Corrected Flag */ 136 #define RAMCFG_FLAG_DOUBLEERR RAMCFG_ISR_DED /*!< RAMCFG Double Error Detected Flag */ 137 #define RAMCFG_FLAG_SRAMBUSY RAMCFG_ISR_SRAMBUSY /*!< RAMCFG SRAM busy Flag */ 138 #define RAMCFG_FLAGS_ALL \ 139 (RAMCFG_ISR_SEDC | RAMCFG_ISR_DED | RAMCFG_ISR_SRAMBUSY) /*!< RAMCFG All Flags */ 140 /** 141 * @} 142 */ 143 144 /** @defgroup RAMCFG_Keys RAMCFG Keys 145 * @brief RAMCFG Keys 146 * @{ 147 */ 148 #define RAMCFG_ERASE_KEY1 (0xCAU) /*!< RAMCFG launch Erase Key 1 */ 149 #define RAMCFG_ERASE_KEY2 (0x53U) /*!< RAMCFG launch Erase Key 2 */ 150 151 #define RAMCFG_ECC_KEY1 (0xAEU) /*!< RAMCFG launch ECC Key 1 */ 152 #define RAMCFG_ECC_KEY2 (0x75U) /*!< RAMCFG launch ECC Key 2 */ 153 /** 154 * @} 155 */ 156 157 158 /** 159 * @} 160 */ 161 162 163 /* Exported macro ------------------------------------------------------------*/ 164 165 /** @defgroup RAMCFG_Exported_Macros RAMCFG Exported Macros 166 * @brief RAMCFG Exported Macros 167 * @{ 168 */ 169 170 /** 171 * @brief Enable the specified RAMCFG interrupts. 172 * @param __HANDLE__ : Specifies RAMCFG handle. 173 * @param __INTERRUPT__: Specifies the RAMCFG interrupt sources to be enabled. 174 * This parameter can be one of the following values: 175 * @arg RAMCFG_IT_SINGLEERR : Single Error Interrupt Mask. 176 * @arg RAMCFG_IT_DOUBLEERR : Double Error Interrupt Mask. 177 * @arg RAMCFG_IT_NMIERR : Double Error Interrupt redirection to NMI Mask. 178 * @arg RAMCFG_IT_ALL : All Interrupt Mask. 179 * @retval None 180 */ 181 #define __HAL_RAMCFG_ENABLE_IT(__HANDLE__, __INTERRUPT__) \ 182 ((__HANDLE__)->Instance->IER |= (__INTERRUPT__)) 183 184 /** 185 * @brief Disable the specified RAMCFG interrupts. 186 * @note This macros is used only to disable RAMCFG_IT_SINGLEERR and RAMCFG_IT_DOUBLEERR 187 * interrupts. RAMCFG_IT_NMIERR interrupt can only be disabled by global peripheral reset or system reset. 188 * @param __HANDLE__ : Specifies RAMCFG handle. 189 * @param __INTERRUPT__: Specifies the RAMCFG interrupt sources to be disabled. 190 * This parameter can be one of the following values: 191 * @arg RAMCFG_IT_SINGLEERR : Single Error Interrupt Mask. 192 * @arg RAMCFG_IT_DOUBLEERR : Double Error Interrupt Mask. 193 * @retval None 194 */ 195 #define __HAL_RAMCFG_DISABLE_IT(__HANDLE__, __INTERRUPT__) \ 196 ((__HANDLE__)->Instance->IER &= ~(__INTERRUPT__)) 197 198 /** 199 * @brief Check whether the specified RAMCFG interrupt source is enabled or not. 200 * @param __HANDLE__ : Specifies the RAMCFG Handle. 201 * @param __INTERRUPT__ : Specifies the RAMCFG interrupt source to check. 202 * This parameter can be one of the following values: 203 * @arg RAMCFG_IT_SINGLEERR : Single Error Interrupt Mask. 204 * @arg RAMCFG_IT_DOUBLEERR : Double Error Interrupt Mask. 205 * @arg RAMCFG_IT_NMIERR : Double Error Interrupt Redirection to NMI Mask. 206 * @retval The new state of __INTERRUPT__ (SET or RESET). 207 */ 208 #define __HAL_RAMCFG_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \ 209 ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? 1U : 0U) 210 211 /** 212 * @brief Get the RAMCFG pending flags. 213 * @param __HANDLE__ : Specifies RAMCFG handle. 214 * @param __FLAG__ : Specifies the flag to be checked. 215 * This parameter can be one of the following values: 216 * @arg RAMCFG_FLAG_SINGLEERR : Single Error Detected and Corrected Flag. 217 * @arg RAMCFG_FLAG_DOUBLEERR : Double Error Detected Flag. 218 * @arg RAMCFG_FLAG_SRAMBUSY : SRAM Busy Flag. 219 * @retval The state of FLAG (SET or RESET). 220 */ 221 #define __HAL_RAMCFG_GET_FLAG(__HANDLE__, __FLAG__) \ 222 (READ_BIT((__HANDLE__)->Instance->ISR, (__FLAG__)) == (__FLAG__)) 223 224 /** 225 * @brief Clear the RAMCFG pending flags. 226 * @param __HANDLE__ : Specifies RAMCFG handle. 227 * @param __FLAG__ : Specifies the flag to be cleared. 228 * This parameter can be any combination of the following values: 229 * @arg RAMCFG_FLAG_SINGLEERR : Single Error Detected and Corrected Flag. 230 * @arg RAMCFG_FLAG_DOUBLEERR : Double Error Detected Flag. 231 * @retval None. 232 */ 233 #define __HAL_RAMCFG_CLEAR_FLAG(__HANDLE__, __FLAG__) \ 234 ((__HANDLE__)->Instance->ICR |= (__FLAG__)) 235 236 /** @brief Reset the RAMCFG handle state. 237 * @param __HANDLE__ : Specifies the RAMCFG Handle. 238 * @retval None. 239 */ 240 #if (USE_HAL_RAMCFG_REGISTER_CALLBACKS == 1) 241 #define __HAL_RAMCFG_RESET_HANDLE_STATE(__HANDLE__) \ 242 do{\ 243 (__HANDLE__)->State = HAL_RAMCFG_STATE_RESET; \ 244 (__HANDLE__)->MspInitCallback = NULL; \ 245 (__HANDLE__)->MspDeInitCallback = NULL; \ 246 }while(0) 247 #else 248 #define __HAL_RAMCFG_RESET_HANDLE_STATE(__HANDLE__) \ 249 do{\ 250 (__HANDLE__)->State = HAL_RAMCFG_STATE_RESET; \ 251 }while(0) 252 #endif /* USE_HAL_RAMCFG_REGISTER_CALLBACKS */ 253 254 /** 255 * @} 256 */ 257 258 259 /* Exported functions --------------------------------------------------------*/ 260 261 /** @defgroup RAMCFG_Exported_Functions RAMCFG Exported Functions 262 * @brief RAMCFG Exported Functions 263 * @{ 264 */ 265 266 /** @defgroup RAMCFG_Exported_Functions_Group1 Initialization and De-Initialization Functions 267 * @brief Initialization and De-Initialization Functions 268 * @{ 269 */ 270 HAL_StatusTypeDef HAL_RAMCFG_Init(RAMCFG_HandleTypeDef *hramcfg); 271 HAL_StatusTypeDef HAL_RAMCFG_DeInit(RAMCFG_HandleTypeDef *hramcfg); 272 void HAL_RAMCFG_MspInit(RAMCFG_HandleTypeDef *hramcfg); 273 void HAL_RAMCFG_MspDeInit(RAMCFG_HandleTypeDef *hramcfg); 274 /** 275 * @} 276 */ 277 278 /** @defgroup RAMCFG_Exported_Functions_Group2 ECC Operation Functions 279 * @brief ECC Operation Functions 280 * @{ 281 */ 282 HAL_StatusTypeDef HAL_RAMCFG_StartECC(RAMCFG_HandleTypeDef *hramcfg); 283 HAL_StatusTypeDef HAL_RAMCFG_StopECC(RAMCFG_HandleTypeDef *hramcfg); 284 HAL_StatusTypeDef HAL_RAMCFG_EnableNotification(RAMCFG_HandleTypeDef *hramcfg, uint32_t Notifications); 285 HAL_StatusTypeDef HAL_RAMCFG_DisableNotification(RAMCFG_HandleTypeDef *hramcfg, uint32_t Notifications); 286 uint32_t HAL_RAMCFG_IsECCSingleErrorDetected(const RAMCFG_HandleTypeDef *hramcfg); 287 uint32_t HAL_RAMCFG_IsECCDoubleErrorDetected(const RAMCFG_HandleTypeDef *hramcfg); 288 uint32_t HAL_RAMCFG_GetSingleErrorAddress(const RAMCFG_HandleTypeDef *hramcfg); 289 uint32_t HAL_RAMCFG_GetDoubleErrorAddress(const RAMCFG_HandleTypeDef *hramcfg); 290 /** 291 * @} 292 */ 293 294 /** @defgroup RAMCFG_Exported_Functions_Group4 Write Protection Functions 295 * @brief Write Protection Functions 296 * @{ 297 */ 298 HAL_StatusTypeDef HAL_RAMCFG_EnableWriteProtection(RAMCFG_HandleTypeDef *hramcfg, uint32_t StartPage, uint32_t NbPage); 299 /** 300 * @} 301 */ 302 303 /** @defgroup RAMCFG_Exported_Functions_Group5 Erase Operation Functions 304 * @brief Erase Operation Functions 305 * @{ 306 */ 307 HAL_StatusTypeDef HAL_RAMCFG_Erase(RAMCFG_HandleTypeDef *hramcfg); 308 /** 309 * @} 310 */ 311 312 /** @defgroup RAMCFG_Exported_Functions_Group6 Handle Interrupt and Callbacks Functions 313 * @brief Handle Interrupt and Callbacks Functions 314 * @{ 315 */ 316 void HAL_RAMCFG_IRQHandler(RAMCFG_HandleTypeDef *hramcfg); 317 void HAL_RAMCFG_DetectSingleErrorCallback(RAMCFG_HandleTypeDef *hramcfg); 318 void HAL_RAMCFG_DetectDoubleErrorCallback(RAMCFG_HandleTypeDef *hramcfg); 319 #if (USE_HAL_RAMCFG_REGISTER_CALLBACKS == 1) 320 HAL_StatusTypeDef HAL_RAMCFG_RegisterCallback(RAMCFG_HandleTypeDef *hramcfg, 321 HAL_RAMCFG_CallbackIDTypeDef CallbackID, 322 void (* pCallback)(RAMCFG_HandleTypeDef *_hramcfg)); 323 HAL_StatusTypeDef HAL_RAMCFG_UnRegisterCallback(RAMCFG_HandleTypeDef *hramcfg, HAL_RAMCFG_CallbackIDTypeDef CallbackID); 324 #endif /* USE_HAL_RAMCFG_REGISTER_CALLBACKS */ 325 /** 326 * @} 327 */ 328 329 /** @defgroup RAMCFG_Exported_Functions_Group7 State and Error Functions 330 * @brief State and Error Functions 331 * @{ 332 */ 333 uint32_t HAL_RAMCFG_GetError(const RAMCFG_HandleTypeDef *hramcfg); 334 HAL_RAMCFG_StateTypeDef HAL_RAMCFG_GetState(const RAMCFG_HandleTypeDef *hramcfg); 335 /** 336 * @} 337 */ 338 339 /** 340 * @} 341 */ 342 343 344 /* Private Constants ---------------------------------------------------------*/ 345 346 /** @defgroup RAMCFG_Private_Constants RAMCFG Private Defines and Constants 347 * @brief RAMCFG Private Defines and Constants 348 * @{ 349 */ 350 /** 351 * @} 352 */ 353 354 355 /* Private macros ------------------------------------------------------------*/ 356 357 /** @defgroup RAMCFG_Private_Macros RAMCFG Private Macros 358 * @brief RAMCFG Private Macros 359 * @{ 360 */ 361 #define IS_RAMCFG_INTERRUPT(INTERRUPT) \ 362 (((INTERRUPT) != 0U) && (((INTERRUPT) & ~(RAMCFG_IT_SINGLEERR | RAMCFG_IT_DOUBLEERR | RAMCFG_IT_NMIERR)) == 0U)) 363 364 365 #define IS_RAMCFG_WRITEPROTECTION_PAGE(PAGE) ((PAGE) <= 64U) 366 367 368 /** 369 * @} 370 */ 371 372 373 /* Private functions ---------------------------------------------------------*/ 374 375 /** @defgroup RAMCFG_Private_Functions RAMCFG Private Functions 376 * @brief RAMCFG Private Functions 377 * @{ 378 */ 379 /** 380 * @} 381 */ 382 383 /** 384 * @} 385 */ 386 387 /** 388 * @} 389 */ 390 391 #ifdef __cplusplus 392 } 393 #endif 394 395 #endif /* STM32H5xx_HAL_RAMCFG_H */ 396