FuSa 8-Bit Libraries Safety Framework
Loading...
Searching...
No Matches
error_handler_actions.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_tasks_config.h>
35
36static errId_t errorIdStack[NOTIFICATION_LOG_SIZE];
37static uint8_t errorIdStackIndex = 0U;
38
40{
41 // Convert ID to a value for storing the reset reason in persistent memory
42 const uint8_t idVal = (uint8_t)id;
43
45 MW_EnableForceFloat(); // Force float (tri-state) all I/O pins
47
48 // Try to issue a software reset until successful or the watchdog expires
49 while (FOREVER)
50 {
52 // If reset failed, try stopping the heartbeat signal to get an external system reset
54 MW_EnableForceFloat(); // In case the previous attempt failed
55 }
56}
57
59{
60 // Ignore push if stack is full or Error ID is ERRID_NONE
61 if ((errorIdStackIndex < NOTIFICATION_LOG_SIZE) && (id != ERRID_NONE))
62 {
63 errorIdStack[errorIdStackIndex] = id;
64 errorIdStackIndex++;
65 }
66}
67
69{
71
72 // Ensure stack is not empty
73 if (errorIdStackIndex > 0U)
74 {
75 errorIdStackIndex--;
76 // Get last Error ID from stack
77 id = errorIdStack[errorIdStackIndex];
78 }
79
80 // Ensure Error ID is valid
81 if (id >= ERRID_MAX)
82 {
83 id = ERRID_ERRID_VAL;
84 }
85 return id;
86}
errId_t
Defines unique Error IDs for reporting system errors to EH_HandleError.
@ ERRID_MAX
@ ERRID_NONE
@ ERRID_ERRID_VAL
Contains API prototypes for Error Handler Actions.
#define NOTIFICATION_LOG_SIZE
Configures the maximum number of Error IDs allowed in the Notification Error Log.
errId_t EH_PopNotificationLog(void)
Pops the last Error ID from the Notification Error Log for error handling.
void EH_PushNotificationLog(errId_t id)
Pushes Error ID to the Notification Error Log for later handling.
void EH_InitiateSafeState(errId_t id)
Transitions the system into a Safe State and resets the device.
void MW_StopHeartbeat(void)
Stops the Heartbeat output signal.
void MW_EnableForceFloat(void)
Enables forced floating (tri-stating) of all I/O pins.
void MW_DisableGlobalInterrupts(void)
Disables global interrupts on the device.
void MW_StorePersistentVal(persistentVal_t valueType, uint8_t value)
Stores a value in General Purpose Registers (GPR) for perserving data between resets.
@ PVAL_ERRID_REASON
void MW_ResetDevice(void)
Issues a software reset request to reset the device.
#define FOREVER
Allows testing of infinite while loops by replacing the definition during testing.