S32 SDK
erm_driver.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  */
37 #include "erm_driver.h"
38 
39 /*******************************************************************************
40  * Variables
41  ******************************************************************************/
42 /* Table of base addresses for ERM instances */
44 
45 /*******************************************************************************
46  * Code
47  ******************************************************************************/
48 /*FUNCTION**********************************************************************
49  *
50  * Function Name : ERM_DRV_Init
51  * Description : This function initializes ERM driver based on user configuration input,
52  * channelCnt takes values between 1 and the maximum channel count supported by the hardware.
53  *
54  * Implements : ERM_DRV_Init_Activity
55  *END**************************************************************************/
56 void ERM_DRV_Init(uint32_t instance,
57  uint8_t channelCnt,
58  const erm_user_config_t * userConfigArr)
59 {
60  DEV_ASSERT(instance < ERM_INSTANCE_COUNT);
61  DEV_ASSERT(userConfigArr != NULL);
62  DEV_ASSERT(channelCnt > 0U);
63  DEV_ASSERT(channelCnt <= ERM_EARn_COUNT);
64  ERM_Type * base = g_ermBase[instance];
65  uint8_t i;
66 
67  /* Initializes the module */
68  ERM_HAL_Init(base);
69 
70  /* Sets interrupt notification from user configuration input */
71  for (i = 0U; i < channelCnt; i++)
72  {
73  ERM_DRV_SetInterruptConfig(instance, userConfigArr[i].channel, *userConfigArr[i].interruptCfg);
74  }
75 }
76 
77 /*FUNCTION**********************************************************************
78  *
79  * Function Name : ERM_DRV_Deinit
80  * Description : This function sets the default configuration.
81  *
82  * Implements : ERM_DRV_Deinit_Activity
83  *END**************************************************************************/
84 void ERM_DRV_Deinit(uint32_t instance)
85 {
86  DEV_ASSERT(instance < ERM_INSTANCE_COUNT);
87  ERM_Type * base = g_ermBase[instance];
88 
89  /* Set the default configuration */
90  ERM_HAL_Init(base);
91 }
92 
93 /*FUNCTION**********************************************************************
94  *
95  * Function Name : ERM_DRV_SetInterruptConfig
96  * Description : This function sets interrupt notification based on interrupt
97  * notification configuration input.
98  *
99  * Implements : ERM_DRV_SetInterruptConfig_Activity
100  *END**************************************************************************/
101 void ERM_DRV_SetInterruptConfig(uint32_t instance,
102  uint8_t channel,
103  erm_interrupt_config_t interruptCfg)
104 {
105  DEV_ASSERT(instance < ERM_INSTANCE_COUNT);
106  DEV_ASSERT(channel < ERM_EARn_COUNT);
107  ERM_Type * base = g_ermBase[instance];
108 
109  /* Set interrupt notification base on interrupt notification configuration input */
112 }
113 
114 /*FUNCTION**********************************************************************
115  *
116  * Function Name : ERM_DRV_GetInterruptConfig
117  * Description : This function gets the current interrupt configuration of the available events
118  * (which interrupts are enabled/disabled).
119  *
120  * Implements : ERM_DRV_GetInterruptConfig_Activity
121  *END**************************************************************************/
122 void ERM_DRV_GetInterruptConfig(uint32_t instance,
123  uint8_t channel,
124  erm_interrupt_config_t * const interruptPtr)
125 {
126  DEV_ASSERT(instance < ERM_INSTANCE_COUNT);
127  DEV_ASSERT(channel < ERM_EARn_COUNT);
128  DEV_ASSERT(interruptPtr != NULL);
129  const ERM_Type * base = g_ermBase[instance];
130 
131  /* Get interrupt notification into interrupt notification configuration input */
134 }
135 
136 /*FUNCTION**********************************************************************
137  *
138  * Function Name : ERM_DRV_ClearEvent
139  * Description : This function clears the record of an event. If the corresponding interrupt is enabled,
140  * the interrupt notification will be cleared.
141  *
142  * Implements : ERM_DRV_ClearEvent_Activity
143  *END**************************************************************************/
144 void ERM_DRV_ClearEvent(uint32_t instance,
145  uint8_t channel,
146  erm_ecc_event_t eccEvent)
147 {
148  DEV_ASSERT(instance < ERM_INSTANCE_COUNT);
149  DEV_ASSERT(channel < ERM_EARn_COUNT);
150  ERM_Type * base = g_ermBase[instance];
151 
152  /* Clear event */
153  ERM_HAL_ClearEvent(base, channel, eccEvent);
154 }
155 
156 /*FUNCTION**********************************************************************
157  *
158  * Function Name : ERM_DRV_GetErrorDetail
159  * Description : This function gets the address of the last ECC event in Memory n
160  * and the types of the event.
161  *
162  * Implements : ERM_DRV_GetErrorDetail_Activity
163  *END**************************************************************************/
165  uint8_t channel,
166  uint32_t * addressPtr)
167 {
168  DEV_ASSERT(instance < ERM_INSTANCE_COUNT);
169  DEV_ASSERT(channel < ERM_EARn_COUNT);
170  DEV_ASSERT(addressPtr != NULL);
171  const ERM_Type * base = g_ermBase[instance];
172 
173  /* Get the address of the last ECC event in Memory n and ECC event */
174  return ERM_HAL_GetErrorDetail(base, channel, addressPtr);
175 }
176 
177 /*******************************************************************************
178  * EOF
179  ******************************************************************************/
static bool ERM_HAL_IsEventInterruptEnabled(const ERM_Type *const base, uint8_t channel, erm_ecc_event_t eccEvent)
Checks if the Memory n interrupt event is enabled.
Definition: erm_hal.h:146
static void ERM_HAL_EnableEventInterrupt(ERM_Type *const base, uint8_t channel, erm_ecc_event_t eccEvent, bool enable)
Enables Memory n interrupt event.
Definition: erm_hal.h:93
erm_ecc_event_t ERM_DRV_GetErrorDetail(uint32_t instance, uint8_t channel, uint32_t *addressPtr)
Gets the address of the last ECC event in Memory n and ECC event.
Definition: erm_driver.c:164
void ERM_HAL_Init(ERM_Type *const base)
Initializes the ERM module.
Definition: erm_hal.c:44
ERM interrupt notification configuration structure Implements : erm_interrupt_config_t_Class.
Definition: erm_driver.h:46
void ERM_DRV_GetInterruptConfig(uint32_t instance, uint8_t channel, erm_interrupt_config_t *const interruptPtr)
Gets interrupt notification.
Definition: erm_driver.c:122
ERM user configuration structure Implements : erm_user_config_t_Class.
Definition: erm_driver.h:56
#define ERM_EARn_COUNT
Definition: S32K144.h:3255
#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
#define ERM_BASE_PTRS
Definition: S32K144.h:3281
#define ERM_INSTANCE_COUNT
Definition: S32K144.h:3270
void ERM_DRV_ClearEvent(uint32_t instance, uint8_t channel, erm_ecc_event_t eccEvent)
Clears error event and the corresponding interrupt notification.
Definition: erm_driver.c:144
ERM_Type *const g_ermBase[]
Table of base addresses for ERM instances.
Definition: erm_driver.c:43
static void ERM_HAL_ClearEvent(ERM_Type *const base, uint8_t channel, erm_ecc_event_t eccEvent)
Clears error event and the corresponding interrupt notification.
Definition: erm_hal.h:217
void ERM_DRV_Init(uint32_t instance, uint8_t channelCnt, const erm_user_config_t *userConfigArr)
Initializes the ERM module.
Definition: erm_driver.c:56
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
void ERM_DRV_SetInterruptConfig(uint32_t instance, uint8_t channel, erm_interrupt_config_t interruptCfg)
Sets interrupt notification.
Definition: erm_driver.c:101
void ERM_DRV_Deinit(uint32_t instance)
Sets the default configuration.
Definition: erm_driver.c:84