temp

Dependencies:   mbed SDFileSystem MS5607 ADXL345_I2C FATFileSystem

Committer:
IKobayashi
Date:
Mon Mar 16 23:37:42 2020 +0900
Revision:
0:c88c3b616c00
copy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IKobayashi 0:c88c3b616c00 1 #ifndef HMC5883L_H
IKobayashi 0:c88c3b616c00 2 #define HMC5883L_H
IKobayashi 0:c88c3b616c00 3
IKobayashi 0:c88c3b616c00 4 #include "mbed.h"
IKobayashi 0:c88c3b616c00 5
IKobayashi 0:c88c3b616c00 6 #define HMC5883L_IDENT_A 0x0A // In this case the identification register A is used to identify the devide. ASCII value H
IKobayashi 0:c88c3b616c00 7 #define HMC5883L_I2C 0x1E // 7-bit address. 0x3C write, 0x3D read.
IKobayashi 0:c88c3b616c00 8 #define HMC5883L_I2C_WRITE 0x3C // Same as (& 0xFE), ensure that the MSB bit is being set to zero (RW=0 -> Writing)
IKobayashi 0:c88c3b616c00 9 #define HMC5883L_I2C_READ 0x3D // Same as (| 0x01), ensure that the MSB bit is being set to one (RW=1 -> Reading)
IKobayashi 0:c88c3b616c00 10
IKobayashi 0:c88c3b616c00 11 #define HMC5883L_CONFIG_A 0x00
IKobayashi 0:c88c3b616c00 12 #define HMC5883L_CONFIG_B 0x01
IKobayashi 0:c88c3b616c00 13 #define HMC5883L_MODE 0x02
IKobayashi 0:c88c3b616c00 14 #define HMC5883L_STATUS 0x09
IKobayashi 0:c88c3b616c00 15
IKobayashi 0:c88c3b616c00 16 #define HMC5883L_X_MSB 0x03
IKobayashi 0:c88c3b616c00 17 #define HMC5883L_X_LSB 0x04
IKobayashi 0:c88c3b616c00 18 #define HMC5883L_Z_MSB 0x05
IKobayashi 0:c88c3b616c00 19 #define HMC5883L_Z_LSB 0x06
IKobayashi 0:c88c3b616c00 20 #define HMC5883L_Y_MSB 0x07
IKobayashi 0:c88c3b616c00 21 #define HMC5883L_Y_LSB 0x08
IKobayashi 0:c88c3b616c00 22
IKobayashi 0:c88c3b616c00 23
IKobayashi 0:c88c3b616c00 24 class HMC5883L
IKobayashi 0:c88c3b616c00 25 {
IKobayashi 0:c88c3b616c00 26
IKobayashi 0:c88c3b616c00 27 public:
IKobayashi 0:c88c3b616c00 28
IKobayashi 0:c88c3b616c00 29 HMC5883L(PinName sda, PinName scl);
IKobayashi 0:c88c3b616c00 30 float getMx();
IKobayashi 0:c88c3b616c00 31 float getMy();
IKobayashi 0:c88c3b616c00 32 float getMz();
IKobayashi 0:c88c3b616c00 33 private:
IKobayashi 0:c88c3b616c00 34 void Write(char reg_address, char data);
IKobayashi 0:c88c3b616c00 35 char Read(char data);
IKobayashi 0:c88c3b616c00 36 void MultiByteRead(char address, char* output, int size);
IKobayashi 0:c88c3b616c00 37 I2C i2c;
IKobayashi 0:c88c3b616c00 38
IKobayashi 0:c88c3b616c00 39 };
IKobayashi 0:c88c3b616c00 40
IKobayashi 0:c88c3b616c00 41 #endif /* HMC5883L_H */