|
@@ -79,17 +79,17 @@ using namespace upm;
|
79
|
79
|
|
80
|
80
|
Hmc5883l::Hmc5883l()
|
81
|
81
|
{
|
82
|
|
- i2c = new maa::I2CSlave(26, 27);
|
|
82
|
+ i2c = maa_i2c_init();
|
83
|
83
|
|
84
|
|
- i2c->address(HMC5883L_I2C_ADDR);
|
|
84
|
+ maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
85
|
85
|
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
|
86
|
86
|
rx_tx_buf[1] = GA_1_3_REG;
|
87
|
|
- i2c->write(rx_tx_buf, 2);
|
|
87
|
+ maa_i2c_write(i2c, rx_tx_buf, 2);
|
88
|
88
|
|
89
|
|
- i2c->address(HMC5883L_I2C_ADDR);
|
|
89
|
+ maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
90
|
90
|
rx_tx_buf[0] = HMC5883L_MODE_REG;
|
91
|
91
|
rx_tx_buf[1] = HMC5883L_CONT_MODE;
|
92
|
|
- i2c->write(rx_tx_buf, 2);
|
|
92
|
+ maa_i2c_write(i2c, rx_tx_buf, 2);
|
93
|
93
|
|
94
|
94
|
Hmc5883l::update();
|
95
|
95
|
}
|
|
@@ -97,11 +97,11 @@ Hmc5883l::Hmc5883l()
|
97
|
97
|
int
|
98
|
98
|
Hmc5883l::update(void)
|
99
|
99
|
{
|
100
|
|
- i2c->address(HMC5883L_I2C_ADDR);
|
101
|
|
- i2c->write(HMC5883L_DATA_REG);
|
|
100
|
+ maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
|
101
|
+ maa_i2c_write_byte(i2c, HMC5883L_DATA_REG);
|
102
|
102
|
|
103
|
|
- i2c->address(HMC5883L_I2C_ADDR);
|
104
|
|
- i2c->read(rx_tx_buf, DATA_REG_SIZE);
|
|
103
|
+ maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
|
104
|
+ maa_i2c_read(i2c, rx_tx_buf, DATA_REG_SIZE);
|
105
|
105
|
|
106
|
106
|
// x
|
107
|
107
|
coor[0] = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_X_LSB_REG] ;
|
|
@@ -109,6 +109,8 @@ Hmc5883l::update(void)
|
109
|
109
|
coor[2] = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Z_LSB_REG] ;
|
110
|
110
|
// y
|
111
|
111
|
coor[1] = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Y_LSB_REG] ;
|
|
112
|
+
|
|
113
|
+ return MAA_SUCCESS;
|
112
|
114
|
}
|
113
|
115
|
|
114
|
116
|
float
|