磁気センサv4
Dependencies: mbed
Fork of mag_sensor by
Diff: main.cpp
- Revision:
- 3:7644f7b86ae0
- Parent:
- 1:21ba826811d6
- Child:
- 4:1d0dbfceeaed
--- a/main.cpp Sun Aug 12 06:34:00 2018 +0000 +++ b/main.cpp Sun Aug 12 08:44:07 2018 +0000 @@ -1,4 +1,4 @@ -/*MPU9250_PROGRAM ver2.2 PROGRAMED BY RYOTARO FUNAI 2018/08/10*/ +/*MPU9250_PROGRAM ver? PROGRAMED BY RYOTARO FUNAI 2018/08/12*/ #include <mbed.h> #include <math.h> @@ -126,39 +126,10 @@ char cmd[2]; cmd[0] = reg; //レジスタ指定 cmd[1] = data; //送信するデータ - i2c.write(addr, cmd, 2); //レジスタ指定はどうする? -} -/* -void readMagData(int16_t * destination) -{ - uint8_t rawData[7]; // x/y/z gyro register data, ST2 register stored here, must read ST2 at end of data acquisition - if(readByte(AK8963_ADDRESS, AK8963_ST1) & 0x01) { // wait for magnetometer data ready bit to be set - readBytes(AK8963_ADDRESS, AK8963_XOUT_L, 7, &rawData[0]); // Read the six raw data and ST2 registers sequentially into data array - uint8_t c = rawData[6]; // End data read by reading ST2 register - if(!(c & 0x08)) { // Check if magnetic sensor overflow set, if not then report data - destination[0] = (int16_t)(((int16_t)rawData[1] << 8) | rawData[0]); // Turn the MSB and LSB into a signed 16-bit value - destination[1] = (int16_t)(((int16_t)rawData[3] << 8) | rawData[2]) ; // Data stored as little Endian - destination[2] = (int16_t)(((int16_t)rawData[5] << 8) | rawData[4]) ; - } - } + i2c.write(addr, cmd, 2); //レジスタ指定はこうする } -void getMres() { - switch (Mscale) - { - // Possible magnetometer scales (and their register bit settings) are: - // 14 bit resolution (0) and 16 bit resolution (1) - case MFS_14BITS: - mRes = 10.0*4912.0/8190.0; // Proper scale to return milliGauss - break; - case MFS_16BITS: - mRes = 10.0*4912.0/32760.0; // Proper scale to return milliGauss - break; - } -} -*/ - -//Who_am_Iアドレスで接続確認ができる。0x48もしくは10進数で72が返ってくればok +//Who_am_Iアドレスで接続確認ができる。0x48もしくは10進数で72が返ってくればおk uint8_t IDcheck(){ uint8_t address; i2cRead(AK8963_ADDRESS, Magadd, 1, &address);