1 /**
2 ******************************************************************************
3 * @file stm32h7xx_hal_ramecc.c
4 * @author MCD Application Team
5 * @brief RAMECC HAL module driver.
6 * This file provides firmware functions to manage the following
7 * functionalities of the RAM ECC monitoring (RAMECC) peripheral:
8 * + Initialization and de-initialization functions
9 * + Monitoring operation functions
10 * + Error information functions
11 * + State and error functions
12 ******************************************************************************
13 * @attention
14 *
15 * Copyright (c) 2017 STMicroelectronics.
16 * All rights reserved.
17 *
18 * This software is licensed under terms that can be found in the LICENSE file
19 * in the root directory of this software component.
20 * If no LICENSE file comes with this software, it is provided AS-IS.
21 *
22 ******************************************************************************
23 @verbatim
24 ==============================================================================
25 ##### How to use this driver #####
26 ==============================================================================
27 [..]
28 (#) Enable and latch error information through HAL_RAMECC_Init().
29
30 (#) For a given Monitor, enable and disable interrupt through
31 HAL_RAMECC_EnableNotification().
32 To enable a notification for a given RAMECC instance, use global
33 interrupts.
34 To enable a notification for only RAMECC monitor, use monitor interrupts.
35 All possible notifications are defined in the driver header file under
36 RAMECC_Interrupt group.
37
38 *** Silent mode ***
39 ===================
40 [..]
41 (+) Use HAL_RAMECC_StartMonitor() to start RAMECC latch failing
42 information without enabling any notification.
43
44 *** Interrupt mode ***
45 ======================
46 [..]
47 (+) Use HAL_RAMECC_EnableNotification() to enable interrupts for a
48 given error.
49 (+) Configure the RAMECC interrupt priority using
50 HAL_NVIC_SetPriority().
51 (+) Enable the RAMECC IRQ handler using HAL_NVIC_EnableIRQ().
52 (+) Start RAMECC latch failing information using HAL_RAMECC_StartMonitor().
53
54 *** Failing information ***
55 ======================
56 [..]
57 (#) Use HAL_RAMECC_GetFailingAddress() function to return the RAMECC
58 failing address.
59 (#) Use HAL_RAMECC_GetFailingDataLow() function to return the RAMECC
60 failing data low.
61 (#) Use HAL_RAMECC_GetFailingDataHigh() function to return the RAMECC
62 failing data high.
63 (#) Use HAL_RAMECC_GetHammingErrorCode() function to return the RAMECC
64 Hamming bits injected.
65 (#) Use HAL_RAMECC_IsECCSingleErrorDetected() function to check if a single
66 error was detected and corrected.
67 (#) Use HAL_RAMECC_IsECCDoubleErrorDetected() function to check if a double
68 error was dedetected.
69
70 *** RAMECC HAL driver macros list ***
71 =============================================
72 [..]
73 Below the list of used macros in RAMECC HAL driver.
74
75 (+) __HAL_RAMECC_ENABLE_IT : Enable the specified ECCRAM Monitor
76 interrupts.
77 (+) __HAL_RAMECC_DISABLE_IT : Disable the specified ECCRAM Monitor
78 interrupts.
79 (+) __HAL_RAMECC_GET_FLAG : Return the current RAMECC Monitor selected
80 flag.
81 (+) __HAL_RAMECC_CLEAR_FLAG : Clear the current RAMECC Monitor selected
82 flag.
83
84 ##### Callback registration #####
85 ==================================
86 [..]
87 (#) The compilation define USE_HAL_RAMECC_REGISTER_CALLBACKS when set to 1
88 allows the user to configure dynamically the driver callback.
89
90 [..]
91 (#) Use Function HAL_RAMECC_RegisterCallback() to register a user callback.
92 (#) Function HAL_RAMECC_RegisterCallback() allows to register following callback:
93 (+) RAMECCErrorCode : RAMECC error code detection.
94 (#) This function takes as parameters the HAL peripheral handle
95 and a pointer to the user callback function.
96
97 [..]
98 (#) Use function HAL_RAMECC_UnRegisterCallback() to reset a callback to the default
99 weak function.
100 (#) HAL_RAMECC_UnRegisterCallback() takes as parameters the HAL peripheral handle.
101 (#) This function allows to reset following callback:
102 (+) RAMECCErrorCode : RAMECC error code detection.
103 [..]
104 (#) When The compilation define USE_HAL_RAMECC_REGISTER_CALLBACKS is set to 0 or
105 not defined, the callback registration feature is not available
106 and weak callbacks are used.
107
108 @endverbatim
109 */
110
111 /* Includes ------------------------------------------------------------------*/
112 #include "stm32h7xx_hal.h"
113
114 /** @addtogroup STM32H7xx_HAL_Driver
115 * @{
116 */
117
118 /** @defgroup RAMECC RAMECC
119 * @brief RAMECC HAL module driver
120 * @{
121 */
122
123 #ifdef HAL_RAMECC_MODULE_ENABLED
124
125 /* Private types -------------------------------------------------------------*/
126 /* Private variables ---------------------------------------------------------*/
127 /* Private constants ---------------------------------------------------------*/
128 /* Private macros ------------------------------------------------------------*/
129 /* Private functions ---------------------------------------------------------*/
130 /* Exported functions --------------------------------------------------------*/
131
132 /** @addtogroup RAMECC_Exported_Functions
133 * @{
134 */
135
136 /** @addtogroup RAMECC_Exported_Functions_Group1
137 *
138 @verbatim
139 ===============================================================================
140 ##### Initialization and de-initialization functions #####
141 ===============================================================================
142 [..]
143 This section provides functions allowing to initialize the RAMECC Monitor.
144 [..]
145 The HAL_RAMECC_Init() function follows the RAMECC configuration procedures
146 as described in reference manual.
147 The HAL_RAMECC_DeInit() function allows to deinitialize the RAMECC monitor.
148
149 @endverbatim
150 * @{
151 */
152
153 /**
154 * @brief Initialize the RAMECC by clearing flags and disabling interrupts.
155 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that contains
156 * the configuration information for the specified RAMECC
157 * Monitor.
158 * @retval HAL status.
159 */
HAL_RAMECC_Init(RAMECC_HandleTypeDef * hramecc)160 HAL_StatusTypeDef HAL_RAMECC_Init(RAMECC_HandleTypeDef *hramecc)
161 {
162 /* Check the RAMECC peripheral handle */
163 if (hramecc == NULL)
164 {
165 /* Return HAL status */
166 return HAL_ERROR;
167 }
168
169 /* Check the parameters */
170 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
171
172 /* Change RAMECC peripheral state */
173 hramecc->State = HAL_RAMECC_STATE_BUSY;
174
175 /* Disable RAMECC monitor */
176 hramecc->Instance->CR &= ~RAMECC_CR_ECCELEN;
177
178 /* Disable all global interrupts */
179 ((RAMECC_TypeDef *)((uint32_t)hramecc->Instance & 0xFFFFFF00U))->IER &= \
180 ~(RAMECC_IER_GIE | RAMECC_IER_GECCSEIE | RAMECC_IER_GECCDEIE | RAMECC_IER_GECCDEBWIE);
181
182 /* Disable all interrupts monitor */
183 hramecc->Instance->CR &= ~(RAMECC_CR_ECCSEIE | RAMECC_CR_ECCDEIE | RAMECC_CR_ECCDEBWIE);
184
185 /* Clear RAMECC monitor flags */
186 __HAL_RAMECC_CLEAR_FLAG (hramecc, RAMECC_FLAGS_ALL);
187
188 /* Initialise the RAMECC error code */
189 hramecc->ErrorCode = HAL_RAMECC_ERROR_NONE;
190
191 /* Initialise the RAMECC error detected code */
192 hramecc->RAMECCErrorCode = HAL_RAMECC_NO_ERROR;
193
194 /* Update the RAMECC state */
195 hramecc->State = HAL_RAMECC_STATE_READY;
196
197 /* Return HAL status */
198 return HAL_OK;
199 }
200
201 /**
202 * @brief DeInitializes the RAMECC peripheral.
203 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that contains
204 * the configuration information for the specified RAMECC
205 * Monitor.
206 * @retval HAL status.
207 */
HAL_RAMECC_DeInit(RAMECC_HandleTypeDef * hramecc)208 HAL_StatusTypeDef HAL_RAMECC_DeInit(RAMECC_HandleTypeDef *hramecc)
209 {
210 /* Check the RAMECC peripheral handle */
211 if (hramecc == NULL)
212 {
213 /* Return HAL status */
214 return HAL_ERROR;
215 }
216
217 /* Check the parameters */
218 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
219
220 /* Disable RAMECC monitor */
221 hramecc->Instance->CR &= ~RAMECC_CR_ECCELEN;
222
223 /* Disable all global interrupts */
224 ((RAMECC_TypeDef *)((uint32_t)hramecc->Instance & 0xFFFFFF00U))->IER &= \
225 ~(RAMECC_IER_GIE | RAMECC_IER_GECCSEIE | RAMECC_IER_GECCDEIE | RAMECC_IER_GECCDEBWIE);
226
227 /* Disable all interrupts monitor */
228 hramecc->Instance->CR &= ~(RAMECC_CR_ECCSEIE | RAMECC_CR_ECCDEIE | RAMECC_CR_ECCDEBWIE);
229
230 /* Clear RAMECC monitor flags */
231 __HAL_RAMECC_CLEAR_FLAG (hramecc, RAMECC_FLAGS_ALL);
232
233 #if (USE_HAL_RAMECC_REGISTER_CALLBACKS == 1)
234 /* Clean callback */
235 hramecc->DetectErrorCallback = NULL;
236 #endif /* USE_HAL_RAMECC_REGISTER_CALLBACKS */
237
238 /* Initialize the RAMECC error code */
239 hramecc->ErrorCode = HAL_RAMECC_ERROR_NONE;
240
241 /* Initialize the RAMECC error detected code */
242 hramecc->RAMECCErrorCode = HAL_RAMECC_NO_ERROR;
243
244 /* Change RAMECC peripheral state */
245 hramecc->State = HAL_RAMECC_STATE_RESET;
246
247 /* Return HAL status */
248 return HAL_OK;
249 }
250
251 /**
252 * @}
253 */
254
255 /** @addtogroup RAMECC_Exported_Functions_Group2
256 *
257 @verbatim
258 ===============================================================================
259 ##### Monitoring operation functions #####
260 ===============================================================================
261 [..] This section provides functions allowing to:
262 (+) Configure latching error information.
263 (+) Configure RAMECC Global/Monitor interrupts.
264 (+) Register and Unregister RAMECC callbacks
265 (+) Handle RAMECC interrupt request
266
267 @endverbatim
268 * @{
269 */
270
271 /**
272 * @brief Starts the RAMECC latching error information.
273 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that contains
274 * the configuration information for the specified RAMECC
275 * Monitor.
276 * @retval HAL status.
277 */
HAL_RAMECC_StartMonitor(RAMECC_HandleTypeDef * hramecc)278 HAL_StatusTypeDef HAL_RAMECC_StartMonitor(RAMECC_HandleTypeDef *hramecc)
279 {
280 /* Check the parameters */
281 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
282
283 /* Check RAMECC state */
284 if (hramecc->State == HAL_RAMECC_STATE_READY)
285 {
286 /* Change RAMECC peripheral state */
287 hramecc->State = HAL_RAMECC_STATE_BUSY;
288
289 /* Enable RAMECC monitor */
290 hramecc->Instance->CR |= RAMECC_CR_ECCELEN;
291
292 /* Change RAMECC peripheral state */
293 hramecc->State = HAL_RAMECC_STATE_READY;
294 }
295 else
296 {
297 /* Update the error code */
298 hramecc->ErrorCode = HAL_RAMECC_ERROR_BUSY;
299
300 /* Return HAL status */
301 return HAL_ERROR;
302 }
303
304 /* Return HAL status */
305 return HAL_OK;
306 }
307
308 /**
309 * @brief Stop the RAMECC latching error information.
310 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that contains
311 * the configuration information for the specified RAMECC
312 * Monitor.
313 * @retval HAL status.
314 */
HAL_RAMECC_StopMonitor(RAMECC_HandleTypeDef * hramecc)315 HAL_StatusTypeDef HAL_RAMECC_StopMonitor(RAMECC_HandleTypeDef *hramecc)
316 {
317 /* Check the parameters */
318 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
319
320 /* Check RAMECC state */
321 if (hramecc->State == HAL_RAMECC_STATE_READY)
322 {
323 /* Change RAMECC peripheral state */
324 hramecc->State = HAL_RAMECC_STATE_BUSY;
325
326 /* Disable RAMECC monitor */
327 hramecc->Instance->CR &= ~RAMECC_CR_ECCELEN;
328
329 /* Change RAMECC peripheral state */
330 hramecc->State = HAL_RAMECC_STATE_READY;
331 }
332 else
333 {
334 /* Update the error code */
335 hramecc->ErrorCode = HAL_RAMECC_ERROR_BUSY;
336
337 /* Return HAL status */
338 return HAL_ERROR;
339 }
340
341 /* Return HAL status */
342 return HAL_OK;
343 }
344
345 /**
346 * @brief Enable the RAMECC error interrupts.
347 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that
348 * contains the configuration information for the
349 * specified RAMECC Monitor.
350 * @param Notifications Select the notification.
351 * @retval HAL status.
352 */
HAL_RAMECC_EnableNotification(RAMECC_HandleTypeDef * hramecc,uint32_t Notifications)353 HAL_StatusTypeDef HAL_RAMECC_EnableNotification(RAMECC_HandleTypeDef *hramecc, uint32_t Notifications)
354 {
355 /* Check the parameters */
356 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
357 assert_param (IS_RAMECC_INTERRUPT (Notifications));
358
359 /* Check RAMECC state */
360 if (hramecc->State == HAL_RAMECC_STATE_READY)
361 {
362 /* Change RAMECC peripheral state */
363 hramecc->State = HAL_RAMECC_STATE_BUSY;
364
365 /* Enable RAMECC interrupts */
366 __HAL_RAMECC_ENABLE_IT (hramecc, Notifications);
367
368 /* Change RAMECC peripheral state */
369 hramecc->State = HAL_RAMECC_STATE_READY;
370 }
371 else
372 {
373 /* Update the error code */
374 hramecc->ErrorCode = HAL_RAMECC_ERROR_BUSY;
375
376 /* Return HAL status */
377 return HAL_ERROR;
378 }
379
380 /* Return HAL status */
381 return HAL_OK;
382 }
383
384 /**
385 * @brief Disable the RAMECC error interrupts.
386 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that
387 * contains the configuration information for the
388 * specified RAMECC Monitor.
389 * @param Notifications Select the notification.
390 * @retval HAL status.
391 */
HAL_RAMECC_DisableNotification(RAMECC_HandleTypeDef * hramecc,uint32_t Notifications)392 HAL_StatusTypeDef HAL_RAMECC_DisableNotification(RAMECC_HandleTypeDef *hramecc, uint32_t Notifications)
393 {
394 /* Check the parameters */
395 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
396 assert_param (IS_RAMECC_INTERRUPT (Notifications));
397
398 /* Check RAMECC state */
399 if (hramecc->State == HAL_RAMECC_STATE_READY)
400 {
401 /* Change RAMECC peripheral state */
402 hramecc->State = HAL_RAMECC_STATE_BUSY;
403
404 /* Disable RAMECC interrupts */
405 __HAL_RAMECC_DISABLE_IT (hramecc, Notifications);
406
407 /* Change RAMECC peripheral state */
408 hramecc->State = HAL_RAMECC_STATE_READY;
409 }
410 else
411 {
412 /* Update the error code */
413 hramecc->ErrorCode = HAL_RAMECC_ERROR_BUSY;
414
415 /* Return HAL status */
416 return HAL_ERROR;
417 }
418
419 /* Return HAL status */
420 return HAL_OK;
421 }
422
423 /**
424 * @}
425 */
426
427 /** @addtogroup RAMECC_Exported_Functions_Group3
428 *
429 @verbatim
430 ===============================================================================
431 ##### Handle Interrupt and Callbacks Functions #####
432 ===============================================================================
433 [..]
434 This section provides functions to handle RAMECC interrupts and
435 Register / UnRegister the different callbacks.
436 [..]
437 The HAL_RAMECC_IRQHandler() function allows the user to handle the active RAMECC
438 interrupt request.
439 The HAL_RAMECC_RegisterCallback() function allows the user to register the selected
440 RAMECC callbacks.
441 The HAL_RAMECC_UnRegisterCallback() function allows the user to unregister the
442 selected RAMECC callbacks.
443 @endverbatim
444 * @{
445 */
446
447 #if (USE_HAL_RAMECC_REGISTER_CALLBACKS == 1)
448 /**
449 * @brief Register callbacks.
450 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that contains
451 * the configuration information for the specified RAMECC
452 * Monitor.
453 * @param pCallback pointer to private callbacsk function which has pointer to
454 * a RAMECC_HandleTypeDef structure as parameter.
455 * @retval HAL status.
456 */
HAL_RAMECC_RegisterCallback(RAMECC_HandleTypeDef * hramecc,void (* pCallback)(RAMECC_HandleTypeDef * _hramecc))457 HAL_StatusTypeDef HAL_RAMECC_RegisterCallback (RAMECC_HandleTypeDef *hramecc, void (* pCallback)(RAMECC_HandleTypeDef *_hramecc))
458 {
459 HAL_StatusTypeDef status = HAL_OK;
460
461 if (pCallback == NULL)
462 {
463 /* Update the error code */
464 hramecc->ErrorCode |= HAL_RAMECC_ERROR_INVALID_CALLBACK;
465
466 /* Return HAL status */
467 return HAL_ERROR;
468 }
469
470 /* Check the parameters */
471 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
472
473 /* Check RAMECC state */
474 if (hramecc->State == HAL_RAMECC_STATE_READY)
475 {
476 hramecc->DetectErrorCallback = pCallback;
477 }
478 else
479 {
480 /* Update the error code */
481 hramecc->ErrorCode = HAL_RAMECC_ERROR_INVALID_CALLBACK;
482
483 /* Update HAL status */
484 status = HAL_ERROR;
485 }
486
487 /* Return HAL status */
488 return status;
489 }
490
491 /**
492 * @brief UnRegister callbacks.
493 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that contains
494 * the configuration information for the specified RAMECC
495 * Monitor.
496 * @retval HAL status.
497 */
HAL_RAMECC_UnRegisterCallback(RAMECC_HandleTypeDef * hramecc)498 HAL_StatusTypeDef HAL_RAMECC_UnRegisterCallback(RAMECC_HandleTypeDef *hramecc)
499 {
500 HAL_StatusTypeDef status = HAL_OK;
501
502 /* Check the parameters */
503 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
504
505 /* Check RAMECC state */
506 if (hramecc->State == HAL_RAMECC_STATE_READY)
507 {
508 hramecc->DetectErrorCallback = NULL;
509 }
510 else
511 {
512 /* Update the error code */
513 hramecc->ErrorCode = HAL_RAMECC_ERROR_INVALID_CALLBACK;
514
515 /* Update HAL status */
516 status = HAL_ERROR;
517 }
518
519 /* Return HAL status */
520 return status;
521 }
522 #endif /* USE_HAL_RAMECC_REGISTER_CALLBACKS */
523
524 /**
525 * @brief Handles RAMECC interrupt request.
526 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that contains
527 * the configuration information for the specified RAMECC
528 * Monitor.
529 * @retval None.
530 */
HAL_RAMECC_IRQHandler(RAMECC_HandleTypeDef * hramecc)531 void HAL_RAMECC_IRQHandler(RAMECC_HandleTypeDef *hramecc)
532 {
533 uint32_t ier_reg = ((RAMECC_TypeDef *)((uint32_t)hramecc->Instance & 0xFFFFFF00U))->IER;
534 uint32_t cr_reg = hramecc->Instance->CR >> 1U;
535 uint32_t sr_reg = hramecc->Instance->SR;
536
537 /* Update global interrupt variables */
538 if ((ier_reg & RAMECC_IER_GIE) == RAMECC_IER_GIE)
539 {
540 ier_reg = RAMECC_IT_GLOBAL_ALL;
541 }
542
543 /* Store the ECC Single error detected */
544 if ((sr_reg & RAMECC_SR_SEDCF) == RAMECC_SR_SEDCF)
545 {
546 hramecc->RAMECCErrorCode |= HAL_RAMECC_SINGLEERROR_DETECTED;
547 }
548
549 /* Store the ECC double error detected */
550 if ((sr_reg & (RAMECC_SR_DEDF | RAMECC_SR_DEBWDF)) != 0U)
551 {
552 hramecc->RAMECCErrorCode |= HAL_RAMECC_DOUBLEERROR_DETECTED;
553 }
554
555 /* Clear active flags */
556 __HAL_RAMECC_CLEAR_FLAG (hramecc, (((ier_reg | cr_reg) & (sr_reg << 1U)) >> 1U));
557
558 /* Check if a valid double error callback is registered */
559 #if (USE_HAL_RAMECC_REGISTER_CALLBACKS == 1)
560 /* Check if a valid error callback is registered */
561 if (hramecc->DetectErrorCallback != NULL)
562 {
563 /* Error detection callback */
564 hramecc->DetectErrorCallback(hramecc);
565 }
566 #else
567 HAL_RAMECC_DetectErrorCallback(hramecc);
568 #endif /* USE_HAL_RAMECC_REGISTER_CALLBACKS */
569 }
570
571 /**
572 * @brief RAMECC error detection callback.
573 * @param hramecc : Pointer to a RAMECC_HandleTypeDef structure that contains
574 * the configuration information for the specified RAMECC.
575 * @retval None.
576 */
HAL_RAMECC_DetectErrorCallback(RAMECC_HandleTypeDef * hramecc)577 __weak void HAL_RAMECC_DetectErrorCallback(RAMECC_HandleTypeDef *hramecc)
578 {
579 /* Prevent unused argument(s) compilation warning */
580 UNUSED(hramecc);
581
582 /* NOTE : This function should not be modified, when the callback is needed,
583 the HAL_RAMECC_DetectDoubleErrorCallback can be implemented in
584 the user file. */
585 }
586
587 /**
588 * @}
589 */
590
591 /** @addtogroup RAMECC_Exported_Functions_Group4
592 *
593 @verbatim
594 ===============================================================================
595 ##### Error information functions #####
596 ===============================================================================
597 [..] This section provides functions allowing to:
598 (+) Get failing address.
599 (+) Get failing data low.
600 (+) Get failing data high.
601 (+) Get hamming bits injected.
602 (+) Check single error flag.
603 (+) Check double error flag.
604
605 @endverbatim
606 * @{
607 */
608
609 /**
610 * @brief Return the RAMECC failing address.
611 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that contains
612 * the configuration information for the specified RAMECC
613 * Monitor.
614 * @retval Failing address offset.
615 */
HAL_RAMECC_GetFailingAddress(const RAMECC_HandleTypeDef * hramecc)616 uint32_t HAL_RAMECC_GetFailingAddress(const RAMECC_HandleTypeDef *hramecc)
617 {
618 /* Check the parameters */
619 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
620
621 /* Return failing address */
622 return hramecc->Instance->FAR;
623 }
624
625 /**
626 * @brief Return the RAMECC data low.
627 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that contains
628 * the configuration information for the specified RAMECC
629 * Monitor.
630 * @retval Failing data low.
631 */
HAL_RAMECC_GetFailingDataLow(const RAMECC_HandleTypeDef * hramecc)632 uint32_t HAL_RAMECC_GetFailingDataLow(const RAMECC_HandleTypeDef *hramecc)
633 {
634 /* Check the parameters */
635 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
636
637 /* Return failing data low */
638 return hramecc->Instance->FDRL;
639 }
640
641 /**
642 * @brief Return the RAMECC data high.
643 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that contains
644 * the configuration information for the specified RAMECC
645 * Monitor.
646 * @retval Failing data high.
647 */
HAL_RAMECC_GetFailingDataHigh(const RAMECC_HandleTypeDef * hramecc)648 uint32_t HAL_RAMECC_GetFailingDataHigh(const RAMECC_HandleTypeDef *hramecc)
649 {
650 /* Check the parameters */
651 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
652
653 /* Return failing data high */
654 return hramecc->Instance->FDRH;
655 }
656
657 /**
658 * @brief Return the RAMECC Hamming bits injected.
659 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that contains
660 * the configuration information for the specified RAMECC
661 * Monitor.
662 * @retval Hamming bits injected.
663 */
HAL_RAMECC_GetHammingErrorCode(const RAMECC_HandleTypeDef * hramecc)664 uint32_t HAL_RAMECC_GetHammingErrorCode(const RAMECC_HandleTypeDef *hramecc)
665 {
666 /* Check the parameters */
667 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
668
669 /* Return hamming bits injected */
670 return hramecc->Instance->FECR;
671 }
672
673 /**
674 * @brief Check if an ECC single error was occurred.
675 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that contains
676 * the configuration information for the specified RAMECC
677 * Monitor.
678 * @retval State of bit (1 or 0).
679 */
HAL_RAMECC_IsECCSingleErrorDetected(const RAMECC_HandleTypeDef * hramecc)680 uint32_t HAL_RAMECC_IsECCSingleErrorDetected(const RAMECC_HandleTypeDef *hramecc)
681 {
682 /* Check the parameters */
683 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
684
685 /* Return the state of SEDC flag */
686 return ((READ_BIT(hramecc->Instance->SR, RAMECC_SR_SEDCF) == (RAMECC_SR_SEDCF)) ? 1UL : 0UL);
687 }
688
689 /**
690 * @brief Check if an ECC double error was occurred.
691 * @param hramecc Pointer to a RAMECC_HandleTypeDef structure that contains
692 * the configuration information for the specified RAMECC
693 * Monitor.
694 * @retval State of bit (1 or 0).
695 */
HAL_RAMECC_IsECCDoubleErrorDetected(const RAMECC_HandleTypeDef * hramecc)696 uint32_t HAL_RAMECC_IsECCDoubleErrorDetected(const RAMECC_HandleTypeDef *hramecc)
697 {
698 /* Check the parameters */
699 assert_param (IS_RAMECC_MONITOR_ALL_INSTANCE (hramecc->Instance));
700
701 /* Return the state of DEDF | DEBWDF flags */
702 return ((READ_BIT(hramecc->Instance->SR, (RAMECC_SR_DEDF | RAMECC_SR_DEBWDF)) != 0U) ? 1UL : 0UL);
703 }
704
705 /**
706 * @}
707 */
708
709 /** @addtogroup RAMECC_Exported_Functions_Group5
710 *
711 @verbatim
712 ===============================================================================
713 ##### State and Error Functions #####
714 ===============================================================================
715 [..]
716 This section provides functions allowing to check and get the RAMECC state
717 and the error code .
718 [..]
719 The HAL_RAMECC_GetState() function allows to get the RAMECC peripheral
720 state.
721 The HAL_RAMECC_GetError() function allows to Get the RAMECC peripheral error
722 code.
723 The HAL_RAMECC_GetRAMECCError() function allows to Get the RAMECC error code
724 detected.
725
726 @endverbatim
727 * @{
728 */
729
730 /**
731 * @brief Get the RAMECC peripheral state.
732 * @param hramecc : Pointer to a RAMECC_HandleTypeDef structure that
733 * contains the configuration information for the
734 * specified RAMECC instance.
735 * @retval RAMECC state.
736 */
HAL_RAMECC_GetState(const RAMECC_HandleTypeDef * hramecc)737 HAL_RAMECC_StateTypeDef HAL_RAMECC_GetState(const RAMECC_HandleTypeDef *hramecc)
738 {
739 /* Return the RAMECC state */
740 return hramecc->State;
741 }
742
743 /**
744 * @brief Get the RAMECC peripheral error code.
745 * @param hramecc : Pointer to a RAMECC_HandleTypeDef structure that
746 * contains the configuration information for the
747 * specified RAMECC instance.
748 * @retval RAMECC error code.
749 */
HAL_RAMECC_GetError(const RAMECC_HandleTypeDef * hramecc)750 uint32_t HAL_RAMECC_GetError(const RAMECC_HandleTypeDef *hramecc)
751 {
752 /* Return the RAMECC error code */
753 return hramecc->ErrorCode;
754 }
755
756 /**
757 * @brief Get the RAMECC error code detected.
758 * @param hramecc : Pointer to a RAMECC_HandleTypeDef structure that
759 * contains the configuration information for the
760 * specified RAMECC instance.
761 * @retval RAMECC error code detected.
762 */
HAL_RAMECC_GetRAMECCError(const RAMECC_HandleTypeDef * hramecc)763 uint32_t HAL_RAMECC_GetRAMECCError(const RAMECC_HandleTypeDef *hramecc)
764 {
765 /* Return the RAMECC error code detected*/
766 return hramecc->RAMECCErrorCode;
767 }
768
769 /**
770 * @}
771 */
772 #endif /* HAL_RAMECC_MODULE_ENABLED */
773 /**
774 * @}
775 */
776
777 /**
778 * @}
779 */
780