RtosTimerをクラス内で使うテスト

Dependencies:   mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
ryood
Date:
Mon May 30 11:06:44 2016 +0000
Parent:
1:747445d49c3d
Commit message:
RtosTImer?2?????

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 747445d49c3d -r ff926e519980 main.cpp
--- a/main.cpp	Mon May 30 10:58:42 2016 +0000
+++ b/main.cpp	Mon May 30 11:06:44 2016 +0000
@@ -4,10 +4,12 @@
 class TestClass
 {
 public:
-    TestClass(uint32_t _updateTime) :  updateTime(_updateTime),
+    TestClass(const char* _instanceName, uint32_t _updateTime) :
+        updateTime(_updateTime),
         timer(&TestClass::threadHelper, osTimerPeriodic, (void *)this)
     {
         //NOTE: The RTOS hasn't started yet, so we can't create the internal thread here
+        strncpy(instanceName, _instanceName, 20);
     }
 
     void run() {
@@ -19,6 +21,7 @@
     }
 
 private:
+    char instanceName[20];
     uint32_t updateTime;
     RtosTimer timer;
 
@@ -33,7 +36,7 @@
     }
 
     void threadMethod() {
-        printf("In threadMethod()\r\n");
+        printf("In threadMethod()\t%s\r\n", instanceName);
     }
 };
 
@@ -43,9 +46,14 @@
     
     while (true) {
         printf("In main loop\r\n");
-        TestClass test(1000);
-        test.run();
+        TestClass test1("test1", 1000);
+        TestClass test2("test2", 500);
+        test1.run();
+        test2.run();
         Thread::wait(10000);
-        test.stop();
+        /*
+        test1.stop();
+        test2.stop();
+        */
     }
 }