Fix some dosctrings errors and trailing whitespaces

Signed-off-by: Kirill Luchikhin <kirill.luchikhin@intel.com>
This commit is contained in:
Kirill Luchikhin
2014-07-29 21:46:48 +04:00
parent 731704eaac
commit d15bf22536
21 changed files with 134 additions and 107 deletions

View File

@ -36,7 +36,7 @@ using namespace upm;
MMA7455::MMA7455 (int bus, int devAddr) {
unsigned char data = 0;
int nBytes = 0;
m_name = "MMA7455";
m_controlAddr = devAddr;
@ -49,7 +49,7 @@ MMA7455::MMA7455 (int bus, int devAddr) {
fprintf(stderr, "Messed up i2c bus\n");
return;
}
// setting GLVL 0x1 (64LSB/g) and MODE 0x1 (Measurement Mode)
data = (BIT (MMA7455_GLVL0) | BIT (MMA7455_MODE0));
error = ic2WriteReg (MMA7455_MCTL, &data, 0x1);
@ -57,7 +57,7 @@ MMA7455::MMA7455 (int bus, int devAddr) {
std::cout << "ERROR :: MMA7455 instance wan not created (Mode)" << std::endl;
return;
}
if (MRAA_SUCCESS != calibrate ()) {
std::cout << "ERROR :: MMA7455 instance wan not created (Calibrate)" << std::endl;
return;
@ -68,63 +68,63 @@ MMA7455::~MMA7455() {
mraa_i2c_stop(m_i2ControlCtx);
}
mraa_result_t
mraa_result_t
MMA7455::calibrate () {
mraa_result_t error = MRAA_SUCCESS;
int i = 0;
accelData xyz;
xyz.value.x = xyz.value.y = xyz.value.z = 0;
do {
error = readData (&xyz.value.x, &xyz.value.y, &xyz.value.z);
if (MRAA_SUCCESS != error) {
return error;
}
xyz.value.x += 2 * -xyz.value.x;
xyz.value.y += 2 * -xyz.value.y;
xyz.value.z += 2 * -(xyz.value.z - 64);
error = ic2WriteReg (MMA7455_XOFFL, (unsigned char *) &xyz, 0x6);
if (error != MRAA_SUCCESS) {
return error;
}
} while ( ++i < 3 );
return error;
}
mraa_result_t
mraa_result_t
MMA7455::readData (short * ptrX, short * ptrY, short * ptrZ) {
accelData xyz;
unsigned char data = 0;
int nBytes = 0;
/*do {
nBytes = ic2ReadReg (MMA7455_STATUS, &data, 0x1);
} while ( !(data & MMA7455_DRDY) && nBytes == MRAA_SUCCESS);
if (nBytes == MRAA_SUCCESS) {
std::cout << "NO_GDB :: 1" << std::endl;
return MRAA_SUCCESS;
}*/
nBytes = ic2ReadReg (MMA7455_XOUTL, (unsigned char *) &xyz, 0x6);
if (nBytes == 0) {
std::cout << "NO_GDB :: 2" << std::endl;
return MRAA_ERROR_UNSPECIFIED;
}
if (xyz.reg.x_msb & 0x02) {
xyz.reg.x_msb |= 0xFC;
}
if (xyz.reg.y_msb & 0x02) {
xyz.reg.y_msb |= 0xFC;
}
if (xyz.reg.z_msb & 0x02) {
xyz.reg.z_msb |= 0xFC;
}
@ -133,16 +133,16 @@ MMA7455::readData (short * ptrX, short * ptrY, short * ptrZ) {
*ptrX = xyz.value.x;
*ptrY = xyz.value.y;
*ptrZ = xyz.value.z;
return MRAA_SUCCESS;
}
int
int
MMA7455::ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size) {
if (MRAA_SUCCESS != mraa_i2c_address(m_i2ControlCtx, m_controlAddr)) {
return 0;
}
if (MRAA_SUCCESS != mraa_i2c_write_byte(m_i2ControlCtx, reg)) {
return 0;
}
@ -150,11 +150,11 @@ MMA7455::ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size)
if (MRAA_SUCCESS != mraa_i2c_address(m_i2ControlCtx, m_controlAddr)) {
return 0;
}
return (int) mraa_i2c_read(m_i2ControlCtx, buf, size);
}
mraa_result_t
mraa_result_t
MMA7455::ic2WriteReg (unsigned char reg, unsigned char * buf, unsigned char size) {
mraa_result_t error = MRAA_SUCCESS;
@ -173,4 +173,3 @@ MMA7455::ic2WriteReg (unsigned char reg, unsigned char * buf, unsigned char size
return error;
}

View File

@ -53,7 +53,7 @@
#define MMA7455_YOFFH 0x13 // Read/Write, Offset Drift Y MSB
#define MMA7455_ZOFFL 0x14 // Read/Write, Offset Drift Z LSB
#define MMA7455_ZOFFH 0x15 // Read/Write, Offset Drift Z MSB
#define MMA7455_MCTL 0x16 // Read/Write, Mode Control Register
#define MMA7455_MCTL 0x16 // Read/Write, Mode Control Register
#define MMA7455_INTRST 0x17 // Read/Write, Interrupt Latch Reset
#define MMA7455_CTL1 0x18 // Read/Write, Control 1 Register
#define MMA7455_CTL2 0x19 // Read/Write, Control 2 Register
@ -64,11 +64,11 @@
#define MMA7455_TW 0x1E // Read/Write, Time Window for Second Pulse Value
#define MMA7455_RESERVED2 0x1F // Reserved
// Defines for the bits, to be able to change
// Defines for the bits, to be able to change
// between bit number and binary definition.
// By using the bit number, programming the MMA7455
// By using the bit number, programming the MMA7455
// is like programming an AVR microcontroller.
// But instead of using "(1<<X)", or "_BV(X)",
// But instead of using "(1<<X)", or "_BV(X)",
// the Arduino "bit(X)" is used.
#define MMA7455_D0 0
#define MMA7455_D1 1
@ -129,7 +129,7 @@
#define LOW 0
namespace upm {
union accelData {
struct {
unsigned char x_lsb;
@ -139,7 +139,7 @@ union accelData {
unsigned char z_lsb;
unsigned char z_msb;
} reg;
struct {
short x;
short y;
@ -179,12 +179,12 @@ class MMA7455 {
{
return m_name;
}
/**
* Calibrate the sensor
*/
mraa_result_t calibrate ();
/**
* Read X, Y and Z acceleration data
*
@ -193,21 +193,21 @@ class MMA7455 {
* @param ptrZ Z axis
*/
mraa_result_t readData (short * ptrX, short * ptrY, short * ptrZ);
/**
*
*
*
* @param reg register address
* @param buf register data buffer
* @param size buffer size
*/
int ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size);
/**
*
*
*
* @param reg register address
* @param buf register data buffer
* @param buf register data buffer
* @param size buffer size
*/
mraa_result_t ic2WriteReg (unsigned char reg, unsigned char * buf, unsigned char size);