My Project
Macros | Functions
lab4.ino File Reference

Lab 4 : FREERTOS Scheduling and multitasking. More...

#include "lab4_define.h"

Macros

#define DIGIT_ON_STATE   0
 
#define DIGIT_ON_COUNT   3
 
#define DIGIT_OFF_STATE   1
 
#define DIGIT_OFF_COUNT   4
 

Functions

void setup ()
 defines and constants used for the program More...
 
void loop ()
 
void RTtasks (void *pvParameters)
 
void RT1 (void *pvParameters)
 
void RT2 (void *pvParameters)
 
void RT3 (void *pvParameters)
 
void RT3p0 (void *pvParameters)
 
void RT4 (void *pvParameters)
 
void Task_Counter (void *pvParameters)
 
 ISR (TIMER3INTVEC)
 
void digit_light (int index)
 
void digits_dark ()
 
void segsClear ()
 
void segLightUp (volatile int segs[8])
 
int * i2ds (int i)
 
void spiTransfer (volatile byte opcode, volatile byte data)
 
void clearLeds ()
 
void setLeds (void *pvParameters)
 
void restart (void *pvParameters)
 
void chooseDelay ()
 
void playDrivingGame (void *pvParameters)
 
void readButtons (void *pvParameters)
 
void readRotaryEncoder (void *pvParameters)
 
void playMusic (void *pvParameters)
 
void playMusicEnd (void *pvParameters)
 

Detailed Description

Lab 4 : FREERTOS Scheduling and multitasking.

Author
Connor Lowe Leonard Dul
Date
9-June-2021

This lab shows correct implementation of various FreeRTOS tasks. The first demo includes 4 tasks, one which blinks an external led on pin 47. The second task plays the tune from close encounters 3 times then stops. Task3 and 4 compute and FFT of 256 random ints and computes the average time for every 5 FFTs back on the serial link to the computer.

The second part of this lab includes implementing a driving game that is played using a rotary encoder for movement, 2 buttons for movement, a button to reset, a 4 digit seven segment display to show the time driving and keep track of the best time, a speaker to play the music ,and a 8x8 red led matrix to play the game on. The rotary encoder is attatched to pins 50 and 52, and the two buttons for movement are connected to pins 51 and 53. The reset button is attatched to pin 12, the speaker is attatched to pin 6. The 4 digit seven segment display is attatched to pins 22-32, and the 8x8 led matrix is attatched to pins 42, 44, and 46.

Macro Definition Documentation

◆ DIGIT_OFF_COUNT

#define DIGIT_OFF_COUNT   4

◆ DIGIT_OFF_STATE

#define DIGIT_OFF_STATE   1

◆ DIGIT_ON_COUNT

#define DIGIT_ON_COUNT   3

◆ DIGIT_ON_STATE

#define DIGIT_ON_STATE   0

Function Documentation

◆ chooseDelay()

void chooseDelay ( )

chooseDelay() Chooses delay based on time playing.

Author
: Connor Lowe, Leonard Dul

◆ clearLeds()

void clearLeds ( )

clearLeds() Clears all leds on the 8x8 matrix.

Author
: Connor Lowe, Leonard Dul

◆ digit_light()

void digit_light ( int  index)

digit_light(int index) Lower the cathode (to turn on) a specific digit (0-3)

Parameters
index0-3, which digit to enable.
Author
Blake Hannaford

◆ digits_dark()

void digits_dark ( )

digits_dark() Turn off all 4 digits

Author
Blake Hannaford

◆ i2ds()

int* i2ds ( int  i)

i2ds(int i) This funciton converts an int to 4 ints representing the base 10 decimal places.

Parameters
[i]num Number to display on 4 digit seven seg
Author
Blake Hannaford

◆ ISR()

ISR ( TIMER3INTVEC  )

ISR(TIMER3INTVEC) ISR to scan 7 seg display faster than FreeRTOS

Parameters
TIMER3INTVECISR vector
Author
Blake Hannaford

◆ loop()

void loop ( )

loop() Does nothing - blank

