Extra Files#

Some files in the Apps folder don’t contain any task code, but instead contain higher level interfaces, calibration data, and supporting structures. Some of these files will likely be relocated in the future.

Pedal to Percent#

This file contains an array for converting a pedal percentage (the index into the array) into a float between 0 and 1. The mapping is currently linear, but this can be changed. The file was created in order to avoid costly floating point operations (since we’ve turned the floating point unit off), and should really be somewhere else (perhaps the driver layer).

Tasks#

This file contains the storage for all general tasks related objects, including stacks, TCBs, mutexes, and semaphores. All task files include Tasks.h and thus have access to them.

group Tasks

Defines

TASK_INIT_PRIO 2#

Task initialization macro

Parameters:
  • task – name of the task

  • prio – the task’s priority

  • arg – the argument to pass to the task

  • err – the local OS_ERR variable Priority Definitions

TASK_READ_TRITIUM_PRIO 3#
TASK_SEND_TRITIUM_PRIO 4#
TASK_READ_CAR_CAN_PRIO 5#
TASK_SEND_CAR_CAN_PRIO 6#
TASK_PUT_IOSTATE_PRIO 7#
TASK_UPDATE_DISPLAY_PRIO 8#
TASK_DEBUG_DUMP_PRIO 9#
TASK_COMMAND_LINE_PRIO 10#
DEFAULT_STACK_SIZE 256#

Stack Sizes

WATERMARK_STACK_LIMIT DEFAULT_STACK_SIZE/2#
TASK_INIT_STACK_SIZE DEFAULT_STACK_SIZE#
TASK_SEND_TRITIUM_STACK_SIZE DEFAULT_STACK_SIZE#
TASK_READ_CAR_CAN_STACK_SIZE DEFAULT_STACK_SIZE#
TASK_UPDATE_DISPLAY_STACK_SIZE DEFAULT_STACK_SIZE#
TASK_READ_TRITIUM_STACK_SIZE DEFAULT_STACK_SIZE#
TASK_SEND_CAR_CAN_STACK_SIZE DEFAULT_STACK_SIZE#
TASK_DEBUG_DUMP_STACK_SIZE DEFAULT_STACK_SIZE#
TASK_COMMAND_LINE_STACK_SIZE DEFAULT_STACK_SIZE#
TASK_TRACE_LENGTH 8#

Task trace

Stores the last TASK_TRACE_LENGTH tasks that were run The most recent task is at tasks[index], the one before at tasks[index-1], wrapping back around at the beginnning

assertOSError(err) _assertOSError(err);#

Typedefs

typedef uint16_t error_code_t#

Task error variable type

Enums

enum error_scheduler_lock_opt_t#

Error-handling option enums

Values:

enumerator OPT_NO_LOCK_SCHED#
enumerator OPT_LOCK_SCHED#
enum error_recov_opt_t#

Values:

enumerator OPT_RECOV#
enumerator OPT_NONRECOV#

Functions

void Task_Init(void *p_arg)#

Task Prototypes

void Task_SendTritium(void *p_arg)#

Follows the FSM to update the velocity of the car.

void Task_ReadCarCAN(void *p_arg)#
void Task_UpdateDisplay(void *p_arg)#

Loops through the display queue and sends all messages.

void Task_ReadTritium(void *p_arg)#
void Task_SendCarCAN(void *p_arg)#

Grabs the latest messages from the queue and sends over CarCAN.

void Task_DebugDump(void *p_arg)#
void Task_CommandLine(void *p_arg)#
void TaskSwHook_Init(void)#

Initialize the task switch hook Registers the hook with the RTOS.

void EmergencyContactorOpen()#

For use in error handling: opens array and motor precharge bypass contactor and turns on additional brakelight to signal that a critical error happened.

void throwTaskError(error_code_t errorCode, callback_t errorCallback, error_scheduler_lock_opt_t lockSched, error_recov_opt_t nonrecoverable)#

Assert a task error by setting the location variable and optionally locking the scheduler, displaying a fault screen (if nonrecoverable), jumping to a callback function, and entering an infinite loop. Called by task-specific error-assertion functions that are also responsible for setting the error variable.

Assert a task error by setting the location variable and optionally locking the scheduler, displaying a fault screen (if nonrecoverable), jumping to a callback function, and entering an infinite loop. Called by task-specific error-assertion functions that are also responsible for setting the error variable.

Parameters:
  • errorCode – the enum for the specific error that happened

  • errorCallback – a callback function to a handler for that specific error,

  • lockSched – whether or not to lock the scheduler to ensure the error is handled immediately

  • nonrecoverable – whether or not to kill the motor, display the fault screen, and enter an infinite while loop

  • errorCode – the enum for the specific error that happened

  • errorCallback – a callback function to a handler for that specific error,

  • lockSched – whether or not to lock the scheduler to ensure the error is handled immediately. Only applicable for recoverable errors- nonrecoverable errors will always lock

  • nonrecoverable – whether or not to kill the motor, display the fault screen, and enter an infinite while loop

void _assertOSError(OS_ERR err)#

Assert Error if OS function call fails.

Error assertion-related functions

Parameters:

err – OS Error that occurred

Variables

OS_TCB Init_TCB#

TCBs

OS_TCB SendTritium_TCB#
OS_TCB ReadCarCAN_TCB#
OS_TCB UpdateDisplay_TCB#
OS_TCB ReadTritium_TCB#
OS_TCB SendCarCAN_TCB#
OS_TCB DebugDump_TCB#
OS_TCB CommandLine_TCB#
CPU_STK Init_Stk[TASK_INIT_STACK_SIZE]#

Stacks

CPU_STK SendTritium_Stk[TASK_SEND_TRITIUM_STACK_SIZE]#
CPU_STK ReadCarCAN_Stk[TASK_READ_CAR_CAN_STACK_SIZE]#
CPU_STK UpdateDisplay_Stk[TASK_UPDATE_DISPLAY_STACK_SIZE]#
CPU_STK ReadTritium_Stk[TASK_READ_TRITIUM_STACK_SIZE]#
CPU_STK SendCarCAN_Stk[TASK_SEND_CAR_CAN_STACK_SIZE]#
CPU_STK DebugDump_Stk[TASK_DEBUG_DUMP_STACK_SIZE]#
CPU_STK CommandLine_Stk[TASK_COMMAND_LINE_STACK_SIZE]#
OS_Q CANBus_MsgQ#

Queues

OS_TCB *tasks[TASK_TRACE_LENGTH]#
uint32_t index#
task_trace_t PrevTasks#
error_code_t Error_ReadTritium#
error_code_t Error_ReadCarCAN#
error_code_t Error_UpdateDisplay#
error_code_t Error_OS#
struct task_trace_t#