mirror of
https://github.com/eclipse/upm.git
synced 2025-03-14 20:47:30 +03:00
upm: move to maa 0.2.1 C api
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
parent
80dc2b6616
commit
b0684c98a8
@ -5,8 +5,8 @@ set (SWIG_EXECUTABLE /usr/bin/swig)
|
||||
find_package (SWIG REQUIRED)
|
||||
include (${SWIG_USE_FILE})
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(MAA maa>=0.1.1)
|
||||
find_package (PkgConfig REQUIRED)
|
||||
pkg_check_modules (MAA maa>=0.2.1)
|
||||
|
||||
set (CMAKE_SWIG_FLAGS "")
|
||||
|
||||
|
@ -79,17 +79,17 @@ using namespace upm;
|
||||
|
||||
Hmc5883l::Hmc5883l()
|
||||
{
|
||||
i2c = new maa::I2CSlave(26, 27);
|
||||
i2c = maa_i2c_init();
|
||||
|
||||
i2c->address(HMC5883L_I2C_ADDR);
|
||||
maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
|
||||
rx_tx_buf[1] = GA_1_3_REG;
|
||||
i2c->write(rx_tx_buf, 2);
|
||||
maa_i2c_write(i2c, rx_tx_buf, 2);
|
||||
|
||||
i2c->address(HMC5883L_I2C_ADDR);
|
||||
maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
rx_tx_buf[0] = HMC5883L_MODE_REG;
|
||||
rx_tx_buf[1] = HMC5883L_CONT_MODE;
|
||||
i2c->write(rx_tx_buf, 2);
|
||||
maa_i2c_write(i2c, rx_tx_buf, 2);
|
||||
|
||||
Hmc5883l::update();
|
||||
}
|
||||
@ -97,11 +97,11 @@ Hmc5883l::Hmc5883l()
|
||||
int
|
||||
Hmc5883l::update(void)
|
||||
{
|
||||
i2c->address(HMC5883L_I2C_ADDR);
|
||||
i2c->write(HMC5883L_DATA_REG);
|
||||
maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
maa_i2c_write_byte(i2c, HMC5883L_DATA_REG);
|
||||
|
||||
i2c->address(HMC5883L_I2C_ADDR);
|
||||
i2c->read(rx_tx_buf, DATA_REG_SIZE);
|
||||
maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
maa_i2c_read(i2c, rx_tx_buf, DATA_REG_SIZE);
|
||||
|
||||
// x
|
||||
coor[0] = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_X_LSB_REG] ;
|
||||
@ -109,6 +109,8 @@ Hmc5883l::update(void)
|
||||
coor[2] = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Z_LSB_REG] ;
|
||||
// y
|
||||
coor[1] = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Y_LSB_REG] ;
|
||||
|
||||
return MAA_SUCCESS;
|
||||
}
|
||||
|
||||
float
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <maa/maa.h>
|
||||
#include <maa/i2c.h>
|
||||
|
||||
#define MAX_BUFFER_LENGTH 6
|
||||
|
||||
@ -39,7 +39,7 @@ public:
|
||||
private:
|
||||
int coor[3];
|
||||
char rx_tx_buf[MAX_BUFFER_LENGTH];
|
||||
maa::I2CSlave* i2c;
|
||||
maa_i2c_context* i2c;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user