MPU6050のサンプルプログラム2
Dependencies: ConfigFile SDFileSystem mbed
Fork of LAURUS_program by
HMC5883L/HMC5883L.h@1:6cd6d2760856, 2015-05-24 (annotated)
- Committer:
- ojan
- Date:
- Sun May 24 17:32:47 2015 +0000
- Revision:
- 1:6cd6d2760856
- Parent:
- 0:bc6f14fc60c7
Send all sensor's data to PC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ojan | 0:bc6f14fc60c7 | 1 | #pragma once |
ojan | 0:bc6f14fc60c7 | 2 | |
ojan | 0:bc6f14fc60c7 | 3 | const static int hmc_addr = 0x3c; |
ojan | 0:bc6f14fc60c7 | 4 | |
ojan | 0:bc6f14fc60c7 | 5 | typedef union { |
ojan | 0:bc6f14fc60c7 | 6 | char reg[6]; |
ojan | 0:bc6f14fc60c7 | 7 | struct { |
ojan | 0:bc6f14fc60c7 | 8 | uint8_t mag_x_L; |
ojan | 0:bc6f14fc60c7 | 9 | uint8_t mag_x_H; |
ojan | 0:bc6f14fc60c7 | 10 | uint8_t mag_y_L; |
ojan | 0:bc6f14fc60c7 | 11 | uint8_t mag_y_H; |
ojan | 0:bc6f14fc60c7 | 12 | uint8_t mag_z_L; |
ojan | 0:bc6f14fc60c7 | 13 | uint8_t mag_z_H; |
ojan | 0:bc6f14fc60c7 | 14 | } byte; |
ojan | 0:bc6f14fc60c7 | 15 | |
ojan | 0:bc6f14fc60c7 | 16 | int16_t value[3]; |
ojan | 0:bc6f14fc60c7 | 17 | |
ojan | 0:bc6f14fc60c7 | 18 | } HMC_DATA; |
ojan | 0:bc6f14fc60c7 | 19 | |
ojan | 0:bc6f14fc60c7 | 20 | class HMC5883L { |
ojan | 0:bc6f14fc60c7 | 21 | public: |
ojan | 1:6cd6d2760856 | 22 | HMC5883L(I2C* p_i2c); |
ojan | 0:bc6f14fc60c7 | 23 | ~HMC5883L(); |
ojan | 0:bc6f14fc60c7 | 24 | |
ojan | 0:bc6f14fc60c7 | 25 | int init(); |
ojan | 0:bc6f14fc60c7 | 26 | int read(); |
ojan | 0:bc6f14fc60c7 | 27 | |
ojan | 0:bc6f14fc60c7 | 28 | HMC_DATA data; |
ojan | 0:bc6f14fc60c7 | 29 | |
ojan | 0:bc6f14fc60c7 | 30 | private: |
ojan | 0:bc6f14fc60c7 | 31 | I2C* i2c; |
ojan | 0:bc6f14fc60c7 | 32 | }; |