mma7455: fixed typo and minor documentation improvements

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Mihai Tudor Panu 2015-09-04 14:27:18 -07:00
parent 4985cf4b00
commit c45e493b1b
2 changed files with 17 additions and 13 deletions

View File

@ -52,7 +52,7 @@ MMA7455::MMA7455 (int bus, int devAddr) {
// setting GLVL 0x1 (64LSB/g) and MODE 0x1 (Measurement Mode)
data = (BIT (MMA7455_GLVL0) | BIT (MMA7455_MODE0));
error = ic2WriteReg (MMA7455_MCTL, &data, 0x1);
error = i2cWriteReg (MMA7455_MCTL, &data, 0x1);
if (error != MRAA_SUCCESS) {
std::cout << "ERROR :: MMA7455 instance wan not created (Mode)" << std::endl;
return;
@ -86,7 +86,7 @@ MMA7455::calibrate () {
xyz.value.y += 2 * -xyz.value.y;
xyz.value.z += 2 * -(xyz.value.z - 64);
error = ic2WriteReg (MMA7455_XOFFL, (unsigned char *) &xyz, 0x6);
error = i2cWriteReg (MMA7455_XOFFL, (unsigned char *) &xyz, 0x6);
if (error != MRAA_SUCCESS) {
return error;
}
@ -103,7 +103,7 @@ MMA7455::readData (short * ptrX, short * ptrY, short * ptrZ) {
int nBytes = 0;
/*do {
nBytes = ic2ReadReg (MMA7455_STATUS, &data, 0x1);
nBytes = i2cReadReg (MMA7455_STATUS, &data, 0x1);
} while ( !(data & MMA7455_DRDY) && nBytes == MRAA_SUCCESS);
if (nBytes == MRAA_SUCCESS) {
@ -111,7 +111,7 @@ MMA7455::readData (short * ptrX, short * ptrY, short * ptrZ) {
return MRAA_SUCCESS;
}*/
nBytes = ic2ReadReg (MMA7455_XOUTL, (unsigned char *) &xyz, 0x6);
nBytes = i2cReadReg (MMA7455_XOUTL, (unsigned char *) &xyz, 0x6);
if (nBytes == 0) {
std::cout << "NO_GDB :: 2" << std::endl;
return MRAA_ERROR_UNSPECIFIED;
@ -146,7 +146,7 @@ short *MMA7455::readData() {
#endif
int
MMA7455::ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size) {
MMA7455::i2cReadReg (unsigned char reg, unsigned char * buf, unsigned char size) {
if (MRAA_SUCCESS != mraa_i2c_address(m_i2ControlCtx, m_controlAddr)) {
return 0;
}
@ -163,7 +163,7 @@ MMA7455::ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size)
}
mraa_result_t
MMA7455::ic2WriteReg (unsigned char reg, unsigned char * buf, unsigned char size) {
MMA7455::i2cWriteReg (unsigned char reg, unsigned char * buf, unsigned char size) {
mraa_result_t error = MRAA_SUCCESS;
uint8_t data[size + 1];

View File

@ -164,7 +164,7 @@ typedef union {
*
* @brief API for the MMA7455 Accelerometer
*
* This file defines the MMA7455 interface for libmma7455
* This module defines the MMA7455 interface for libmma7455
*
* @image html mma7455.jpg
* @snippet mma7455.cxx Interesting
@ -186,6 +186,8 @@ class MMA7455 {
/**
* Returns the name of the component
*
* @return Name of the component
*/
std::string name()
{
@ -194,6 +196,8 @@ class MMA7455 {
/**
* Calibrates the sensor
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t calibrate ();
@ -203,6 +207,8 @@ class MMA7455 {
* @param ptrX X-axis
* @param ptrY Y-axis
* @param ptrZ Z-axis
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t readData (short * ptrX, short * ptrY, short * ptrZ);
@ -214,28 +220,26 @@ class MMA7455 {
*/
short *readData ();
#endif
/**
*
* Internal function for reading I2C data
*
* @param reg Register address
* @param buf Register data buffer
* @param size Buffer size
*/
int ic2ReadReg (unsigned char reg, unsigned char * buf, unsigned char size);
int i2cReadReg (unsigned char reg, unsigned char * buf, unsigned char size);
/**
*
* Internal function for writing I2C data
*
* @param reg Register address
* @param buf Register data buffer
* @param size Buffer size
*/
mraa_result_t ic2WriteReg (unsigned char reg, unsigned char * buf, unsigned char size);
mraa_result_t i2cWriteReg (unsigned char reg, unsigned char * buf, unsigned char size);
private:
std::string m_name;
int m_controlAddr;
int m_bus;
mraa_i2c_context m_i2ControlCtx;