Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:08

0001 /**
0002   ******************************************************************************
0003   * @file    stm32h7xx_hal_ramecc.c
0004   * @author  MCD Application Team
0005   * @brief   RAMECC HAL module driver.
0006   *          This file provides firmware functions to manage the following
0007   *          functionalities of the RAM ECC monitoring (RAMECC) peripheral:
0008   *           + Initialization and de-initialization functions
0009   *           + Monitoring operation functions
0010   *           + Error information functions
0011   *           + State and error functions
0012   ******************************************************************************
0013   * @attention
0014   *
0015   * Copyright (c) 2017 STMicroelectronics.
0016   * All rights reserved.
0017   *
0018   * This software is licensed under terms that can be found in the LICENSE file
0019   * in the root directory of this software component.
0020   * If no LICENSE file comes with this software, it is provided AS-IS.
0021   *
0022   ******************************************************************************
0023   @verbatim
0024   ==============================================================================
0025                         ##### How to use this driver #####
0026   ==============================================================================
0027   [..]
0028    (#) Enable and latch error information through HAL_RAMECC_Init().
0029 
0030    (#) For a given Monitor, enable and disable interrupt through
0031        HAL_RAMECC_EnableNotification().
0032        To enable a notification for a given RAMECC instance, use global
0033        interrupts.
0034        To enable a notification for only RAMECC monitor, use monitor interrupts.
0035        All possible notifications are defined in the driver header file under
0036        RAMECC_Interrupt group.
0037 
0038      *** Silent mode ***
0039      ===================
0040     [..]
0041           (+) Use HAL_RAMECC_StartMonitor() to start RAMECC latch failing
0042               information without enabling any notification.
0043 
0044      *** Interrupt mode ***
0045      ======================
0046     [..]
0047           (+) Use HAL_RAMECC_EnableNotification() to enable interrupts for a
0048               given error.
0049           (+) Configure the RAMECC interrupt priority using
0050               HAL_NVIC_SetPriority().
0051           (+) Enable the RAMECC IRQ handler using HAL_NVIC_EnableIRQ().
0052           (+) Start RAMECC latch failing information using HAL_RAMECC_StartMonitor().
0053 
0054      *** Failing information ***
0055      ======================
0056     [..]
0057      (#) Use HAL_RAMECC_GetFailingAddress() function to return the RAMECC
0058          failing address.
0059      (#) Use HAL_RAMECC_GetFailingDataLow() function to return the RAMECC
0060          failing data low.
0061      (#) Use HAL_RAMECC_GetFailingDataHigh() function to return the RAMECC
0062          failing data high.
0063      (#) Use HAL_RAMECC_GetHammingErrorCode() function to return the RAMECC
0064          Hamming bits injected.
0065      (#) Use HAL_RAMECC_IsECCSingleErrorDetected() function to check if a single
0066          error was detected and corrected.
0067      (#) Use HAL_RAMECC_IsECCDoubleErrorDetected() function to check if a double
0068          error was dedetected.
0069 
0070      *** RAMECC HAL driver macros list ***
0071      =============================================
0072      [..]
0073        Below the list of used macros in RAMECC HAL driver.
0074 
0075       (+) __HAL_RAMECC_ENABLE_IT  : Enable the specified ECCRAM Monitor
0076                                     interrupts.
0077       (+) __HAL_RAMECC_DISABLE_IT : Disable the specified ECCRAM Monitor
0078                                     interrupts.
0079       (+) __HAL_RAMECC_GET_FLAG   : Return the current RAMECC Monitor selected
0080                                     flag.
0081       (+) __HAL_RAMECC_CLEAR_FLAG : Clear the current RAMECC Monitor selected
0082                                     flag.
0083 
0084     ##### Callback registration #####
0085     ==================================
0086     [..]
0087       (#) The compilation define USE_HAL_RAMECC_REGISTER_CALLBACKS when set to 1
0088           allows the user to configure dynamically the driver callback.
0089 
0090     [..]
0091       (#) Use Function HAL_RAMECC_RegisterCallback() to register a user callback.
0092       (#) Function HAL_RAMECC_RegisterCallback() allows to register following callback:
0093          (+) RAMECCErrorCode        : RAMECC error code detection.
0094       (#) This function takes as parameters the HAL peripheral handle 
0095           and a pointer to the user callback function.
0096 
0097     [..]
0098       (#) Use function HAL_RAMECC_UnRegisterCallback() to reset a callback to the default
0099           weak function.
0100       (#) HAL_RAMECC_UnRegisterCallback() takes as parameters the HAL peripheral handle.
0101       (#) This function allows to reset following callback:
0102           (+) RAMECCErrorCode        : RAMECC error code detection.
0103     [..]
0104       (#) When The compilation define USE_HAL_RAMECC_REGISTER_CALLBACKS is set to 0 or
0105           not defined, the callback registration feature is not available
0106           and weak callbacks are used.
0107  
0108   @endverbatim
0109   */
0110 
0111 /* Includes ------------------------------------------------------------------*/
0112 #include "stm32h7xx_hal.h"
0113 
0114 /** @addtogroup STM32H7xx_HAL_Driver
0115   * @{
0116   */
0117 
0118 /** @defgroup RAMECC RAMECC
0119   * @ingroup RTEMSBSPsARMSTM32H7
0120   * @brief RAMECC HAL module driver
0121   * @{
0122   */
0123 
0124 #ifdef HAL_RAMECC_MODULE_ENABLED
0125 
0126 /* Private types -------------------------------------------------------------*/
0127 /* Private variables ---------------------------------------------------------*/
0128 /* Private constants ---------------------------------------------------------*/
0129 /* Private macros ------------------------------------------------------------*/
0130 /* Private functions ---------------------------------------------------------*/
0131 /* Exported functions --------------------------------------------------------*/
0132 
0133 /** @addtogroup RAMECC_Exported_Functions
0134   * @{
0135   */
0136 
0137 /** @addtogroup RAMECC_Exported_Functions_Group1
0138   *
0139 @verbatim
0140  ===============================================================================
0141              ##### Initialization and de-initialization functions  #####
0142  ===============================================================================
0143     [..]
0144     This section provides functions allowing to initialize the RAMECC Monitor.
0145     [..]
0146     The HAL_RAMECC_Init() function follows the RAMECC configuration procedures
0147     as described in reference manual.
0148     The HAL_RAMECC_DeInit() function allows to deinitialize the RAMECC monitor.
0149 
0150 @endverbatim
0151   * @{
0152   */
0153 
0154 /**
0155   * @brief  Initialize the RAMECC by clearing flags and disabling interrupts.
0156   * @param  hramecc  Pointer to a RAMECC_HandleTypeDef structure that contains
0157   *                  the configuration information for the specified RAMECC
0158   *                  Monitor.
0159   * @retval HAL status.
0160   */
0161 HAL_StatusTypeDef HAL_RAMECC_Init(RAMECC_HandleTypeDef *hramecc)
0162 {
0163   /* Check the RAMECC peripheral handle */
0164   if (hramecc == NULL)
0165   {
0166     /* Return HAL status */
0167     return HAL_ERROR;
0168   }
0169 
0170   /* Check the parameters */
0171   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0172 
0173   /* Change RAMECC peripheral state */
0174   hramecc->State = HAL_RAMECC_STATE_BUSY;
0175 
0176   /* Disable RAMECC monitor */
0177   hramecc->Instance->CR &= ~RAMECC_CR_ECCELEN;
0178 
0179   /* Disable all global interrupts */
0180   ((RAMECC_TypeDef *)((uint32_t)hramecc->Instance & 0xFFFFFF00U))->IER &= \
0181     ~(RAMECC_IER_GIE | RAMECC_IER_GECCSEIE | RAMECC_IER_GECCDEIE | RAMECC_IER_GECCDEBWIE);
0182 
0183   /* Disable all interrupts monitor  */
0184   hramecc->Instance->CR &= ~(RAMECC_CR_ECCSEIE | RAMECC_CR_ECCDEIE | RAMECC_CR_ECCDEBWIE);
0185 
0186   /* Clear RAMECC monitor flags */
0187   __HAL_RAMECC_CLEAR_FLAG (hramecc, RAMECC_FLAGS_ALL);
0188 
0189   /* Initialise the RAMECC error code */
0190   hramecc->ErrorCode = HAL_RAMECC_ERROR_NONE;
0191 
0192   /* Initialise the RAMECC error detected code */
0193   hramecc->RAMECCErrorCode = HAL_RAMECC_NO_ERROR;
0194 
0195   /* Update the RAMECC state */
0196   hramecc->State = HAL_RAMECC_STATE_READY;
0197 
0198   /* Return HAL status */
0199   return HAL_OK;
0200 }
0201 
0202 /**
0203   * @brief  DeInitializes the RAMECC peripheral.
0204   * @param  hramecc  Pointer to a RAMECC_HandleTypeDef structure that contains
0205   *                  the configuration information for the specified RAMECC
0206   *                  Monitor.
0207   * @retval HAL status.
0208   */
0209 HAL_StatusTypeDef HAL_RAMECC_DeInit(RAMECC_HandleTypeDef *hramecc)
0210 {
0211   /* Check the RAMECC peripheral handle */
0212   if (hramecc == NULL)
0213   {
0214     /* Return HAL status */
0215     return HAL_ERROR;
0216   }
0217 
0218   /* Check the parameters */
0219   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0220 
0221   /* Disable RAMECC monitor */
0222   hramecc->Instance->CR &= ~RAMECC_CR_ECCELEN;
0223 
0224   /* Disable all global interrupts */
0225   ((RAMECC_TypeDef *)((uint32_t)hramecc->Instance & 0xFFFFFF00U))->IER &= \
0226     ~(RAMECC_IER_GIE | RAMECC_IER_GECCSEIE | RAMECC_IER_GECCDEIE | RAMECC_IER_GECCDEBWIE);
0227 
0228   /* Disable all interrupts monitor  */
0229   hramecc->Instance->CR &= ~(RAMECC_CR_ECCSEIE | RAMECC_CR_ECCDEIE | RAMECC_CR_ECCDEBWIE);
0230 
0231   /* Clear RAMECC monitor flags */
0232   __HAL_RAMECC_CLEAR_FLAG (hramecc, RAMECC_FLAGS_ALL);
0233 
0234 #if (USE_HAL_RAMECC_REGISTER_CALLBACKS == 1)
0235   /* Clean callback */
0236   hramecc->DetectErrorCallback = NULL;
0237 #endif /* USE_HAL_RAMECC_REGISTER_CALLBACKS */
0238 
0239   /* Initialize the RAMECC error code */
0240   hramecc->ErrorCode = HAL_RAMECC_ERROR_NONE;
0241 
0242   /* Initialize the RAMECC error detected code */
0243   hramecc->RAMECCErrorCode = HAL_RAMECC_NO_ERROR;
0244 
0245   /* Change RAMECC peripheral state */
0246   hramecc->State = HAL_RAMECC_STATE_RESET;
0247 
0248   /* Return HAL status */
0249   return HAL_OK;
0250 }
0251 
0252 /**
0253   * @}
0254   */
0255 
0256 /** @addtogroup RAMECC_Exported_Functions_Group2
0257   *
0258 @verbatim
0259  ===============================================================================
0260                    #####  Monitoring operation functions  #####
0261  ===============================================================================
0262     [..]  This section provides functions allowing to:
0263       (+) Configure latching error information.
0264       (+) Configure RAMECC Global/Monitor interrupts.
0265       (+) Register and Unregister RAMECC callbacks
0266       (+) Handle RAMECC interrupt request
0267 
0268 @endverbatim
0269   * @{
0270   */
0271 
0272 /**
0273   * @brief  Starts the RAMECC latching error information.
0274   * @param  hramecc  Pointer to a RAMECC_HandleTypeDef structure that contains
0275   *                  the configuration information for the specified RAMECC
0276   *                  Monitor.
0277   * @retval HAL status.
0278   */
0279 HAL_StatusTypeDef HAL_RAMECC_StartMonitor(RAMECC_HandleTypeDef *hramecc)
0280 {
0281   /* Check the parameters */
0282   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0283 
0284   /* Check RAMECC state */
0285   if (hramecc->State == HAL_RAMECC_STATE_READY)
0286   {
0287     /* Change RAMECC peripheral state */
0288     hramecc->State = HAL_RAMECC_STATE_BUSY;
0289 
0290     /* Enable RAMECC monitor */
0291     hramecc->Instance->CR |= RAMECC_CR_ECCELEN;
0292 
0293     /* Change RAMECC peripheral state */
0294     hramecc->State = HAL_RAMECC_STATE_READY;
0295   }
0296   else
0297   {
0298     /* Update the error code */
0299     hramecc->ErrorCode = HAL_RAMECC_ERROR_BUSY;
0300 
0301     /* Return HAL status */
0302     return HAL_ERROR;
0303   }
0304 
0305   /* Return HAL status */
0306   return HAL_OK;
0307 }
0308 
0309 /**
0310   * @brief  Stop the RAMECC latching error information.
0311   * @param  hramecc  Pointer to a RAMECC_HandleTypeDef structure that contains
0312   *                  the configuration information for the specified RAMECC
0313   *                  Monitor.
0314   * @retval HAL status.
0315   */
0316 HAL_StatusTypeDef HAL_RAMECC_StopMonitor(RAMECC_HandleTypeDef *hramecc)
0317 {
0318   /* Check the parameters */
0319   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0320 
0321   /* Check RAMECC state */
0322   if (hramecc->State == HAL_RAMECC_STATE_READY)
0323   {
0324     /* Change RAMECC peripheral state */
0325     hramecc->State = HAL_RAMECC_STATE_BUSY;
0326 
0327     /* Disable RAMECC monitor */
0328     hramecc->Instance->CR &= ~RAMECC_CR_ECCELEN;
0329 
0330     /* Change RAMECC peripheral state */
0331     hramecc->State = HAL_RAMECC_STATE_READY;
0332   }
0333   else
0334   {
0335     /* Update the error code */
0336     hramecc->ErrorCode = HAL_RAMECC_ERROR_BUSY;
0337 
0338     /* Return HAL status */
0339     return HAL_ERROR;
0340   }
0341 
0342   /* Return HAL status */
0343   return HAL_OK;
0344 }
0345 
0346 /**
0347   * @brief  Enable the RAMECC error interrupts.
0348   * @param  hramecc        Pointer to a RAMECC_HandleTypeDef structure that
0349   *                        contains the configuration information for the
0350   *                        specified RAMECC Monitor.
0351   * @param  Notifications  Select the notification.
0352   * @retval HAL status.
0353   */
0354 HAL_StatusTypeDef HAL_RAMECC_EnableNotification(RAMECC_HandleTypeDef *hramecc, uint32_t Notifications)
0355 {
0356   /* Check the parameters */
0357   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0358   assert_param (IS_RAMECC_INTERRUPT (Notifications));
0359 
0360   /* Check RAMECC state */
0361   if (hramecc->State == HAL_RAMECC_STATE_READY)
0362   {
0363     /* Change RAMECC peripheral state */
0364     hramecc->State = HAL_RAMECC_STATE_BUSY;
0365 
0366     /* Enable RAMECC interrupts */
0367     __HAL_RAMECC_ENABLE_IT (hramecc, Notifications);
0368 
0369     /* Change RAMECC peripheral state */
0370     hramecc->State = HAL_RAMECC_STATE_READY;
0371   }
0372   else
0373   {
0374     /* Update the error code */
0375     hramecc->ErrorCode = HAL_RAMECC_ERROR_BUSY;
0376 
0377     /* Return HAL status */
0378     return HAL_ERROR;
0379   }
0380 
0381   /* Return HAL status */
0382   return HAL_OK;
0383 }
0384 
0385 /**
0386   * @brief  Disable the RAMECC error interrupts.
0387   * @param  hramecc        Pointer to a RAMECC_HandleTypeDef structure that
0388   *                        contains the configuration information for the
0389   *                        specified RAMECC Monitor.
0390   * @param  Notifications  Select the notification.
0391   * @retval HAL status.
0392   */
0393 HAL_StatusTypeDef HAL_RAMECC_DisableNotification(RAMECC_HandleTypeDef *hramecc, uint32_t Notifications)
0394 {
0395   /* Check the parameters */
0396   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0397   assert_param (IS_RAMECC_INTERRUPT (Notifications));
0398 
0399   /* Check RAMECC state */
0400   if (hramecc->State == HAL_RAMECC_STATE_READY)
0401   {
0402     /* Change RAMECC peripheral state */
0403     hramecc->State = HAL_RAMECC_STATE_BUSY;
0404 
0405     /* Disable RAMECC interrupts */
0406     __HAL_RAMECC_DISABLE_IT (hramecc, Notifications);
0407 
0408     /* Change RAMECC peripheral state */
0409     hramecc->State = HAL_RAMECC_STATE_READY;
0410   }
0411   else
0412   {
0413     /* Update the error code */
0414     hramecc->ErrorCode = HAL_RAMECC_ERROR_BUSY;
0415 
0416     /* Return HAL status */
0417     return HAL_ERROR;
0418   }
0419 
0420   /* Return HAL status */
0421   return HAL_OK;
0422 }
0423 
0424 /**
0425   * @}
0426   */
0427 
0428 /** @addtogroup RAMECC_Exported_Functions_Group3
0429   *
0430 @verbatim
0431  ===============================================================================
0432                ##### Handle Interrupt and Callbacks Functions  #####
0433  ===============================================================================
0434     [..]
0435       This section provides functions to handle RAMECC interrupts and
0436       Register / UnRegister the different callbacks.
0437     [..]
0438       The HAL_RAMECC_IRQHandler() function allows the user to handle the active RAMECC
0439       interrupt request.
0440       The HAL_RAMECC_RegisterCallback() function allows the user to register the selected
0441       RAMECC callbacks.
0442       The HAL_RAMECC_UnRegisterCallback() function allows the user to unregister the
0443       selected RAMECC callbacks.
0444 @endverbatim
0445   * @{
0446   */
0447 
0448 #if (USE_HAL_RAMECC_REGISTER_CALLBACKS == 1)
0449 /**
0450   * @brief  Register callbacks.
0451   * @param  hramecc    Pointer to a RAMECC_HandleTypeDef structure that contains
0452   *                    the configuration information for the specified RAMECC
0453   *                    Monitor.
0454   * @param  pCallback  pointer to private callbacsk function which has pointer to
0455   *                    a RAMECC_HandleTypeDef structure as parameter.
0456   * @retval HAL status.
0457   */
0458 HAL_StatusTypeDef HAL_RAMECC_RegisterCallback (RAMECC_HandleTypeDef *hramecc, void (* pCallback)(RAMECC_HandleTypeDef *_hramecc))
0459 {
0460   HAL_StatusTypeDef status = HAL_OK;
0461 
0462   if (pCallback == NULL)
0463   {
0464     /* Update the error code */
0465     hramecc->ErrorCode |= HAL_RAMECC_ERROR_INVALID_CALLBACK;
0466 
0467     /* Return HAL status */
0468     return HAL_ERROR;
0469   }
0470 
0471   /* Check the parameters */
0472   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0473 
0474   /* Check RAMECC state */
0475   if (hramecc->State == HAL_RAMECC_STATE_READY)
0476   {
0477     hramecc->DetectErrorCallback = pCallback;
0478   }
0479   else
0480   {
0481     /* Update the error code */
0482     hramecc->ErrorCode = HAL_RAMECC_ERROR_INVALID_CALLBACK;
0483 
0484     /* Update HAL status */
0485     status = HAL_ERROR;
0486   }
0487 
0488   /* Return HAL status */
0489   return status;
0490 }
0491 
0492 /**
0493   * @brief  UnRegister callbacks.
0494   * @param  hramecc    Pointer to a RAMECC_HandleTypeDef structure that contains
0495   *                    the configuration information for the specified RAMECC
0496   *                    Monitor.
0497   * @retval HAL status.
0498   */
0499 HAL_StatusTypeDef HAL_RAMECC_UnRegisterCallback(RAMECC_HandleTypeDef *hramecc)
0500 {
0501   HAL_StatusTypeDef status = HAL_OK;
0502 
0503   /* Check the parameters */
0504   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0505 
0506   /* Check RAMECC state */
0507   if (hramecc->State == HAL_RAMECC_STATE_READY)
0508   {
0509     hramecc->DetectErrorCallback = NULL;
0510   }
0511   else
0512   {
0513     /* Update the error code */
0514     hramecc->ErrorCode = HAL_RAMECC_ERROR_INVALID_CALLBACK;
0515 
0516     /* Update HAL status */
0517     status = HAL_ERROR;
0518   }
0519 
0520   /* Return HAL status */
0521   return status;
0522 }
0523 #endif /* USE_HAL_RAMECC_REGISTER_CALLBACKS */
0524 
0525 /**
0526   * @brief  Handles RAMECC interrupt request.
0527   * @param  hramecc  Pointer to a RAMECC_HandleTypeDef structure that contains
0528   *                  the configuration information for the specified RAMECC
0529   *                  Monitor.
0530   * @retval None.
0531   */
0532 void HAL_RAMECC_IRQHandler(RAMECC_HandleTypeDef *hramecc)
0533 {
0534   uint32_t ier_reg = ((RAMECC_TypeDef *)((uint32_t)hramecc->Instance & 0xFFFFFF00U))->IER;
0535   uint32_t cr_reg = hramecc->Instance->CR >> 1U;
0536   uint32_t sr_reg = hramecc->Instance->SR;
0537 
0538   /* Update global interrupt variables */
0539   if ((ier_reg & RAMECC_IER_GIE) == RAMECC_IER_GIE)
0540   {
0541     ier_reg = RAMECC_IT_GLOBAL_ALL;
0542   }
0543 
0544   /* Store the ECC Single error detected */
0545   if ((sr_reg & RAMECC_SR_SEDCF) == RAMECC_SR_SEDCF)
0546   {
0547     hramecc->RAMECCErrorCode |= HAL_RAMECC_SINGLEERROR_DETECTED;
0548   }
0549 
0550   /* Store the ECC double error detected */
0551   if ((sr_reg & (RAMECC_SR_DEDF | RAMECC_SR_DEBWDF)) != 0U)
0552   {
0553     hramecc->RAMECCErrorCode |= HAL_RAMECC_DOUBLEERROR_DETECTED;
0554   }
0555 
0556   /* Clear active flags */
0557   __HAL_RAMECC_CLEAR_FLAG (hramecc, (((ier_reg | cr_reg) & (sr_reg << 1U)) >> 1U));
0558 
0559   /* Check if a valid double error callback is registered */
0560 #if (USE_HAL_RAMECC_REGISTER_CALLBACKS == 1)
0561   /* Check if a valid error callback is registered */
0562   if (hramecc->DetectErrorCallback != NULL)
0563   {
0564     /* Error detection callback */
0565     hramecc->DetectErrorCallback(hramecc);
0566   }
0567 #else
0568   HAL_RAMECC_DetectErrorCallback(hramecc);
0569 #endif /* USE_HAL_RAMECC_REGISTER_CALLBACKS */
0570 }
0571 
0572 /**
0573   * @brief  RAMECC error detection callback.
0574   * @param  hramecc : Pointer to a RAMECC_HandleTypeDef structure that contains
0575   *                   the configuration information for the specified RAMECC.
0576   * @retval None.
0577   */
0578 __weak void HAL_RAMECC_DetectErrorCallback(RAMECC_HandleTypeDef *hramecc)
0579 {
0580   /* Prevent unused argument(s) compilation warning */
0581   UNUSED(hramecc);
0582 
0583   /* NOTE : This function should not be modified, when the callback is needed,
0584             the HAL_RAMECC_DetectDoubleErrorCallback can be implemented in
0585             the user file.                                                    */
0586 }
0587 
0588 /**
0589   * @}
0590   */
0591 
0592 /** @addtogroup RAMECC_Exported_Functions_Group4
0593   *
0594 @verbatim
0595  ===============================================================================
0596                    #####  Error information functions  #####
0597  ===============================================================================
0598     [..]  This section provides functions allowing to:
0599       (+) Get failing address.
0600       (+) Get failing data low.
0601       (+) Get failing data high.
0602       (+) Get hamming bits injected.
0603       (+) Check single error flag.
0604       (+) Check double error flag.
0605 
0606 @endverbatim
0607   * @{
0608   */
0609 
0610 /**
0611   * @brief  Return the RAMECC failing address.
0612   * @param  hramecc  Pointer to a RAMECC_HandleTypeDef structure that contains
0613   *                  the configuration information for the specified RAMECC
0614   *                  Monitor.
0615   * @retval Failing address offset.
0616   */
0617 uint32_t HAL_RAMECC_GetFailingAddress(RAMECC_HandleTypeDef *hramecc)
0618 {
0619   /* Check the parameters */
0620   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0621 
0622   /* Return failing address */
0623   return hramecc->Instance->FAR;
0624 }
0625 
0626 /**
0627   * @brief  Return the RAMECC data low.
0628   * @param  hramecc  Pointer to a RAMECC_HandleTypeDef structure that contains
0629   *                  the configuration information for the specified RAMECC
0630   *                  Monitor.
0631   * @retval Failing data low.
0632   */
0633 uint32_t HAL_RAMECC_GetFailingDataLow(RAMECC_HandleTypeDef *hramecc)
0634 {
0635   /* Check the parameters */
0636   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0637 
0638   /* Return failing data low */
0639   return hramecc->Instance->FDRL;
0640 }
0641 
0642 /**
0643   * @brief  Return the RAMECC data high.
0644   * @param  hramecc  Pointer to a RAMECC_HandleTypeDef structure that contains
0645   *                  the configuration information for the specified RAMECC
0646   *                  Monitor.
0647   * @retval Failing data high.
0648   */
0649 uint32_t HAL_RAMECC_GetFailingDataHigh(RAMECC_HandleTypeDef *hramecc)
0650 {
0651   /* Check the parameters */
0652   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0653 
0654   /* Return failing data high */
0655   return hramecc->Instance->FDRH;
0656 }
0657 
0658 /**
0659   * @brief  Return the RAMECC Hamming bits injected.
0660   * @param  hramecc  Pointer to a RAMECC_HandleTypeDef structure that contains
0661   *                  the configuration information for the specified RAMECC
0662   *                  Monitor.
0663   * @retval Hamming bits injected.
0664   */
0665 uint32_t HAL_RAMECC_GetHammingErrorCode(RAMECC_HandleTypeDef *hramecc)
0666 {
0667   /* Check the parameters */
0668   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0669 
0670   /* Return hamming bits injected */
0671   return hramecc->Instance->FECR;
0672 }
0673 
0674 /**
0675   * @brief  Check if an ECC single error was occurred.
0676   * @param  hramecc  Pointer to a RAMECC_HandleTypeDef structure that contains
0677   *                  the configuration information for the specified RAMECC
0678   *                  Monitor.
0679   * @retval State of bit (1 or 0).
0680   */
0681 uint32_t HAL_RAMECC_IsECCSingleErrorDetected(RAMECC_HandleTypeDef *hramecc)
0682 {
0683   /* Check the parameters */
0684   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0685 
0686   /* Return the state of SEDC flag */
0687   return ((READ_BIT(hramecc->Instance->SR, RAMECC_SR_SEDCF) == (RAMECC_SR_SEDCF)) ? 1UL : 0UL);
0688 }
0689 
0690 /**
0691   * @brief  Check if an ECC double error was occurred.
0692   * @param  hramecc  Pointer to a RAMECC_HandleTypeDef structure that contains
0693   *                  the configuration information for the specified RAMECC
0694   *                  Monitor.
0695   * @retval State of bit (1 or 0).
0696   */
0697 uint32_t HAL_RAMECC_IsECCDoubleErrorDetected(RAMECC_HandleTypeDef *hramecc)
0698 {
0699   /* Check the parameters */
0700   assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
0701 
0702   /* Return the state of DEDF | DEBWDF flags */
0703   return ((READ_BIT(hramecc->Instance->SR, (RAMECC_SR_DEDF | RAMECC_SR_DEBWDF)) != 0U) ? 1UL : 0UL);
0704 }
0705 
0706 /**
0707   * @}
0708   */
0709 
0710 /** @addtogroup RAMECC_Exported_Functions_Group5
0711   *
0712 @verbatim
0713  ===============================================================================
0714                     ##### State and Error Functions  #####
0715  ===============================================================================
0716     [..]
0717     This section provides functions allowing to check and get the RAMECC state
0718     and the error code .
0719     [..]
0720     The HAL_RAMECC_GetState() function allows to get the RAMECC peripheral
0721     state.
0722     The HAL_RAMECC_GetError() function allows to Get the RAMECC peripheral error
0723     code.
0724     The HAL_RAMECC_GetRAMECCError() function allows to Get the RAMECC error code
0725     detected.
0726 
0727 @endverbatim
0728   * @{
0729   */
0730 
0731 /**
0732   * @brief  Get the RAMECC peripheral state.
0733   * @param  hramecc       : Pointer to a RAMECC_HandleTypeDef structure that
0734   *                         contains the configuration information for the
0735   *                         specified RAMECC instance.
0736   * @retval RAMECC state.
0737   */
0738 HAL_RAMECC_StateTypeDef HAL_RAMECC_GetState(RAMECC_HandleTypeDef *hramecc)
0739 {
0740   /* Return the RAMECC state */
0741   return hramecc->State;
0742 }
0743 
0744 /**
0745   * @brief  Get the RAMECC peripheral error code.
0746   * @param  hramecc       : Pointer to a RAMECC_HandleTypeDef structure that
0747   *                         contains the configuration information for the
0748   *                         specified RAMECC instance.
0749   * @retval RAMECC error code.
0750   */
0751 uint32_t HAL_RAMECC_GetError(RAMECC_HandleTypeDef *hramecc)
0752 {
0753   /* Return the RAMECC error code */
0754   return hramecc->ErrorCode;
0755 }
0756 
0757 /**
0758   * @brief  Get the RAMECC error code detected.
0759   * @param  hramecc       : Pointer to a RAMECC_HandleTypeDef structure that
0760   *                         contains the configuration information for the
0761   *                         specified RAMECC instance.
0762   * @retval RAMECC error code detected.
0763   */
0764 uint32_t HAL_RAMECC_GetRAMECCError(RAMECC_HandleTypeDef *hramecc)
0765 {
0766   /* Return the RAMECC error code detected*/
0767   return hramecc->RAMECCErrorCode;
0768 }
0769 
0770 /**
0771   * @}
0772   */
0773 #endif /* HAL_RAMECC_MODULE_ENABLED */
0774 /**
0775   * @}
0776   */
0777 
0778 /**
0779   * @}
0780   */