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:
- 1:632bf9a889cc
- Parent:
- 0:1025ad5aabba
- Child:
- 2:e0c00fd3c351
diff -r 1025ad5aabba -r 632bf9a889cc main.cpp
--- a/main.cpp Wed Jan 08 05:48:01 2020 +0000
+++ b/main.cpp Wed Jan 08 05:59:40 2020 +0000
@@ -1,6 +1,7 @@
#include "mbed.h"
#define ID 0x00
+#define SENSORNUM 2
DigitalOut led(LED1);
Serial pc(USBTX,USBRX,115200);
@@ -12,7 +13,9 @@
Timer t;
Timer constantTimer;//マイコン起動時間計測用タイマー
-uint32_t data=0;
+uint32_t data[SENSORNUM]={0};
+
+uint32_t constantTime=0;
void checkOut()
{
@@ -23,7 +26,8 @@
{
t.stop();
cap1Out=0;
- data=t.read_us();
+ data[0]=t.read_us();
+ constantTime=constantTimer.read_us();
t.reset();
}
@@ -34,14 +38,18 @@
cap1Check.rise(&checkOut);
cap1Get.rise(&get);
-
+
+ constantTimer.start();
while(1) {
cap1Out=1;
//ID表示
pc.printf("%x,",ID);
- pc.printf("%u,",data);
+ pc.printf("%u,",constantTime);
+ for(uint8_t i=0;i<SENSORNUM;i++){
+ pc.printf("%u,",data[i]);
+ }
pc.printf("\r\n");
- wait_us(data*2);
+ wait_us(data[0]*2);
}
}