Update ESM test app to call Sciclient_init
[processor-sdk/pdk.git] / packages / ti / diag / examples / esm_example_app / esm.c
1 /*
2  * ESM Example
3  *
4  * Error Signaling Module (ESM) Example Application
5  *
6  *  Copyright (c) 2020 Texas Instruments Incorporated
7  *
8  *  Redistribution and use in source and binary forms, with or without
9  *  modification, are permitted provided that the following conditions
10  *  are met:
11  *
12  *    Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  *
15  *    Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the
18  *    distribution.
19  *
20  *    Neither the name of Texas Instruments Incorporated nor the names of
21  *    its contributors may be used to endorse or promote products derived
22  *    from this software without specific prior written permission.
23  *
24  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  */
36 /**
37  *  \file esm.c
38  *
39  *  \brief ESM utility functions and handler ISR's
40  */
42 /* ========================================================================== */
43 /*                             Include Files                                  */
44 /* ========================================================================== */
45 /* For Timer functions */
46 #include <ti/osal/osal.h>
48 /* For interrupt ID numbers */
49 #include <ti/csl/soc/cslr_soc_intr.h>
51 /* Sciclient */
52 #include <ti/csl/csl_types.h>
53 #include <ti/drv/sciclient/sciclient.h>
55 /* Diagnostic example utility functions, e.g. print outputs */
56 #include <diag_utils.h>
57 #include <sdr_esm.h>
59 #include "esm.h"
60 #include "event_trig.h"
62 /* ========================================================================== */
63 /*                           Macros & Typedefs                                */
64 /* ========================================================================== */
66 #define MAX_ESM_EVENTS_LOGGED (20)
67 #define MAX_ESM_INSTANCE      (SDR_ESM_INSTANCE_MAIN)
68 #define MAX_ESM_INT_TYPE      (SDR_ESM_INT_TYPE_CFG)
70 /* ESM event log entry */
71 typedef struct
72 {
73     SDR_ESM_InstanceType esmInstance;
74     SDR_ESM_IntType      intType;
75     uint32_t             grpChannel;
76     uint32_t             index;
77     uint32_t             intSrc;
78     uint8_t              useCaseNum;
79 } ESM_Example_log_entry_t;
81 /* ========================================================================== */
82 /*                         Structure Declarations                             */
83 /* ========================================================================== */
85 /* None */
87 /* ========================================================================== */
88 /*                          Function Declarations                             */
89 /* ========================================================================== */
91 static int32_t ESM_Example_EsmInitHandlerInit(SDR_ESM_InstanceType esmInstType);
93 /* ========================================================================== */
94 /*                            Global Variables                                */
95 /* ========================================================================== */
97 static ESM_Example_log_entry_t esmEventLog[MAX_ESM_EVENTS_LOGGED];
98 static uint32_t totalEventsLogged   = 0;
99 static uint32_t totalHiEventsLogged = 0;
100 static uint32_t totalLoEventsLogged = 0;
101 static int32_t  thresholdsReset     = 0;
103 /* Initialization structure for MCU ESM instance */
104 static SDR_ESM_InitConfig_t ESM_Example_esmInitConfig_MCU =
106     .esmErrorConfig = {0u, 3u}, /* Self test error config */
107     .eventMap = {0xffffffffu, 0x033fffffu, 0x7fffffffu, 0xffffffe7u,
108                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
109                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
110                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
111                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
112                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
113                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
114                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
115                 },
116      /**< All events enable: except timer and self test  events, */
117     /*    and Main ESM output.  Disabling vim compare error as well.
118      *    Exclude MCU Timer 0, which is left on by SBL in continuous mode,
119      *    and MCU Timer 1, which is used for controlling the Output pin clearing.
120      *    MCU Timer 2 set to High Priority with output pin routing.
121      *    MCU Timer 3 set to Low Priorirty with no Output pin routing. */
122     .eventPriorityMap = {0xffffffffu, 0x013fffffu, 0x7fffffffu, 0xffffffe6u,
123                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
124                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
125                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
126                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
127                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
128                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
129                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
130                         },
131     /**< All events high priority: except timer, selftest error events,
132      *   and Main ESM output. Exclude MCU Timer 0, which is left on by
133      *   SBL in continuous mode, and MCU Timer 1, which is used for controlling
134      *   the Output pin clearing.
135      *   MCU Timer 2 set to High Priority with output pin routing.
136      *   MCU Timer 3 set to Low Priorirty with no Output pin routing. */
137     .errorOutputMap = {0xffffffffu, 0x013fffffu, 0x7fffffffu, 0xffffffe6u,
138                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
139                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
140                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
141                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
142                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
143                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
144                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
145                       },
146     /**< All events high priority: except timer, selftest error events,
147      *   and Main ESM output. Exclude MCU Timer 0, which is left on by
148      *   SBL in continuous mode, and MCU Timer 1, which is used for controlling
149      *   the Output pin clearing.
150      *   MCU Timer 2 set to High Priority with output pin routing.
151      *   MCU Timer 3 set to Low Priorirty with no Output pin routing. */
152 };
154 /* Initialization structure for WKUP ESM instance */
155 static SDR_ESM_InitConfig_t ESM_Example_esmInitConfig_WKUP =
157     .esmErrorConfig = {0u, 0u}, /* Self test error config */
158     .eventMap = {0xffffffffu, 0x00180003u, 0xffffffffu, 0x00000000u,
159                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
160                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
161                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
162                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
163                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
164                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
165                  0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
166                 },
167      /**< All events enable: except clkstop events for unused clocks */
168     .eventPriorityMap = {0xfffffcffu, 0x00180003u, 0xffffffffu, 0x00000000u,
169                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
170                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
171                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
172                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
173                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
174                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
175                          0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
176                         },
177     /**< All events high priority: except clkstop events for unused clocks,
178      *   and make VTM WKUP_VTM0_THERM_LVL_GT_TH1_INTR_0 and
179      *   WKUP_VTM0_THERM_LVL_LT_TH0_INTR_0 events low priority */
180     .errorOutputMap = {0xfffffcffu, 0x00180003u, 0xffffffffu, 0x00000000u,
181                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
182                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
183                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
184                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
185                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
186                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
187                        0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u,
188                       },
189     /**< All events high priority: except clkstop for unused clocks
190      *   and make VTM WKUP_VTM0_THERM_LVL_GT_TH1_INTR_0 and
191      *   WKUP_VTM0_THERM_LVL_LT_TH0_INTR_0 events not output to pin */
192 };
194 static HwiP_Handle ESM_Example_EsmHiHwiPHandle;
195 static HwiP_Handle ESM_Example_EsmLoHwiPHandle;
196 static HwiP_Handle ESM_Example_EsmCfgHwiPHandle;
198 /* ========================================================================== */
199 /*                            External Variables                              */
200 /* ========================================================================== */
202 /* Completion of Use Case from ESM Handler perspective updates these flags */
203 extern volatile uint32_t esmOutputResult[5];
204 /* Current use case being run */
205 extern volatile uint8_t  currUseCase;
207 /* ========================================================================== */
208 /*                          Function Definitions                              */
209 /* ========================================================================== */
211 /*********************************************************************
212 * @fn      ESM_Example_init
214 * @brief   Initializes Board, Timers, and ESM module
216 * @param   None
218 * @return    0 : Success; < 0 for failures
219 */
220 int32_t ESM_Example_init (void)
222     int32_t retValue=0;
223     Sciclient_ConfigPrms_t config;
224     SDR_Result result;
226 #ifdef UART_PRINTF
227     /* Initialize UART instance */
228     DIAG_uartStdioInit();
229 #endif
231     DIAG_printf("\nESM_Example_init: UART ready to print, proceeding with ESM Example init \n");
233     if (retValue == 0) {
234         /* Initialize Sciclient */
235         retValue = Sciclient_configPrmsInit(&config);
236         if (retValue == CSL_PASS) {
237             retValue = Sciclient_init(&config);
238         }
239         if (retValue != CSL_PASS) {
240             DIAG_printf("ESM_Example_init: Error initializing Sciclient: result = %d\n", retValue);
241             retValue = -1;
242         }
243     }
245     if (retValue == 0) {
246         /* Initialize MCU ESM module */
247         result = SDR_ESM_init(SDR_ESM_INSTANCE_MCU, &ESM_Example_esmInitConfig_MCU);
248         if (result != SDR_PASS) {
249             /* print error and quit */
250              DIAG_printf("ESM_Example_init: Error initializing MCU ESM: result = %d\n", result);
252             retValue = -1;
253         } else {
254             DIAG_printf("\nESM_Example_init: Init MCU ESM complete \n");
255         }
256     }
258     if (retValue == 0) {
259         /* Initialize WKUP ESM module */
260         result = SDR_ESM_init(SDR_ESM_INSTANCE_WKUP, &ESM_Example_esmInitConfig_WKUP);
261         if (result != SDR_PASS) {
262             /* print error and quit */
263             DIAG_printf("ESM_Example_init: Error initializing WKUP ESM: result = %d\n", result);
265             retValue = -1;
266         } else {
267             DIAG_printf("\nESM_Example_init: Init WKUP ESM complete \n");
268         }
269     }
271     if (retValue == 0) {
272         /* Register MCU Esm handlers */
273         retValue = ESM_Example_EsmInitHandlerInit(SDR_ESM_INSTANCE_MCU);
274         if (retValue != 0) {
275             DIAG_printf("\nESM_Example_init: Init MCU ESM handlers failed \n");
276         } else {
277             DIAG_printf("\nESM_Example_init: Init MCU ESM handlers complete \n");
278         }
280         /* Register WKUP Esm handlers */
281         retValue = ESM_Example_EsmInitHandlerInit(SDR_ESM_INSTANCE_WKUP);
282         if (retValue != 0) {
283             DIAG_printf("\nESM_Example_init: Init WKUP ESM handlers failed \n");
284         } else {
285             DIAG_printf("\nESM_Example_init: Init WKUP ESM handlers complete \n");
286         }
287     }
289     return retValue;
292 /*********************************************************************
293 * @fn      ESM_Example_EsmInitHandlerInit
295 * @brief   Register all callbacks for an ESM instance
297 * @param   esmInstType: Instance type of ESM 
299 * @return    0 : Success; < 0 for failures
300 */
301 static int32_t ESM_Example_EsmInitHandlerInit(SDR_ESM_InstanceType esmInstType)
303     int32_t result = 0;
304     uint32_t intNumHi, intNumLo, intNumCfg;
305     HwiP_Params       hwiParams;
306     void (*pHiInterruptHandler)(uintptr_t);
307     void (*pLoInterruptHandler)(uintptr_t);
308     void (*pConfigInterruptHandler)(uintptr_t);
310     switch (esmInstType) {
311         case (SDR_ESM_INSTANCE_WKUP):
312             pHiInterruptHandler = &SDR_ESM_hiInterruptHandler_WKUP;
313             pLoInterruptHandler = &SDR_ESM_loInterruptHandler_WKUP;
314             pConfigInterruptHandler = &SDR_ESM_configInterruptHandler_WKUP;
315             break;
317         case (SDR_ESM_INSTANCE_MAIN):
318             pHiInterruptHandler = &SDR_ESM_hiInterruptHandler_MAIN;
319             pLoInterruptHandler = &SDR_ESM_loInterruptHandler_MAIN;
320             pConfigInterruptHandler = &SDR_ESM_configInterruptHandler_MAIN;
321             break;
323         case (SDR_ESM_INSTANCE_MCU):
324         default:
325             pHiInterruptHandler = &SDR_ESM_hiInterruptHandler_MCU;
326             pLoInterruptHandler = &SDR_ESM_loInterruptHandler_MCU;
327             pConfigInterruptHandler = &SDR_ESM_configInterruptHandler_MCU;
328             break;
329     }
331     /* Get the interrupt number corresponding to ESM HI interrupt */
332     intNumHi = SDR_ESM_getIntNumber(esmInstType,
333                                     SDR_ESM_INT_TYPE_HI);
334     if ( intNumHi == SDR_ESM_INTNUMBER_INVALID ) {
335         result = -1;
336     } else {
337         /* Get the interrupt number corresponding to ESM LO interrupt */
338         intNumLo = SDR_ESM_getIntNumber(esmInstType,
339                                         SDR_ESM_INT_TYPE_LO);
340         if ( intNumLo == SDR_ESM_INTNUMBER_INVALID ) {
341             result = -1;
342         } else {
343             /* Get the interrupt number corresponding to ESM Config interrupt */
344             intNumCfg = SDR_ESM_getIntNumber(esmInstType,
345                                              SDR_ESM_INT_TYPE_CFG);
346             if ( intNumCfg == SDR_ESM_INTNUMBER_INVALID ) {
347                 result = -1;
348             } else {
349                 DIAG_printf("\n ESM_Example_EsmInitHandlerInit: " \
350                             "Obtain interrupt number complete \n");
351                 /* Clear all interrupts first */
352                 HwiP_disableInterrupt(intNumHi);
353                 HwiP_disableInterrupt(intNumLo);
354                 HwiP_disableInterrupt(intNumCfg);
356                 DIAG_printf("\n ESM_Example_EsmInitHandlerInit: " \
357                             "Disable interrupts complete \n");
359                 /* Default parameter initialization */
360                 HwiP_Params_init(&hwiParams);
362                 hwiParams.arg = intNumHi;
363                 DIAG_printf("\n ESM_Example_EsmInitHandlerInit: " \
364                             "HwiP_Params_init complete \n");
366                 /* Register call back function for ESM Hi Interrupt */
367                 ESM_Example_EsmHiHwiPHandle = HwiP_create(intNumHi,
368                                                           (HwiP_Fxn)(*pHiInterruptHandler),
369                                                           (void *)&hwiParams);
370                 DIAG_printf("\n ESM_Example_EsmInitHandlerInit: " \
371                             "intNumHi registration complete \n");
372                 if (ESM_Example_EsmHiHwiPHandle == (HwiP_Handle) NULL) {
373                     result = -1;
374                 } else {
375                     hwiParams.arg = intNumLo;
376                     /* Register call back function for ESM Lo Interrupt */
377                     ESM_Example_EsmLoHwiPHandle = HwiP_create(intNumLo,
378                                                               (HwiP_Fxn)(*pLoInterruptHandler),
379                                                               (void *)&hwiParams);
380                     DIAG_printf("\n ESM_Example_EsmInitHandlerInit: " \
381                                 "intNumLo registration complete \n");
382                     if (ESM_Example_EsmLoHwiPHandle == (HwiP_Handle) NULL) {
383                         result = -1;
384                     } else {
385                         hwiParams.arg = intNumCfg;
386                         /* Register call back function for ESM Config Interrupt */
387                         ESM_Example_EsmCfgHwiPHandle = HwiP_create(intNumCfg,
388                                                    (HwiP_Fxn)(*pConfigInterruptHandler),
389                                                    (void *)&hwiParams);
390                         DIAG_printf("\n ESM_Example_EsmInitHandlerInit: " \
391                                     "intNumCfg registration complete \n");
392                         if (ESM_Example_EsmCfgHwiPHandle == (HwiP_Handle) NULL) {
393                             result = -1;
394                         } else {
395                             /* Enable all ESM Interrupts */
396                             HwiP_enableInterrupt(intNumHi);
397                             HwiP_enableInterrupt(intNumLo);
398                             HwiP_enableInterrupt(intNumCfg);
399                        }
400                     }
401                 }
402             }
403         }
404     }
406     return result;
409 static int32_t deactivateTrigger(SDR_ESM_InstanceType esmInstType,
410                                  SDR_ESM_IntType esmIntType,
411                                  uint32_t intEsmSrc)
413     int32_t retVal = 0;
415     if ((esmInstType == SDR_ESM_INSTANCE_WKUP) && (esmIntType == SDR_ESM_INT_TYPE_LO)) {
416         /* UC-1: Low Priority interrupt on WKUP ESM -
417          * VTM greater than THR1 */
418         if (intEsmSrc ==
419             CSLR_WKUP_ESM0_ESM_LVL_EVENT_WKUP_VTM0_THERM_LVL_GT_TH1_INTR_0)
420         {
421             if (currUseCase == 0)
422             {
423                 if (thresholdsReset == 0)
424                 {
425                     /* Simulate thresholds as if temperature is going to be reduced
426                      * below lt_Thr0 */
427                     diag_esm_setNormalThresholds();
428 #ifdef DEBUG_PRINT
429                     diag_esm_printCurrentThresholds();
430 #endif
431                     thresholdsReset = 1;
432                 }
433                 diag_esm_vtmGtThr1CrossedUpdateInt();
434             } else if ((currUseCase == 1) || (currUseCase == 2))
435             {
436                 if (thresholdsReset == 0)
437                 {
438                     /* Simulate thresholds as if temperature continues to increase
439                      * toward gt_Thr2 */
440                     diag_esm_setThresholdsForCriticalTrigger();
441 #ifdef DEBUG_PRINT
442                     diag_esm_printCurrentThresholds();
443 #endif
444                     thresholdsReset = 1;
445                 }
446                 diag_esm_vtmGtThr1CrossedUpdateInt();
447             }
448         } else if (intEsmSrc ==
449                    CSLR_WKUP_ESM0_ESM_LVL_EVENT_WKUP_VTM0_THERM_LVL_LT_TH0_INTR_0)
450         {
451             diag_esm_vtmLtThr0CrossedUpdateInt();
452 #ifdef DEBUG_PRINT
453             diag_esm_printCurrentThresholds();
454 #endif
455             thresholdsReset = 0;
456             esmOutputResult[currUseCase] = USE_CASE_STATUS_COMPLETED_SUCCESS;
457             if (currUseCase == 1) {
458                 /* At end of this use case, clear the Pin that was left on
459                  * throughout the use case*/
460                 Osal_delay(4);
461                 diag_esm_startPinClearTimer(true);
462             }
463         }
464     } else if ((esmInstType == SDR_ESM_INSTANCE_WKUP) &&
465                (esmIntType == SDR_ESM_INT_TYPE_HI)) {
466         if ((currUseCase == 1) || (currUseCase == 2)) {
467             /* UC-2: High Priority interrupt on WKUP ESM -
468              * VTM greater than THR2, no clearing of
469              * MCU_SAFETY_ERRORn pin */
470             /* UC-3: High Priority interrupt on WKUP ESM -
471              * VTM greater than THR2 with clearing
472              * of MCU_SAFETY_ERRORn pin */
473             if (thresholdsReset == 1)
474             {
475                 /* Simulate thresholds as if temperature is going to be reduced
476                  * below lt_Thr0 */
477                 diag_esm_setNormalThresholds();
478 #ifdef DEBUG_PRINT
479                 diag_esm_printCurrentThresholds();
480 #endif
481                 thresholdsReset = 2;
482             }
483             if (currUseCase == 2) {
484                 diag_esm_startPinClearTimer(false);
485             }
486             diag_esm_vtmGtThr2CrossedUpdateInt();
487         } else {
488             retVal = -1;
489         }
490     } else if (((esmInstType == SDR_ESM_INSTANCE_MCU) &&
491                 (esmIntType == SDR_ESM_INT_TYPE_LO)) ||
492                ((esmInstType == SDR_ESM_INSTANCE_MCU) &&
493                 (esmIntType == SDR_ESM_INT_TYPE_HI))) {
494         /* UC-4: Low Priority interrupt on MCU ESM -
495          * MCU TIMER 2 expiration */
496         /* UC-5: High Priority interrupt on MCU ESM -
497          * MCU TIMER 1 expiration */
498         /* Clear the timer interrupt */
499         retVal = diag_esm_timerUpdateInt(intEsmSrc);
500         if (retVal == 0) {
501             esmOutputResult[currUseCase] = USE_CASE_STATUS_COMPLETED_SUCCESS;
502         }
503     } else {
504         DIAG_printf("ERR: Unexpected ESM Instance %d and ESM Interrupt Type %d \n",
505                     esmInstType, esmIntType);
506         retVal = -1;
507     }
509    return (retVal); 
512 static const char *printEsmIntType(SDR_ESM_IntType esmIntType)
514     char *pStr;
516     switch(esmIntType)
517     {
518         case SDR_ESM_INT_TYPE_HI:
519             pStr = "High Priority ESM event";
520             break;
521         case SDR_ESM_INT_TYPE_LO:
522             pStr = "Low Priority ESM event";
523             break;
524         case SDR_ESM_INT_TYPE_CFG:
525             pStr = "Config ESM event";
526             break;
527         default:
528             pStr = NULL;
529             break;
530     }
532     return pStr;
535 /*********************************************************************
536 * @fn      ESM_Example_printSummary
538 * @brief   Print summary of all the example use cases run
540 * @param   None
542 * @return  None
543 */
544 void ESM_Example_printSummary(void)
546     int32_t i;
548     DIAG_printf("\n\n");
549     DIAG_printf("ESM Example Application summary\n");
550     DIAG_printf("-------------------------------\n");
551     DIAG_printf("Completed %d Use Cases\n", currUseCase);
552     DIAG_printf("Received %d High Priority Interrupts\n", totalHiEventsLogged);
553     DIAG_printf("Received %d Low Priority Interrupts\n", totalLoEventsLogged);
555     DIAG_printf("\nUse Case Event Log\n");
556     DIAG_printf("------------------\n");
557     for (i = 0; i < totalEventsLogged; i++) {
558         DIAG_printf("\nUse Case %d: ESM Call back function called : grpChannel 0x%x, " \
559                     "index 0x%x, intSrc 0x%x \n",
560                     esmEventLog[i].useCaseNum,
561                     esmEventLog[i].grpChannel,
562                     esmEventLog[i].index,
563                     esmEventLog[i].intSrc);
564         DIAG_printf("  ESM instance #%d, ESM interrupt type = %s\n",
565                     esmEventLog[i].esmInstance,
566                     printEsmIntType(esmEventLog[i].intType));
568     }
571 void SDR_ESM_applicationCallbackFunction(SDR_ESM_InstanceType esmInstType,
572                                          SDR_ESM_IntType esmIntType,
573                                          uint32_t grpChannel,
574                                          uint32_t index,
575                                          uint32_t intSrc)
577     /* Log the event */
578     esmEventLog[totalEventsLogged].useCaseNum  = currUseCase;
579     esmEventLog[totalEventsLogged].esmInstance = esmInstType;
580     esmEventLog[totalEventsLogged].intType     = esmIntType;
581     esmEventLog[totalEventsLogged].grpChannel  = grpChannel;
582     esmEventLog[totalEventsLogged].index       = index;
583     esmEventLog[totalEventsLogged].intSrc      = intSrc;
585     totalEventsLogged++;
586     if (esmIntType == SDR_ESM_INT_TYPE_HI) {
587         totalHiEventsLogged++;
588     } else if (esmIntType == SDR_ESM_INT_TYPE_LO) {
589         totalLoEventsLogged++;
590     }
592     /* Any additional customer-specific actions to address ESM event
593      * can be added here */
595     deactivateTrigger(esmInstType, esmIntType, intSrc);
597 #ifdef PRINT_EVENTS
598     /* Print information to screen */
599     DIAG_printf("\n  ESM Call back function called : instType 0x%x, intType 0x%x, " \
600                 "grpChannel 0x%x, index 0x%x, intSrc 0x%x \n",
601                 esmInstType, esmIntType, grpChannel, index, intSrc);
602     DIAG_printf("  Take action \n");
604     DIAG_printf("  ESM instance #%d, ESM interrupt type = %s\n",
605                 esmInstType, printEsmIntType(esmIntType));
606 #endif
607     esmOutputResult[currUseCase]= USE_CASE_STATUS_COMPLETED_SUCCESS;
609     return;
612 void SDR_assertExternalFunction(SDR_assertErrorNumber errorNumber)
615     DIAG_printf("\n  Assert called with error Number %d \n",
616                 errorNumber);
617     /* Asserts are fatal: Currently just wait for ever */
618     while(1);