mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 01:41:12 +03:00
mraa: change all existing code to use libmraa.
* Made CMake depend on 0.4 libmraa Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
This commit is contained in:
@ -79,17 +79,17 @@ using namespace upm;
|
||||
|
||||
Hmc5883l::Hmc5883l(int bus)
|
||||
{
|
||||
m_i2c = maa_i2c_init(bus);
|
||||
m_i2c = mraa_i2c_init(bus);
|
||||
|
||||
maa_i2c_address(m_i2c, HMC5883L_I2C_ADDR);
|
||||
mraa_i2c_address(m_i2c, HMC5883L_I2C_ADDR);
|
||||
m_rx_tx_buf[0] = HMC5883L_CONF_REG_B;
|
||||
m_rx_tx_buf[1] = GA_1_3_REG;
|
||||
maa_i2c_write(m_i2c, m_rx_tx_buf, 2);
|
||||
mraa_i2c_write(m_i2c, m_rx_tx_buf, 2);
|
||||
|
||||
maa_i2c_address(m_i2c, HMC5883L_I2C_ADDR);
|
||||
mraa_i2c_address(m_i2c, HMC5883L_I2C_ADDR);
|
||||
m_rx_tx_buf[0] = HMC5883L_MODE_REG;
|
||||
m_rx_tx_buf[1] = HMC5883L_CONT_MODE;
|
||||
maa_i2c_write(m_i2c, m_rx_tx_buf, 2);
|
||||
mraa_i2c_write(m_i2c, m_rx_tx_buf, 2);
|
||||
|
||||
Hmc5883l::update();
|
||||
}
|
||||
@ -97,11 +97,11 @@ Hmc5883l::Hmc5883l(int bus)
|
||||
int
|
||||
Hmc5883l::update(void)
|
||||
{
|
||||
maa_i2c_address(m_i2c, HMC5883L_I2C_ADDR);
|
||||
maa_i2c_write_byte(m_i2c, HMC5883L_DATA_REG);
|
||||
mraa_i2c_address(m_i2c, HMC5883L_I2C_ADDR);
|
||||
mraa_i2c_write_byte(m_i2c, HMC5883L_DATA_REG);
|
||||
|
||||
maa_i2c_address(m_i2c, HMC5883L_I2C_ADDR);
|
||||
maa_i2c_read(m_i2c, m_rx_tx_buf, DATA_REG_SIZE);
|
||||
mraa_i2c_address(m_i2c, HMC5883L_I2C_ADDR);
|
||||
mraa_i2c_read(m_i2c, m_rx_tx_buf, DATA_REG_SIZE);
|
||||
|
||||
// x
|
||||
m_coor[0] = (m_rx_tx_buf[HMC5883L_X_MSB_REG] << 8 ) | m_rx_tx_buf[HMC5883L_X_LSB_REG];
|
||||
@ -110,7 +110,7 @@ Hmc5883l::update(void)
|
||||
// y
|
||||
m_coor[1] = (m_rx_tx_buf[HMC5883L_Y_MSB_REG] << 8 ) | m_rx_tx_buf[HMC5883L_Y_LSB_REG];
|
||||
|
||||
return MAA_SUCCESS;
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
||||
float
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <maa/i2c.h>
|
||||
#include <mraa/i2c.h>
|
||||
|
||||
#define MAX_BUFFER_LENGTH 6
|
||||
|
||||
@ -55,7 +55,7 @@ public:
|
||||
private:
|
||||
int m_coor[3];
|
||||
uint8_t m_rx_tx_buf[MAX_BUFFER_LENGTH];
|
||||
maa_i2c_context m_i2c;
|
||||
mraa_i2c_context m_i2c;
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user