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.
Revision 7:49b71bc18049, committed 2019-10-17
- Comitter:
- ykuroda
- Date:
- Thu Oct 17 09:10:11 2019 +0000
- Parent:
- 6:c99eb661c3e6
- Commit message:
- 1;
Changed in this revision
| main.cpp | 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 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); // 寝ているスレッドを起こす.この処理は一瞬
}
}
+
--- a/mbed-os.lib Fri Jun 23 14:42:43 2017 -0500 +++ b/mbed-os.lib Thu Oct 17 09:10:11 2019 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#c9e63f14085f5751ff5ead79a7c0382d50a813a2 +https://github.com/ARMmbed/mbed-os/#679d24833acf0a0b5b0d528576bb37c70863bc4e