Kenji Arai / Mbed 2 deprecated GR-PEACH_test_on_rtos_works_well

Dependencies:   L3GD20 LIS3DH TextLCD mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Sat Feb 07 21:25:10 2015 +0000
Parent:
7:3f763de12768
Child:
9:de986e74bd93
Commit message:
use mbed-src latest version and everything works well (Fix most of BUGs)

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-src-v442-pre.lib Show diff for this revision Revisions of this file
mbed-src.lib Show annotated file Show diff for this revision Revisions of this file
mon.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Jan 10 04:59:10 2015 +0000
+++ b/main.cpp	Sat Feb 07 21:25:10 2015 +0000
@@ -2,11 +2,11 @@
  * mbed Application program for the mbed
  *      Test program for GR-PEACH
  *
- * Copyright (c) 2014 Kenji Arai / JH1PJL
+ * Copyright (c) 2014,'15 Kenji Arai / JH1PJL
  *  http://www.page.sannet.ne.jp/kenjia/index.html
  *  http://mbed.org/users/kenjiArai/
  *      Created: November  29th, 2014
- *      Revised: January   10th, 2015
+ *      Revised: Feburary   8th, 2015
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
@@ -104,7 +104,8 @@
  
 Mail<mail_t, 16> mail_box;
 
-uint8_t show_flag;
+uint8_t show_flag0;
+uint8_t show_flag1;
 uint32_t count;
 
 #if defined(TARGET_RZ_A1H)
@@ -153,6 +154,32 @@
     }
 }
 
+void watch_time (void const *args) {
+    uint32_t i = 0;
+    struct tm t;
+    time_t seconds;
+    char buf[64];
+
+#if 1
+    t.tm_year       = 15 + 100;
+    t.tm_mon        = 2 - 1;
+    t.tm_mday       = 7;
+    t.tm_hour       = 22;
+    t.tm_min        = 21;
+    t.tm_sec        = 20;
+    seconds = mktime(&t);
+    set_time(seconds);
+#endif
+    while (true) {
+        seconds = time(NULL);
+        strftime(buf, 40, "%B %d,'%y, %H:%M:%S", localtime(&seconds));
+        if (show_flag1){
+            printf("[TASK1] %s, No:%5d, Ticker:%10u\r\n",buf, i++,  us_ticker_read());
+        }
+        Thread::wait(1000);
+    }
+}
+
 // Interrupt routine
 void queue_isr0() {
     queue0.put((uint32_t*)1);
@@ -200,15 +227,10 @@
 }
 
 // Thread definition
-#if defined(TARGET_RZ_A1H)
-osThreadDef(update_angle, osPriorityNormal, 2048);
-osThreadDef(monitor, osPriorityNormal, 2048);
-osThreadDef(display, osPriorityAboveNormal, 2048);
-#elif defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
 osThreadDef(update_angle, osPriorityNormal, 1024);
 osThreadDef(monitor, osPriorityNormal, 1024);
 osThreadDef(display, osPriorityAboveNormal, 1024);
-#endif
+osThreadDef(watch_time, osPriorityNormal, 1024);
 
 int main(void) {
     PRINTF("\r\nstep1\r\n");
@@ -233,7 +255,8 @@
     Ticker ticker0;
     Ticker ticker1;
     ticker0.attach(queue_isr0, TIME_BASE_S);
-    
+
+ 
     PRINTF("step5\r\n");
     // Starts threads
     if (osThreadCreate(osThread(display), NULL) == NULL){
@@ -245,6 +268,9 @@
     if (osThreadCreate(osThread(update_angle), NULL) == NULL){
         PRINTF("ERROR1\r\n");
     }
+    if (osThreadCreate(osThread(watch_time), NULL) == NULL){
+        printf("ERROR5\r\n");
+    }
     // I2C LCD
 #ifdef USE_I2C_LCD
     // ---->lock
@@ -258,12 +284,13 @@
     i2c_mutex.unlock();
 #endif
     count = 0;
-    PRINTF("step6\r\n");   
+    PRINTF("step6\r\n");
     while (true) {
         osEvent evt = mail_box.get();
         if (evt.status == osEventMail) {
             mail_t *mail = (mail_t*)evt.value.p;
-            if (show_flag){
+            if (show_flag0){
+                PRINTF("[MAIN]\r\n");
                 PRINTF("This is dummy!, ");
                 PRINTF("Volt: %.2f V, "   , mail->voltage);
                 PRINTF("Current: %.2f A, "     , mail->current);
--- a/mbed-src-v442-pre.lib	Sat Jan 10 04:59:10 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/teams/GR-PEACH_producer_meeting/code/mbed-src-v442-pre/#379b742bea7e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-src.lib	Sat Feb 07 21:25:10 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-src/#12a9a5f8fea0
--- a/mon.cpp	Sat Jan 10 04:59:10 2015 +0000
+++ b/mon.cpp	Sat Feb 07 21:25:10 2015 +0000
@@ -7,7 +7,7 @@
  *      Created:  May       15th, 2010
  *      Spareted: June      25th, 2014      mon() & mon_hw()
  *      Ported:   July      12th, 2014      from L152RE
- *      Revised: January    10th, 2015
+ *      Revised:  Feburary   8th, 2015
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
@@ -26,7 +26,7 @@
 //  Definition ------------------------------------------------------------------------------------
 #define BAUD(x)                 pc.baud(x)
 #define GETC(x)                 pc.getc(x)
-#define PUTC(x)                 pc.putc(x)
+#define PUTC(x)                 pc.putc(x);
 #define PRINTF(...)             pc.printf(__VA_ARGS__)
 #define READABLE(x)             pc.readable(x)
 
@@ -35,7 +35,8 @@
 
 extern float fa[3];    // Acc  0:X, 1:Y, 2:Z
 extern float fg[3];    // Gyro 0:X, 1:Y, 2:Z
-extern uint8_t show_flag;
+extern uint8_t show_flag0;
+extern uint8_t show_flag1;
 
 //  ROM / Constant data ---------------------------------------------------------------------------
 static char *const mon_msg = "Monitor for mbed system, created on "__DATE__"";
@@ -118,6 +119,7 @@
     PRINTF("m - Show mail data");           put_rn();
     PRINTF("s - Show USER Button");         put_rn();
     PRINTF("t - Check and set RTC");        put_rn();
+    PRINTF("r - Show RTC date & time");     put_rn();
     PRINTF("x - Goto HW monitor");          put_rn();
     PRINTF("q - Return to main");           put_rn();
 }
@@ -222,13 +224,13 @@
         case 'm' :
             put_rn();
             while(true) {
-                show_flag = 1;
+                show_flag0 = 1;
                 if ( READABLE() ) {
                     break;
                 }
                 Thread::wait(100); // Wait 100mS
             }
-            show_flag = 0;
+            show_flag0 = 0;
             break;
     //---------------------------------------------------------------------------------------------
     //  Show switch status
@@ -261,6 +263,20 @@
             chk_and_set_time(ptr);               
             break;
     //---------------------------------------------------------------------------------------------
+    //  check and set RTC
+    //---------------------------------------------------------------------------------------------
+        case 'r' :
+            put_r(); 
+            while(true) {
+                show_flag1 = 1;
+                if ( READABLE() ) {
+                    break;
+                }
+                Thread::wait(50); // Wait 100mS
+            }
+            show_flag1 = 0;             
+            break;
+    //---------------------------------------------------------------------------------------------
     //  help
     //---------------------------------------------------------------------------------------------
         case '?' :