FuSa 8-Bit Libraries Safety Framework
Loading...
Searching...
No Matches
task_manager_startup.c
Go to the documentation of this file.
1
22
23// Standard Library Includes
24#include <stddef.h>
25#include <stdint.h>
26
27// Framework Includes
29#include <tasks_config.h>
30#include <tasks_shared.h>
31#include <tasks_startup.h>
32
33void TM_Startup(const scheduleEntry_t appStartupSchedule[], uint8_t scheduleLength)
34{
36 // Initialize hardware safety mechanisms according to configs and FMEDA
38 // Ensure startup diagnostics Task has fixed duration
40 asm("wdr");
42 // Execute all Tasks in application schedule, skip if Task function pointer is NULL
43
44 for (uint8_t i = 0U; i < scheduleLength; i++)
45 {
46 task_t nextTask = appStartupSchedule[i].task;
47 uint32_t nextDuration = appStartupSchedule[i].duration;
48 if (nextTask != NULL)
49 {
50 // Ensure next Task has fixed duration
51 T_HandleSyncWatchdog(nextDuration);
52 nextTask();
53 }
54 }
55
56 // Ensure a fixed duration, including the time until the next T_HandleSyncWatchdog call
57 uint32_t exitDuration = DUR_START_MISSION_MODE + DUR_UNTIL_FIRST_SCHEDULE;
58 T_HandleSyncWatchdog(exitDuration);
59 T_StartMissionMode(); // Exit Safe State
60}
void(* task_t)(void)
Defines a function pointer type for tasks.
static const scheduleEntry_t appStartupSchedule[STARTUP_SCHEDULE_LEN]
Defines an example Application Startup Schedule with optional Tasks.
void T_HandleSyncWatchdog(uint32_t newTimeout)
Waits until the current Synchronous Watchdog timeout is completed before clearing and setting the nex...
void T_RunStartupDiagnostics(void)
Runs all enabled startup diagnostics and reports any detected faults to the Error Handler.
void T_HandlePreStartupErrors(void)
Retrieves and validates stored Pre-startup error flags from persistent memory and reports them to the...
void T_StartMissionMode(void)
Transitions the device from Safe State into Mission Mode.
void T_InitSafetySystem(void)
Initializes the Safety System according to Assumptions of Use and user configurations.
void TM_Startup(const scheduleEntry_t appStartupSchedule[], uint8_t scheduleLength)
Manages and synchronizes safety system and application startup Tasks.
#define DUR_START_MISSION_MODE
Configures the run-time duration for T_StartMissionMode in system clock cycles.
#define DUR_RUN_STARTUP_DIAGNOSTICS
Configures the run-time duration for T_RunStartupDiagnostics in system clock cycles.
#define DUR_UNTIL_FIRST_SCHEDULE
Configures the run-time duration between exiting TM_Startup and the first T_HandleSyncWatchdog call i...
Defines a schedule entry containing a task function pointer and its duration.