Example software for a Cyclic Executive

Dependencies:   MCP23017 SDFileSystem WattBob_TextLCD mbed

Committer:
sk398
Date:
Fri Feb 26 10:36:23 2016 +0000
Revision:
4:b85bc0d810e1
Parent:
3:c611b9bb5770
Child:
5:250f51c80ac1
Display function works, Analog function works, digitalIN function works.; ; Freq measurement still to work.; ; Display to be changed to class structure

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 2:22ebabd78084 28 // Global definitions
sk398 1:221d677fe0d3 29 #define HIGH 1
sk398 1:221d677fe0d3 30 #define LOW 0
sk398 1:221d677fe0d3 31
sk398 3:c611b9bb5770 32 #define TRUE 1
sk398 3:c611b9bb5770 33 #define FALSE 0
sk398 3:c611b9bb5770 34
sk398 2:22ebabd78084 35 // Task 1 definitions
sk398 1:221d677fe0d3 36 #define WATCHDOG_PULSE_WIDTH 15
sk398 1:221d677fe0d3 37
sk398 2:22ebabd78084 38 // Task 2 definitions
sk398 2:22ebabd78084 39
sk398 2:22ebabd78084 40 // Task 3 definitions
sk398 2:22ebabd78084 41
sk398 2:22ebabd78084 42 // Task 4 definitions
sk398 4:b85bc0d810e1 43 #define NUM_ANALOG_SAMPLES 4.0
sk398 2:22ebabd78084 44
sk398 2:22ebabd78084 45 // Task 5 definitions
sk398 2:22ebabd78084 46
sk398 2:22ebabd78084 47 // Task 6 definitions
sk398 2:22ebabd78084 48
sk398 2:22ebabd78084 49
sk398 2:22ebabd78084 50 /* ####################### Class definitions and prototypes ####################### */
sk398 1:221d677fe0d3 51
sk398 1:221d677fe0d3 52 /* ==================================== Task 1 ==================================== */
sk398 2:22ebabd78084 53 // Measure freuqnecy
sk398 1:221d677fe0d3 54 class Task1
sk398 1:221d677fe0d3 55 {
sk398 1:221d677fe0d3 56 public:
sk398 1:221d677fe0d3 57 Task1(PinName squareWaveInPin);
sk398 4:b85bc0d810e1 58 int ReadFrequency();
sk398 1:221d677fe0d3 59
sk398 1:221d677fe0d3 60 private:
sk398 4:b85bc0d810e1 61 Timer _Task1Timer;
sk398 4:b85bc0d810e1 62
sk398 4:b85bc0d810e1 63 void MeasureFrequency();
sk398 4:b85bc0d810e1 64 void StopCounter();
sk398 4:b85bc0d810e1 65
sk398 4:b85bc0d810e1 66 volatile int measuredFrequency;
sk398 4:b85bc0d810e1 67
sk398 4:b85bc0d810e1 68 InterruptIn *_squareWaveIn;
sk398 1:221d677fe0d3 69
sk398 1:221d677fe0d3 70 };
sk398 1:221d677fe0d3 71
sk398 1:221d677fe0d3 72
sk398 1:221d677fe0d3 73 /* ==================================== Task 2 ==================================== */
sk398 2:22ebabd78084 74 // Digital Input
sk398 1:221d677fe0d3 75 class Task2
sk398 1:221d677fe0d3 76 {
sk398 1:221d677fe0d3 77 public:
sk398 1:221d677fe0d3 78 Task2(PinName digitalInCheckPin);
sk398 3:c611b9bb5770 79 bool digitalInState();
sk398 3:c611b9bb5770 80
sk398 1:221d677fe0d3 81 private:
sk398 1:221d677fe0d3 82 DigitalIn *_digitalInCheck;
sk398 1:221d677fe0d3 83
sk398 1:221d677fe0d3 84 };
sk398 1:221d677fe0d3 85
sk398 1:221d677fe0d3 86
sk398 1:221d677fe0d3 87 /* ==================================== Task 3 ==================================== */
sk398 2:22ebabd78084 88 // Output watchdog pulse
sk398 1:221d677fe0d3 89 class Task3
sk398 1:221d677fe0d3 90 {
sk398 1:221d677fe0d3 91 public:
sk398 1:221d677fe0d3 92 Task3(PinName WatchdogPin);
sk398 1:221d677fe0d3 93 void OutputWatchdogPulse();
sk398 1:221d677fe0d3 94
sk398 1:221d677fe0d3 95 private:
sk398 1:221d677fe0d3 96 DigitalOut *_Watchdog;
sk398 1:221d677fe0d3 97 };
sk398 1:221d677fe0d3 98
sk398 1:221d677fe0d3 99
sk398 2:22ebabd78084 100 /* ==================================== Task 4 ==================================== */
sk398 2:22ebabd78084 101 // Read 2 analog inputs
sk398 2:22ebabd78084 102 class Task4
sk398 2:22ebabd78084 103 {
sk398 2:22ebabd78084 104 public:
sk398 3:c611b9bb5770 105 Task4(PinName Analog1Pin,PinName Analog2Pin);
sk398 3:c611b9bb5770 106 float *returnAnalogReadings();
sk398 2:22ebabd78084 107
sk398 2:22ebabd78084 108 private:
sk398 3:c611b9bb5770 109 AnalogIn *_AnalogIn1;
sk398 3:c611b9bb5770 110 AnalogIn *_AnalogIn2;
sk398 2:22ebabd78084 111 };
sk398 2:22ebabd78084 112
sk398 3:c611b9bb5770 113 //
sk398 3:c611b9bb5770 114 ///* ==================================== Task 5 ==================================== */
sk398 3:c611b9bb5770 115 //// Display outputs to LCD
sk398 3:c611b9bb5770 116 //class Task5
sk398 3:c611b9bb5770 117 //{
sk398 3:c611b9bb5770 118 //public:
sk398 3:c611b9bb5770 119 // Task5();
sk398 3:c611b9bb5770 120 //
sk398 3:c611b9bb5770 121 //private:
sk398 3:c611b9bb5770 122 //
sk398 3:c611b9bb5770 123 //
sk398 3:c611b9bb5770 124 //};
sk398 3:c611b9bb5770 125 //
sk398 3:c611b9bb5770 126 ///* ==================================== Task 6 ==================================== */
sk398 3:c611b9bb5770 127 //// Logical checks
sk398 3:c611b9bb5770 128 //class Task6
sk398 3:c611b9bb5770 129 //{
sk398 3:c611b9bb5770 130 //public:
sk398 3:c611b9bb5770 131 // Task5();
sk398 3:c611b9bb5770 132 //
sk398 3:c611b9bb5770 133 //private:
sk398 3:c611b9bb5770 134 //
sk398 3:c611b9bb5770 135 //
sk398 3:c611b9bb5770 136 //};
sk398 3:c611b9bb5770 137 //
sk398 3:c611b9bb5770 138 ///* ==================================== Task 7 ==================================== */
sk398 3:c611b9bb5770 139 //// Save data to SD Card
sk398 3:c611b9bb5770 140 //class Task7
sk398 3:c611b9bb5770 141 //{
sk398 3:c611b9bb5770 142 //public:
sk398 3:c611b9bb5770 143 // Task7();
sk398 3:c611b9bb5770 144 //
sk398 3:c611b9bb5770 145 //private:
sk398 3:c611b9bb5770 146 //
sk398 3:c611b9bb5770 147 //
sk398 3:c611b9bb5770 148 //};
sk398 1:221d677fe0d3 149
sk398 1:221d677fe0d3 150 #endif