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 0:f8007033a4ad, committed 2017-07-22
- Comitter:
- MikamiUitOpen
- Date:
- Sat Jul 22 02:57:55 2017 +0000
- Commit message:
- 1
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r f8007033a4ad main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sat Jul 22 02:57:55 2017 +0000
@@ -0,0 +1,63 @@
+//-------------------------------------------------------
+// 割り込みサービスルーチン (ISR) をクラスの中に作る例
+// Example to define interrupt service routinr (ISR)
+// in class
+//
+// 2017/07/22, Copyright (c) 2017 MIKAMI, Naoki
+//-------------------------------------------------------
+
+#include "mbed.h"
+
+/*
+// これでも大丈夫 (OK)
+// static メンバ関数を使う方法,Using static member function
+class myClass
+{
+public:
+ myClass()
+ {
+ timer.attach(myClass::AtTime, 1);
+ }
+private:
+ Ticker timer;
+ static DigitalOut led1;
+ static int flip;
+
+ // ISR for Ticker (static function)
+ static void AtTime()
+ {
+ led1 = flip;
+ flip = !flip;
+ }
+};
+DigitalOut myClass::led1(LED1);
+int myClass::flip = 0;
+*/
+
+// myClass の別の書き方 (alternative version)
+class myClass
+{
+public:
+ myClass() : led1_(LED1), flip_(0)
+ {
+ timer_.attach(callback(this, &myClass::AtTime), 0.1f);
+ }
+private:
+ Ticker timer_;
+ DigitalOut led1_;
+ int flip_;
+
+ // ISR for Ticker
+ void AtTime()
+ {
+ led1_ = flip_;
+ flip_ = !flip_;
+ }
+};
+
+int main()
+{
+ myClass obj;
+
+ while (true) {}
+}
diff -r 000000000000 -r f8007033a4ad mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Jul 22 02:57:55 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/a97add6d7e64 \ No newline at end of file