Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MCP23017 WattBob_TextLCD mbed-rtos mbed
Diff: main.cpp
- Revision:
- 4:70553c83c65a
- Parent:
- 0:10e3e2697134
- Child:
- 5:e1ade53bce83
diff -r b6dae7e36e01 -r 70553c83c65a main.cpp
--- a/main.cpp Tue Mar 07 14:02:10 2017 +0000
+++ b/main.cpp Tue Mar 07 15:15:13 2017 +0000
@@ -1,12 +1,85 @@
+// Paramater Allocation
+// Paramater: 17
+// Log Option: 1 (uSD)
+// Watchdog Pulse Length: 6ms
+// 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"
+
+#define BACK_LIGHT_ON(INTERFACE) INTERFACE->write_bit(1,BL_BIT)
+#define BACK_LIGHT_OFF(INTERFACE) INTERFACE->write_bit(0,BL_BIT)
-DigitalOut myled(LED1);
+// 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
+
+// Digital I/O p11 to p20
+DigitalIn FqIn(p11); // Digital frequency in for measurement
+DigitalIn DSIn(p12); // Digital switch input
+DigitalOut WD_pulse(p14); // Watchdog Pulse
+SDFileSystem uSD(p5, p6, p7, p8, "uSD"); //uSD pinout
+
+// Analogue I/O p15 to p20
+AnalogIn A1_in(p15); // Analogue input to be filtered
+AnalogIn A2_in(p16); // Analogue input to be filtered
+
+// Timer objects
+Timer timer; // Frequency Timer
+Timer tick; // Clock timer for CycExec
+Timer idle; // Timer for idle states
+
+// Constant Declaration
+const int SampFreq = 100;
+
+// Variable Declaration
+long int tck = 0; // Used to define what task is called (CycExec)
-int main() {
- while(1) {
- myled = 1;
- wait(0.2);
- myled = 0;
- wait(0.2);
- }
+int period = 0; // Frequency timer variable (Frequency Check)
+int freq = 0; // Frequency return variable (Frequency Check)
+
+bool switch_state = 0; // Switch high or low (Digital In)
+
+int A1_val = 0; // Analogue 1 return variable (Analogue In)
+int A2_val = 0; // Analogue 2 return variable (Analogue In)
+
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Main Program
+//
+
+int main()
+{
+ // LCD Init
+ par_port = new MCP23017(p9, p10, 0x40); // initialise 16-bit I/O chip
+ lcd = new WattBob_TextLCD(par_port); // initialise 2*26 char display
+ par_port->write_bit(1,BL_BIT); // turn LCD backlight ON
+ lcd->cls(); // clear display
+
+ // .csv log Init
+ fp = fopen ("/uSD/log.csv", "w"); // 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
+ while(1){
+ }
}
+
+void CycExec()
+{
+ idle.stop();
+
+ if(tck % 40 = 0) // Every Second (needs offset)
+
+
+
+
+