V 1.1
Fork of HMC5883L by
Embed:
(wiki syntax)
Show/hide line numbers
HMC5883L.h
00001 #ifndef HMC5883L_H 00002 #define HMC5883L_H 00003 00004 #include "mbed.h" 00005 00006 #define HMC5883L_IDENT_A 0x0A // In this case the identification register A is used to identify the devide. ASCII value H 00007 #define HMC5883L_I2C 0x1E // 7-bit address. 0x3C write, 0x3D read. 00008 #define HMC5883L_I2C_WRITE 0x3C // Same as (& 0xFE), ensure that the MSB bit is being set to zero (RW=0 -> Writing) 00009 #define HMC5883L_I2C_READ 0x3D // Same as (| 0x01), ensure that the MSB bit is being set to one (RW=1 -> Reading) 00010 00011 #define HMC5883L_CONFIG_A 0x00 00012 #define HMC5883L_CONFIG_B 0x01 00013 #define HMC5883L_MODE 0x02 00014 #define HMC5883L_STATUS 0x09 00015 00016 #define HMC5883L_X_MSB 0x03 00017 #define HMC5883L_X_LSB 0x04 00018 #define HMC5883L_Z_MSB 0x05 00019 #define HMC5883L_Z_LSB 0x06 00020 #define HMC5883L_Y_MSB 0x07 00021 #define HMC5883L_Y_LSB 0x08 00022 00023 00024 class HMC5883L 00025 { 00026 00027 public: 00028 00029 HMC5883L(PinName sda, PinName scl); 00030 float getMx(); 00031 float getMy(); 00032 float getMz(); 00033 private: 00034 void Write(char reg_address, char data); 00035 char Read(char data); 00036 void MultiByteRead(char address, char* output, int size); 00037 I2C i2c; 00038 00039 }; 00040 00041 #endif /* HMC5883L_H */ 00042
Generated on Thu Jul 28 2022 13:27:56 by 1.7.2