I2c-compass.cpp: fix example to use HMC5883L_CONT_MODE
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -86,25 +86,32 @@ void
|
|||||||
sig_handler(int signo)
|
sig_handler(int signo)
|
||||||
{
|
{
|
||||||
if (signo == SIGINT) {
|
if (signo == SIGINT) {
|
||||||
printf("closing PWM nicely\n");
|
printf("closing nicely\n");
|
||||||
running = -1;
|
running = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main ()
|
int main ()
|
||||||
{
|
{
|
||||||
//! [Interesting]
|
|
||||||
maa::I2c* i2c;
|
|
||||||
i2c = new maa::I2c(0);
|
|
||||||
float direction = 0;
|
float direction = 0;
|
||||||
int16_t x = 0, y = 0, z = 0;
|
int16_t x = 0, y = 0, z = 0;
|
||||||
uint8_t rx_tx_buf[MAX_BUFFER_LENGTH];
|
uint8_t rx_tx_buf[MAX_BUFFER_LENGTH];
|
||||||
|
|
||||||
|
//! [Interesting]
|
||||||
|
maa::I2c* i2c;
|
||||||
|
i2c = new maa::I2c(0);
|
||||||
|
|
||||||
i2c->address(HMC5883L_I2C_ADDR);
|
i2c->address(HMC5883L_I2C_ADDR);
|
||||||
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
|
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
|
||||||
rx_tx_buf[1] = GA_1_3_REG;
|
rx_tx_buf[1] = GA_1_3_REG;
|
||||||
i2c->write(rx_tx_buf, 2);
|
i2c->write(rx_tx_buf, 2);
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
|
||||||
|
i2c->address(HMC5883L_I2C_ADDR);
|
||||||
|
rx_tx_buf[0] = HMC5883L_MODE_REG;
|
||||||
|
rx_tx_buf[1] = HMC5883L_CONT_MODE;
|
||||||
|
i2c->write(rx_tx_buf, 2);
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
while (running == 0) {
|
while (running == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user