chad
Dependencies: MCP23017 WattBob_TextLCD mbed-rtos mbed
Diff: main.cpp
- Revision:
- 12:d088f8024cf0
- Parent:
- 11:b48ff77c664a
- Child:
- 13:ad04937ca366
diff -r b48ff77c664a -r d088f8024cf0 main.cpp --- a/main.cpp Tue Mar 07 19:07:24 2017 +0000 +++ b/main.cpp Tue Mar 07 21:18:02 2017 +0000 @@ -13,6 +13,7 @@ #include "WattBob_TextLCD.h" #include "SDFileSystem.h" #include "tasks.h" +#include "rtos.h" #define BACK_LIGHT_ON(INTERFACE) INTERFACE->write_bit(1,BL_BIT) #define BACK_LIGHT_OFF(INTERFACE) INTERFACE->write_bit(0,BL_BIT) @@ -27,14 +28,14 @@ DigitalIn DS(p12); // Digital switch input DigitalIn DS_s(p13); // Digital shutdown switch DigitalOut WD_pulse_out(p14); // Watchdog Pulse -SDFileSystem uSD(p5, p6, p7, p8, "uSD"); //uSD pinout +SDFileSystem sd(p5, p6, p7, p8, "sd"); //uSD pinout // Analogue I/O p15 to p20 AnalogIn A1_(p15); // Analogue input to be filtered AnalogIn A2_(p16); // Analogue input to be filtered // Timer objects -Ticker tick; // Clock timer for CycExec +Thread tick; // Clock timer for CycExec Timer timer; // Frequency Timer Timer T5; // Timer for idle states @@ -50,10 +51,10 @@ int freq = 0; // Frequency return variable (Frequency Check) bool DSIn = DS; // Switch Input boolean -bool switch_state = 0; // Switch high or low (Digital In) +int switch_state = 0; // Switch high or low (Digital In) -bool WD_pulse; -//bool WD_pulse_out = WD_pulse; +int WD_pulse; + int A1_in = A1_; // Analogue 1 input variable int A2_in = A2_; // Analogue 2 input variable @@ -80,12 +81,14 @@ lcd->cls(); // clear display // .csv log Init - fo = fopen ("/uSD/log.csv", "a"); // Pointer to log file on uSD + fo = fopen ("/sd/log.txt", "a"); // Pointer to log file on uSD fprintf(fo, "Log of Frazer Legge's Embedded Software Assignment 2\n\n"); // - tick.attach(&CycExec, 0.025); // Period set to 25ms +// tick.attach(&CycExec, 0.025); // Period set to 25ms while(1){ + tick.start(&CycExec); + wait_ms(25); } } @@ -98,7 +101,7 @@ Task2(DSIn, switch_state); } else if(tck % 80 == 7){ // Every 2 sec - Task3(WD_pulse, WD); + Task3(WD_pulse_out, WD); } else if(tck % 20 == 0){ // Every 1/2 sec Task4(A1_val, A2_val, A1_in, A2_in); @@ -112,10 +115,11 @@ else if(tck % 20 == 10){ // Every 1/2 sec Task7(logcount, freq, switch_state, A1_val, A2_val); } - else if(tck % 20 == 12){ - Task8(DS_sIn, tick, T5); - } + //else{ + // Task8(DS_sIn, tick, T5); + //} tck++; + WD_pulse_out = WD_pulse; }