For D

Dependents:   PWM_2_way_level-r1 StepLogger-Serial

MMA8451Q_tb.h

Committer:
tim_b
Date:
2014-06-09
Revision:
2:34878ff9bbd7
Parent:
1:c6db5b21ad79

File content as of revision 2:34878ff9bbd7:

#ifndef MMA8451Q_tb_H
#define MMA8451Q_tb_H

#include "mbed.h"

class MMA8451Q
{
public:
  /**
  * MMA8451Q constructor
  *
  * @param sda SDA pin
  * @param sdl SCL pin
  * @param addr addr of the I2C peripheral
  */
  MMA8451Q(PinName sda, PinName scl, int addr);

  /**
  * MMA8451Q destructor
  */
  ~MMA8451Q();

  /**
   * Get the value of the WHO_AM_I register
   *
   * @returns WHO_AM_I value
   */
  uint8_t getWhoAmI();

  /**
   * Get X axis acceleration
   *
   * @returns X axis acceleration
   */
  float getAccX();

  /**
   * Get Y axis acceleration
   *
   * @returns Y axis acceleration
   */
  float getAccY();

  /**
   * Get Z axis acceleration
   *
   * @returns Z axis acceleration
   */
  float getAccZ();

  /**
   * Get XYZ axis acceleration
   *
   * @param res array where acceleration data will be stored
   */
  void getAccAllAxis(float * res);
  
  // Get all axis in one read of all six registers (x,y,z MSB and LSB)
  // Takes a pointer to a 3 member array
  void fastRead(float * acc_arr);
  
  void readRegs(int addr, uint8_t * data, int len);
  void writeRegs(uint8_t * data, int len);
  int16_t getAccAxis(uint8_t addr);

private:
  I2C m_i2c;
  int m_addr;


};

#endif