Example software for a Cyclic Executive

Dependencies:   MCP23017 SDFileSystem WattBob_TextLCD mbed

Tasks.h

Committer:
sk398
Date:
2016-02-29
Revision:
6:ceda53939eb8
Parent:
5:250f51c80ac1
Child:
7:2973bf297f3d

File content as of revision 6:ceda53939eb8:

/* #####################################################################
                                Tasks.h
                                -------
                
                     Embedded Software - Assignment 2
                     --------------------------------
 
 Written by:        Steven Kay
 
 Date:              February 2016
 
 Function:          This 
 
 Version:           1.0
 
 Version History
 ---------------
 
 1.1                rgdfgdfgdfggdfgdg
 
 1.0                gdgddfdddgd
    
 ##################################################################### */

#ifndef _TASKS_H_
#define _TASKS_H_

// Includes to operate the LCD Display
#include "MCP23017.h"
#include "WattBob_TextLCD.h"

// Includes to operate the SD Card system
#include "SDFileSystem.h"

// Global definitions
#define HIGH 1
#define LOW 0

#define TRUE 1
#define FALSE 0

// Task 1 definitions
#define WATCHDOG_PULSE_WIDTH 15

// Task 2 definitions

// Task 3 definitions

// Task 4 definitions
#define NUM_ANALOG_SAMPLES 4.0

// Task 5 definitions

// Task 6 definitions
#define ERROR_CODE_CDTN_MET 3
#define ERROR_CODE_CDTN_FAIL 0

/* ####################### Class definitions and prototypes ####################### */

/* ==================================== Task 1 ==================================== */
// Measure freuqnecy
class Task1
{
public:
    Task1(PinName squareWaveInPin);
    int ReadFrequency();
        
private:
    Timer _Task1Timer;
    
    void MeasureFrequency();
    void StopCounter();
    
    volatile int measuredFrequency;
    
    InterruptIn *_squareWaveIn;
    
protected:
        
};


/* ==================================== Task 2 ==================================== */ 
// Digital Input
class Task2
{
public:
    Task2(PinName digitalInCheckPin);
    bool digitalInState();
    
private:

    
protected:
    DigitalIn *_digitalInCheck;
    
};


/* ==================================== Task 3 ==================================== */ 
// Output watchdog pulse
class Task3
{
public:
    Task3(PinName WatchdogPin);
    void OutputWatchdogPulse();
        
private:


protected:
    DigitalOut *_Watchdog;

};


/* ==================================== Task 4 ==================================== */ 
// Read 2 analog inputs 
class Task4
{
public:
    Task4(PinName Analog1Pin,PinName Analog2Pin);
    float *returnAnalogReadings();
    
private:


protected:
    AnalogIn *_AnalogIn1;
    AnalogIn *_AnalogIn2;   

};

//* ==================================== Task 5 ==================================== */
// Display outputs to LCD
class Task5
{
public:
    Task5(PinName sda, PinName scl, int address);
    void updateDisplay( int task1Param,
                        int task2Param,
                        int errorState,
                        float task4Channel1,
                        float task4Channel2  );
                             
private:


protected:
    MCP23017 *_par_port;
    WattBob_TextLCD *_lcd; 

};

///* ==================================== Task 6 ==================================== */
// Logical checks
class Task6
{
public:
    int updateErrorCode(int switch_1, float analog1, float analog2);  

private:


protected:


};

/* ==================================== Task 7 ==================================== */
// Save data to SD Card
class Task7
{
public:
    Task7(  PinName mosi,
            PinName miso,
            PinName sck,
            PinName cs,
            const char* SDName,
            const char *dir     );

    void writeData(const char *dataStream);
    int openFile(const char *dirFile, const char *accessType);
    void closeFile();
    
private:
    void makeDirectory(const char *dir);

protected:
    SDFileSystem *_sd;
    FILE *fp;
};

#endif