/*------------------------------------------------------------------*/ void main(void) { // Init the system C_HEAT_Init(); // Start the watchdog WATCHDOG_Init(); while(1) // 'for ever' (Super Loop) { // Find out what temperature the user requires // (via the user interface) C_HEAT_Get_Required_Temperature(); // Find out what the current room temperature is // (via temperature sensor) C_HEAT_Get_Actual_Temperature(); // Adjust the gas burner, as required C_HEAT_Control_Boiler(); // Feed the watchdog WATCHDOG_Feed(); } }
/*--------------------------------------------------------------------*- SYSTEM_Configure_Required_Mode() Configure the system in the required mode. -*--------------------------------------------------------------------*/ void SYSTEM_Configure_Required_Mode(void) { switch (System_mode_G) { default: // Default to "FAIL_SILENT" case FAIL_SILENT: // Reset caused by WDT // Trigger "fail silent" behaviour SYSTEM_Perform_Safe_Shutdown(); break; case NORMAL: mcu_init(); // Set up WDT // Set to overflow after ~12ms WATCHDOG_Init(); // Set up scheduler for 1 ms ticks SCH_Init(); // Prepare for heartbeat task HEARTBEAT_Init(); // Add tasks to schedule. // Parameters are: // 1. Task name // 2. Initial delay / offset (in Ticks) // 3. Task period (in Ticks): Must be > 0 // 4. Task WCET (in microseconds) // 5. Task BCET (in microseconds) // Add watchdog task first SCH_Add_Task(WATCHDOG_Update, 0, 1500, 10, 0); // Add heartbeat task SCH_Add_Task(HEARTBEAT_Update, 0, 1000, 20, 0); // Feed the watchdog WATCHDOG_Update(); break; } }