![]() |
AVR SD Safety Framework 1.0.0
|
Contains API prototypes and defines for the Error Manager. More...
Files | |
| file | midware_error_manager.c |
| Implements APIs for the Error Manager. | |
| file | midware_error_manager.h |
| Contains API prototypes and defines for the Error Manager. | |
| file | midware_error_manager_diag.c |
| Implements APIs for the Error Manager Diagnostics. | |
| file | midware_error_manager_diag.h |
| Contains API prototypes and defines for the Error Manager Diagnostics. | |
Data Structures | |
| struct | errChConfig_t |
| Holds an error channel configuration for configuring the ERRCTRL. More... | |
| struct | errChConfigs_t |
| Holds configurations for all error channels. More... | |
Enumerations | |
| enum | errCh_t |
| Hardware error channels found in the Error Controller. More... | |
| enum | errChSeverity_t |
| Type definitions for error channel severity level. More... | |
Functions | |
| errFlag_t | MW_GetErrorChannel (errCh_t ch) |
| Reads the status of the specified error channel. | |
| errCh_t | MW_GetFirstSetErrorChannel (void) |
| Returns the first set error channel in the Error Controller. | |
| errFlag_t | MW_ClearErrorChannel (errCh_t ch) |
| Clears the specified error channel and confirms that the channel is cleared. | |
| errFlag_t | MW_CheckIoSafe (void) |
| Checks if all I/O pins are floated (tri-stated). | |
| void | MW_EnableForceFloat (void) |
| Enables forced floating (tri-stating) of all I/O pins. | |
| errFlag_t | MW_DisableForceFloat (void) |
| Disables forced floating (tri-stating) of all I/O pins. | |
| void | MW_StartHeartbeat (void) |
| Starts the Heartbeat output signal. | |
| void | MW_StopHeartbeat (void) |
| Stops the Heartbeat output signal. | |
| void | MW_SetAlarmInterruptType (bool useNmi) |
| Selects whether a normal or a Non-Maskable Interrupt (NMI) should occur when the Error Controller is in the ALARM state. | |
| errFlag_t | MW_ConfigErrorChannels (const errChConfigs_t *configs, uint8_t timeout) |
| Sets the error controller timeout duration and configures all error channels with the provided settings. | |
| errFlag_t | MW_DiagErrorChannelSplim (void) |
| Performs error injection diagnostic to detect faults in the SPLIM error channel. | |
| errFlag_t | MW_DiagErrorChannelCfd0 (void) |
| Performs error injection diagnostic to detect faults in the CFD0 error channel. | |
| errFlag_t | MW_DiagErrorChannelCfd1 (void) |
| Performs error injection diagnostic to detect faults in the CFD1 error channel. | |
| errFlag_t | MW_DiagErrorChannelCfm0 (void) |
| Performs error injection diagnostic to detect faults in the CFM0 error channel. | |
| errFlag_t | MW_DiagErrorChannelCfm1 (void) |
| Performs error injection diagnostic to detect faults in the CFM1 error channel. | |
| errFlag_t | MW_DiagErrorChannelEeprom (void) |
| Performs error injection diagnostic to detect faults in the EEPROM error channel. | |
| errFlag_t | MW_DiagErrorChannelEvsys0 (void) |
| Performs error injection diagnostic to detect faults in the EVSYS0 error channel. | |
| errFlag_t | MW_DiagErrorChannelEvsys1 (void) |
| Performs error injection diagnostic to detect faults in the EVSYS1 error channel. | |
Contains API prototypes and defines for the Error Manager.
The Error Manager provides services to Tasks to ensure correct interaction with features of the ERRCTRL peripheral.
| enum errCh_t |
Hardware error channels found in the Error Controller.
Each member of this enum corresponds to an error channel in the ERRCTRL. For a detailed description of each Error Channel, refer to the data sheet.
| enum errChSeverity_t |
Type definitions for error channel severity level.
| errFlag_t MW_CheckIoSafe | ( | void | ) |
Checks if all I/O pins are floated (tri-stated).
This function determines if all I/O pins are floated, indicating that the device is in a Safe State.
| ERROR | One or more I/O pins are not floated. |
| NO_ERROR | All I/O pins are floated. |
Clears the specified error channel and confirms that the channel is cleared.
This function clears the error channel by clearing its error flag in the Error Status Flag register. If clearing fails, it indicates that one of the error channel sources has not been cleared and an error is returned.
| ch | Which error channel to clear. |
| ERROR | Failed to clear the error channel, or invalid error channel input. |
| NO_ERROR | Error channel was cleared successfully. |
| errFlag_t MW_ConfigErrorChannels | ( | const errChConfigs_t * | configs, |
| uint8_t | timeout ) |
Sets the error controller timeout duration and configures all error channels with the provided settings.
This function configures the severity and floatIo setting for each error channel, and the timeout value for the Error Controller timeout mechanism. A countdown from the current timeout value is automatically started when entering the CONFIG state or ALARM state. If it times out, the Error Controller will automatically reset the device.
If the severity configuration for a channel is invalid, that channel will not be configured, and the function will return errFlag_t ERROR. All other channels with valid input will still be configured.
The system transitions to the CONFIG state for the error channel configuration. After the configuration is complete, the system is transitioned to the NORMAL state which is when the new timeout value is loaded.
Global interrupts are disabled during configuration to avoid timing out while the error controller is in the CONFIG state and restored to the original setting after configuration is complete.
Assumes the existing timeout is sufficiently long to complete configuration.
The timeout value is updated after all configuration is done and should be configured to account for the next entry into CONFIG state in addition to the ALARM state timeout.
Disabling the timeout mechanism (timeout = 0) is not permitted, and will return ERROR without configuring any channels.
The errChConfigs_t configs pointer must be initialized for all error channels, otherwise it will lead to undefined behavior.
| configs | The configuration for all error channels. |
| timeout | The next timeout value to use after configuration. |
| ERROR | Invalid timeout or config detected, or Error Controller is not in NORMAL state. |
| NO_ERROR | No invalid input detected. |
| errFlag_t MW_DiagErrorChannelCfd0 | ( | void | ) |
Performs error injection diagnostic to detect faults in the CFD0 error channel.
This function injects an error on the Clock Failure Detected 0 (CFD0) error channel directly to detect any faults in the error channel mechanism.
During the diagnostic, the CFD0 error channel is configured to have errChSeverity_t NOTIFICATION and disabled automatic float of all I/O pins. The original configuration is restored when the diagnostic is complete.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by initiating the error injection.
Error injection will not be initiated if the Error Controller is not in NORMAL state or the CFD0 error channel is already set.
| ERROR | Fault detected in the CFD0 error channel, or error injection did not start. |
| NO_ERROR | No fault detected in the CFD0 error channel. |
| errFlag_t MW_DiagErrorChannelCfd1 | ( | void | ) |
Performs error injection diagnostic to detect faults in the CFD1 error channel.
This function injects an error on the Clock Failure Detected 1 (CFD1) error channel directly to detect any faults in the error channel mechanism.
During the diagnostic, the CFD1 error channel is configured to have errChSeverity_t NOTIFICATION and disabled automatic float of all I/O pins. The original configuration is restored when the diagnostic is complete.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by initiating the error injection.
Error injection will not be initiated if the Error Controller is not in NORMAL state or the CFD1 error channel is already set.
| ERROR | Fault detected in the CFD1 error channel, or error injection did not start. |
| NO_ERROR | No fault detected in the CFD1 error channel. |
| errFlag_t MW_DiagErrorChannelCfm0 | ( | void | ) |
Performs error injection diagnostic to detect faults in the CFM0 error channel.
This function injects an error on the Clock Frequency Measurement Error 0 (CFM0) error channel directly to detect any faults in the error channel mechanism.
During the diagnostic, the CFM0 error channel is configured to have errChSeverity_t NOTIFICATION and disabled automatic float of all I/O pins. The original configuration is restored when the diagnostic is complete.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by initiating the error injection.
Error injection will not be initiated if the Error Controller is not in NORMAL state or the CFM0 error channel is already set.
| ERROR | Fault detected in the CFM0 error channel, or error injection did not start. |
| NO_ERROR | No fault detected in the CFM0 error channel. |
| errFlag_t MW_DiagErrorChannelCfm1 | ( | void | ) |
Performs error injection diagnostic to detect faults in the CFM1 error channel.
This function injects an error on the Clock Frequency Measurement Error 1 (CFM1) error channel directly to detect any faults in the error channel mechanism.
During the diagnostic, the CFM1 error channel is configured to have errChSeverity_t NOTIFICATION and disabled automatic float of all I/O pins. The original configuration is restored when the diagnostic is complete.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by initiating the error injection.
Error injection will not be initiated if the Error Controller is not in NORMAL state or the CFM1 error channel is already set.
| ERROR | Fault detected in the CFM1 error channel, or error injection did not start. |
| NO_ERROR | No fault detected in the CFM1 error channel. |
| errFlag_t MW_DiagErrorChannelEeprom | ( | void | ) |
Performs error injection diagnostic to detect faults in the EEPROM error channel.
This function injects an error on the EEPROM error channel directly to detect any faults in the error channel mechanism.
During the diagnostic, the EEPROM error channel is configured to have errChSeverity_t NOTIFICATION and disabled automatic float of all I/O pins. The original configuration is restored when the diagnostic is complete.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by initiating the error injection.
Error injection will not be initiated if the Error Controller is not in NORMAL state or the EEPROM error channel is already set.
| ERROR | Fault detected in the EEPROM error channel, or error injection did not start. |
| NO_ERROR | No fault detected in the EEPROM error channel. |
| errFlag_t MW_DiagErrorChannelEvsys0 | ( | void | ) |
Performs error injection diagnostic to detect faults in the EVSYS0 error channel.
This function injects an error on the Event System Input 0 (EVSYS0) error channel directly to detect any faults in the error channel mechanism.
During the diagnostic, the EVSYS0 error channel is configured to have errChSeverity_t NOTIFICATION and disabled automatic float of all I/O pins. The original configuration is restored when the diagnostic is complete.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by initiating the error injection.
Error injection will not be initiated if the Error Controller is not in NORMAL state or the EVSYS0 error channel is already set.
| ERROR | Fault detected in the EVSYS0 error channel, or error injection did not start. |
| NO_ERROR | No fault detected in the EVSYS0 error channel. |
| errFlag_t MW_DiagErrorChannelEvsys1 | ( | void | ) |
Performs error injection diagnostic to detect faults in the EVSYS1 error channel.
This function injects an error on the Event System Input 1 (EVSYS1) error channel directly to detect any faults in the error channel mechanism.
During the diagnostic, the EVSYS1 error channel is configured to have errChSeverity_t NOTIFICATION and disabled automatic float of all I/O pins. The original configuration is restored when the diagnostic is complete.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by initiating the error injection.
Error injection will not be initiated if the Error Controller is not in NORMAL state or the EVSYS1 error channel is already set.
| ERROR | Fault detected in the EVSYS1 error channel, or error injection did not start. |
| NO_ERROR | No fault detected in the EVSYS1 error channel. |
| errFlag_t MW_DiagErrorChannelSplim | ( | void | ) |
Performs error injection diagnostic to detect faults in the SPLIM error channel.
This function injects an error on the Stack Pointer Limit (SPLIM) error channel directly to detect any faults in the error channel mechanism.
During the diagnostic, the SPLIM error channel is configured to have errChSeverity_t NOTIFICATION and disabled automatic float of all I/O pins. The original configuration is restored when the diagnostic is complete.
This function disables global interrupts during its execution to ensure atomic execution and that accidental interrupts are not triggered by initiating the error injection.
Error injection will not be initiated if the Error Controller is not in NORMAL state or the SPLIM error channel is already set.
| ERROR | Fault detected in the SPLIM error channel, or error injection did not start. |
| NO_ERROR | No fault detected in the SPLIM error channel. |
| errFlag_t MW_DisableForceFloat | ( | void | ) |
Disables forced floating (tri-stating) of all I/O pins.
This function attempts to disable the forced floating of all I/O pins and will return an errFlag_t which reflects whether the disabling was successful or not.
| ERROR | Failed to disable forced floating. |
| NO_ERROR | Successfully disabled forced floating. |
| void MW_EnableForceFloat | ( | void | ) |
Enables forced floating (tri-stating) of all I/O pins.
This function will immediately float all I/O pins, thereby transitioning the device into a Safe State.
Reads the status of the specified error channel.
This function reads the Error Status Flag of the specified error channel and returns an error if the flag is set.
| ch | Which error channel to read. |
| ERROR | Error channel is set, or invalid error channel input. |
| NO_ERROR | Error channel is not set. |
| errCh_t MW_GetFirstSetErrorChannel | ( | void | ) |
Returns the first set error channel in the Error Controller.
This function reads the Error Status Flag register and returns the first error channel that is set, starting from the lowest numbered channel in errCh_t. If no error channel is set, ERRCH_MAX is returned. The reported channel is not cleared, see MW_ClearErrorChannel.
MW_GetErrorChannel to check a specific channel.
| void MW_SetAlarmInterruptType | ( | bool | useNmi | ) |
Selects whether a normal or a Non-Maskable Interrupt (NMI) should occur when the Error Controller is in the ALARM state.
This function configures the interrupt type setting for when the ERRCTRL transitions into the ALARM state. This occurs when an error channel configured to ERRCH_SEVERITY_NONCRITICAL is set.
If NMI is enabled, it may preempt an ongoing interrupt handler for the same error source. Since the error source can generate both a direct interrupt and an ERRCTRL interrupt, this creates an interrupt handling hazard that can leave the software state inconsistent. It is recommended that the NMI routine triggers a device reset.
| useNmi | Enables or disables using NMI when the ERRCTRL issues an Interrupt Request (IRQ) after entering the ALARM state. |
| void MW_StartHeartbeat | ( | void | ) |
Starts the Heartbeat output signal.
This function enables the 1 kHz square wave heartbeat signal output on an I/O pin. When enabled, the error controller will tri-state the signal when it enters the FAULT state, and force it low when entering the CONFIG state.
| void MW_StopHeartbeat | ( | void | ) |
Stops the Heartbeat output signal.
This function stops the heartbeat output on the configured I/O pin. Stopping the heartbeat can be used to explicitly signal a failure to the surrounding system. See MW_StartHeartbeat.