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

View File

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