![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A data logger for the FRDM-K64F taking readings from the FXOS8700CQ accelerometer/magnometer at 200Hz.
Dependencies: FXOS8700CQ SDFileSystem mbed
Fork of Hello_FXOS8700Q by
main.cpp@4:4b494ca218ff, 2014-04-23 (annotated)
- Committer:
- JimCarver
- Date:
- Wed Apr 23 17:12:21 2014 +0000
- Revision:
- 4:4b494ca218ff
- Parent:
- 3:912ef9b2cc6a
- Child:
- 5:061ab9f2c002
experiment
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JimCarver | 0:748fe54f0947 | 1 | #include "mbed.h" |
JimCarver | 0:748fe54f0947 | 2 | #include "FXOS8700Q.h" |
JimCarver | 0:748fe54f0947 | 3 | |
JimCarver | 4:4b494ca218ff | 4 | |
JimCarver | 2:5f34f99b07c5 | 5 | //FXOS8700Q combo( A4, A5, FXOS8700CQ_SLAVE_ADDR0); // Proper Ports and I2C address for FReescale Multi Axis shield |
JimCarver | 4:4b494ca218ff | 6 | FXOS8700Q_acc acc( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // Proper Ports and I2C Address for K64F Freedom board |
JimCarver | 4:4b494ca218ff | 7 | FXOS8700Q_mag mag( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // Proper Ports and I2C Address for K64F Freedom board |
JimCarver | 4:4b494ca218ff | 8 | |
JimCarver | 0:748fe54f0947 | 9 | Serial pc(USBTX, USBRX); |
JimCarver | 0:748fe54f0947 | 10 | |
JimCarver | 4:4b494ca218ff | 11 | MotionSensorDataUnits mag; |
JimCarver | 4:4b494ca218ff | 12 | MotionSensorDataUnits acc; |
JimCarver | 4:4b494ca218ff | 13 | |
JimCarver | 3:912ef9b2cc6a | 14 | /* |
JimCarver | 3:912ef9b2cc6a | 15 | int main(void) { |
JimCarver | 3:912ef9b2cc6a | 16 | MotionSensor sensor; |
JimCarver | 3:912ef9b2cc6a | 17 | |
JimCarver | 3:912ef9b2cc6a | 18 | sensor.sampleRate(50); |
JimCarver | 3:912ef9b2cc6a | 19 | sensor.enable(); |
JimCarver | 3:912ef9b2cc6a | 20 | while(1) |
JimCarver | 3:912ef9b2cc6a | 21 | { |
JimCarver | 3:912ef9b2cc6a | 22 | if(sensor.dataReady()) |
JimCarver | 3:912ef9b2cc6a | 23 | { |
JimCarver | 3:912ef9b2cc6a | 24 | SensorDataUnits formatted_data; |
JimCarver | 3:912ef9b2cc6a | 25 | sensor.getAxis(formatted_data); |
JimCarver | 3:912ef9b2cc6a | 26 | printf(asdfadsf); |
JimCarver | 3:912ef9b2cc6a | 27 | } |
JimCarver | 3:912ef9b2cc6a | 28 | if(sensor.dataReady()) |
JimCarver | 3:912ef9b2cc6a | 29 | { |
JimCarver | 3:912ef9b2cc6a | 30 | SensorDataCounts raw_data; |
JimCarver | 3:912ef9b2cc6a | 31 | sensor.getAxis(formatted_data); |
JimCarver | 3:912ef9b2cc6a | 32 | printf(asdfasdf); |
JimCarver | 3:912ef9b2cc6a | 33 | } |
JimCarver | 3:912ef9b2cc6a | 34 | if(sensor.dataReady()) |
JimCarver | 3:912ef9b2cc6a | 35 | { |
JimCarver | 3:912ef9b2cc6a | 36 | printf x(),y(),x()); |
JimCarver | 3:912ef9b2cc6a | 37 | } |
JimCarver | 3:912ef9b2cc6a | 38 | if(sensor.dataReady()) |
JimCarver | 3:912ef9b2cc6a | 39 | { |
JimCarver | 3:912ef9b2cc6a | 40 | printf(x(),y(),z()); |
JimCarver | 3:912ef9b2cc6a | 41 | } |
JimCarver | 3:912ef9b2cc6a | 42 | } |
JimCarver | 3:912ef9b2cc6a | 43 | } |
JimCarver | 3:912ef9b2cc6a | 44 | |
JimCarver | 3:912ef9b2cc6a | 45 | */ |
JimCarver | 3:912ef9b2cc6a | 46 | |
JimCarver | 3:912ef9b2cc6a | 47 | |
JimCarver | 3:912ef9b2cc6a | 48 | |
JimCarver | 0:748fe54f0947 | 49 | |
JimCarver | 0:748fe54f0947 | 50 | int main() { |
JimCarver | 0:748fe54f0947 | 51 | float acc_data[3], mag_data[3]; |
JimCarver | 0:748fe54f0947 | 52 | |
JimCarver | 0:748fe54f0947 | 53 | printf("\r\n\nFXOS8700Q Who Am I= %X\r\n", combo.getWhoAmI()); |
JimCarver | 0:748fe54f0947 | 54 | while (true) { |
JimCarver | 4:4b494ca218ff | 55 | combo.getAxis(acc); |
JimCarver | 4:4b494ca218ff | 56 | combo.getAxis(mag); |
JimCarver | 0:748fe54f0947 | 57 | printf("FXOS8700Q ACC: X=%1.4f Y=%1.4f Z=%1.4f ", acc_data[0], acc_data[1], acc_data[2]); |
JimCarver | 0:748fe54f0947 | 58 | printf(" MAG: X=%4.1f Y=%4.1f Z=%4.1f\r\n\n", mag_data[0], mag_data[1], mag_data[2]); |
JimCarver | 0:748fe54f0947 | 59 | wait(1.0); |
JimCarver | 0:748fe54f0947 | 60 | } |
JimCarver | 0:748fe54f0947 | 61 | } |