FuSa 8-Bit Libraries Safety Framework
Loading...
Searching...
No Matches
tasks_shared.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
29#include <define_error_flags.h>
30#include <define_error_ids.h>
31#include <error_handler.h>
35#include <tasks_config.h>
36#include <tasks_shared.h>
38
39// Private function prototypes
40
41/*
42 * The following functions are designed to optimize memory and execution time usage by leveraging
43 * static configuration and elimination of dead code at compile-time: the checker code for each
44 * channel is only compiled if the corresponding Error ID is configured to 'NOTIFICATION'
45 * criticality. It is assumed that in most applications, few or no channels are set to
46 * 'NOTIFICATION', resulting in significant potential savings in both hex file size and execution
47 * time with higher optimization levels.
48 */
49static void HandleClockNotificationErrors(void);
50static void HandleCpuNotificationErrors(void);
51static void HandleMemoryNotificationErrors(void);
52static void HandlePowerNotificationErrors(void);
53static void HandleWatchdogNotificationErrors(void);
54static void HandleEvsysNotificationErrors(void);
55
57{
58 /*
59 * For each Error Controller channel configured with 'NOTIFICATION' criticality, clear the error
60 * source and channel if set, then report to the Error Handler.
61 */
62 HandleClockNotificationErrors();
63 HandleCpuNotificationErrors();
64 HandleMemoryNotificationErrors();
65 HandlePowerNotificationErrors();
66 HandleWatchdogNotificationErrors();
67 HandleEvsysNotificationErrors();
68
69 // Go through each error in the notification error log and call the configured callback
71}
72
73static void HandleClockNotificationErrors(void)
74{
76 {
78 }
79
81 {
83 }
84
86 {
88 }
89
91 {
93 }
94}
95
96static void HandleCpuNotificationErrors(void)
97{
99 {
101 }
102
104 {
106 }
107
109 {
111 }
112}
113
114static void HandleMemoryNotificationErrors(void)
115{
116
118 {
120 }
121
123 {
125 }
126
128 {
130 }
131
133 {
135 }
136
138 {
140 }
141}
142
143static void HandlePowerNotificationErrors(void)
144{
146 {
148 }
149
151 {
153 }
154}
155
156static void HandleWatchdogNotificationErrors(void)
157{
159 {
161 }
162}
163
164static void HandleEvsysNotificationErrors(void)
165{
167 {
169 }
170
172 {
174 }
175}
176
177void T_HandleSyncWatchdog(uint32_t newTimeout)
178{
179 errFlag_t flag = NO_ERROR;
180
181 MW_PreClearSwdt(); // Send pre-clear command
182
183 // Set the closed window period equal to the new timeout value
184 uint32_t newReset = newTimeout + SWDT_OPEN_WINDOW;
185 if (newReset < newTimeout) // Test for overflow
186 {
187 flag = ERROR;
188 }
189 else
190 {
191 // Set timeout for the next SWDT period
192 flag = MW_SetSwdtResetValue(newReset);
193 }
195
196 /* Intentional misra-c2012-2.2/14.3 deviation */
198 {
199 // Verify that the SWDT counter is not stuck
200 flag = MW_DiagSwdtCount();
201 // Report potential error now to avoid waiting on exiting closed window forever
203 }
204
205 // Wait until the closed window is over and send clear command within the small open window
206 MW_ClearSwdt();
207}
208
210{
211 /* Intentional misra-c2012-2.2/14.3 deviation */
213 {
214 // Ensure the WDT counter is running
215 errFlag_t flag = MW_DiagWdtCountEnd(); // Assumes MW_DiagWdtCountBegin() has been called
217 }
218
219 MW_ClearWdt(); // Reset the Watchdog
220}
Define for criticality of specific errors.
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.
@ NO_ERROR
Defines for IDs associated with specific errors.
@ ERRID_SWDT_RESET_VAL
@ ERRID_CFD1_CH
@ ERRID_SWDT_CH
@ ERRID_CFM1_CH
@ ERRID_VREGWARN_CH
@ ERRID_BUSERR_CH
@ ERRID_FLASH1_CH
@ ERRID_RAM1_CH
@ ERRID_VREGFAIL_CH
@ ERRID_SPLIM_CH
@ ERRID_EEPROM_CH
@ ERRID_CFD0_CH
@ ERRID_DIAG_WDT_COUNT
@ ERRID_EVSYS0_CH
@ ERRID_OPC_CH
@ ERRID_FLASH2_CH
@ ERRID_DIAG_SWDT_COUNT
@ ERRID_RAM2_CH
@ ERRID_CFM0_CH
@ ERRID_EVSYS1_CH
const errCrit_t errorIdCritLut[ERRID_MAX]
Configures the criticality of all Error IDs for handling in EH_HandleError.
void EH_ProcessNotificationLog(void)
Processes all Error IDs in the log by calling the configured handler callback.
void EH_HandleError(errFlag_t flag, errId_t id)
Handles error based on configured Error ID criticality if the error flag is set.
void ReportClearEepromChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearFlash2ChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearRam2ChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearFlash1ChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void T_HandleSyncWatchdog(uint32_t newTimeout)
Waits until the current Synchronous Watchdog timeout is completed before clearing and setting the nex...
void ReportClearSwdtChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearEvsys1ChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearCfd0ChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearRam1ChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearVregwarnChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearSplimChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearBuserrChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearOpcChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearCfm0ChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearCfd1ChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearVregfailChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void T_HandleWatchdog(void)
Clears the Watchdog Timer (WDT) while performing the WDT count diagnostic.
void ReportClearCfm1ChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void ReportClearEvsys0ChannelError(void)
Private function, only exposed for unit testing and should not be called directly.
void T_HandleNotificationErrors(void)
Ensures Error IDs with 'NOTIFICATION' criticality are handled.
#define SWDT_OPEN_WINDOW
Configures the open window size used for the Synchronous Watchdog (SWDT).
#define DIAG_PERIODIC_SWDT_COUNT
Enables or disables execution of the SWDT count diagnostic in T_HandleSyncWatchdog.
#define DIAG_PERIODIC_WDT_COUNT
Enables or disables periodic completion of the WDT Count diagnostic in T_HandleWatchdog.
#define ENABLED
Used to enable optional Task features through macro configurations.
void MW_PreClearSwdt(void)
Sends a PRECLEAR command to the Synchronous Watchdog.
void MW_ClearSwdt(void)
Sends a CLEAR command to the Synchronous Watchdog.
errFlag_t MW_DiagSwdtCount(void)
Performs diagnostic to detect faults in the Synchronous Watchdog Timer (SWDT) Counter mechanism.
errFlag_t MW_SetSwdtResetValue(uint32_t resetVal)
Sets the Synchronous Watchdog Timer countdown reset value.
void MW_ClearWdt(void)
Clears the Watchdog Timer by issuing a Watchdog Reset (WDR) instruction.
errFlag_t MW_DiagWdtCountEnd(void)
Completes diagnostic to detect faults in the Watchdog Timer (WDT) Counter mechanism.
Contains API prototypes for the Watchdog Manager diagnostics.
Contains private function prototypes for tasks_shared.h.