Added a GPIO to power on/off for external I2C sensor(s) (with LEDs)

Dependencies:   UniGraphic mbed vt100

18-Jun-2018 外部センサの電源オン・オフ機能は下位互換の為に無効になっていました。 この版で再度有効にしました。

Committer:
Rhyme
Date:
Mon Jun 18 01:56:00 2018 +0000
Revision:
1:8d65cfc3a2e2
Parent:
0:846e2321c637
External sensor power on/off function enabled. (Previously disabled)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:846e2321c637 1 #ifndef _MMA8451Q_H_
Rhyme 0:846e2321c637 2 #define _MMA8451Q_H_
Rhyme 0:846e2321c637 3
Rhyme 0:846e2321c637 4 #include "mbed.h"
Rhyme 0:846e2321c637 5 /**
Rhyme 0:846e2321c637 6 * MMA8451Q 3-Axis, 14-bit/8-bit Digital Accelerometer
Rhyme 0:846e2321c637 7 */
Rhyme 0:846e2321c637 8
Rhyme 0:846e2321c637 9 class MMA8451Q {
Rhyme 0:846e2321c637 10 public:
Rhyme 0:846e2321c637 11 /**
Rhyme 0:846e2321c637 12 * MMA8451Q constructor
Rhyme 0:846e2321c637 13 *
Rhyme 0:846e2321c637 14 * @param i2c pointer to the I2C object
Rhyme 0:846e2321c637 15 * @param addr 7bit addr of the I2C peripheral
Rhyme 0:846e2321c637 16 */
Rhyme 0:846e2321c637 17 MMA8451Q(I2C *i2c, int addr);
Rhyme 0:846e2321c637 18
Rhyme 0:846e2321c637 19 /**
Rhyme 0:846e2321c637 20 * MMA8451Q destructor
Rhyme 0:846e2321c637 21 */
Rhyme 0:846e2321c637 22 ~MMA8451Q();
Rhyme 0:846e2321c637 23
Rhyme 0:846e2321c637 24 /**
Rhyme 0:846e2321c637 25 * get all x, y, z data as int16_t
Rhyme 0:846e2321c637 26 * @param data[] three int16_t data will be returned
Rhyme 0:846e2321c637 27 * @returns I2C status 0: success others: I2C error
Rhyme 0:846e2321c637 28 */
Rhyme 0:846e2321c637 29 int getAllRawData(int16_t data[]) ;
Rhyme 0:846e2321c637 30
Rhyme 0:846e2321c637 31 /**
Rhyme 0:846e2321c637 32 * get all x, y, z data as float
Rhyme 0:846e2321c637 33 * @param data three float data will be returned
Rhyme 0:846e2321c637 34 * @returns I2C status 0: success others: I2C error
Rhyme 0:846e2321c637 35 */
Rhyme 0:846e2321c637 36 int getAllData(float value[]) ;
Rhyme 0:846e2321c637 37 int16_t getRawData(uint8_t addr) ;
Rhyme 0:846e2321c637 38 int16_t getRawX(void) ;
Rhyme 0:846e2321c637 39 int16_t getRawY(void) ;
Rhyme 0:846e2321c637 40 int16_t getRawZ(void) ;
Rhyme 0:846e2321c637 41
Rhyme 0:846e2321c637 42 float getAccX(void) ;
Rhyme 0:846e2321c637 43 float getAccY(void) ;
Rhyme 0:846e2321c637 44 float getAccZ(void) ;
Rhyme 0:846e2321c637 45
Rhyme 0:846e2321c637 46 private:
Rhyme 0:846e2321c637 47 I2C *p_i2c;
Rhyme 0:846e2321c637 48 int m_addr;
Rhyme 0:846e2321c637 49 int readRegs(int addr, uint8_t * data, int len);
Rhyme 0:846e2321c637 50 int writeRegs(uint8_t * data, int len);
Rhyme 0:846e2321c637 51 } ;
Rhyme 0:846e2321c637 52
Rhyme 0:846e2321c637 53 #endif /* _MMA8451Q_H_ */