Author
Connor Lowe, Leonard Dul

◆ playDrivingGame()

void playDrivingGame ( void *  pvParameters)

useEncoderWithMatrix(void *p) Reads data from Encoder and maps the values to light up the corrosponding led on the 8x8 matrix.

Author
: Connor Lowe, Leonard Dul

◆ playMusic()

void playMusic ( void *  pvParameters)

playMusic(void *p) Plays mario tune while driving.

Author
: Connor Lowe, Leonard Dul

◆ playMusicEnd()

void playMusicEnd ( void *  pvParameters)

playMusicEnd(void *p) Plays mario at end of game.

Author
: Connor Lowe, Leonard Dul

◆ readButtons()

void readButtons ( void *  pvParameters)

readButtons(void *p) Reads data from the buttons and maps it to the car position

Author
: Connor Lowe, Leonard Dul

◆ readRotaryEncoder()

void readRotaryEncoder ( void *  pvParameters)

readRotaryEncoder(void *p) Reads data from Encoder and maps it to the car position.

Author
: Connor Lowe, Leonard Dul

◆ restart()

void restart ( void *  pvParameters)

restart(void *pvParameters) Restarts the game keeping track of best score.

Author
: Connor Lowe, Leonard Dul

◆ RT1()

void RT1 ( void *  pvParameters)

RT1(void *p) This funciton blinks an on board led on for 1000ms then off for 200ms.

Author
Connor Lowe, Leonard Dul

◆ RT2()

void RT2 ( void *  pvParameters)

RT2(void *p) This funciton plays the 5 note tune from close encounters of the third kind for 2 seconds, then rests for 1.5 seconds, then repeats.
After repeating 2 times, the tune stops.

Author
Connor Lowe, Leonard Dul

◆ RT3()

void RT3 ( void *  pvParameters)

RT3(void *p) This funciton computes a 256 sample FFT 5 times and reports the average time back on the serial line in milliseconds.

Author
Connor Lowe, Leonard Dul

◆ RT3p0()

void RT3p0 ( void *  pvParameters)

RT3p0(void *p) This funciton computes randomizes a 256 sample for the FFT and initialized notification queues.

Author
Connor Lowe, Leonard Dul

◆ RT4()

void RT4 ( void *  pvParameters)

RT4(void *p) This funciton computes a 256 sample FFT reports back to RT4 when done.

Author
Connor Lowe, Leonard Dul

◆ RTtasks()

void RTtasks ( void *  pvParameters)

RT tasks for lab 4 RT(void *p) This funciton starts 4 RT tasks. 1 blinks an led, 2 plays the tune from close encounters, and 3/4 compute an FFT, reporting the time it takes to the serial line.

Author
Connor Lowe, Leonard Dul

◆ segLightUp()

void segLightUp ( volatile int  segs[8])

segLightUp(volatile int segs[8]) Set output bits to light specific segments

Parameters
segs[8]An array of 8 ints. 0 of the segment is off, 1 if on
Author
Blake Hannaford

◆ segsClear()

void segsClear ( )

segsClear() Clear all the segment lines

Author
Blake Hannaford

◆ setLeds()

void setLeds ( void *  pvParameters)

setLed() Sets all leds on the 8x8 matrix according to game state.

Author
: Connor Lowe, Leonard Dul

◆ setup()

void setup ( )

defines and constants used for the program

setup() Sets up the initial state of the program. Either for RT tasks or to play the driving game. To choose one you must uncomment the associated task. Note both may not run at the same time.

Author
Connor Lowe, Leonard Dul

◆ spiTransfer()

void spiTransfer ( volatile byte  opcode,
volatile byte  data 
)

for LED matrix driving game spiTransfer(volatile byte opcode, volatile byte data) Given code for writing data to led matrix with spi protocol.

Author
: Ishaan Bhimani

◆ Task_Counter()

void Task_Counter ( void *  pvParameters)

for Task Counter - display driving time Task_Counter(void *pvParameters) Counts for seconds driving.

Author
Blake Hannaford