Proj 324 Final

Fork of ELEC351_Group_T by Plymouth ELEC351 Group T

Committer:
thomasmorris
Date:
Fri Dec 29 21:21:46 2017 +0000
Revision:
21:3c078c799caa
Parent:
20:cbb71f84cff9
Child:
22:eb4cc12087b2
MESSAGE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thomasmorris 6:97f586597310 1 /*
thomasmorris 6:97f586597310 2 ELEC 351 Group T
thomasmorris 6:97f586597310 3 Team Members : Christopher Hills, Thomas Morris
thomasmorris 8:0e4481b64353 4 Current Verision 3
thomasmorris 6:97f586597310 5 Overiew: Working Tasks 1,5,7
thomasmorris 8:0e4481b64353 6
thomasmorris 12:536eca338ae8 7 Last Revision: Added Mail Box to serial
thomasmorris 8:0e4481b64353 8 Todo:
thomasmorris 12:536eca338ae8 9 make a mailbox within SD card, LCD, network so they can be used from within
thomasmorris 12:536eca338ae8 10 Fix the network so it uses the mail box data.
thomasmorris 12:536eca338ae8 11 Place the LCD write functions in their own function
thomasmorris 6:97f586597310 12 */
thomasmorris 6:97f586597310 13
thomasmorris 8:0e4481b64353 14 //Includes and Definitions
noutram 1:e1cf7663f5ff 15 #include "sample_hardware.hpp"
noutram 3:a88838ff33e7 16 #include "Networkbits.hpp"
thomasmorris 5:2594b953f111 17 #include "rtos.h"
thomasmorris 5:2594b953f111 18 #include "LED.hpp"
thomasmorris 8:0e4481b64353 19 #include "DATA.hpp"
chills 20:cbb71f84cff9 20 #include "LCD.hpp"
thomasmorris 5:2594b953f111 21 #define SamplingTime 1
thomasmorris 5:2594b953f111 22 #define NotSamplingTime 0
thomasmorris 7:dfe19413fdc2 23 #define Print_Time_to_LCD 1
thomasmorris 7:dfe19413fdc2 24 #define Dont_Print_Time_to_LCD 0
chills 15:c1592fc1a501 25 #define TimerInterval 1 //This is in seconds
thomasmorris 7:dfe19413fdc2 26 #define EDGE_RISEN 1
thomasmorris 7:dfe19413fdc2 27 #define EDGE_FALLEN 0
chills 16:067916791a25 28 #define mailsize 5
thomasmorris 8:0e4481b64353 29
thomasmorris 8:0e4481b64353 30
thomasmorris 5:2594b953f111 31 Serial pc(USBTX, USBRX);
thomasmorris 21:3c078c799caa 32 //SW1+SW2 are declared as interrupt ins in sample hardware.cpp
thomasmorris 8:0e4481b64353 33
thomasmorris 8:0e4481b64353 34
thomasmorris 8:0e4481b64353 35 //Thread IDs
thomasmorris 5:2594b953f111 36 osThreadId idMain;
thomasmorris 5:2594b953f111 37 osThreadId id1;
thomasmorris 5:2594b953f111 38 osThreadId id2;
thomasmorris 5:2594b953f111 39 osThreadId id3;
thomasmorris 5:2594b953f111 40 osThreadId id4;
noutram 0:36e89e3ed7c4 41
thomasmorris 21:3c078c799caa 42
thomasmorris 7:dfe19413fdc2 43 Timeout sw1TimeOut;//Used to prevent switch bounce
thomasmorris 7:dfe19413fdc2 44
thomasmorris 5:2594b953f111 45 LED Red_led(PE_15);
thomasmorris 5:2594b953f111 46 LED Yellow_led(PB_10);
thomasmorris 5:2594b953f111 47 LED Green_led(PB_11);
thomasmorris 5:2594b953f111 48
chills 20:cbb71f84cff9 49 LCD LCD(D8,D9,D4,A0,A1,A2,A3,D7,D6,D3,D1);
thomasmorris 21:3c078c799caa 50 char LCD_buffer [50];
thomasmorris 21:3c078c799caa 51 int LCD_sprintf;
chills 20:cbb71f84cff9 52
thomasmorris 8:0e4481b64353 53 //Tickers
thomasmorris 8:0e4481b64353 54
thomasmorris 5:2594b953f111 55 Ticker Sample_timer;
thomasmorris 8:0e4481b64353 56
noutram 3:a88838ff33e7 57 //Threads
thomasmorris 5:2594b953f111 58 Thread t1;
thomasmorris 5:2594b953f111 59 Thread t2;
thomasmorris 21:3c078c799caa 60 Thread t3;
thomasmorris 21:3c078c799caa 61 Thread t4;
thomasmorris 21:3c078c799caa 62 Thread t180;//cos yolo
thomasmorris 7:dfe19413fdc2 63
thomasmorris 7:dfe19413fdc2 64 double temp = 0;
thomasmorris 7:dfe19413fdc2 65 double pressure = 0;
thomasmorris 7:dfe19413fdc2 66 double lux = 0;
chills 10:46946784326d 67 string buffer_time = 0;
thomasmorris 7:dfe19413fdc2 68
thomasmorris 7:dfe19413fdc2 69 char buffer[32];
chills 15:c1592fc1a501 70 char scom_time_buffer[32];
chills 17:37d883f40c3d 71 char msel_time_buffer[32];
thomasmorris 7:dfe19413fdc2 72
thomasmorris 7:dfe19413fdc2 73 void SW1FallingEdge();
thomasmorris 7:dfe19413fdc2 74 void SW1TimeOutHandler();
thomasmorris 7:dfe19413fdc2 75
thomasmorris 7:dfe19413fdc2 76 int mode = 0;
thomasmorris 7:dfe19413fdc2 77
chills 17:37d883f40c3d 78 Mail<DATA, mailsize> mail_box; //Mail Queue, Type DATA, Capacity mailsize(defined above), name mail_box
thomasmorris 8:0e4481b64353 79
chills 13:db857b3744c6 80 void Network() //Interrupt service routine for handling the timeout
thomasmorris 8:0e4481b64353 81 {
chills 13:db857b3744c6 82 osEvent evt_network = mail_box.get(); //Get the latest entry from "mail_box"
chills 13:db857b3744c6 83
chills 13:db857b3744c6 84 if (evt_network.status == osEventMail)
chills 13:db857b3744c6 85 {
chills 17:37d883f40c3d 86 DATA *Rec_Data_Network = (DATA*)evt_network.value.p; //Create pointer to mailbox
chills 17:37d883f40c3d 87 DATA msg_network; //Create temporary instance of DATA class
chills 13:db857b3744c6 88
chills 17:37d883f40c3d 89 msg_network.set_time(Rec_Data_Network->get_time()); //Copy time from mailbox to temporary instance
chills 17:37d883f40c3d 90 msg_network.set_temperature(Rec_Data_Network->get_temperature()); //Copy temperature from mailbox to temporary instance
chills 17:37d883f40c3d 91 msg_network.set_pressure(Rec_Data_Network->get_pressure()); //Copy pressure from mailbox to temporary instance
chills 17:37d883f40c3d 92 msg_network.set_light(Rec_Data_Network->get_light()); //Copy light from mailbox to temporary instance
chills 17:37d883f40c3d 93 mail_box.free(Rec_Data_Network); //Free space in the mailbox (delete earliest sample taken)
chills 13:db857b3744c6 94
thomasmorris 18:194a606ccd47 95 networktest();
chills 13:db857b3744c6 96 }
chills 13:db857b3744c6 97 }
chills 13:db857b3744c6 98
thomasmorris 8:0e4481b64353 99 void SW1TimeOutHandler()
thomasmorris 8:0e4481b64353 100 {
thomasmorris 7:dfe19413fdc2 101 sw1TimeOut.detach(); //Stop the timeout counter firing
thomasmorris 7:dfe19413fdc2 102 SW1.fall(&SW1FallingEdge); //Now wait for a falling edge
thomasmorris 7:dfe19413fdc2 103 }
thomasmorris 12:536eca338ae8 104 void SDWrite()//End of skype chat
thomasmorris 12:536eca338ae8 105 {
chills 13:db857b3744c6 106 osEvent evt_sd = mail_box.get(); //Get the latest entry from "mail_box"
chills 13:db857b3744c6 107
chills 13:db857b3744c6 108 if (evt_sd.status == osEventMail)
chills 13:db857b3744c6 109 {
chills 17:37d883f40c3d 110 DATA *Rec_Data_SD = (DATA*)evt_sd.value.p; //Create pointer to mailbox
chills 17:37d883f40c3d 111 DATA msg_sd; //Create temporary instance of DATA class
chills 13:db857b3744c6 112
chills 17:37d883f40c3d 113 msg_sd.set_time(Rec_Data_SD->get_time()); //Copy time from mailbox to temporary instance
chills 17:37d883f40c3d 114 msg_sd.set_temperature(Rec_Data_SD->get_temperature()); //Copy temperature from mailbox to temporary instance
chills 17:37d883f40c3d 115 msg_sd.set_pressure(Rec_Data_SD->get_pressure()); //Copy pressure from mailbox to temporary instance
chills 17:37d883f40c3d 116 msg_sd.set_light(Rec_Data_SD->get_light()); //Copy light from mailbox to temporary instance
chills 17:37d883f40c3d 117 mail_box.free(Rec_Data_SD); //Free space in the mailbox (delete earliest sample taken)
chills 13:db857b3744c6 118 }
thomasmorris 12:536eca338ae8 119 }
thomasmorris 7:dfe19413fdc2 120 //Interrupt service routive for SW1 falling edge (release)
thomasmorris 19:54bc302a82ea 121 void SW1FallingEdge()
thomasmorris 19:54bc302a82ea 122 {
thomasmorris 7:dfe19413fdc2 123 SW1.fall(NULL); //Disable this interrupt
chills 16:067916791a25 124 Yellow_led.Toggle(); //Toggle LED
thomasmorris 7:dfe19413fdc2 125
thomasmorris 7:dfe19413fdc2 126 mode = mode +1;//Cycles through modes
thomasmorris 7:dfe19413fdc2 127 if(mode >1)
thomasmorris 7:dfe19413fdc2 128 {
thomasmorris 7:dfe19413fdc2 129 mode = 0;
thomasmorris 7:dfe19413fdc2 130 }
thomasmorris 7:dfe19413fdc2 131
thomasmorris 7:dfe19413fdc2 132 sw1TimeOut.attach(&SW1TimeOutHandler, 0.2); //Start timeout counter
thomasmorris 7:dfe19413fdc2 133 }
thomasmorris 7:dfe19413fdc2 134 void ModeSelection()
thomasmorris 7:dfe19413fdc2 135 {
thomasmorris 7:dfe19413fdc2 136 while(1){
chills 13:db857b3744c6 137
chills 16:067916791a25 138 //Thread::wait(1000);
chills 13:db857b3744c6 139
chills 13:db857b3744c6 140 osEvent evt_lcd = mail_box.get(); //Get the latest entry from "mail_box"
chills 13:db857b3744c6 141
chills 13:db857b3744c6 142 if (evt_lcd.status == osEventMail)
thomasmorris 7:dfe19413fdc2 143 {
chills 17:37d883f40c3d 144 DATA *Rec_Data_LCD = (DATA*)evt_lcd.value.p; //Create pointer to mailbox
chills 17:37d883f40c3d 145 DATA msg_lcd; //Create temporary instance of DATA class
chills 13:db857b3744c6 146
chills 17:37d883f40c3d 147 msg_lcd.set_time(Rec_Data_LCD->get_time()); //Copy time from mailbox to temporary instance
chills 17:37d883f40c3d 148 msg_lcd.set_temperature(Rec_Data_LCD->get_temperature()); //Copy temperature from mailbox to temporary instance
chills 17:37d883f40c3d 149 msg_lcd.set_pressure(Rec_Data_LCD->get_pressure()); //Copy pressure from mailbox to temporary instance
chills 17:37d883f40c3d 150 msg_lcd.set_light(Rec_Data_LCD->get_light()); //Copy light from mailbox to temporary instance
chills 17:37d883f40c3d 151 mail_box.free(Rec_Data_LCD); //Free space in the mailbox (delete earliest sample taken)
chills 13:db857b3744c6 152
chills 13:db857b3744c6 153 if(mode == 0)//Print values to the LCD
chills 13:db857b3744c6 154 {
chills 13:db857b3744c6 155 //Write new data to LCD (not fast!)
thomasmorris 21:3c078c799caa 156
thomasmorris 21:3c078c799caa 157 /*LCD_sprintf = */sprintf (LCD_buffer, "%1.1f %1.1f %1.1f",msg_lcd.get_temperature(),msg_lcd.get_pressure(),msg_lcd.get_light());//Used for converting to a sting
thomasmorris 21:3c078c799caa 158
thomasmorris 21:3c078c799caa 159 //LCD.Display_Clear();
thomasmorris 21:3c078c799caa 160 LCD.DDRAM_Address(0x00);
thomasmorris 21:3c078c799caa 161 LCD.Write_String("Temp Pres li");
thomasmorris 21:3c078c799caa 162 LCD.DDRAM_Address(0x40);
thomasmorris 21:3c078c799caa 163
thomasmorris 21:3c078c799caa 164 LCD.Write_String(LCD_buffer);
thomasmorris 21:3c078c799caa 165 //LCD.Write_String("Temp Pres li\n");
thomasmorris 21:3c078c799caa 166 //LCD.Write_String("%1.1f ", msg_lcd.get_temperature());//Print Temperature to LCD
thomasmorris 21:3c078c799caa 167 //LCD.Write_String("%1.1f ", msg_lcd.get_pressure());//Print Pressure to LCD
thomasmorris 21:3c078c799caa 168 //LCD.Write_String("%1.1f\n", msg_lcd.get_light()); //Print Light to LCD
thomasmorris 21:3c078c799caa 169
chills 13:db857b3744c6 170 }
chills 13:db857b3744c6 171 else if(mode == 1)//Print the Time to the LCD
chills 13:db857b3744c6 172 {
chills 17:37d883f40c3d 173 time_t msel_time = msg_lcd.get_time(); //Declare local variable for time
thomasmorris 18:194a606ccd47 174 strftime(scom_time_buffer, 32, "%I:%M %p", localtime(&msel_time)); //Format time as a string
thomasmorris 21:3c078c799caa 175 LCD.Display_Clear();
thomasmorris 21:3c078c799caa 176 LCD_sprintf = sprintf (LCD_buffer, "%s",scom_time_buffer);
thomasmorris 21:3c078c799caa 177 LCD.DDRAM_Address(0x00);
thomasmorris 21:3c078c799caa 178 LCD.Write_String("Current Time:");
thomasmorris 21:3c078c799caa 179 LCD.DDRAM_Address(0x40);
thomasmorris 21:3c078c799caa 180 LCD.Write_String(LCD_buffer);
thomasmorris 21:3c078c799caa 181
chills 13:db857b3744c6 182 }
chills 13:db857b3744c6 183 else
chills 13:db857b3744c6 184 {
chills 13:db857b3744c6 185 mode = 0;
chills 13:db857b3744c6 186 }
thomasmorris 7:dfe19413fdc2 187 }
thomasmorris 7:dfe19413fdc2 188 }
thomasmorris 7:dfe19413fdc2 189 }
thomasmorris 7:dfe19413fdc2 190
thomasmorris 5:2594b953f111 191 void Serial_Comms()//Thread for Serial Communications
thomasmorris 5:2594b953f111 192 {
thomasmorris 5:2594b953f111 193 while(1)
thomasmorris 5:2594b953f111 194 {
chills 13:db857b3744c6 195 osEvent evt_serial = mail_box.get(); //Get the latest entry from "mail_box"
chills 10:46946784326d 196
chills 13:db857b3744c6 197 if (evt_serial.status == osEventMail)
thomasmorris 12:536eca338ae8 198 {
chills 17:37d883f40c3d 199 DATA *Rec_Data_Serial = (DATA*)evt_serial.value.p; //Create pointer to mailbox
chills 17:37d883f40c3d 200 DATA msg_serial; //Create temporary instance of DATA class
chills 11:e7b5ed6cd3cf 201
chills 17:37d883f40c3d 202 msg_serial.set_time(Rec_Data_Serial->get_time()); //Copy time from mailbox to temporary instance
chills 17:37d883f40c3d 203 msg_serial.set_temperature(Rec_Data_Serial->get_temperature()); //Copy teperature from mailbox to temporary instance
chills 17:37d883f40c3d 204 msg_serial.set_pressure(Rec_Data_Serial->get_pressure()); //Copy pressure from mailbox to temporary instance
chills 17:37d883f40c3d 205 msg_serial.set_light(Rec_Data_Serial->get_light()); //Copy light from mailbox to temporary instance
chills 17:37d883f40c3d 206 mail_box.free(Rec_Data_Serial); //Free space in the mailbox (delete earliest sample taken)
chills 11:e7b5ed6cd3cf 207
chills 17:37d883f40c3d 208 time_t scom_time = msg_serial.get_time(); //Declare local variable for time
chills 17:37d883f40c3d 209 strftime(scom_time_buffer, 32, "%I:%M %p\t", localtime(&scom_time)); //Format time as a string
chills 17:37d883f40c3d 210 pc.printf("Time = %s", scom_time_buffer); //Print the string formatted time
chills 15:c1592fc1a501 211
chills 13:db857b3744c6 212 pc.printf("Temperature = %f\t", msg_serial.get_temperature()); //Print Temperature
chills 13:db857b3744c6 213 pc.printf("Pressure = %f\t", msg_serial.get_pressure()); //Print Pressure
chills 13:db857b3744c6 214 pc.printf("Light = %f\n\r", msg_serial.get_light()); //Print Light
chills 10:46946784326d 215 }
thomasmorris 7:dfe19413fdc2 216 Green_led.Toggle();
chills 16:067916791a25 217 //Thread::wait(1000);
thomasmorris 5:2594b953f111 218 }
thomasmorris 5:2594b953f111 219 }
thomasmorris 5:2594b953f111 220
chills 10:46946784326d 221 void Sample_signal_set() //Sets the Signal for when to sample the sensors
thomasmorris 5:2594b953f111 222 {
chills 10:46946784326d 223 t1.signal_set(SamplingTime); //Set the sampling thread signal high
thomasmorris 5:2594b953f111 224 }
thomasmorris 5:2594b953f111 225 void Sample()//Samples the hardware and prints the result to the LCD
thomasmorris 5:2594b953f111 226 {
thomasmorris 5:2594b953f111 227 while(1)
thomasmorris 5:2594b953f111 228 {
chills 10:46946784326d 229 Thread::signal_wait(SamplingTime); //Set the time between samples
chills 10:46946784326d 230
chills 10:46946784326d 231 temp = sensor.getTemperature(); //Read Temperature
chills 10:46946784326d 232 pressure = sensor.getPressure(); //Read Pressure
chills 10:46946784326d 233 lux = adcIn.read(); //Read Light
chills 16:067916791a25 234 time_t buffer_time = time(NULL); //Read Time
thomasmorris 7:dfe19413fdc2 235
chills 16:067916791a25 236 DATA *Send_Data = mail_box.alloc(); //Allocate a block from the memory pool, Type Data
thomasmorris 5:2594b953f111 237
chills 16:067916791a25 238 if (Send_Data == NULL){ //If Data is empty
chills 16:067916791a25 239 //pc.printf("Out of memory\n\r"); //Print out of memory warning
chills 10:46946784326d 240 return;
chills 10:46946784326d 241 }
chills 10:46946784326d 242
chills 10:46946784326d 243 Send_Data->set_time(buffer_time); //Pass in Time
chills 10:46946784326d 244 Send_Data->set_temperature(temp); //Pass in Temp
chills 10:46946784326d 245 Send_Data->set_pressure(pressure); //Pass in Pres
chills 10:46946784326d 246 Send_Data->set_light(lux); //Pass in Light
chills 10:46946784326d 247
chills 10:46946784326d 248 osStatus stat = mail_box.put(Send_Data); //Puts "Send_Data" into the mailbox
chills 10:46946784326d 249
chills 10:46946784326d 250 if (stat == osErrorResource){ //If mailbox overfills
chills 10:46946784326d 251 //pc.printf("queue->put() Error code: %4Xh, Resource not available\r\n", stat); //Print error message
chills 10:46946784326d 252 mail_box.free(Send_Data); //Free the mail box
chills 10:46946784326d 253 return;
chills 10:46946784326d 254 }
thomasmorris 5:2594b953f111 255 Red_led.Toggle();
thomasmorris 5:2594b953f111 256 t1.signal_set(NotSamplingTime);
thomasmorris 5:2594b953f111 257 }
thomasmorris 5:2594b953f111 258 }
thomasmorris 5:2594b953f111 259 int main()
thomasmorris 5:2594b953f111 260 {
thomasmorris 21:3c078c799caa 261
thomasmorris 21:3c078c799caa 262
noutram 1:e1cf7663f5ff 263 //Greeting
chills 16:067916791a25 264 pc.printf("Test Start");
chills 16:067916791a25 265 pc.printf("\n\r");
chills 16:067916791a25 266
chills 10:46946784326d 267 set_time(1512940530); //Set RTC time to December 10 2017
chills 10:46946784326d 268 pc.baud(9600); //Sets the Serial Comms Baud Rate
thomasmorris 5:2594b953f111 269
chills 20:cbb71f84cff9 270 LCD.Initialise();
chills 20:cbb71f84cff9 271 LCD.DDRAM_Address(0x40);
thomasmorris 21:3c078c799caa 272
thomasmorris 21:3c078c799caa 273
chills 10:46946784326d 274 post(); //Power on Self Test
noutram 1:e1cf7663f5ff 275
noutram 3:a88838ff33e7 276 //Initialise the SD card (this needs to move)
noutram 1:e1cf7663f5ff 277 if ( sd.init() != 0) {
noutram 1:e1cf7663f5ff 278 printf("Init failed \n");
noutram 3:a88838ff33e7 279 lcd.cls();
thomasmorris 21:3c078c799caa 280 lcd.printf("CANNOT INIT SD"); //Change me
noutram 1:e1cf7663f5ff 281 errorCode(FATAL);
noutram 1:e1cf7663f5ff 282 }
noutram 1:e1cf7663f5ff 283
noutram 1:e1cf7663f5ff 284 //Create a filing system for SD Card
noutram 1:e1cf7663f5ff 285 FATFileSystem fs("sd", &sd);
noutram 0:36e89e3ed7c4 286
noutram 1:e1cf7663f5ff 287 //Open to WRITE
noutram 1:e1cf7663f5ff 288 FILE* fp = fopen("/sd/test.csv","a");
noutram 1:e1cf7663f5ff 289 if (fp == NULL) {
noutram 1:e1cf7663f5ff 290 error("Could not open file for write\n");
noutram 3:a88838ff33e7 291 lcd.cls();
thomasmorris 21:3c078c799caa 292 lcd.printf("CANNOT OPEN FILE\n\n");//Change me
noutram 1:e1cf7663f5ff 293 errorCode(FATAL);
noutram 1:e1cf7663f5ff 294 }
noutram 3:a88838ff33e7 295
noutram 3:a88838ff33e7 296 //Last message before sampling begins
thomasmorris 21:3c078c799caa 297 lcd.cls();//change me
thomasmorris 21:3c078c799caa 298 lcd.printf("READY\n\n");//change me
thomasmorris 21:3c078c799caa 299
thomasmorris 5:2594b953f111 300
thomasmorris 5:2594b953f111 301 //Run interrupt
thomasmorris 5:2594b953f111 302 Sample_timer.attach(&Sample_signal_set,TimerInterval);
thomasmorris 7:dfe19413fdc2 303 SW1.fall(&SW1FallingEdge);
thomasmorris 5:2594b953f111 304 //Run Threads
thomasmorris 5:2594b953f111 305
thomasmorris 21:3c078c799caa 306 Thread t4(osPriorityAboveNormal);//Sets the Priority bigly
thomasmorris 5:2594b953f111 307 t1.start(Sample);
thomasmorris 5:2594b953f111 308 t2.start(Serial_Comms);
thomasmorris 21:3c078c799caa 309 t3.start(ModeSelection);
thomasmorris 21:3c078c799caa 310 t4.start(Network);
thomasmorris 21:3c078c799caa 311
thomasmorris 21:3c078c799caa 312
thomasmorris 5:2594b953f111 313 //Main thread ID
thomasmorris 5:2594b953f111 314
thomasmorris 5:2594b953f111 315 idMain = osThreadGetId(); //CMSIS RTOS call
thomasmorris 5:2594b953f111 316
thomasmorris 5:2594b953f111 317 //Thread ID
thomasmorris 5:2594b953f111 318 id1 = t1.gettid();
thomasmorris 5:2594b953f111 319 id2 = t2.gettid();
thomasmorris 21:3c078c799caa 320 id3 = t3.gettid();
thomasmorris 21:3c078c799caa 321 id4 = t4.gettid();
thomasmorris 21:3c078c799caa 322
thomasmorris 5:2594b953f111 323
thomasmorris 5:2594b953f111 324 //Toggle Green LED after a button has been pressed
noutram 1:e1cf7663f5ff 325 //Press either switch to unmount
thomasmorris 7:dfe19413fdc2 326 DigitalIn onBoardSwitch(USER_BUTTON);
thomasmorris 21:3c078c799caa 327
thomasmorris 7:dfe19413fdc2 328 while (onBoardSwitch == 0){
thomasmorris 7:dfe19413fdc2 329
noutram 1:e1cf7663f5ff 330 }
noutram 1:e1cf7663f5ff 331
noutram 1:e1cf7663f5ff 332 //Close File
chills 15:c1592fc1a501 333 /*
noutram 1:e1cf7663f5ff 334 fclose(fp);
noutram 1:e1cf7663f5ff 335
noutram 1:e1cf7663f5ff 336 //Close down
noutram 1:e1cf7663f5ff 337 sd.deinit();
noutram 1:e1cf7663f5ff 338 printf("Unmounted...\n");
noutram 1:e1cf7663f5ff 339 lcd.cls();
noutram 1:e1cf7663f5ff 340 lcd.printf("Unmounted...\n\n");
chills 15:c1592fc1a501 341 */
noutram 1:e1cf7663f5ff 342
noutram 1:e1cf7663f5ff 343 while(true) {
noutram 1:e1cf7663f5ff 344 greenLED = 1;
noutram 1:e1cf7663f5ff 345 wait(0.5);
noutram 1:e1cf7663f5ff 346 greenLED = 0;
noutram 1:e1cf7663f5ff 347 wait(0.1);
noutram 0:36e89e3ed7c4 348 }
noutram 0:36e89e3ed7c4 349 }
noutram 0:36e89e3ed7c4 350
noutram 1:e1cf7663f5ff 351
noutram 1:e1cf7663f5ff 352