Jim Carver
/
Hello_FXLS8471Q
A simple hello world for the FXLS8471Q using SPI mode
main.cpp@0:91ae2a9f7da6, 2014-04-19 (annotated)
- Committer:
- JimCarver
- Date:
- Sat Apr 19 16:44:55 2014 +0000
- Revision:
- 0:91ae2a9f7da6
Hello World for FXLS8471Q
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JimCarver | 0:91ae2a9f7da6 | 1 | #include "mbed.h" |
JimCarver | 0:91ae2a9f7da6 | 2 | #include "FXLS8471Q.h" |
JimCarver | 0:91ae2a9f7da6 | 3 | |
JimCarver | 0:91ae2a9f7da6 | 4 | FXLS8471Q acc(D11, D12, D13, D10); |
JimCarver | 0:91ae2a9f7da6 | 5 | Serial pc(USBTX, USBRX); |
JimCarver | 0:91ae2a9f7da6 | 6 | |
JimCarver | 0:91ae2a9f7da6 | 7 | |
JimCarver | 0:91ae2a9f7da6 | 8 | int main() { |
JimCarver | 0:91ae2a9f7da6 | 9 | float acc_data[3]; |
JimCarver | 0:91ae2a9f7da6 | 10 | |
JimCarver | 0:91ae2a9f7da6 | 11 | printf("\r\n\nFXLS8471Q Who Am I= %X\r\n", acc.getWhoAmI()); |
JimCarver | 0:91ae2a9f7da6 | 12 | while (true) { |
JimCarver | 0:91ae2a9f7da6 | 13 | acc.ReadXYZ(acc_data); |
JimCarver | 0:91ae2a9f7da6 | 14 | printf("FXLS8471Q X=%1.4f Y=%1.4f Z=%1.4f\r\n", acc_data[0], acc_data[1], acc_data[2]); |
JimCarver | 0:91ae2a9f7da6 | 15 | wait(1.0); |
JimCarver | 0:91ae2a9f7da6 | 16 | } |
JimCarver | 0:91ae2a9f7da6 | 17 | } |