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:
- HidetoN
- Date:
- 2020-01-08
- Revision:
- 1:632bf9a889cc
- Parent:
- 0:1025ad5aabba
- Child:
- 2:e0c00fd3c351
File content as of revision 1:632bf9a889cc:
#include "mbed.h"
#define ID 0x00
#define SENSORNUM 2
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[SENSORNUM]={0};
uint32_t constantTime=0;
void checkOut()
{
t.start();
}
void get()
{
t.stop();
cap1Out=0;
data[0]=t.read_us();
constantTime=constantTimer.read_us();
t.reset();
}
int main()
{
pc.printf("Hello!\r\n");
cap1Check.rise(&checkOut);
cap1Get.rise(&get);
constantTimer.start();
while(1) {
cap1Out=1;
//ID表示
pc.printf("%x,",ID);
pc.printf("%u,",constantTime);
for(uint8_t i=0;i<SENSORNUM;i++){
pc.printf("%u,",data[i]);
}
pc.printf("\r\n");
wait_us(data[0]*2);
}
}