.

Dependencies:   SDHCFileSystem mbed

Files at this revision

API Documentation at this revision

Comitter:
TickTock
Date:
Sun Dec 16 00:25:57 2012 +0000
Parent:
12:7cd4e9303165
Child:
14:ed5d2a503374
Commit message:
Programs RTC from pc

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Dec 15 23:47:34 2012 +0000
+++ b/main.cpp	Sun Dec 16 00:25:57 2012 +0000
@@ -109,6 +109,7 @@
 FILE *file;
 char fileName[32] = "" ;
 char writeBuffer[maxBufLen][13];
+char c;
 char sTemp[35] ;
 volatile int writePointer = 0;
 volatile int secsIdle = canTimeout;
@@ -235,12 +236,36 @@
         // So, set a near-recent date in 2012
 
         // enter people-values here
-        t.tm_year = 2012 ; // 28 May 2012
-        t.tm_mon = 6 ; // 1 to 12
-        t.tm_mday = 1;
-        t.tm_hour = 12; // 12:59:56 PM (after noon)
-        t.tm_min = 59;
-        t.tm_sec = 56;
+        pc.printf("\nEnter year (yyyy):");
+        pc.scanf("%s", &sTemp);
+        t.tm_year = atoi(sTemp);
+        
+        pc.printf("\nEnter month (mm):");
+        pc.scanf("%2s", &sTemp);
+        t.tm_mon = atoi(sTemp);
+        
+        pc.printf("\nEnter day (dd):");
+        pc.scanf("%2s", &sTemp);
+        t.tm_mday = atoi(sTemp);
+        
+        pc.printf("\nEnter hour (hh):");
+        pc.scanf("%2s", &sTemp);
+        t.tm_hour = atoi(sTemp);
+        
+        pc.printf("\nEnter minute (mm):");
+        pc.scanf("%2s", &sTemp);
+        t.tm_min = atoi(sTemp);
+        
+        pc.printf("\nEnter seconds (ss):");
+        pc.scanf("%2s", &sTemp);
+        t.tm_sec = atoi(sTemp);
+        
+        //t.tm_year = 2012 ; // 28 May 2012
+        //t.tm_mon = 6 ; // 1 to 12
+        //t.tm_mday = 1;
+        //t.tm_hour = 12; // 12:59:56 PM (after noon)
+        //t.tm_min = 59;
+        //t.tm_sec = 56;
 
         // adjust for tm structure required values
         t.tm_year = t.tm_year - 1900;
@@ -250,7 +275,7 @@
         set_time(mktime(&t));
         seconds = time(NULL);
 
-        pc.printf("Set RTC to:\n" );
+        pc.printf("\n\mRTC set to:  " );
         strftime(sTemp, 32, "%a %m/%d/%Y %X", localtime(&seconds));
         pc.printf("%s\n", sTemp); // DAY MM/DD/YYYY HH:MM:SS
     }
@@ -311,7 +336,7 @@
                     } // if (logOpen)
                 }
                 if (canIdle) { // canbus idle --> sleep to save power
-                    LPC_RTC->CIIR=0x00; // block RTC interrupts
+                    //LPC_RTC->CIIR=0x00; // block RTC interrupts
                     led1=0;
                     led2=0;
                     led3=0;
@@ -322,7 +347,7 @@
                         __wfi(); // freeze CPU and wait for interrupt (from canbus)
                     if (time(NULL)>(secs+3600))
                         logOpen = false; // Start new file if asleep for more than an hour
-                    LPC_RTC->CIIR=0x01; // re-enable RTC interrupts
+                    //LPC_RTC->CIIR=0x01; // re-enable RTC interrupts
                 }
                 wait(0.25); // We get >2K messages per second
             } while ((PB1==1)&&(CD==1)&&logOpen); // keep going until button or SDram removed