xWRL6432 MMWAVE-L-SDK  05.04.00.01
esm/v0/esm.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
49 #ifndef ESM_H_
50 #define ESM_H_
51 
52 /* ========================================================================== */
53 /* Include Files */
54 /* ========================================================================== */
55 #include <stdint.h>
56 #include <kernel/dpl/HwiP.h>
57 #include <drivers/hw_include/cslr_soc.h>
58 #include <drivers/hw_include/cslr_esm.h>
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 /* ========================================================================== */
65 /* Macros & Typedefs */
66 /* ========================================================================== */
67 
69 typedef void *ESM_Handle;
70 
72 #define ESM_ERRNO_BASE (-3000)
73 
80 #define ESM_EINVAL (ESM_ERRNO_BASE-1)
81 
82 #define ESM_ENOINIT (ESM_ERRNO_BASE-2)
83 
84 #define ESM_EREINIT (ESM_ERRNO_BASE-3)
85 
86 #define ESM_ENOMEM (ESM_ERRNO_BASE-4)
87 
90 #define ESM_MAX_NOTIFIERS (4U)
91 
92 #define ESM_MAX_ISR_COUNT (4U)
93 
94 #define CSL_APP_ESM_ESMEKR_EKEY_NORMAL_MODE (0x0U)
95 #define CSL_APP_ESM_ESMEKR_EKEY_ERROR_PIN_RESET (0x5U)
96 #define CSL_APP_ESM_ESMEKR_EKEY_ERROR_FORCE_MODE (0xAU)
97 
98 /* ========================================================================== */
99 /* enums */
100 /* ========================================================================== */
101 
103 typedef enum
104 {
110 
112 typedef enum
113 {
119 
120 /* ========================================================================== */
121 /* Structure Declarations */
122 /* ========================================================================== */
123 
133 typedef void (*ESM_CallBack)(void* arg);
134 
136 typedef struct
137 {
138  uint32_t grpIntrStatus[ESM_NUM_INTR_PER_GROUP / 32U];
141 
148 typedef struct
149 {
150  uint32_t groupNumber;
152  uint32_t errorNumber;
158  void *arg;
163 
174 typedef struct
175 {
186 
196 typedef struct {
197  CSL_app_esmRegs *ptrESMRegs;
199  CSL_app_ctrlRegs *ptrCtrlRegs;
201  uint32_t numGroup1Err;
203  uint32_t highPrioIntNum;
205  uint32_t lowPrioIntNum;
211 } ESM_Attrs;
212 
220 typedef struct
221 {
224  uint32_t esmBaseAddr;
228  void *hwiHandleHi;
232  void *hwiHandleLo;
238  uint32_t numGroup1Err;
240  uint32_t debugEsmISRCount[ESM_MAX_ISR_COUNT];
242 } ESM_Object;
243 
250 typedef struct {
255 } ESM_Config;
256 
258 extern ESM_Config gEsmConfig[];
260 extern uint32_t gEsmConfigNum;
261 
262 /* ========================================================================== */
263 /* Function Declarations */
264 /* ========================================================================== */
265 
270 void ESM_init(void);
271 
276 void ESM_deinit(void);
277 
291 ESM_Handle ESM_open(uint32_t index, ESM_OpenParams *params);
292 
302 void ESM_close(ESM_Handle handle);
303 
318 int32_t ESM_registerNotifier(ESM_Handle handle, ESM_NotifyParams* params, int32_t* errCode);
319 
334 int32_t ESM_deregisterNotifier(ESM_Handle handle, int32_t notifyIndex, int32_t* errCode);
335 
344 void ESM_setMode(uint32_t baseAddr, uint32_t mode);
345 
355 int32_t ESM_setErrPinLowTimePreload(uint32_t baseAddr, uint32_t lowTime);
356 
364 uint32_t ESM_getCurrErrPinLowTimeCnt(uint32_t baseAddr);
365 
373 uint32_t ESM_getErrPinStatus(uint32_t baseAddr);
374 
381 void ESM_resetErrPin(uint32_t baseAddr);
382 
392 uint32_t ESM_getIntrStatus(uint32_t baseAddr, uint32_t intrSrc);
393 
408 int32_t ESM_getGroupIntrStatus(uint32_t baseAddr,
409  uint32_t grpNum,
410  ESM_GroupIntrStatus *intrstatus);
411 
412 /* ========================================================================== */
413 /* Static Function Definitions */
414 /* ========================================================================== */
415 static inline void ESM_Params_init(ESM_OpenParams *openPrms)
416 {
417  if (openPrms != NULL)
418  {
419  openPrms->bClearErrors = FALSE;
420  }
421 }
422 
423 #ifdef __cplusplus
424 }
425 #endif
426 
427 #endif /* #ifndef ESM_H_ */
428 
ESM_NotifyParams::arg
void * arg
Definition: esm/v0/esm.h:158
ESM_getIntrStatus
uint32_t ESM_getIntrStatus(uint32_t baseAddr, uint32_t intrSrc)
This API is used to get the interrupt status.
ESM_Attrs::highPrioIntNum
uint32_t highPrioIntNum
Definition: esm/v0/esm.h:203
ESM_OperationMode
ESM_OperationMode
Enum to select the ESM Operation Mode.
Definition: esm/v0/esm.h:113
gEsmConfigNum
uint32_t gEsmConfigNum
Externally defined driver configuration array size.
ESM_Object::esmBaseAddr
uint32_t esmBaseAddr
Definition: esm/v0/esm.h:224
ESM_NotifyParams::errorNumber
uint32_t errorNumber
Definition: esm/v0/esm.h:152
ESM_Object::esmHandle
ESM_Handle esmHandle
Definition: esm/v0/esm.h:222
ESM_Attrs::ptrCtrlRegs
CSL_app_ctrlRegs * ptrCtrlRegs
Definition: esm/v0/esm.h:199
ESM_CallBack
void(* ESM_CallBack)(void *arg)
Callback function which is invoked by the ESM module if a notify function is registered using the ESM...
Definition: esm/v0/esm.h:133
ESM_OpenParams
ESM Open Parameters.
Definition: esm/v0/esm.h:175
ESM_NotifyParams::setIntrPriorityLvl
uint32_t setIntrPriorityLvl
Definition: esm/v0/esm.h:154
CSL_APP_ESM_ESMEKR_EKEY_ERROR_FORCE_MODE
#define CSL_APP_ESM_ESMEKR_EKEY_ERROR_FORCE_MODE
Definition: esm/v0/esm.h:96
ESM_INTR_PRIORITY_LEVEL_LOW
@ ESM_INTR_PRIORITY_LEVEL_LOW
Definition: esm/v0/esm.h:105
ESM_MAX_ISR_COUNT
#define ESM_MAX_ISR_COUNT
Maximum ISR supported.
Definition: esm/v0/esm.h:92
ESM_close
void ESM_close(ESM_Handle handle)
The function closes a ESM peripheral specified by the ESM handle.
ESM_deinit
void ESM_deinit(void)
The functions de-initializes the ESM module.
ESM_NotifyParams::notify
ESM_CallBack notify
Definition: esm/v0/esm.h:160
ESM_Object::params
ESM_OpenParams params
Definition: esm/v0/esm.h:226
ESM_IntrPriorityLvl
ESM_IntrPriorityLvl
Enum to select level for interrupt.
Definition: esm/v0/esm.h:104
ESM_Config
ESM Instance configuration.
Definition: esm/v0/esm.h:250
ESM_setErrPinLowTimePreload
int32_t ESM_setErrPinLowTimePreload(uint32_t baseAddr, uint32_t lowTime)
This API is used to configure the low time counter pre-load value.
ESM_Attrs::ptrESMRegs
CSL_app_esmRegs * ptrESMRegs
Definition: esm/v0/esm.h:197
ESM_OPERATION_MODE_ERROR_FORCE
@ ESM_OPERATION_MODE_ERROR_FORCE
Definition: esm/v0/esm.h:116
ESM_setMode
void ESM_setMode(uint32_t baseAddr, uint32_t mode)
This API is used to configure operation mode of ESM module.
ESM_Object::numGroup1Err
uint32_t numGroup1Err
Definition: esm/v0/esm.h:238
gEsmConfig
ESM_Config gEsmConfig[]
Externally defined driver configuration array.
ESM_Attrs::intrLowPriority
uint8_t intrLowPriority
Definition: esm/v0/esm.h:209
ESM_Attrs::lowPrioIntNum
uint32_t lowPrioIntNum
Definition: esm/v0/esm.h:205
CSL_APP_ESM_ESMEKR_EKEY_NORMAL_MODE
#define CSL_APP_ESM_ESMEKR_EKEY_NORMAL_MODE
Definition: esm/v0/esm.h:94
ESM_resetErrPin
void ESM_resetErrPin(uint32_t baseAddr)
This API is used to reset the nERROR pin. This will set the nERROR pin to high.
HwiP.h
ESM_Object
ESM Driver Object.
Definition: esm/v0/esm.h:221
ESM_OPERATION_MODE_NORMAL
@ ESM_OPERATION_MODE_NORMAL
Definition: esm/v0/esm.h:114
ESM_getErrPinStatus
uint32_t ESM_getErrPinStatus(uint32_t baseAddr)
This API is used to get the current status of nERROR pin.
ESM_getCurrErrPinLowTimeCnt
uint32_t ESM_getCurrErrPinLowTimeCnt(uint32_t baseAddr)
This API is used to get the current value of low time counter.
ESM_registerNotifier
int32_t ESM_registerNotifier(ESM_Handle handle, ESM_NotifyParams *params, int32_t *errCode)
Register the notifers. The ESM module will call back if error interrupt is detected.
ESM_MAX_NOTIFIERS
#define ESM_MAX_NOTIFIERS
Maximum number of notify callbacks supported.
Definition: esm/v0/esm.h:90
ESM_NotifyParams::enableInfluenceOnErrPin
Bool enableInfluenceOnErrPin
Definition: esm/v0/esm.h:156
ESM_Object::hwiHandleLo
void * hwiHandleLo
Definition: esm/v0/esm.h:232
ESM_Attrs
ESM Hardware Atrributes.
Definition: esm/v0/esm.h:196
ESM_NotifyParams::groupNumber
uint32_t groupNumber
Definition: esm/v0/esm.h:150
ESM_getGroupIntrStatus
int32_t ESM_getGroupIntrStatus(uint32_t baseAddr, uint32_t grpNum, ESM_GroupIntrStatus *intrstatus)
This API is used to get the interrupt/error status for a group.
ESM_INTR_PRIORITY_LEVEL_HIGH
@ ESM_INTR_PRIORITY_LEVEL_HIGH
Definition: esm/v0/esm.h:107
ESM_Config::object
ESM_Object * object
Definition: esm/v0/esm.h:253
ESM_deregisterNotifier
int32_t ESM_deregisterNotifier(ESM_Handle handle, int32_t notifyIndex, int32_t *errCode)
Deregister the ESM notifers.
ESM_Attrs::numGroup1Err
uint32_t numGroup1Err
Definition: esm/v0/esm.h:201
HwiP_Object
Opaque Hwi object used with the Hwi APIs.
Definition: HwiP.h:91
ESM_NotifyParams
Parameters used to register the ESM notify function to handle Group1 and Group2 errors....
Definition: esm/v0/esm.h:149
ESM_init
void ESM_init(void)
The functions initializes the ESM module.
ESM_GroupIntrStatus
Structure to access the status of interrupts belonging to a group.
Definition: esm/v0/esm.h:137
ESM_NUM_INTR_PER_GROUP
#define ESM_NUM_INTR_PER_GROUP
Definition: cslr_soc_defines.h:113
ESM_Attrs::intrHighPriority
uint8_t intrHighPriority
Definition: esm/v0/esm.h:207
ESM_Object::hwiHandleHi
void * hwiHandleHi
Definition: esm/v0/esm.h:228
ESM_OpenParams::bClearErrors
Bool bClearErrors
Definition: esm/v0/esm.h:176
ESM_Config::hwAttrs
const ESM_Attrs * hwAttrs
Definition: esm/v0/esm.h:251
ESM_Params_init
static void ESM_Params_init(ESM_OpenParams *openPrms)
Definition: esm/v0/esm.h:415
ESM_Object::hwiHiObj
HwiP_Object hwiHiObj
Definition: esm/v0/esm.h:230
ESM_Object::hwiLoObj
HwiP_Object hwiLoObj
Definition: esm/v0/esm.h:234
ESM_open
ESM_Handle ESM_open(uint32_t index, ESM_OpenParams *params)
Opens a ESM object with the index and parameters specified, and returns a ESM_Handle.
ESM_Handle
void * ESM_Handle
A handle that is returned from a ESM_open() call.
Definition: esm/v0/esm.h:69