S32 SDK
erm_hal.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016 NXP
4  * All rights reserved.
5  *
6  * THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
7  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
9  * IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
10  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
11  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
12  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
14  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
15  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
16  * THE POSSIBILITY OF SUCH DAMAGE.
17  */
26 #include "erm_hal.h"
27 
28 /*******************************************************************************
29  * Variables
30  ******************************************************************************/
31 
32 /*******************************************************************************
33  * Code
34  ******************************************************************************/
35 /*FUNCTION**********************************************************************
36  *
37  * Function Name : ERM_HAL_Init
38  * Description : This function initializes the module to default configuration,
39  * the configuration register is initialized with interrupt notification disabled
40  * for all channels and the status register events are cleared.
41  *
42  * Implements : ERM_HAL_Init_Activity
43  *END**************************************************************************/
44 void ERM_HAL_Init(ERM_Type * const base)
45 {
46  base->CR0 = 0UL;
47  /* Write 1 to clear flags */
48  base->SR0 = 0xFFFFFFFFUL;
49 }
50 
51 /*FUNCTION**********************************************************************
52  *
53  * Function Name : ERM_HAL_GetErrorDetail
54  * Description : This function gets the address of the last ECC event
55  * in Memory n and ECC event.
56  *
57  * Implements : ERM_HAL_GetErrorDetail_Activity
58  *END**************************************************************************/
60  uint8_t channel,
61  uint32_t * addressPtr)
62 {
63  DEV_ASSERT(addressPtr != NULL);
65 
66  /* Single-bit correction ECC events */
67  if (ERM_HAL_IsEventDetected(base, channel, ERM_EVENT_SINGLE_BIT) != false)
68  {
69  /* Assign eccEvent is Single-bit correction ECC events */
70  eccEvent = ERM_EVENT_SINGLE_BIT;
71  /* Address */
72  *addressPtr = ERM_HAL_GetLastErrorAddress(base, channel);
73  }
74  /* Non-correctable ECC events */
75  else
76  {
77  if (ERM_HAL_IsEventDetected(base, channel, ERM_EVENT_NON_CORRECTABLE) != false)
78  {
79  /* Assign eccEvent is Non-correctable ECC events */
80  eccEvent = ERM_EVENT_NON_CORRECTABLE;
81  /* Address */
82  *addressPtr = ERM_HAL_GetLastErrorAddress(base, channel);
83  }
84  }
85 
86  return eccEvent;
87 }
88 
89 /*******************************************************************************
90  * EOF
91  ******************************************************************************/
void ERM_HAL_Init(ERM_Type *const base)
Initializes the ERM module.
Definition: erm_hal.c:44
static uint32_t ERM_HAL_GetLastErrorAddress(const ERM_Type *const base, uint8_t channel)
Gets the address of the last ECC event in Memory n.
Definition: erm_hal.h:253
__IO uint32_t CR0
Definition: S32K144.h:3259
#define DEV_ASSERT(x)
Definition: devassert.h:78
erm_ecc_event_t
ERM types of ECC events Implements : erm_ecc_event_t_Class.
Definition: erm_hal.h:49
erm_ecc_event_t ERM_HAL_GetErrorDetail(const ERM_Type *const base, uint8_t channel, uint32_t *addressPtr)
Gets the address of the last ECC event in Memory n and ECC event.
Definition: erm_hal.c:59
static bool ERM_HAL_IsEventDetected(const ERM_Type *const base, uint8_t channel, erm_ecc_event_t eccEvent)
Checks if the Memory n error event is detected.
Definition: erm_hal.h:183
__IO uint32_t SR0
Definition: S32K144.h:3261