Example software for a Cyclic Executive

Dependencies:   MCP23017 SDFileSystem WattBob_TextLCD mbed

Committer:
sk398
Date:
Fri Feb 26 10:44:38 2016 +0000
Revision:
5:250f51c80ac1
Parent:
4:b85bc0d810e1
Child:
6:ceda53939eb8
LCD output now successfully contained within class definition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sk398 4:b85bc0d810e1 1 /* #####################################################################
sk398 4:b85bc0d810e1 2 Tasks.h
sk398 4:b85bc0d810e1 3 -------
sk398 4:b85bc0d810e1 4
sk398 4:b85bc0d810e1 5 Embedded Software - Assignment 2
sk398 4:b85bc0d810e1 6 --------------------------------
sk398 4:b85bc0d810e1 7
sk398 4:b85bc0d810e1 8 Written by: Steven Kay
sk398 4:b85bc0d810e1 9
sk398 4:b85bc0d810e1 10 Date: February 2016
sk398 4:b85bc0d810e1 11
sk398 4:b85bc0d810e1 12 Function: This
sk398 4:b85bc0d810e1 13
sk398 4:b85bc0d810e1 14 Version: 1.0
sk398 4:b85bc0d810e1 15
sk398 4:b85bc0d810e1 16 Version History
sk398 4:b85bc0d810e1 17 ---------------
sk398 4:b85bc0d810e1 18
sk398 4:b85bc0d810e1 19 1.1 rgdfgdfgdfggdfgdg
sk398 4:b85bc0d810e1 20
sk398 4:b85bc0d810e1 21 1.0 gdgddfdddgd
sk398 4:b85bc0d810e1 22
sk398 4:b85bc0d810e1 23 ##################################################################### */
sk398 2:22ebabd78084 24
sk398 1:221d677fe0d3 25 #ifndef _TASKS_H_
sk398 1:221d677fe0d3 26 #define _TASKS_H_
sk398 1:221d677fe0d3 27
sk398 5:250f51c80ac1 28 #include "MCP23017.h"
sk398 5:250f51c80ac1 29 #include "WattBob_TextLCD.h"
sk398 5:250f51c80ac1 30
sk398 2:22ebabd78084 31 // Global definitions
sk398 1:221d677fe0d3 32 #define HIGH 1
sk398 1:221d677fe0d3 33 #define LOW 0
sk398 1:221d677fe0d3 34
sk398 3:c611b9bb5770 35 #define TRUE 1
sk398 3:c611b9bb5770 36 #define FALSE 0
sk398 3:c611b9bb5770 37
sk398 2:22ebabd78084 38 // Task 1 definitions
sk398 1:221d677fe0d3 39 #define WATCHDOG_PULSE_WIDTH 15
sk398 1:221d677fe0d3 40
sk398 2:22ebabd78084 41 // Task 2 definitions
sk398 2:22ebabd78084 42
sk398 2:22ebabd78084 43 // Task 3 definitions
sk398 2:22ebabd78084 44
sk398 2:22ebabd78084 45 // Task 4 definitions
sk398 4:b85bc0d810e1 46 #define NUM_ANALOG_SAMPLES 4.0
sk398 2:22ebabd78084 47
sk398 2:22ebabd78084 48 // Task 5 definitions
sk398 2:22ebabd78084 49
sk398 2:22ebabd78084 50 // Task 6 definitions
sk398 2:22ebabd78084 51
sk398 2:22ebabd78084 52
sk398 2:22ebabd78084 53 /* ####################### Class definitions and prototypes ####################### */
sk398 1:221d677fe0d3 54
sk398 1:221d677fe0d3 55 /* ==================================== Task 1 ==================================== */
sk398 2:22ebabd78084 56 // Measure freuqnecy
sk398 1:221d677fe0d3 57 class Task1
sk398 1:221d677fe0d3 58 {
sk398 1:221d677fe0d3 59 public:
sk398 1:221d677fe0d3 60 Task1(PinName squareWaveInPin);
sk398 4:b85bc0d810e1 61 int ReadFrequency();
sk398 1:221d677fe0d3 62
sk398 1:221d677fe0d3 63 private:
sk398 4:b85bc0d810e1 64 Timer _Task1Timer;
sk398 4:b85bc0d810e1 65
sk398 4:b85bc0d810e1 66 void MeasureFrequency();
sk398 4:b85bc0d810e1 67 void StopCounter();
sk398 4:b85bc0d810e1 68
sk398 4:b85bc0d810e1 69 volatile int measuredFrequency;
sk398 4:b85bc0d810e1 70
sk398 4:b85bc0d810e1 71 InterruptIn *_squareWaveIn;
sk398 1:221d677fe0d3 72
sk398 1:221d677fe0d3 73 };
sk398 1:221d677fe0d3 74
sk398 1:221d677fe0d3 75
sk398 1:221d677fe0d3 76 /* ==================================== Task 2 ==================================== */
sk398 2:22ebabd78084 77 // Digital Input
sk398 1:221d677fe0d3 78 class Task2
sk398 1:221d677fe0d3 79 {
sk398 1:221d677fe0d3 80 public:
sk398 1:221d677fe0d3 81 Task2(PinName digitalInCheckPin);
sk398 3:c611b9bb5770 82 bool digitalInState();
sk398 3:c611b9bb5770 83
sk398 1:221d677fe0d3 84 private:
sk398 1:221d677fe0d3 85 DigitalIn *_digitalInCheck;
sk398 1:221d677fe0d3 86
sk398 1:221d677fe0d3 87 };
sk398 1:221d677fe0d3 88
sk398 1:221d677fe0d3 89
sk398 1:221d677fe0d3 90 /* ==================================== Task 3 ==================================== */
sk398 2:22ebabd78084 91 // Output watchdog pulse
sk398 1:221d677fe0d3 92 class Task3
sk398 1:221d677fe0d3 93 {
sk398 1:221d677fe0d3 94 public:
sk398 1:221d677fe0d3 95 Task3(PinName WatchdogPin);
sk398 1:221d677fe0d3 96 void OutputWatchdogPulse();
sk398 1:221d677fe0d3 97
sk398 1:221d677fe0d3 98 private:
sk398 1:221d677fe0d3 99 DigitalOut *_Watchdog;
sk398 1:221d677fe0d3 100 };
sk398 1:221d677fe0d3 101
sk398 1:221d677fe0d3 102
sk398 2:22ebabd78084 103 /* ==================================== Task 4 ==================================== */
sk398 2:22ebabd78084 104 // Read 2 analog inputs
sk398 2:22ebabd78084 105 class Task4
sk398 2:22ebabd78084 106 {
sk398 2:22ebabd78084 107 public:
sk398 3:c611b9bb5770 108 Task4(PinName Analog1Pin,PinName Analog2Pin);
sk398 3:c611b9bb5770 109 float *returnAnalogReadings();
sk398 2:22ebabd78084 110
sk398 2:22ebabd78084 111 private:
sk398 3:c611b9bb5770 112 AnalogIn *_AnalogIn1;
sk398 3:c611b9bb5770 113 AnalogIn *_AnalogIn2;
sk398 2:22ebabd78084 114 };
sk398 2:22ebabd78084 115
sk398 5:250f51c80ac1 116 //* ==================================== Task 5 ==================================== */
sk398 5:250f51c80ac1 117 // Display outputs to LCD
sk398 5:250f51c80ac1 118 class Task5
sk398 5:250f51c80ac1 119 {
sk398 5:250f51c80ac1 120 public:
sk398 5:250f51c80ac1 121 Task5(PinName sda, PinName scl, int address);
sk398 5:250f51c80ac1 122 void updateDisplay(int task1Param,int task2Param, float task4Channel1, float task4Channel2);
sk398 5:250f51c80ac1 123
sk398 5:250f51c80ac1 124
sk398 5:250f51c80ac1 125 private:
sk398 5:250f51c80ac1 126
sk398 5:250f51c80ac1 127
sk398 5:250f51c80ac1 128 protected:
sk398 5:250f51c80ac1 129 MCP23017 *_par_port;
sk398 5:250f51c80ac1 130 WattBob_TextLCD *_lcd;
sk398 5:250f51c80ac1 131
sk398 5:250f51c80ac1 132
sk398 5:250f51c80ac1 133 };
sk398 3:c611b9bb5770 134 //
sk398 3:c611b9bb5770 135 ///* ==================================== Task 6 ==================================== */
sk398 3:c611b9bb5770 136 //// Logical checks
sk398 3:c611b9bb5770 137 //class Task6
sk398 3:c611b9bb5770 138 //{
sk398 3:c611b9bb5770 139 //public:
sk398 3:c611b9bb5770 140 // Task5();
sk398 3:c611b9bb5770 141 //
sk398 3:c611b9bb5770 142 //private:
sk398 3:c611b9bb5770 143 //
sk398 3:c611b9bb5770 144 //
sk398 3:c611b9bb5770 145 //};
sk398 3:c611b9bb5770 146 //
sk398 3:c611b9bb5770 147 ///* ==================================== Task 7 ==================================== */
sk398 3:c611b9bb5770 148 //// Save data to SD Card
sk398 3:c611b9bb5770 149 //class Task7
sk398 3:c611b9bb5770 150 //{
sk398 3:c611b9bb5770 151 //public:
sk398 3:c611b9bb5770 152 // Task7();
sk398 3:c611b9bb5770 153 //
sk398 3:c611b9bb5770 154 //private:
sk398 3:c611b9bb5770 155 //
sk398 3:c611b9bb5770 156 //
sk398 3:c611b9bb5770 157 //};
sk398 1:221d677fe0d3 158
sk398 1:221d677fe0d3 159 #endif