オムロンのMEMS熱センサー

Dependents:   YOZAKURA_ARM YOZAKURA_ARM_USB YOZAKURA_ARM_USB_Keyboard

Committer:
yusuke_kyo
Date:
Wed Apr 08 08:04:48 2015 +0000
Revision:
3:c7d3279ba305
Parent:
2:3e02b45037da
Child:
4:6a5ab8af56a4
double -> void

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yusuke_kyo 0:42f5bfa6b545 1 #include "MEMS.h"
yusuke_kyo 0:42f5bfa6b545 2 #include "mbed.h"
yusuke_kyo 0:42f5bfa6b545 3
yusuke_kyo 0:42f5bfa6b545 4 MEMS::MEMS(PinName sda, PinName scl)
yusuke_kyo 0:42f5bfa6b545 5 : _mems(sda, scl) {
yusuke_kyo 0:42f5bfa6b545 6
yusuke_kyo 0:42f5bfa6b545 7 }
yusuke_kyo 0:42f5bfa6b545 8
yusuke_kyo 3:c7d3279ba305 9 void MEMS::temp(float* dt) {
yusuke_kyo 0:42f5bfa6b545 10
yusuke_kyo 0:42f5bfa6b545 11 char I2C_rd[64]; // 生データ
yusuke_kyo 1:17f329471d0c 12 short datr[16]; // 16点 温度データ(10倍整数)
yusuke_kyo 0:42f5bfa6b545 13 short PTAT; // センサ内部PTAT温度データ(10倍整数)
yusuke_kyo 1:17f329471d0c 14 // double dt[16]; // 16点 温度データ
yusuke_kyo 0:42f5bfa6b545 15 short d_PTAT; // センサ内部PTAT温度データ
yusuke_kyo 0:42f5bfa6b545 16 int i,j;
yusuke_kyo 0:42f5bfa6b545 17 int itemp;
yusuke_kyo 0:42f5bfa6b545 18
yusuke_kyo 0:42f5bfa6b545 19 //// measure
yusuke_kyo 0:42f5bfa6b545 20 _mems.start();
yusuke_kyo 0:42f5bfa6b545 21 _mems.write(D6T_addr);
yusuke_kyo 0:42f5bfa6b545 22 _mems.write(D6T_cmd);
yusuke_kyo 0:42f5bfa6b545 23 // Repeated Start condition
yusuke_kyo 0:42f5bfa6b545 24 _mems.read(D6T_addr,I2C_rd,35);
yusuke_kyo 0:42f5bfa6b545 25 // if(check_PEC(I2C_rd) == -1) continue; // error
yusuke_kyo 0:42f5bfa6b545 26 for(i=0,j=0;i<17;i++){
yusuke_kyo 0:42f5bfa6b545 27 itemp = (I2C_rd[j++] & 0xff);
yusuke_kyo 0:42f5bfa6b545 28 itemp += I2C_rd[j++] * 256;
yusuke_kyo 0:42f5bfa6b545 29 if(i == 0) PTAT = itemp;
yusuke_kyo 0:42f5bfa6b545 30 else datr[i-1] = itemp;
yusuke_kyo 0:42f5bfa6b545 31 }
yusuke_kyo 0:42f5bfa6b545 32 for(i=0;i<16;i++){
yusuke_kyo 0:42f5bfa6b545 33 dt[i] = 0.1 * datr[i];
yusuke_kyo 0:42f5bfa6b545 34 }
yusuke_kyo 0:42f5bfa6b545 35 d_PTAT = 0.1 * PTAT;
yusuke_kyo 0:42f5bfa6b545 36 }