You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

310 lines
12 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_ramecc.h
  4. * @author MCD Application Team
  5. * @brief Header file of RAMECC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  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. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32H7xx_HAL_RAMECC_H
  21. #define STM32H7xx_HAL_RAMECC_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx_hal_def.h"
  27. /** @addtogroup STM32H7xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup RAMECC
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup RAMECC_Exported_Types RAMECC Exported Types
  35. * @brief RAMECC Exported Types
  36. * @{
  37. */
  38. /**
  39. * @brief HAL RAMECC State structures definition
  40. */
  41. typedef enum
  42. {
  43. HAL_RAMECC_STATE_RESET = 0x00U, /*!< RAMECC not yet initialized or disabled */
  44. HAL_RAMECC_STATE_READY = 0x01U, /*!< RAMECC initialized and ready for use */
  45. HAL_RAMECC_STATE_BUSY = 0x02U, /*!< RAMECC process is ongoing */
  46. HAL_RAMECC_STATE_ERROR = 0x03U, /*!< RAMECC error state */
  47. }HAL_RAMECC_StateTypeDef;
  48. /**
  49. * @brief RAMECC handle Structure definition
  50. */
  51. typedef struct __RAMECC_HandleTypeDef
  52. {
  53. RAMECC_MonitorTypeDef *Instance; /*!< Register base address */
  54. __IO HAL_RAMECC_StateTypeDef State; /*!< RAMECC state */
  55. void (* DetectErrorCallback)( struct __RAMECC_HandleTypeDef *hramecc); /*!< RAMECC error detect callback */
  56. }RAMECC_HandleTypeDef;
  57. /**
  58. * @}
  59. */
  60. /* Exported constants --------------------------------------------------------*/
  61. /** @defgroup RAMECC_Interrupt RAMECC interrupts
  62. * @{
  63. */
  64. #define RAMECC_IT_GLOBAL_ID 0x10000000UL
  65. #define RAMECC_IT_MONITOR_ID 0x20000000UL
  66. #define RAMECC_IT_GLOBAL_ENABLE (RAMECC_IT_GLOBAL_ID | RAMECC_IER_GIE)
  67. #define RAMECC_IT_GLOBAL_SINGLEERR_R (RAMECC_IT_GLOBAL_ID | RAMECC_IER_GECCSEIE)
  68. #define RAMECC_IT_GLOBAL_DOUBLEERR_R (RAMECC_IT_GLOBAL_ID | RAMECC_IER_GECCDEIE)
  69. #define RAMECC_IT_GLOBAL_DOUBLEERR_W (RAMECC_IT_GLOBAL_ID | RAMECC_IER_GECCDEBWIE)
  70. #define RAMECC_IT_GLOBAL_ALL (RAMECC_IT_GLOBAL_ID | RAMECC_IER_GIE | RAMECC_IER_GECCSEIE | RAMECC_IER_GECCDEIE | RAMECC_IER_GECCDEBWIE)
  71. #define RAMECC_IT_MONITOR_SINGLEERR_R (RAMECC_IT_MONITOR_ID | RAMECC_CR_ECCSEIE)
  72. #define RAMECC_IT_MONITOR_DOUBLEERR_R (RAMECC_IT_MONITOR_ID | RAMECC_CR_ECCDEIE)
  73. #define RAMECC_IT_MONITOR_DOUBLEERR_W (RAMECC_IT_MONITOR_ID | RAMECC_CR_ECCDEBWIE)
  74. #define RAMECC_IT_MONITOR_ALL (RAMECC_IT_MONITOR_ID | RAMECC_CR_ECCDEBWIE | RAMECC_CR_ECCDEIE | RAMECC_CR_ECCSEIE)
  75. /**
  76. * @}
  77. */
  78. /** @defgroup RAMECC_FLAG RAMECC Monitor flags
  79. * @{
  80. */
  81. #define RAMECC_FLAG_SINGLEERR_R RAMECC_SR_SEDCF
  82. #define RAMECC_FLAG_DOUBLEERR_R RAMECC_SR_DEDF
  83. #define RAMECC_FLAG_DOUBLEERR_W RAMECC_SR_DEBWDF
  84. #define RAMECC_FLAGS_ALL (RAMECC_SR_SEDCF | RAMECC_SR_DEDF | RAMECC_SR_DEBWDF)
  85. /**
  86. * @}
  87. */
  88. /* Exported macro ------------------------------------------------------------*/
  89. /** @defgroup RAMECC_Exported_Macros RAMECC Exported Macros
  90. * @{
  91. */
  92. #define __HAL_RAMECC_ENABLE_GLOBAL_IT(__HANDLE__, __INTERRUPT__) ((((RAMECC_TypeDef *)((uint32_t)(__HANDLE__)->Instance & 0xFFFFFF00U))->IER) |= ((__INTERRUPT__) & ~RAMECC_IT_GLOBAL_ID))
  93. #define __HAL_RAMECC_ENABLE_MONITOR_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= ((__INTERRUPT__) & ~RAMECC_IT_MONITOR_ID))
  94. /**
  95. * @brief Enable the specified RAMECC interrupts.
  96. * @param __HANDLE__ : RAMECC handle.
  97. * @param __INTERRUPT__: specifies the RAMECC interrupt sources to be enabled or disabled.
  98. * This parameter can be one of the following values:
  99. * @arg RAMECC_IT_GLOBAL_E : Global interrupt enable mask.
  100. * @arg RAMECC_IT_GLOBAL_SEE : Global ECC single error interrupt enable.
  101. * @arg RAMECC_IT_GLOBAL_DEE : Global ECC double error interrupt enable.
  102. * @arg RAMECC_IT_GLOBAL_DEBWE : Global ECC double error on byte write (BW) interrupt enable.
  103. * @arg RAMECC_IT_GLOBAL_ALL : All Global ECC interrupts enable mask.
  104. * @arg RAMECC_IT_MONITOR_SEE : Monitor ECC single error interrupt enable.
  105. * @arg RAMECC_IT_MONITOR_DEE : Monitor ECC double error interrupt enable.
  106. * @arg RAMECC_IT_MONITOR_DEBWE : Monitor ECC double error on byte write (BW) interrupt enable.
  107. * @arg RAMECC_IT_MONITOR_ALL : All Monitor ECC interrupts enable mask.
  108. * @retval None
  109. */
  110. #define __HAL_RAMECC_ENABLE_IT(__HANDLE__, __INTERRUPT__) ( \
  111. (IS_RAMECC_GLOBAL_INTERRUPT(__INTERRUPT__)) ? (__HAL_RAMECC_ENABLE_GLOBAL_IT((__HANDLE__), (__INTERRUPT__))) :\
  112. (__HAL_RAMECC_ENABLE_MONITOR_IT((__HANDLE__), (__INTERRUPT__))))
  113. #define __HAL_RAMECC_DISABLE_GLOBAL_IT(__HANDLE__, __INTERRUPT__) ((((RAMECC_TypeDef *)((uint32_t)&(__HANDLE__)->Instance & 0xFFFFFF00U))->IER) &= ~((__INTERRUPT__) & ~RAMECC_IT_GLOBAL_ID))
  114. #define __HAL_RAMECC_DISABLE_MONITOR_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~((__INTERRUPT__) & ~RAMECC_IT_MONITOR_ID))
  115. /**
  116. * @brief Disable the specified RAMECC interrupts.
  117. * @param __HANDLE__ : RAMECC handle.
  118. * @param __INTERRUPT__: specifies the RAMECC interrupt sources to be enabled or disabled.
  119. * This parameter can be one of the following values:
  120. * @arg RAMECC_IT_GLOBAL_E : Global interrupt enable mask.
  121. * @arg RAMECC_IT_GLOBAL_SEE : Global ECC single error interrupt enable.
  122. * @arg RAMECC_IT_GLOBAL_DEE : Global ECC double error interrupt enable.
  123. * @arg RAMECC_IT_GLOBAL_DEBWE : Global ECC double error on byte write (BW) interrupt enable.
  124. * @arg RAMECC_IT_GLOBAL_ALL : All Global ECC interrupts enable mask.
  125. * @arg RAMECC_IT_MONITOR_SEE : Monitor ECC single error interrupt enable.
  126. * @arg RAMECC_IT_MONITOR_DEE : Monitor ECC double error interrupt enable.
  127. * @arg RAMECC_IT_MONITOR_DEBWE : Monitor ECC double error on byte write (BW) interrupt enable.
  128. * @arg RAMECC_IT_MONITOR_ALL : All Monitor ECC interrupts enable mask.
  129. * @retval None
  130. */
  131. #define __HAL_RAMECC_DISABLE_IT(__HANDLE__, __INTERRUPT__) ( \
  132. (IS_RAMECC_GLOBAL_INTERRUPT(__INTERRUPT__)) ? (__HAL_RAMECC_DISABLE_GLOBAL_IT((__HANDLE__), (__INTERRUPT__))) :\
  133. (__HAL_RAMECC_DISABLE_MONITOR_IT((__HANDLE__), (__INTERRUPT__))))
  134. /**
  135. * @brief Get the RAMECC pending flags.
  136. * @param __HANDLE__ : RAMECC handle.
  137. * @param __FLAG__ : specifies the flag to clear.
  138. * This parameter can be any combination of the following values:
  139. * @arg RAMECC_FLAG_SEDCF : RAMECC instance ECC single error detected and corrected flag.
  140. * @arg RAMECC_FLAG_DEDF : RAMECC instance ECC double error detected flag.
  141. * @arg RAMECC_FLAG_DEBWDF : RAMECC instance ECC double error on byte write (BW) detected flag.
  142. * @arg RAMECC_FLAGS_ALL : RAMECC instance all flag.
  143. * @retval None.
  144. */
  145. #define __HAL_RAMECC_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR &= (__FLAG__))
  146. /**
  147. * @brief Clear the RAMECC pending flags.
  148. * @param __HANDLE__ : RAMECC handle.
  149. * @param __FLAG__ : specifies the flag to clear.
  150. * This parameter can be any combination of the following values:
  151. * @arg RAMECC_FLAG_SEDCF : RAMECC instance ECC single error detected and corrected flag.
  152. * @arg RAMECC_FLAG_DEDF : RAMECC instance ECC double error detected flag.
  153. * @arg RAMECC_FLAG_DEBWDF : RAMECC instance ECC double error on byte write (BW) detected flag.
  154. * @arg RAMECC_FLAGS_ALL : RAMECC instance all flag.
  155. * @retval None.
  156. */
  157. #define __HAL_RAMECC_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR &= ~(__FLAG__))
  158. /**
  159. * @}
  160. */
  161. /* Exported functions --------------------------------------------------------*/
  162. /** @defgroup RAMECC_Exported_Functions RAMECC Exported Functions
  163. * @brief RAMECC Exported functions
  164. * @{
  165. */
  166. /** @defgroup RAMECC_Exported_Functions_Group1 Initialization and de-initialization functions
  167. * @brief Initialization and de-initialization functions
  168. * @{
  169. */
  170. HAL_StatusTypeDef HAL_RAMECC_Init(RAMECC_HandleTypeDef *hramecc);
  171. HAL_StatusTypeDef HAL_RAMECC_DeInit(RAMECC_HandleTypeDef *hramecc);
  172. /**
  173. * @}
  174. */
  175. /** @defgroup RAMECC_Exported_Functions_Group2 monitoring operation functions
  176. * @brief monitoring operation functions
  177. * @{
  178. */
  179. HAL_StatusTypeDef HAL_RAMECC_StartMonitor(RAMECC_HandleTypeDef *hramecc);
  180. HAL_StatusTypeDef HAL_RAMECC_StopMonitor(RAMECC_HandleTypeDef *hramecc);
  181. HAL_StatusTypeDef HAL_RAMECC_EnableNotification(RAMECC_HandleTypeDef *hramecc, uint32_t Notifications);
  182. HAL_StatusTypeDef HAL_RAMECC_DisableNotification(RAMECC_HandleTypeDef *hramecc, uint32_t Notifications);
  183. void HAL_RAMECC_IRQHandler(RAMECC_HandleTypeDef *hramecc);
  184. HAL_StatusTypeDef HAL_RAMECC_RegisterCallback(RAMECC_HandleTypeDef *hramecc, void (* pCallback)(RAMECC_HandleTypeDef *_hramecc));
  185. HAL_StatusTypeDef HAL_RAMECC_UnRegisterCallback(RAMECC_HandleTypeDef *hramecc);
  186. /**
  187. * @}
  188. */
  189. /** @defgroup RAMECC_Exported_Functions_Group3 Error informations functions
  190. * @brief Error informations functions
  191. * @{
  192. */
  193. uint32_t HAL_RAMECC_GetFailingAddress(RAMECC_HandleTypeDef *hramecc);
  194. uint32_t HAL_RAMECC_GetFailingDataLow(RAMECC_HandleTypeDef *hramecc);
  195. uint32_t HAL_RAMECC_GetFailingDataHigh(RAMECC_HandleTypeDef *hramecc);
  196. uint32_t HAL_RAMECC_GetHammingErrorCode(RAMECC_HandleTypeDef *hramecc);
  197. /**
  198. * @}
  199. */
  200. /**
  201. * @}
  202. */
  203. /* Private Constants -------------------------------------------------------------*/
  204. /** @defgroup RAMECC_Private_Constants RAMECC Private Constants
  205. * @brief RAMECC private defines and constants
  206. * @{
  207. */
  208. /**
  209. * @}
  210. */
  211. /* Private macros ------------------------------------------------------------*/
  212. /** @defgroup RAMECC_Private_Macros RAMECC Private Macros
  213. * @brief RAMECC private macros
  214. * @{
  215. */
  216. #define IS_RAMECC_GLOBAL_INTERRUPT(INTERRUPT) ((((INTERRUPT) & RAMECC_IT_GLOBAL_ENABLE) == RAMECC_IT_GLOBAL_ENABLE) || \
  217. (((INTERRUPT) & RAMECC_IT_GLOBAL_SINGLEERR_R) == RAMECC_IT_GLOBAL_SINGLEERR_R) || \
  218. (((INTERRUPT) & RAMECC_IT_GLOBAL_DOUBLEERR_R) == RAMECC_IT_GLOBAL_DOUBLEERR_R) || \
  219. (((INTERRUPT) & RAMECC_IT_GLOBAL_DOUBLEERR_W) == RAMECC_IT_GLOBAL_DOUBLEERR_W) || \
  220. (((INTERRUPT) & RAMECC_IT_GLOBAL_ALL) == RAMECC_IT_GLOBAL_ALL))
  221. #define IS_RAMECC_MONITOR_INTERRUPT(INTERRUPT) ((((INTERRUPT) & RAMECC_IT_MONITOR_SINGLEERR_R) == RAMECC_IT_MONITOR_SINGLEERR_R) || \
  222. (((INTERRUPT) & RAMECC_IT_MONITOR_DOUBLEERR_R) == RAMECC_IT_MONITOR_DOUBLEERR_R) || \
  223. (((INTERRUPT) & RAMECC_IT_MONITOR_DOUBLEERR_W) == RAMECC_IT_MONITOR_DOUBLEERR_W) || \
  224. (((INTERRUPT) & RAMECC_IT_MONITOR_ALL) == RAMECC_IT_MONITOR_ALL))
  225. #define IS_RAMECC_INTERRUPT(INTERRUPT) ((IS_RAMECC_GLOBAL_INTERRUPT(INTERRUPT)) || \
  226. (IS_RAMECC_MONITOR_INTERRUPT(INTERRUPT)))
  227. /**
  228. * @}
  229. */
  230. /** @defgroup RAMECC_FLAG RAMECC Monitor flags
  231. * @{
  232. */
  233. /* Private functions ---------------------------------------------------------*/
  234. /** @defgroup RAMECC_Private_Functions RAMECC Private Functions
  235. * @brief RAMECC private functions
  236. * @{
  237. */
  238. /**
  239. * @}
  240. */
  241. /**
  242. * @}
  243. */
  244. /**
  245. * @}
  246. */
  247. /**
  248. * @}
  249. */
  250. #ifdef __cplusplus
  251. }
  252. #endif
  253. #endif /* STM32H7xx_HAL_RAMECC_H */
  254. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/