FuSa 8-Bit Libraries Safety Framework
Loading...
Searching...
No Matches
tasks_scheduler.c
Go to the documentation of this file.
1
22
23// Standard Library Includes
24#include <stdbool.h>
25#include <stdint.h>
26
27// Framework Includes
28#include <define_error_flags.h>
29#include <define_error_ids.h>
30#include <define_tasks_config.h>
31#include <error_handler.h>
37#include <tasks_config.h>
38#include <tasks_scheduler.h>
39
45#define DIAG_QUEUE_START 0U
46
47// Private function wrapper prototype for diagnostic with input parameter
48#if (DIAG_PERIODIC_SWDT_EXPIRE == ENABLED)
49static errFlag_t RunDiagSwdtExpire(void);
50#endif // DIAG_PERIODIC_SWDT_EXPIRE == ENABLED
51
57typedef errFlag_t (*diagFunc_t)(void);
58
64typedef struct
65{
66 diagFunc_t diagnostic;
67 errId_t id;
68} diagEntry_t;
69
70/* cppcheck-suppress misra-c2012-8.9 */
71static const diagEntry_t diagQueue[] = {
76// Optional diagnostics are excluded compile-time depending on configuration
77#if (DIAG_PERIODIC_CFM0 == ENABLED)
79#endif
80#if (DIAG_PERIODIC_CFM1 == ENABLED)
82#endif
83#if (DIAG_PERIODIC_CFD0 == ENABLED)
85#endif
86#if (DIAG_PERIODIC_VMON == ENABLED)
88#endif
89#if (DIAG_PERIODIC_ECC_EEPROM == ENABLED)
91#endif
92#if (DIAG_PERIODIC_SWDT_EXPIRE == ENABLED)
93 // Calls a static function since the diagnostic has an input parameter
94 { &RunDiagSwdtExpire, ERRID_DIAG_SWDT_EXPIRE },
95#endif
96#if (DIAG_PERIODIC_ERRCH_SPLIM == ENABLED)
98#endif
99#if (DIAG_PERIODIC_ERRCH_CFD0 == ENABLED)
101#endif
102#if (DIAG_PERIODIC_ERRCH_CFM0 == ENABLED)
104#endif
105#if (DIAG_PERIODIC_ERRCH_CFD1 == ENABLED)
107#endif
108#if (DIAG_PERIODIC_ERRCH_CFM1 == ENABLED)
110#endif
111#if (DIAG_PERIODIC_ERRCH_EEPROM == ENABLED)
113#endif
114#if (DIAG_PERIODIC_ERRCH_EVSYS0 == ENABLED)
116#endif
117#if (DIAG_PERIODIC_ERRCH_EVSYS1 == ENABLED)
119#endif
120#if (DIAG_PERIODIC_CFD1 == ENABLED)
122#endif
123#if (DIAG_PERIODIC_VMON == ENABLED)
125#endif
126};
127
129{
130 static uint8_t nextDiagIndex = DIAG_QUEUE_START; // Saves the state between function calls
131 const uint8_t queueSize = sizeof(diagQueue) / sizeof(diagQueue[0U]);
132
133 const diagEntry_t nextDiagEntry = diagQueue[nextDiagIndex];
134
135 const errFlag_t flag = nextDiagEntry.diagnostic();
136 const errId_t id = nextDiagEntry.id;
137 EH_HandleError(flag, id);
138
139 nextDiagIndex++;
140 if (nextDiagIndex >= queueSize)
141 {
142 nextDiagIndex = DIAG_QUEUE_START; // Wrap around to the beginning of the queue
143 }
144}
145
147{
148 return; // TODO: Implement Initiate Idle Sleep API
149}
150
151// Wrapper for the diagnostic function to allow scheduling despite requiring an input parameter
152#if (DIAG_PERIODIC_SWDT_EXPIRE == ENABLED)
153static errFlag_t RunDiagSwdtExpire(void)
154{
155 // Force the SWDT to expire and restart it with a new configured timeout duration
157 return flag;
158}
159#endif // DIAG_PERIODIC_SWDT_EXPIRE == ENABLED
Defines error flag type for indicating detected errors in Middleware services.
errFlag_t
Defines the error flag used by Middleware services to indicate error detection.
Defines for IDs associated with specific errors.
errId_t
Defines unique Error IDs for reporting system errors to EH_HandleError.
@ ERRID_DIAG_ERRCH_CFM0
@ ERRID_DIAG_SWDT_EXPIRE
@ ERRID_DIAG_ERRCH_EVSYS1
@ ERRID_DIAG_ERRCH_EVSYS0
@ ERRID_DIAG_ERRCH_CFM1
@ ERRID_DIAG_PARITY_NVM
@ ERRID_DIAG_CFD0
@ ERRID_DIAG_CFM1
@ ERRID_DIAG_PARITY_RAM
@ ERRID_DIAG_ECC_EEPROM
@ ERRID_DIAG_VMON_OVER
@ ERRID_DIAG_ERRCH_CFD1
@ ERRID_DIAG_ERRCH_EEPROM
@ ERRID_DIAG_CFM0
@ ERRID_DIAG_ERRCH_SPLIM
@ ERRID_DIAG_CFD1
@ ERRID_DIAG_ECC_FLASH
@ ERRID_DIAG_ECC_RAM
@ ERRID_DIAG_ERRCH_CFD0
@ ERRID_DIAG_VMON_UNDER
errFlag_t MW_DiagClockCfd0Begin(void)
Starts error injection diagnostic to detect faults in the Clock Failure Detection 0 (CFD0) monitor.
errFlag_t MW_DiagClockCfm1(void)
Performs error injection diagnostic to detect faults in the Clock Frequency Measure 1 (CFM1) monitor.
errFlag_t MW_DiagClockCfm0(void)
Performs error injection diagnostic to detect faults in the Clock Frequency Measure 0 (CFM0) monitor.
errFlag_t MW_DiagClockCfd1Begin(void)
Starts error injection diagnostic to detect faults in the Clock Failure Detection 1 (CFD1) monitor.
void EH_HandleError(errFlag_t flag, errId_t id)
Handles error based on configured Error ID criticality if the error flag is set.
errFlag_t MW_DiagErrorChannelCfd1(void)
Performs error injection diagnostic to detect faults in the CFD1 error channel.
errFlag_t MW_DiagErrorChannelEvsys0(void)
Performs error injection diagnostic to detect faults in the EVSYS0 error channel.
errFlag_t MW_DiagErrorChannelSplim(void)
Performs error injection diagnostic to detect faults in the SPLIM error channel.
errFlag_t MW_DiagErrorChannelCfm1(void)
Performs error injection diagnostic to detect faults in the CFM1 error channel.
errFlag_t MW_DiagErrorChannelCfm0(void)
Performs error injection diagnostic to detect faults in the CFM0 error channel.
errFlag_t MW_DiagErrorChannelEeprom(void)
Performs error injection diagnostic to detect faults in the EEPROM error channel.
errFlag_t MW_DiagErrorChannelCfd0(void)
Performs error injection diagnostic to detect faults in the CFD0 error channel.
errFlag_t MW_DiagErrorChannelEvsys1(void)
Performs error injection diagnostic to detect faults in the EVSYS1 error channel.
errFlag_t MW_DiagNvmEepromEcc(void)
This function performs error injection diagnostic to detect faults in the NVMCTRL ECC checkers with E...
errFlag_t MW_DiagRamEcc(void)
This function performs error injection diagnostic to detect faults in the redundant RAMCTRL ECC check...
errFlag_t MW_DiagRamParity(void)
This function performs error injection diagnostic to detect faults in the RAM parity checker triggere...
errFlag_t MW_DiagNvmParity(void)
This function performs error injection diagnostic to detect faults in the CPU and NVM bus parity chec...
errFlag_t MW_DiagNvmFlashEcc(void)
This function performs error injection diagnostic to detect faults in the NVMCTRL ECC checkers with F...
errFlag_t MW_DiagVmonUnderBegin(void)
Starts error injection diagnostic to detect faults in the VMON undervoltage detector.
errFlag_t MW_DiagVmonOverBegin(void)
Starts error injection diagnostic to detect faults in the VMON overvoltage detector.
void T_InitiateIdleSleep(void)
Initiates device sleep in Idle mode and optionally enables CRC scan of Flash.
void T_RunNextLatentFaultDiag(void)
Runs a different latent fault diagnostic function each time it is called.
#define DIAG_QUEUE_START
The index of the first diagnostic function in the diagnostic queue.
#define DIAG_PERIODIC_SWDT_RESET_VAL
Configures the new SWDT reset value after performing the SWDT Expire diagnostic in T_RunNextLatentFau...
errFlag_t MW_DiagSwdtExpire(uint32_t newReset)
Performs error injection diagnostic to detect faults in the Synchronous Watchdog Timer (SWDT) Expire ...
Contains API prototypes for the Clock Manager Diagnostics.
Contains API prototypes and defines for the Error Manager Diagnostics.
Contains API prototypes for the Memory Manager Diagnostics.
Implements APIs for the Power Manager Diagnostics.
Contains API prototypes for the Watchdog Manager diagnostics.