Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: UniGraphic mbed vt100
sensors/MMA8451Q.h@0:0b6732b53bf4, 2018-04-24 (annotated)
- Committer:
- Rhyme
- Date:
- Tue Apr 24 08:58:33 2018 +0000
- Revision:
- 0:0b6732b53bf4
Temporary Connector Reversed Version
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Rhyme | 0:0b6732b53bf4 | 1 | #ifndef _MMA8451Q_H_ |
| Rhyme | 0:0b6732b53bf4 | 2 | #define _MMA8451Q_H_ |
| Rhyme | 0:0b6732b53bf4 | 3 | |
| Rhyme | 0:0b6732b53bf4 | 4 | #include "mbed.h" |
| Rhyme | 0:0b6732b53bf4 | 5 | /** |
| Rhyme | 0:0b6732b53bf4 | 6 | * MMA8451Q 3-Axis, 14-bit/8-bit Digital Accelerometer |
| Rhyme | 0:0b6732b53bf4 | 7 | */ |
| Rhyme | 0:0b6732b53bf4 | 8 | |
| Rhyme | 0:0b6732b53bf4 | 9 | class MMA8451Q { |
| Rhyme | 0:0b6732b53bf4 | 10 | public: |
| Rhyme | 0:0b6732b53bf4 | 11 | /** |
| Rhyme | 0:0b6732b53bf4 | 12 | * MMA8451Q constructor |
| Rhyme | 0:0b6732b53bf4 | 13 | * |
| Rhyme | 0:0b6732b53bf4 | 14 | * @param i2c pointer to the I2C object |
| Rhyme | 0:0b6732b53bf4 | 15 | * @param addr 7bit addr of the I2C peripheral |
| Rhyme | 0:0b6732b53bf4 | 16 | */ |
| Rhyme | 0:0b6732b53bf4 | 17 | MMA8451Q(I2C *i2c, int addr); |
| Rhyme | 0:0b6732b53bf4 | 18 | |
| Rhyme | 0:0b6732b53bf4 | 19 | /** |
| Rhyme | 0:0b6732b53bf4 | 20 | * MMA8451Q destructor |
| Rhyme | 0:0b6732b53bf4 | 21 | */ |
| Rhyme | 0:0b6732b53bf4 | 22 | ~MMA8451Q(); |
| Rhyme | 0:0b6732b53bf4 | 23 | |
| Rhyme | 0:0b6732b53bf4 | 24 | /** |
| Rhyme | 0:0b6732b53bf4 | 25 | * get all x, y, z data as int16_t |
| Rhyme | 0:0b6732b53bf4 | 26 | * @param data[] three int16_t data will be returned |
| Rhyme | 0:0b6732b53bf4 | 27 | * @returns I2C status 0: success others: I2C error |
| Rhyme | 0:0b6732b53bf4 | 28 | */ |
| Rhyme | 0:0b6732b53bf4 | 29 | int getAllRawData(int16_t data[]) ; |
| Rhyme | 0:0b6732b53bf4 | 30 | |
| Rhyme | 0:0b6732b53bf4 | 31 | /** |
| Rhyme | 0:0b6732b53bf4 | 32 | * get all x, y, z data as float |
| Rhyme | 0:0b6732b53bf4 | 33 | * @param data three float data will be returned |
| Rhyme | 0:0b6732b53bf4 | 34 | * @returns I2C status 0: success others: I2C error |
| Rhyme | 0:0b6732b53bf4 | 35 | */ |
| Rhyme | 0:0b6732b53bf4 | 36 | int getAllData(float value[]) ; |
| Rhyme | 0:0b6732b53bf4 | 37 | int16_t getRawData(uint8_t addr) ; |
| Rhyme | 0:0b6732b53bf4 | 38 | int16_t getRawX(void) ; |
| Rhyme | 0:0b6732b53bf4 | 39 | int16_t getRawY(void) ; |
| Rhyme | 0:0b6732b53bf4 | 40 | int16_t getRawZ(void) ; |
| Rhyme | 0:0b6732b53bf4 | 41 | |
| Rhyme | 0:0b6732b53bf4 | 42 | float getAccX(void) ; |
| Rhyme | 0:0b6732b53bf4 | 43 | float getAccY(void) ; |
| Rhyme | 0:0b6732b53bf4 | 44 | float getAccZ(void) ; |
| Rhyme | 0:0b6732b53bf4 | 45 | |
| Rhyme | 0:0b6732b53bf4 | 46 | private: |
| Rhyme | 0:0b6732b53bf4 | 47 | I2C *p_i2c; |
| Rhyme | 0:0b6732b53bf4 | 48 | int m_addr; |
| Rhyme | 0:0b6732b53bf4 | 49 | int readRegs(int addr, uint8_t * data, int len); |
| Rhyme | 0:0b6732b53bf4 | 50 | int writeRegs(uint8_t * data, int len); |
| Rhyme | 0:0b6732b53bf4 | 51 | } ; |
| Rhyme | 0:0b6732b53bf4 | 52 | |
| Rhyme | 0:0b6732b53bf4 | 53 | #endif /* _MMA8451Q_H_ */ |