![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
chad
Dependencies: MCP23017 WattBob_TextLCD mbed-rtos mbed
Diff: main.cpp
- Revision:
- 13:ad04937ca366
- Parent:
- 12:d088f8024cf0
- Child:
- 14:ede0e7ed2745
--- a/main.cpp Tue Mar 07 21:18:02 2017 +0000 +++ b/main.cpp Tue Mar 07 22:32:06 2017 +0000 @@ -5,23 +5,13 @@ // Watchdog Repetion Rate: 0.5 // Error Display: 1 (LCD) // Execution time display: Task5 (LDC display) - - -#include "mbed.h" -#include "MCP23017.h" -#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) +#include "main.h" // Pointers to LCD Screen MCP23017 *par_port; // pointer to 16-bit parallel I/O chip WattBob_TextLCD *lcd; // pointer to 2*16 character LCD object -FILE *fo; // pointer to uSD object +FILE *fp; // pointer to uSD object // Digital I/O p11 to p20 DigitalIn Fq(p11); // Digital frequency in for measurement @@ -35,7 +25,8 @@ AnalogIn A2_(p16); // Analogue input to be filtered // Timer objects -Thread tick; // Clock timer for CycExec +//Ticker tick; // Clock timer for CycExec +Thread tick; Timer timer; // Frequency Timer Timer T5; // Timer for idle states @@ -51,7 +42,7 @@ int freq = 0; // Frequency return variable (Frequency Check) bool DSIn = DS; // Switch Input boolean -int switch_state = 0; // Switch high or low (Digital In) +int switch_state = 0; int WD_pulse; @@ -70,7 +61,37 @@ // // Main Program // -void CycExec(); + +void CycExec() +{/* + if(tck % 40 == 4){ // Every Second (needs offset) + Task1(); + } + else if(tck % 13 == 8){ // Every 1/3 sec + Task2(); + } + else if(tck % 80 == 7){ // Every 2 sec + Task3(); + } + else if(tck % 20 == 0){ // Every 1/2 sec + Task4(); + } + else if(tck % 80 == 1){ // Every 2 sec + Task5(); + } + else if(tck % 20 == 3){ // Every 0.5 sec + Task6(); + } + else if(tck % 20 == 10){ // Every 1/2 sec + Task7(); + }*/ + //else{ + // Task8(); + //} + Task1(); + tck++; + WD_pulse_out = WD_pulse; +} int main() { @@ -81,58 +102,13 @@ lcd->cls(); // clear display // .csv log Init - 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"); + fp = fopen ("/sd/log.txt", "a"); // Pointer to log file on uSD + fprintf(fp, "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); + wait_ms(100); } -} - -void CycExec() -{ - if(tck % 40 == 4){ // Every Second (needs offset) - Task1(timer, FqIn, SampFreq, period, freq); - } - else if(tck % 13 == 8){ // Every 1/3 sec - Task2(DSIn, switch_state); - } - else if(tck % 80 == 7){ // Every 2 sec - Task3(WD_pulse_out, WD); - } - else if(tck % 20 == 0){ // Every 1/2 sec - Task4(A1_val, A2_val, A1_in, A2_in); - } - else if(tck % 80 == 1){ // Every 2 sec - Task5(freq, switch_state, A1_val, A2_val); - } - else if(tck % 20 == 3){ // Every 0.5 sec - Task6(switch_state, A1_val, A2_val, error_code); - } - else if(tck % 20 == 10){ // Every 1/2 sec - Task7(logcount, freq, switch_state, A1_val, A2_val); - } - //else{ - // Task8(DS_sIn, tick, T5); - //} - tck++; - WD_pulse_out = WD_pulse; -} - - - - - - - - - - - - - - - +} \ No newline at end of file