![]() |
FuSa 8-Bit Libraries Safety Framework
|
Contains API prototypes for Startup Tasks. More...
Files | |
| file | tasks_startup.c |
| Implements APIs for Startup Tasks. | |
| file | tasks_startup_callbacks.c |
| Implements API for Startup Tasks callback example. | |
| file | tasks_startup_callbacks.h |
| Contains API prototype for Startup Tasks callback example. | |
| file | tasks_startup_private.c |
| Implements private function APIs for tasks_startup.h. | |
| file | tasks_startup_private.h |
| Contains private function prototypes for tasks_startup.h. | |
Functions | |
| void | T_HandlePreStartupErrors (void) |
| Retrieves and validates stored Pre-startup error flags from persistent memory and reports them to the Error Handler. | |
| void | T_InitSafetySystem (void) |
| Initializes the Safety System according to Assumptions of Use and user configurations. | |
| void | T_RunStartupDiagnostics (void) |
| Runs all enabled startup diagnostics and reports any detected faults to the Error Handler. | |
| void | T_StartMissionMode (void) |
| Transitions the device from Safe State into Mission Mode. | |
| void | T_HandleResetReason (void) |
| Retrieves and validates stored reset info from persistent memory and issues configurable callback for handling. | |
| void | T_ResetReasonExampleCallback (resetInfo_t resetInfo) |
| Demonstrates an implementation of a Handle Reset Reason callback function. | |
Contains API prototypes for Startup Tasks.
The Startup Tasks APIs are used by the Startup Task Manager to initialize the Safety System.
| void T_HandlePreStartupErrors | ( | void | ) |
Retrieves and validates stored Pre-startup error flags from persistent memory and reports them to the Error Handler.
This function is responsible for retrieving and validating error flags stored in persistent memory. If the flags are reliable, all stored flags are evaluated and handled using EH_HandleError.
The error flags are stored in persistent memory by T_EnsureSafeState for safe I/O faults and by T_RunResetDiagnosticFsm when it comes to Pre-Startup diagnostics. If the error flags in persistent memory is determined to be unreliable, it is reported to the Error Handler with the ERRID_GPR_FLAGS Error ID without reporting the stored errors.
Definition at line 51 of file tasks_startup.c.
| void T_HandleResetReason | ( | void | ) |
Retrieves and validates stored reset info from persistent memory and issues configurable callback for handling.
This function is responsible for retrieving and validating the reset reason stored in persistent memory. If the reset reason is valid, it then issues a configurable resetReasonCallback to handle the reset reason. If the reset is due to a software reset it will also handle the stored Error ID and pass it to the callback.
The reset reason is stored in persistent memory by T_DetermineResetReason. If the reset reason value in persistent memory is determined to be unreliable, it is reported to the Error Handler with the ERRID_GPR_VALS Error ID without calling the callback function. If the stored value itself is not in the valid range of the reset reason type, it will default to RSTRSN_UNKNOWN.
The Error ID is stored in persistent memory by EH_InitiateSafeState. If the Error ID is valid and is a software reset then the function will retrieve the Error ID. If the stored value itself is not in the valid range of the Error ID type, it will default to ERRID_NONE.
Definition at line 176 of file tasks_startup.c.
| void T_InitSafetySystem | ( | void | ) |
Initializes the Safety System according to Assumptions of Use and user configurations.
This function initializes device safety mechanisms and safety related features according to safety requirements derived from the Assumptions of Use (AoUs) for the device Technical Safety Concept and Safety Element out of Context (SEooC) definition. This ensures that the Safety System is initialized during the Startup sequence. Some settings are application dependent and can be configured using macros at compile-time. However, some settings require broader application context or is not strictly safety related. These settings should be configured later by the application. Any configuration errors detected are reported to the Error Handler.
Watchdogs: The Watchdog Timer (WDT) is enabled in Normal mode with an initial duration configured by INIT_WDT_DURATION for the duration of the Startup sequence. The Synchronous Watchdog Timer (SWDT) is enabled in clock mode with a fixed open window configured by SWDT_OPEN_WINDOW and an initial closed window configured by INIT_SWDT_DURATION. The register protection feature is enabled to avoid accidental modification, but is not locked since the open window is intended to be updated later.
Clocks: The main clock is set to use the internal high frequency oscillator as the source and to run at a frequency configured by INIT_CLOCK_FRQ and INIT_CLOCK_DIV. The Clock Failure Detect 0 (CFD0) is enabled to monitor the main clock with the internal 32K oscillator as reference. The Clock Frequency Monitor 0 (CFM0) is enabled to monitor the main clock in continuous mode with the internal 32K oscillator as reference, using a tolerance window configured by INIT_CFM0_WIN_LOW, INIT_CFM0_WIN_REF and INIT_CFM0_WIN_HIGH.
Error Controller: The error controller ALARM state timeout (time until promoting a NONCRITICAL error to CRITICAL) is configured by INIT_ERRCTRL_TIMEOUT. The error controller heartbeat feature is configured by HEARTBEAT_OUTPUT. The criticality configured for each Error ID corresponding to a specific error controller channel (ending with _CH) in errorIdCritLut is translated to a severity for each error channel. The I/O float setting for each channel is configured by INIT_FLOAT_NONCRITICAL and INIT_FLOAT_NOTIFICATION depending on the channel severity.
Interrupts: The interrupt scheduling and priority is configured by INIT_INT_ROUND_ROBIN, INIT_INT_LVL0_START and INIT_INT_LVL1. All device error interrupt sources are enabled, regardless of the configured criticality of their corresponding Error IDs since:
All sources in the following interrupt vectors are enabled:
Power: Sets the device sleep mode to SLP_MODE_IDLE since deeper sleep modes requires special consideration. See TM_Shutdown. The Voltage Regulator Monitor (VMON) mode and sleep mode is configured by INIT_VMON_FULL_POWER_MODE and INIT_VMON_ALWAYS_ON. The Voltage Level Monitor (VLM) level threshold (percentage relative to Brown-out Detector level) and trigger is configured by INIT_VLM_THRESHOLD and INIT_VLM_TRIGGER.
Memories: Enables the Stack Pointer Limit (SPLIM) feature by setting a RAM address limit configured by INIT_STACK_LIMIT and optionally locking that value depending on INIT_STACK_LIMIT_LOCK configuration. The NVM ECC behaviour when reading all ones from an address is configured by INIT_NVM_ECC_ALL_ONES.
Definition at line 74 of file tasks_startup.c.
| void T_ResetReasonExampleCallback | ( | resetInfo_t | resetInfo | ) |
Demonstrates an implementation of a Handle Reset Reason callback function.
| resetInfo | A structure containing the Reset Reason as determined in T_DetermineResetReason and the software reset Error ID as determined in EH_InitiateSafeState. The values are validated in T_HandleResetReason before the callback is called. |
Definition at line 26 of file tasks_startup_callbacks.c.
| void T_RunStartupDiagnostics | ( | void | ) |
Runs all enabled startup diagnostics and reports any detected faults to the Error Handler.
This function runs a series of startup diagnostics to detect any latent faults in the system by performing error injections in the hardware safety mechanisms on the device. Any faults detected are reported to the Error Handler.
Configuration Macros:
Definition at line 103 of file tasks_startup.c.
| void T_StartMissionMode | ( | void | ) |
Transitions the device from Safe State into Mission Mode.
This function is responsible for transitioning the system from the Safe State used while running the Startup sequence to the Mission Mode state required when running the application. The Watchdog is configured to run in Window mode (WWDT) with a timeout configured by WWDT_OPEN_WINDOW and WWDT_CLOSED_WINDOW to ensure the device meets the Fault Detection Time Interval (FDTI). Global interrupts are enabled to ensure that any detected hardware errors are reported and handled. If STRICT_SAFE_STATE is enabled, this function also disables force floating (tri-stating) of all I/O pins simultaneously, ensuring a strict transition between the Safe State and Mission Mode even if peripherals and PORT pins have been initialized. Any detected configuration errors are reported to the Error Handler.
Definition at line 151 of file tasks_startup.c.