realtime process control with RTOS

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Files at this revision

API Documentation at this revision

Comitter:
ykuroda
Date:
Fri Nov 25 17:29:55 2016 +0000
Parent:
15:26d1c87c3fc0
Commit message:
add comments

Changed in this revision

img/uvision.png Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os-example.lib Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Oct 24 14:30:02 2016 +0100
+++ b/main.cpp	Fri Nov 25 17:29:55 2016 +0000
@@ -1,13 +1,42 @@
+//
+//  mbed-os-control-ex1
+//  正確な時間管理をするプログラムの例
+//
+//  20161027 ... v1.0 ... written by Y.Kuroda
+//
+//
 #include "mbed.h"
+#include "rtos.h"
 
+const int DELTA_T = 100;    // mainスレッドの時間間隔の設定 [ms]
+const int SIG_MYT = 0x1;    // signal番号
 DigitalOut led1(LED1);
 
-// main() runs in its own thread in the OS
-// (note the calls to Thread::wait below for delays)
-int main() {
-    while (true) {
-        led1 = !led1;
-        Thread::wait(500);
+void robot_control(void const* arg) {   // ロボットの制御をするスレッド
+    while(true){
+        Thread::signal_wait(SIG_MYT);   // シグナルを待つ
+
+        // ここに自分のプログラムを書きます.
+        //
+        //
+        //
+        Thread::wait(10);   //これは時間稼ぎのダミー.消して良い.
+        //
+        //
+        //
+
+        led1 = 0;   // ループの最後でLEDを消す.処理が重くなると明るくなる
     }
 }
 
+
+int main() {
+    Thread mythread(robot_control, (void*)0);   // ロボ制御スレッドを起動
+
+    while(true){
+        Thread::wait(DELTA_T);          // mainスレッドの時間間隔の設定 [ms]
+        led1 = 1;                       // 処理の先頭でLEDをを点灯
+        mythread.signal_set(SIG_MYT);   // スレッドへ再開シグナルを送る
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os-example.lib	Fri Nov 25 17:29:55 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-blinky/#26d1c87c3fc0
--- a/mbed-os.lib	Mon Oct 24 14:30:02 2016 +0100
+++ b/mbed-os.lib	Fri Nov 25 17:29:55 2016 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#e435a07d9252f133ea3d9f6c95dfb176f32ab9b6
+https://github.com/ARMmbed/mbed-os/#d5de476f74dd4de27012eb74ede078f6330dfc3f