Solar Car Team at UVA
Embedded Subteam
Ethan Mathias
Embedded Lead
C++ and FreeRTOS
Part 2
How do we make the code that controls the car?
Overview
Data Types: Casting
Pointers
Pointers
Pointers in Function Calls
Pointers to Pointers
References in Function Calls
Arrays
or
Arrays
Reacting to Events
There are two ways a task can find out "is there new data yet?"
Polling: ask on a timer, over and over, whether anything's ready
Example: CAN::read() checks the FIFO every 1ms, whether or not a message is there
Simple to write, but the CPU keeps doing work even when there's nothing to do
Interrupt: the hardware itself signals the CPU the instant something actually happens
Example: HAL_UART_RxCpltCallback() fires the moment a byte arrives
The task sleeps in between, using zero CPU until there's really something to do
�
Polling in a Thread
Timeout and MessageQueue
CAN
CAN: Defining Messages
CAN: Sending Messages
CAN: Sending Messages
CAN: Receiving Messages
CAN: Receiving Messages
CAN: Two Networks
Heartbeat: the Safety Net
Documentation: Comments
Documentation: Docstrings
Style Guide: Naming
Style Guide: Misc.
Logging Hierarchy