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:
- rary
- Date:
- 2020-07-20
- Revision:
- 1:17efbc35c3ba
- Parent:
- 0:637769b3a60b
File content as of revision 1:17efbc35c3ba:
#include "mbed.h"
#include "EEPROM.h"
#include "LPS33HW.h"
Timer t; //時間計測
Serial pc(USBTX, USBRX);
LPS33HW lps(p9, p10);
EEPROM e2prom(p9, p10);
#define ADDR 0xA6 //コントロールアドレス
int pointerAddress = 0;
//main
int main()
{
int n;
char data_read[128];
char s[128]; //データ格納配列
pc.baud(460800);
//readEEPROM(ADDR, pointerAddress, data_read, h);
//pc.printf("Previous data stored:%s\r\n", data_read);
t.start(); //timer Start
for(n = 0; n < 500; n++) {
lps.start(1); //気圧センサスタート
double P = lps.data_read(); //気圧データ取得
double T = t.read(); //時刻データ取得
sprintf(s, "%d, %.3f, %.3f\r\n", n, T, P); //floatからchar*へ変換
// write tha data
e2prom.write(ADDR, pointerAddress, s, 128);
pc.printf("%d, Data written: %s\r\n", n, s);
pointerAddress = pointerAddress + 128; //アドレスずらし
memset(s, '\0' , 128 ); //初期化
wait(0.01);
}
//read the data
pointerAddress = 0;
pc.printf("Data read\r\n");
for(n = 0; n < 500; n++) {
e2prom.read(ADDR, pointerAddress, data_read, 128);
pc.printf("%s", data_read);
pointerAddress = pointerAddress + 128;
memset(data_read, '\0' , 128 ); //初期化
}
pc.printf("Finish");
}