![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Embedded software Assessment 2
Dependencies: MCP23017 SDFileSystem USBDevice WattBob_TextLCD mbed
main.cpp@16:0a2138a18f26, 2014-02-26 (annotated)
- Committer:
- muaiyd
- Date:
- Wed Feb 26 22:09:17 2014 +0000
- Revision:
- 16:0a2138a18f26
- Parent:
- 13:6094b94b3b7c
- Child:
- 17:dba09fb3f508
Finish comment and pin out to check the taskes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
muaiyd | 16:0a2138a18f26 | 1 | /* |
muaiyd | 16:0a2138a18f26 | 2 | This software is built to test (Cyclic Executive). Five main functions are used in and every one of them |
muaiyd | 16:0a2138a18f26 | 3 | has its own time of repetition. To execute this, a Ticker was used to call a function every 100 mSec. |
muaiyd | 16:0a2138a18f26 | 4 | In other words, when 100 mSec is passed, the Cycle function is called and so on every 100 mSec. In this |
muaiyd | 16:0a2138a18f26 | 5 | software a benefit is a token place for the difference between a float division with integer one. For example |
muaiyd | 16:0a2138a18f26 | 6 | float(Counter/4.0)-Counter/4 if the Counter is a real repetition of 4 so the result of this will be 0. As a |
muaiyd | 16:0a2138a18f26 | 7 | result every 4 cycle (400 mSec) the condition be true and calling the function. Also, after 8 cycles (800 mSec) |
muaiyd | 16:0a2138a18f26 | 8 | the condition is true for two factions, but the processor will implement on the priority that it was put in |
muaiyd | 16:0a2138a18f26 | 9 | the program. |
muaiyd | 16:0a2138a18f26 | 10 | |
muaiyd | 16:0a2138a18f26 | 11 | */ |
muaiyd | 0:86bba6bf9b6f | 12 | #include "Function.h" |
muaiyd | 16:0a2138a18f26 | 13 | |
muaiyd | 16:0a2138a18f26 | 14 | uint16_t Counter=0; |
muaiyd | 16:0a2138a18f26 | 15 | void CycleFunction(); |
muaiyd | 0:86bba6bf9b6f | 16 | |
muaiyd | 0:86bba6bf9b6f | 17 | int main(){ |
muaiyd | 0:86bba6bf9b6f | 18 | Init_LCD(); |
muaiyd | 12:582753a4f1fb | 19 | InitFile(); |
muaiyd | 16:0a2138a18f26 | 20 | LogTimer.start(); |
muaiyd | 16:0a2138a18f26 | 21 | //Call the CycleFunction every 100 msec |
muaiyd | 16:0a2138a18f26 | 22 | Cycle.attach(&CycleFunction,0.1); |
muaiyd | 16:0a2138a18f26 | 23 | } |
muaiyd | 16:0a2138a18f26 | 24 | |
muaiyd | 16:0a2138a18f26 | 25 | void CycleFunction(){ |
muaiyd | 16:0a2138a18f26 | 26 | TickerPin=!(TickerPin); |
muaiyd | 16:0a2138a18f26 | 27 | Counter++; |
muaiyd | 16:0a2138a18f26 | 28 | if((float(Counter/4.0)-Counter/4)==0) ReadDigitalin(); |
muaiyd | 16:0a2138a18f26 | 29 | if((float(Counter/8.0)-Counter/8)==0) ReadAnalogin(); |
muaiyd | 16:0a2138a18f26 | 30 | if((float(Counter/10.0)-Counter/10)==0) FreqMsur(); |
muaiyd | 16:0a2138a18f26 | 31 | if((float(Counter/15.0)-Counter/15)==0) BinaryCounter(); |
muaiyd | 16:0a2138a18f26 | 32 | if((float(Counter/18.0)-Counter/18)==0) InputCheck(); |
muaiyd | 16:0a2138a18f26 | 33 | if((float(Counter/20.0)-Counter/20)==0) Display(); |
muaiyd | 16:0a2138a18f26 | 34 | if((float(Counter/50.0)-Counter/50)==0) LogFile(); |
muaiyd | 16:0a2138a18f26 | 35 | //The least common multiple for all the above is 1800 cycles |
muaiyd | 16:0a2138a18f26 | 36 | // so every 180 Sec all the functions are repeated |
muaiyd | 16:0a2138a18f26 | 37 | if(Counter==1800) Counter=0; |
muaiyd | 0:86bba6bf9b6f | 38 | } |