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.
main.cpp
- Committer:
- ykuroda
- Date:
- 2019-10-17
- Revision:
- 7:49b71bc18049
- Parent:
- 5:476186ff82cf
- Child:
- 8:0318c56aae15
File content as of revision 7:49b71bc18049:
// たぶん一番簡単な時間管理プログラム - OS5
// 2019.10.17 ... Y.Kuroda
#include "mbed.h"
Thread thread;
DigitalOut p1(LED1);
#define CYC_FLAG 1
void my_thread() // スレッドにする関数.正確な時間間隔で起こされる
{
while (true) {
ThisThread::flags_wait_all(CYC_FLAG); // 起こされるまで寝ている
//
p1 = !p1; // ユーザコードはここに書く
//
}
}
int main (void) { // mainスレッド
thread.start(callback(my_thread)); // 関数をスレッドとして起動する
while (true) { // スレッドの一つとして走る
wait(0.01); // 待つことしかしてないのでかなり正確
thread.flags_set(CYC_FLAG); // 寝ているスレッドを起こす.この処理は一瞬
}
}