|
My Project
|
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) |
Lab 4 : FREERTOS Scheduling and multitasking.
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.
| #define DIGIT_OFF_COUNT 4 |
| #define DIGIT_OFF_STATE 1 |
| #define DIGIT_ON_COUNT 3 |
| #define DIGIT_ON_STATE 0 |
| void chooseDelay | ( | ) |
chooseDelay() Chooses delay based on time playing.
| void clearLeds | ( | ) |
clearLeds() Clears all leds on the 8x8 matrix.
| void digit_light | ( | int | index | ) |
digit_light(int index) Lower the cathode (to turn on) a specific digit (0-3)
| index | 0-3, which digit to enable. |
| void digits_dark | ( | ) |
digits_dark() Turn off all 4 digits
| int* i2ds | ( | int | i | ) |
i2ds(int i) This funciton converts an int to 4 ints representing the base 10 decimal places.
| [i] | num Number to display on 4 digit seven seg |
| ISR | ( | TIMER3INTVEC | ) |
ISR(TIMER3INTVEC) ISR to scan 7 seg display faster than FreeRTOS
| TIMER3INTVEC | ISR vector |
| void loop | ( | ) |
loop() Does nothing - blank
| 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.
| void playMusic | ( | void * | pvParameters | ) |
playMusic(void *p) Plays mario tune while driving.
| void playMusicEnd | ( | void * | pvParameters | ) |
playMusicEnd(void *p) Plays mario at end of game.
| void readButtons | ( | void * | pvParameters | ) |
readButtons(void *p) Reads data from the buttons and maps it to the car position
| void readRotaryEncoder | ( | void * | pvParameters | ) |
readRotaryEncoder(void *p) Reads data from Encoder and maps it to the car position.
| void restart | ( | void * | pvParameters | ) |
restart(void *pvParameters) Restarts the game keeping track of best score.
| void RT1 | ( | void * | pvParameters | ) |
RT1(void *p) This funciton blinks an on board led on for 1000ms then off for 200ms.
| 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.
| 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.
| void RT3p0 | ( | void * | pvParameters | ) |
RT3p0(void *p) This funciton computes randomizes a 256 sample for the FFT and initialized notification queues.
| void RT4 | ( | void * | pvParameters | ) |
RT4(void *p) This funciton computes a 256 sample FFT reports back to RT4 when done.
| 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.
| void segLightUp | ( | volatile int | segs[8] | ) |
segLightUp(volatile int segs[8]) Set output bits to light specific segments
| segs[8] | An array of 8 ints. 0 of the segment is off, 1 if on |
| void segsClear | ( | ) |
segsClear() Clear all the segment lines
| void setLeds | ( | void * | pvParameters | ) |
setLed() Sets all leds on the 8x8 matrix according to game state.
| 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.
| 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.
| void Task_Counter | ( | void * | pvParameters | ) |
for Task Counter - display driving time Task_Counter(void *pvParameters) Counts for seconds driving.