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:
- 0:1025ad5aabba
- Child:
- 1:632bf9a889cc
diff -r 000000000000 -r 1025ad5aabba main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Jan 08 05:48:01 2020 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+
+#define ID 0x00
+
+DigitalOut led(LED1);
+Serial pc(USBTX,USBRX,115200);
+
+//cap1
+DigitalOut cap1Out(A1);
+InterruptIn cap1Check(A0);
+InterruptIn cap1Get(A2);
+
+Timer t;
+Timer constantTimer;//マイコン起動時間計測用タイマー
+uint32_t data=0;
+
+void checkOut()
+{
+ t.start();
+}
+
+void get()
+{
+ t.stop();
+ cap1Out=0;
+ data=t.read_us();
+ t.reset();
+}
+
+int main()
+{
+
+ pc.printf("Hello!\r\n");
+
+ cap1Check.rise(&checkOut);
+ cap1Get.rise(&get);
+
+ while(1) {
+ cap1Out=1;
+
+ //ID表示
+ pc.printf("%x,",ID);
+ pc.printf("%u,",data);
+ pc.printf("\r\n");
+ wait_us(data*2);
+ }
+}