1 #ifndef LIBPROPELLER_LSM303DLHC_H_
2 #define LIBPROPELLER_LSM303DLHC_H_
67 status_ = bus_->
Ping(kDeviceMagnAddress);
68 if (status_ ==
false) {
72 status_ = bus_->
Ping(kDeviceAcclAddress);
73 if (status_ ==
false) {
79 bus_->
Put(kDeviceMagnAddress, kCRA_REG_M, 0b10011100);
80 bus_->
Put(kDeviceMagnAddress, kCRB_REG_M, kGain_1_3);
81 bus_->
Put(kDeviceMagnAddress, kMR_REG_M, 0b00000000);
84 bus_->
Put(kDeviceAcclAddress, kCTRL_REG1_A, 0b10010111);
85 bus_->
Put(kDeviceAcclAddress, kCTRL_REG4_A, 0b00111000);
102 if (status_ ==
false) {
107 if (bus_->
Get(kDeviceAcclAddress, kOUT_X_L_A, data, 6) ==
false) {
116 x = ((data[0] | (data[1] << 8)) << 16) >> 16;
117 y = ((data[2] | (data[3] << 8)) << 16) >> 16;
118 z = ((data[4] | (data[5] << 8)) << 16) >> 16;
135 if (status_ ==
false) {
140 if (bus_->
Get(kDeviceMagnAddress, kOUT_X_H_M, data, 6) ==
false) {
148 x = ((data[1] | (data[0] << 8)) << 16) >> 16;
149 z = ((data[3] | (data[2] << 8)) << 16) >> 16;
150 y = ((data[5] | (data[4] << 8)) << 16) >> 16;
160 const static unsigned char kDeviceAcclAddress = 0b00110010;
161 const static unsigned char kDeviceMagnAddress = 0b00111100;
164 const static unsigned char kCTRL_REG1_A = 0x20;
165 const static unsigned char kCTRL_REG4_A = 0x23;
166 const static unsigned char kOUT_X_L_A = 0x28 | 0x80;
169 const static unsigned char kCRA_REG_M = 0x00;
170 const static unsigned char kCRB_REG_M = 0x01;
171 const static unsigned char kMR_REG_M = 0x02;
172 const static unsigned char kOUT_X_H_M = 0x03 | 0x80;
174 const static unsigned char kGain_1_9 = 0b01000000;
175 const static unsigned char kGain_1_3 = 0b00100000;
178 #endif // LIBPROPELLER_LSM303DLHC_H_