use mbed-src latest version and everything works well. RTC is also fine.
Dependencies: L3GD20 LIS3DH TextLCD mbed-rtos mbed
Use standard library mbed & mbed-rtos (GR-PEACH can run without mbed-src and special mbed-rtos).
Diff: main.cpp
- Revision:
- 8:4006b111c0d4
- Parent:
- 6:f14cce59e7fe
- Child:
- 9:de986e74bd93
--- 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);