|
@@ -79,17 +79,17 @@ using namespace upm;
|
79
|
79
|
|
80
|
80
|
Hmc5883l::Hmc5883l()
|
81
|
81
|
{
|
82
|
|
- i2c = maa_i2c_init();
|
|
82
|
+ m_i2c = maa_i2c_init();
|
83
|
83
|
|
84
|
|
- maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
85
|
|
- rx_tx_buf[0] = HMC5883L_CONF_REG_B;
|
86
|
|
- rx_tx_buf[1] = GA_1_3_REG;
|
87
|
|
- maa_i2c_write(i2c, rx_tx_buf, 2);
|
|
84
|
+ maa_i2c_address(m_i2c, HMC5883L_I2C_ADDR);
|
|
85
|
+ m_rx_tx_buf[0] = HMC5883L_CONF_REG_B;
|
|
86
|
+ m_rx_tx_buf[1] = GA_1_3_REG;
|
|
87
|
+ maa_i2c_write(m_i2c, m_rx_tx_buf, 2);
|
88
|
88
|
|
89
|
|
- maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
90
|
|
- rx_tx_buf[0] = HMC5883L_MODE_REG;
|
91
|
|
- rx_tx_buf[1] = HMC5883L_CONT_MODE;
|
92
|
|
- maa_i2c_write(i2c, rx_tx_buf, 2);
|
|
89
|
+ maa_i2c_address(m_i2c, HMC5883L_I2C_ADDR);
|
|
90
|
+ m_rx_tx_buf[0] = HMC5883L_MODE_REG;
|
|
91
|
+ m_rx_tx_buf[1] = HMC5883L_CONT_MODE;
|
|
92
|
+ maa_i2c_write(m_i2c, m_rx_tx_buf, 2);
|
93
|
93
|
|
94
|
94
|
Hmc5883l::update();
|
95
|
95
|
}
|
|
@@ -97,18 +97,18 @@ Hmc5883l::Hmc5883l()
|
97
|
97
|
int
|
98
|
98
|
Hmc5883l::update(void)
|
99
|
99
|
{
|
100
|
|
- maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
101
|
|
- maa_i2c_write_byte(i2c, HMC5883L_DATA_REG);
|
|
100
|
+ maa_i2c_address(m_i2c, HMC5883L_I2C_ADDR);
|
|
101
|
+ maa_i2c_write_byte(m_i2c, HMC5883L_DATA_REG);
|
102
|
102
|
|
103
|
|
- maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
104
|
|
- maa_i2c_read(i2c, rx_tx_buf, DATA_REG_SIZE);
|
|
103
|
+ maa_i2c_address(m_i2c, HMC5883L_I2C_ADDR);
|
|
104
|
+ maa_i2c_read(m_i2c, m_rx_tx_buf, DATA_REG_SIZE);
|
105
|
105
|
|
106
|
106
|
// x
|
107
|
|
- coor[0] = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_X_LSB_REG] ;
|
|
107
|
+ m_coor[0] = (m_rx_tx_buf[HMC5883L_X_MSB_REG] << 8 ) | m_rx_tx_buf[HMC5883L_X_LSB_REG];
|
108
|
108
|
// z
|
109
|
|
- coor[2] = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Z_LSB_REG] ;
|
|
109
|
+ m_coor[2] = (m_rx_tx_buf[HMC5883L_Z_MSB_REG] << 8 ) | m_rx_tx_buf[HMC5883L_Z_LSB_REG];
|
110
|
110
|
// y
|
111
|
|
- coor[1] = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Y_LSB_REG] ;
|
|
111
|
+ m_coor[1] = (m_rx_tx_buf[HMC5883L_Y_MSB_REG] << 8 ) | m_rx_tx_buf[HMC5883L_Y_LSB_REG];
|
112
|
112
|
|
113
|
113
|
return MAA_SUCCESS;
|
114
|
114
|
}
|
|
@@ -116,7 +116,7 @@ Hmc5883l::update(void)
|
116
|
116
|
float
|
117
|
117
|
Hmc5883l::direction(void)
|
118
|
118
|
{
|
119
|
|
- return atan2(coor[1] * SCALE_0_92_MG, coor[0] * SCALE_0_92_MG);
|
|
119
|
+ return atan2(m_coor[1] * SCALE_0_92_MG, m_coor[0] * SCALE_0_92_MG);
|
120
|
120
|
}
|
121
|
121
|
|
122
|
122
|
float
|
|
@@ -128,5 +128,5 @@ Hmc5883l::heading(void)
|
128
|
128
|
int*
|
129
|
129
|
Hmc5883l::coordinates(void)
|
130
|
130
|
{
|
131
|
|
- return &coor[0];
|
|
131
|
+ return &m_coor[0];
|
132
|
132
|
}
|