Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 7:49b71bc18049
- Parent:
- 5:476186ff82cf
- Child:
- 8:0318c56aae15
--- a/main.cpp Fri Jun 23 14:42:43 2017 -0500
+++ b/main.cpp Thu Oct 17 09:10:11 2019 +0000
@@ -1,21 +1,26 @@
+// たぶん一番簡単な時間管理プログラム - OS5
+// 2019.10.17 ... Y.Kuroda
#include "mbed.h"
-
Thread thread;
-DigitalOut led(LED1);
+DigitalOut p1(LED1);
+#define CYC_FLAG 1
-void led_thread() {
+void my_thread() // スレッドにする関数.正確な時間間隔で起こされる
+{
while (true) {
- // Signal flags that are reported as event are automatically cleared.
- Thread::signal_wait(0x1);
- led = !led;
+ ThisThread::flags_wait_all(CYC_FLAG); // 起こされるまで寝ている
+ //
+ p1 = !p1; // ユーザコードはここに書く
+ //
}
}
-int main (void) {
- thread.start(callback(led_thread));
+int main (void) { // mainスレッド
+ thread.start(callback(my_thread)); // 関数をスレッドとして起動する
- while (true) {
- wait(1);
- thread.signal_set(0x1);
+ while (true) { // スレッドの一つとして走る
+ wait(0.01); // 待つことしかしてないのでかなり正確
+ thread.flags_set(CYC_FLAG); // 寝ているスレッドを起こす.この処理は一瞬
}
}
+