![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
test module for fibo
Fork of ReadingMag_HMC5883L by
HMC5883L.h@1:ed9abb368fcf, 2015-03-02 (annotated)
- Committer:
- masterholy
- Date:
- Mon Mar 02 09:06:19 2015 +0000
- Revision:
- 1:ed9abb368fcf
- Parent:
- 0:6bc5f85ca6fa
test module for fibo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jose_claudiojr | 0:6bc5f85ca6fa | 1 | #ifndef HMC5883L_H |
jose_claudiojr | 0:6bc5f85ca6fa | 2 | #define HMC5883L_H |
jose_claudiojr | 0:6bc5f85ca6fa | 3 | |
jose_claudiojr | 0:6bc5f85ca6fa | 4 | #include "mbed.h" |
jose_claudiojr | 0:6bc5f85ca6fa | 5 | |
jose_claudiojr | 0:6bc5f85ca6fa | 6 | #define HMC5883L_IDENT_A 0x0A // In this case the identification register A is used to identify the devide. ASCII value H |
jose_claudiojr | 0:6bc5f85ca6fa | 7 | #define HMC5883L_I2C 0x1E // 7-bit address. 0x3C write, 0x3D read. |
jose_claudiojr | 0:6bc5f85ca6fa | 8 | #define HMC5883L_I2C_WRITE 0x3C // Same as (& 0xFE), ensure that the MSB bit is being set to zero (RW=0 -> Writing) |
jose_claudiojr | 0:6bc5f85ca6fa | 9 | #define HMC5883L_I2C_READ 0x3D // Same as (| 0x01), ensure that the MSB bit is being set to one (RW=1 -> Reading) |
jose_claudiojr | 0:6bc5f85ca6fa | 10 | |
jose_claudiojr | 0:6bc5f85ca6fa | 11 | #define HMC5883L_CONFIG_A 0x00 |
jose_claudiojr | 0:6bc5f85ca6fa | 12 | #define HMC5883L_CONFIG_B 0x01 |
jose_claudiojr | 0:6bc5f85ca6fa | 13 | #define HMC5883L_MODE 0x02 |
jose_claudiojr | 0:6bc5f85ca6fa | 14 | #define HMC5883L_STATUS 0x09 |
jose_claudiojr | 0:6bc5f85ca6fa | 15 | |
jose_claudiojr | 0:6bc5f85ca6fa | 16 | #define HMC5883L_X_MSB 0x03 |
jose_claudiojr | 0:6bc5f85ca6fa | 17 | #define HMC5883L_X_LSB 0x04 |
jose_claudiojr | 0:6bc5f85ca6fa | 18 | #define HMC5883L_Z_MSB 0x05 |
jose_claudiojr | 0:6bc5f85ca6fa | 19 | #define HMC5883L_Z_LSB 0x06 |
jose_claudiojr | 0:6bc5f85ca6fa | 20 | #define HMC5883L_Y_MSB 0x07 |
jose_claudiojr | 0:6bc5f85ca6fa | 21 | #define HMC5883L_Y_LSB 0x08 |
jose_claudiojr | 0:6bc5f85ca6fa | 22 | |
jose_claudiojr | 0:6bc5f85ca6fa | 23 | |
jose_claudiojr | 0:6bc5f85ca6fa | 24 | class HMC5883L |
jose_claudiojr | 0:6bc5f85ca6fa | 25 | { |
jose_claudiojr | 0:6bc5f85ca6fa | 26 | |
jose_claudiojr | 0:6bc5f85ca6fa | 27 | public: |
jose_claudiojr | 0:6bc5f85ca6fa | 28 | |
jose_claudiojr | 0:6bc5f85ca6fa | 29 | HMC5883L(PinName sda, PinName scl); |
jose_claudiojr | 0:6bc5f85ca6fa | 30 | float getMx(); |
jose_claudiojr | 0:6bc5f85ca6fa | 31 | float getMy(); |
jose_claudiojr | 0:6bc5f85ca6fa | 32 | float getMz(); |
jose_claudiojr | 0:6bc5f85ca6fa | 33 | private: |
jose_claudiojr | 0:6bc5f85ca6fa | 34 | void Write(char reg_address, char data); |
jose_claudiojr | 0:6bc5f85ca6fa | 35 | char Read(char data); |
jose_claudiojr | 0:6bc5f85ca6fa | 36 | void MultiByteRead(char address, char* output, int size); |
jose_claudiojr | 0:6bc5f85ca6fa | 37 | I2C i2c; |
jose_claudiojr | 0:6bc5f85ca6fa | 38 | |
jose_claudiojr | 0:6bc5f85ca6fa | 39 | }; |
jose_claudiojr | 0:6bc5f85ca6fa | 40 | |
jose_claudiojr | 0:6bc5f85ca6fa | 41 | #endif /* HMC5883L_H */ |