Files
RTOS/config/task_config.h
T
root ca13734bf0 Add full automotive RTOS project
Add kernel (Cortex-M0/M3/M4, Tricore, S32K, RISC-V ports), drivers,
middleware (CAN stack, diagnostics, safety), applications, board
support, build/test tooling, and documentation.
2026-08-23 03:35:29 -04:00

192 lines
7.4 KiB
C

/**
* @file task_config.h
* @brief Task configuration for automotive applications
*/
#ifndef TASK_CONFIG_H
#define TASK_CONFIG_H
#include "kernel_config.h"
/* ============================================================================
* Task Priority Definitions
* ============================================================================ */
/* Critical safety tasks (highest priority) */
#define TASK_PRIORITY_SAFETY_CRITICAL 0
#define TASK_PRIORITY_ENGINE_CONTROL 1
#define TASK_PRIORITY_BRAKE_CONTROL 1
#define TASK_PRIORITY_ABS_CONTROL 2
#define TASK_PRIORITY_AIRBAG_CONTROL 2
/* Real-time control tasks */
#define TASK_PRIORITY_FUEL_INJECTION 3
#define TASK_PRIORITY_IGNITION_CONTROL 3
#define TASK_PRIORITY_TRANSMISSION 4
#define TASK_PRIORITY_STEERING_CONTROL 4
/* Communication tasks */
#define TASK_PRIORITY_CAN_COMM 5
#define TASK_PRIORITY_LIN_COMM 6
#define TASK_PRIORITY_DIAGNOSTICS 6
/* Sensor processing tasks */
#define TASK_PRIORITY_SENSOR_READING 7
#define TASK_PRIORITY_SENSOR_FUSION 7
#define TASK_PRIORITY_DATA_LOGGING 8
/* Body control tasks */
#define TASK_PRIORITY_BODY_CONTROL 8
#define TASK_PRIORITY_DOOR_CONTROL 9
#define TASK_PRIORITY_LIGHTING_CONTROL 9
/* User interface tasks */
#define TASK_PRIORITY_DISPLAY 10
#define TASK_PRIORITY_GAUGE_CONTROL 10
#define TASK_PRIORITY_INFOTAINMENT 11
/* Background tasks (lowest priority) */
#define TASK_PRIORITY_DIAGNOSTIC_MONITOR 12
#define TASK_PRIORITY_MAINTENANCE 13
#define TASK_PRIORITY_IDLE IDLE_TASK_PRIORITY
/* ============================================================================
* Task Period Definitions (in milliseconds)
* ============================================================================ */
/* Safety-critical periods */
#define TASK_PERIOD_AIRBAG_CONTROL 1
#define TASK_PERIOD_ABS_CONTROL 1
#define TASK_PERIOD_ENGINE_CONTROL 1
/* Control loop periods */
#define TASK_PERIOD_FUEL_INJECTION 5
#define TASK_PERIOD_IGNITION_CONTROL 5
#define TASK_PERIOD_BRAKE_CONTROL 5
#define TASK_PERIOD_STEERING_CONTROL 5
/* Communication periods */
#define TASK_PERIOD_CAN_COMM 10
#define TASK_PERIOD_LIN_COMM 20
#define TASK_PERIOD_DIAGNOSTICS 50
/* Sensor periods */
#define TASK_PERIOD_SENSOR_READING 2
#define TASK_PERIOD_SENSOR_FUSION 10
#define TASK_PERIOD_DATA_LOGGING 100
/* Body control periods */
#define TASK_PERIOD_BODY_CONTROL 50
#define TASK_PERIOD_DOOR_CONTROL 100
#define TASK_PERIOD_LIGHTING_CONTROL 100
/* Display periods */
#define TASK_PERIOD_DISPLAY 50
#define TASK_PERIOD_GAUGE_CONTROL 10
#define TASK_PERIOD_INFOTAINMENT 100
/* Background periods */
#define TASK_PERIOD_DIAGNOSTIC_MONITOR 500
#define TASK_PERIOD_MAINTENANCE 1000
/* ============================================================================
* Task Stack Sizes (in bytes)
* ============================================================================ */
/* Safety-critical task stacks */
#define TASK_STACK_AIRBAG_CONTROL 2048
#define TASK_STACK_ABS_CONTROL 2048
#define TASK_STACK_ENGINE_CONTROL 2048
/* Control task stacks */
#define TASK_STACK_FUEL_INJECTION 1024
#define TASK_STACK_IGNITION_CONTROL 1024
#define TASK_STACK_BRAKE_CONTROL 1024
#define TASK_STACK_STEERING_CONTROL 1024
/* Communication task stacks */
#define TASK_STACK_CAN_COMM 2048
#define TASK_STACK_LIN_COMM 1024
#define TASK_STACK_DIAGNOSTICS 2048
/* Sensor task stacks */
#define TASK_STACK_SENSOR_READING 1024
#define TASK_STACK_SENSOR_FUSION 2048
#define TASK_STACK_DATA_LOGGING 4096
/* Body control task stacks */
#define TASK_STACK_BODY_CONTROL 1024
#define TASK_STACK_DOOR_CONTROL 1024
#define TASK_STACK_LIGHTING_CONTROL 1024
/* Display task stacks */
#define TASK_STACK_DISPLAY 4096
#define TASK_STACK_GAUGE_CONTROL 1024
#define TASK_STACK_INFOTAINMENT 8192
/* Background task stacks */
#define TASK_STACK_DIAGNOSTIC_MONITOR 2048
#define TASK_STACK_MAINTENANCE 1024
/* ============================================================================
* Task Configuration Table
* ============================================================================ */
typedef struct {
const char* name;
uint8_t priority;
uint16_t period_ms;
uint32_t stack_size;
uint32_t deadline_ms;
bool is_periodic;
bool is_critical;
} TaskConfigEntry_t;
/* Task configuration table */
static const TaskConfigEntry_t task_config_table[] = {
/* Name Priority Period Stack Deadline Periodic Critical */
{"Airbag Control", 0, 1, 2048, 2, true, true},
{"ABS Control", 2, 1, 2048, 2, true, true},
{"Engine Control", 1, 1, 2048, 2, true, true},
{"Brake Control", 1, 5, 1024, 10, true, true},
{"Fuel Injection", 3, 5, 1024, 10, true, false},
{"Ignition Control", 3, 5, 1024, 10, true, false},
{"Steering Control", 4, 5, 1024, 10, true, false},
{"Transmission Control", 4, 10, 2048, 20, true, false},
{"CAN Communication", 5, 10, 2048, 20, true, false},
{"LIN Communication", 6, 20, 1024, 40, true, false},
{"Diagnostics", 6, 50, 2048, 100, true, false},
{"Sensor Reading", 7, 2, 1024, 4, true, false},
{"Sensor Fusion", 7, 10, 2048, 20, true, false},
{"Data Logging", 8, 100, 4096, 200, true, false},
{"Body Control", 8, 50, 1024, 100, true, false},
{"Door Control", 9, 100, 1024, 200, true, false},
{"Lighting Control", 9, 100, 1024, 200, true, false},
{"Display", 10, 50, 4096, 100, true, false},
{"Gauge Control", 10, 10, 1024, 20, true, false},
{"Infotainment", 11, 100, 8192, 200, true, false},
{"Diagnostic Monitor", 12, 500, 2048, 1000, true, false},
{"Maintenance", 13, 1000, 1024, 2000, true, false},
};
/* Number of tasks in configuration table */
#define TASK_CONFIG_COUNT (sizeof(task_config_table) / sizeof(TaskConfigEntry_t))
/* ============================================================================
* Task Supervision Configuration
* ============================================================================ */
/* Enable task supervision */
#define TASK_SUPERVISION_ENABLED 1
/* Default task timeout in milliseconds */
#define TASK_DEFAULT_TIMEOUT_MS 1000
/* Maximum alive counter before reset */
#define TASK_MAX_ALIVE_COUNT 5
/* Task supervision check period */
#define TASK_SUPERVISION_PERIOD_MS 100
#endif /* TASK_CONFIG_H */