mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 01:41:12 +03:00
java: changed some C types to C++ types
Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com> Conflicts: src/mma7455/mma7455.cxx src/mma7455/mma7455.h src/sm130/sm130.cxx src/sm130/sm130.h
This commit is contained in:

committed by
Mihai Tudor Panu

parent
b8835958e2
commit
ab730038fd
@ -34,7 +34,8 @@
|
||||
|
||||
using namespace upm;
|
||||
|
||||
MPL3115A2::MPL3115A2 (int bus, int devAddr, uint8_t mode) {
|
||||
MPL3115A2::MPL3115A2 (int bus, int devAddr, uint8_t mode) : m_i2ControlCtx(bus)
|
||||
{
|
||||
int id;
|
||||
|
||||
m_name = MPL3115A2_NAME;
|
||||
@ -42,10 +43,8 @@ MPL3115A2::MPL3115A2 (int bus, int devAddr, uint8_t mode) {
|
||||
m_controlAddr = devAddr;
|
||||
m_bus = bus;
|
||||
|
||||
m_i2ControlCtx = mraa_i2c_init(m_bus);
|
||||
|
||||
mraa_result_t ret = mraa_i2c_address(m_i2ControlCtx, m_controlAddr);
|
||||
if (ret != MRAA_SUCCESS) {
|
||||
mraa::Result ret = m_i2ControlCtx.address(m_controlAddr);
|
||||
if (ret != mraa::SUCCESS) {
|
||||
fprintf(stderr, "Error accessing i2c bus\n");
|
||||
}
|
||||
|
||||
@ -57,10 +56,6 @@ MPL3115A2::MPL3115A2 (int bus, int devAddr, uint8_t mode) {
|
||||
}
|
||||
}
|
||||
|
||||
MPL3115A2::~MPL3115A2() {
|
||||
mraa_i2c_stop(m_i2ControlCtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function to test the device and verify that is appears operational
|
||||
* Typically functioning sensors will return "noisy" values and would
|
||||
@ -146,14 +141,14 @@ int
|
||||
MPL3115A2::sampleData(void)
|
||||
{
|
||||
int val;
|
||||
mraa_result_t ret;
|
||||
mraa::Result ret;
|
||||
int tries = 15;
|
||||
uint32_t us_delay;
|
||||
|
||||
// trigger measurement
|
||||
ret = i2cWriteReg(MPL3115A2_CTRL_REG1,
|
||||
MPL3115A2_CTRL_OST | MPL3115A2_SETOVERSAMPLE(m_oversampling));
|
||||
if (MRAA_SUCCESS != ret) {
|
||||
if (mraa::SUCCESS != ret) {
|
||||
fprintf(stdout, "Write to trigger measurement failed\n");
|
||||
return -1;
|
||||
}
|
||||
@ -296,13 +291,13 @@ MPL3115A2::convertPaToinHg(float fPressure)
|
||||
* Functions to read and write data to the i2c device
|
||||
*/
|
||||
|
||||
mraa_result_t
|
||||
mraa::Result
|
||||
MPL3115A2::i2cWriteReg (uint8_t reg, uint8_t value) {
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
mraa::Result error = mraa::SUCCESS;
|
||||
|
||||
uint8_t data[2] = { reg, value };
|
||||
mraa_i2c_address (m_i2ControlCtx, m_controlAddr);
|
||||
error = mraa_i2c_write (m_i2ControlCtx, data, 2);
|
||||
m_i2ControlCtx.address (m_controlAddr);
|
||||
error = m_i2ControlCtx.write (data, 2);
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -311,16 +306,16 @@ uint16_t
|
||||
MPL3115A2::i2cReadReg_16 (int reg) {
|
||||
uint16_t data;
|
||||
|
||||
mraa_i2c_address(m_i2ControlCtx, m_controlAddr);
|
||||
data = (uint16_t)mraa_i2c_read_byte_data(m_i2ControlCtx, reg) << 8;
|
||||
data |= (uint16_t)mraa_i2c_read_byte_data(m_i2ControlCtx, reg+1);
|
||||
m_i2ControlCtx.address(m_controlAddr);
|
||||
data = (uint16_t)m_i2ControlCtx.readReg(reg) << 8;
|
||||
data |= (uint16_t)m_i2ControlCtx.readReg(reg+1);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
MPL3115A2::i2cReadReg_8 (int reg) {
|
||||
mraa_i2c_address(m_i2ControlCtx, m_controlAddr);
|
||||
return mraa_i2c_read_byte_data(m_i2ControlCtx, reg);
|
||||
m_i2ControlCtx.address(m_controlAddr);
|
||||
return m_i2ControlCtx.readReg(reg);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <mraa/i2c.h>
|
||||
#include <mraa/i2c.hpp>
|
||||
#include <math.h>
|
||||
|
||||
#define MPL3115A2_NAME "mpl3115a2"
|
||||
@ -92,8 +92,10 @@ class MPL3115A2 {
|
||||
|
||||
/**
|
||||
* MPL3115A2 object destructor; basically, it closes the I2C connection.
|
||||
*/
|
||||
~MPL3115A2();
|
||||
* ~MPL3115A2();
|
||||
* no need for this here, as the I2c connection will be closed when the
|
||||
* m_i2ControlCtx variable will go out of scope
|
||||
**/
|
||||
|
||||
/**
|
||||
* Tests the sensor and tries to determine if the sensor is operating by looking
|
||||
@ -222,7 +224,7 @@ class MPL3115A2 {
|
||||
* @param reg Address of the register
|
||||
* @param value Byte to be written
|
||||
*/
|
||||
mraa_result_t i2cWriteReg (uint8_t reg, uint8_t value);
|
||||
mraa::Result i2cWriteReg (uint8_t reg, uint8_t value);
|
||||
|
||||
/**
|
||||
* Reads two bytes from an I2C register
|
||||
@ -243,7 +245,7 @@ class MPL3115A2 {
|
||||
|
||||
int m_controlAddr;
|
||||
int m_bus;
|
||||
mraa_i2c_context m_i2ControlCtx;
|
||||
mraa::I2c m_i2ControlCtx;
|
||||
|
||||
uint8_t m_oversampling;
|
||||
int32_t m_iPressure;
|
||||
|
Reference in New Issue
Block a user