![](/media/cache/group/IMG_1289.JPG.50x50_q85.jpg)
Test program for FXOS8700CQ. Minimum functionality has been implemented, so far.
Dependencies: FXOS8700CQ mbed vt100
main.cpp@0:6a51e9fa41a0, 2015-12-25 (annotated)
- Committer:
- Rhyme
- Date:
- Fri Dec 25 05:43:12 2015 +0000
- Revision:
- 0:6a51e9fa41a0
- Child:
- 1:4bb4d99d4be5
First commit before publishing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:6a51e9fa41a0 | 1 | #include "mbed.h" |
Rhyme | 0:6a51e9fa41a0 | 2 | #include "vt100.h" |
Rhyme | 0:6a51e9fa41a0 | 3 | #include "FXOS8700CQ.h" |
Rhyme | 0:6a51e9fa41a0 | 4 | #include "MSS.h" |
Rhyme | 0:6a51e9fa41a0 | 5 | |
Rhyme | 0:6a51e9fa41a0 | 6 | /* |
Rhyme | 0:6a51e9fa41a0 | 7 | * I2C address could be 0x1C, 0x1D, 0x1E, 0x1F |
Rhyme | 0:6a51e9fa41a0 | 8 | * 0x1E (SA1 = 0, SA0 = 0) |
Rhyme | 0:6a51e9fa41a0 | 9 | * 0x1D (SA1 = 0, SA0 = 1) |
Rhyme | 0:6a51e9fa41a0 | 10 | * 0x1C (SA1 = 1, SA0 = 0) |
Rhyme | 0:6a51e9fa41a0 | 11 | * 0x1F (SA1 = 1, SA1 = 1) |
Rhyme | 0:6a51e9fa41a0 | 12 | */ |
Rhyme | 0:6a51e9fa41a0 | 13 | #define FXOS8700CQ_I2C_ADDRESS (0x1E) |
Rhyme | 0:6a51e9fa41a0 | 14 | |
Rhyme | 0:6a51e9fa41a0 | 15 | vt100 *tty = 0 ; |
Rhyme | 0:6a51e9fa41a0 | 16 | FXOS8700CQ *fxos = 0 ; |
Rhyme | 0:6a51e9fa41a0 | 17 | |
Rhyme | 0:6a51e9fa41a0 | 18 | int main() { |
Rhyme | 0:6a51e9fa41a0 | 19 | int16_t accData[3], mgnData[3] ; |
Rhyme | 0:6a51e9fa41a0 | 20 | tty = new vt100() ; |
Rhyme | 0:6a51e9fa41a0 | 21 | tty->cls() ; |
Rhyme | 0:6a51e9fa41a0 | 22 | |
Rhyme | 0:6a51e9fa41a0 | 23 | fxos = new FXOS8700CQ(PIN_SDA, PIN_SCL, FXOS8700CQ_I2C_ADDRESS) ; |
Rhyme | 0:6a51e9fa41a0 | 24 | fxos->init() ; |
Rhyme | 0:6a51e9fa41a0 | 25 | |
Rhyme | 0:6a51e9fa41a0 | 26 | while(1) { |
Rhyme | 0:6a51e9fa41a0 | 27 | fxos->readAccMgnData(accData, mgnData) ; |
Rhyme | 0:6a51e9fa41a0 | 28 | printf("ACC X[%d], Y[%d], Z[%d], MGN X[%d], Y[%d], Z[%d]\n", |
Rhyme | 0:6a51e9fa41a0 | 29 | accData[0], accData[1], accData[2], |
Rhyme | 0:6a51e9fa41a0 | 30 | mgnData[0], mgnData[1], mgnData[2]) ; |
Rhyme | 0:6a51e9fa41a0 | 31 | wait(0.2) ; |
Rhyme | 0:6a51e9fa41a0 | 32 | } |
Rhyme | 0:6a51e9fa41a0 | 33 | } |