mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 17:31:13 +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
@ -29,7 +29,7 @@
|
||||
|
||||
using namespace upm;
|
||||
|
||||
HTU21D::HTU21D(int bus, int devAddr) {
|
||||
HTU21D::HTU21D(int bus, int devAddr) : m_i2ControlCtx(bus) {
|
||||
m_temperature = 0;
|
||||
m_humidity = 0;
|
||||
|
||||
@ -38,25 +38,19 @@ HTU21D::HTU21D(int bus, int devAddr) {
|
||||
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");
|
||||
}
|
||||
resetSensor();
|
||||
}
|
||||
|
||||
HTU21D::~HTU21D() {
|
||||
mraa_i2c_stop(m_i2ControlCtx);
|
||||
}
|
||||
|
||||
void
|
||||
HTU21D::resetSensor(void)
|
||||
{
|
||||
uint8_t data;
|
||||
mraa_i2c_address (m_i2ControlCtx, m_controlAddr);
|
||||
mraa_i2c_write (m_i2ControlCtx, &data, 1);
|
||||
m_i2ControlCtx.address (m_controlAddr);
|
||||
m_i2ControlCtx.write (&data, 1);
|
||||
usleep(20000);
|
||||
}
|
||||
|
||||
@ -207,13 +201,13 @@ HTU21D::testSensor(void)
|
||||
* Functions to read and write data to the i2c device
|
||||
*/
|
||||
|
||||
mraa_result_t
|
||||
mraa::Result
|
||||
HTU21D::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;
|
||||
}
|
||||
@ -221,15 +215,15 @@ HTU21D::i2cWriteReg (uint8_t reg, uint8_t value) {
|
||||
uint16_t
|
||||
HTU21D::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
|
||||
HTU21D::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 HTU21D_NAME "htu21d"
|
||||
@ -90,11 +90,6 @@ class HTU21D {
|
||||
*/
|
||||
HTU21D (int bus, int devAddr=HTU21D_I2C_ADDRESS);
|
||||
|
||||
/**
|
||||
* HTU21D object destructor; basically, it closes the I2C connection.
|
||||
*/
|
||||
~HTU21D ();
|
||||
|
||||
/**
|
||||
* Initiates a temperature/pressure mesasurement and waits for the function
|
||||
* to complete. The humidity and temperature registers can be read
|
||||
@ -149,7 +144,7 @@ class HTU21D {
|
||||
* @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 a two-byte register
|
||||
@ -181,7 +176,7 @@ class HTU21D {
|
||||
|
||||
int m_controlAddr;
|
||||
int m_bus;
|
||||
mraa_i2c_context m_i2ControlCtx;
|
||||
mraa::I2c m_i2ControlCtx;
|
||||
|
||||
int32_t m_temperature;
|
||||
int32_t m_humidity;
|
||||
|
Reference in New Issue
Block a user