Example software for a Cyclic Executive
Dependencies: MCP23017 SDFileSystem WattBob_TextLCD mbed
Diff: Tasks.cpp
- Revision:
- 4:b85bc0d810e1
- Parent:
- 3:c611b9bb5770
- Child:
- 5:250f51c80ac1
--- a/Tasks.cpp Wed Feb 17 10:22:50 2016 +0000 +++ b/Tasks.cpp Fri Feb 26 10:36:23 2016 +0000 @@ -1,37 +1,57 @@ -/* ############################################################################### -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -############################################################################### */ +/* ##################################################################### + Tasks.cpp + --------- + + Embedded Software - Assignment 2 + -------------------------------- + + Written by: Steven Kay + + Date: February 2016 + + Function: This + + Version: 1.0 + + Version History + --------------- + + 1.1 rgdfgdfgdfggdfgdg + + 1.0 gdgddfdddgd + + ##################################################################### */ #include "mbed.h" #include "Tasks.h" - +#include "MCP23017.h" +#include "WattBob_TextLCD.h" /* ==================================== Task 1 ==================================== */ Task1::Task1(PinName squareWaveInPin) { - Timer Task1Timer; - _squareWaveIn = new DigitalIn(squareWaveInPin); + _squareWaveIn = new InterruptIn(squareWaveInPin); } -int Task1::MeasureFreq() -{ - return 0; +void Task1::MeasureFrequency() +{ + _Task1Timer.start(); + _squareWaveIn -> rise(this,&Task1::StopCounter); } +void Task1::StopCounter() +{ + _Task1Timer.stop(); + measuredFrequency = _Task1Timer.read_us(); + _Task1Timer.reset(); +} + +int Task1::ReadFrequency() +{ + _squareWaveIn -> rise(this,&Task1::MeasureFrequency); + + return measuredFrequency; +} /* ==================================== Task 2 ==================================== */ Task2::Task2(PinName digitalInCheckPin) @@ -79,19 +99,32 @@ float readBuffer_2 = 0.0; float outputBuffer[2]; - float *outputBufferPtr =&outputBuffer[0]; // outputBuffer[0] = _AnalogIn1 -> read(); // outputBuffer[1] = _AnalogIn2 -> read(); for(int readCount = 0;readCount < NUM_ANALOG_SAMPLES; readCount++) { - readBuffer_1 += _AnalogIn1 -> read(); - readBuffer_2 += _AnalogIn2 -> read(); + readBuffer_1 += ((_AnalogIn1 -> read())*3.3); +// printf("Buffer 1 %f\r\n",readBuffer_1); + readBuffer_2 += ((_AnalogIn2 -> read())*3.3); +// printf("Buffer 2 %f\r\n",readBuffer_2); } outputBuffer[0] = readBuffer_1/NUM_ANALOG_SAMPLES; - outputBuffer[1] = readBuffer_1/NUM_ANALOG_SAMPLES; +// printf("outputBuffer[0] %f\r\n",outputBuffer[0]); + outputBuffer[1] = readBuffer_2/NUM_ANALOG_SAMPLES; +// printf("outputBuffer[1] %f\r\n",outputBuffer[1]); + float *outputBufferPtr =&outputBuffer[0]; + return outputBufferPtr; } + +/* ==================================== Task 5 ==================================== */ +Task5::Task5() +{ + + +} +