fsfs
Dependencies: 4DGL-uLCD-SE LSM303D mbed
Fork of LSM303D_SPI by
main.cpp@1:bad5121a35c7, 2015-01-15 (annotated)
- Committer:
- shurjo_1234
- Date:
- Thu Jan 15 19:55:22 2015 +0000
- Revision:
- 1:bad5121a35c7
- Parent:
- 0:684294feee71
- Child:
- 2:2a81657780dc
k
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shurjo_1234 | 0:684294feee71 | 1 | #include "mbed.h" |
shurjo_1234 | 0:684294feee71 | 2 | #include "LSM303D.h" |
shurjo_1234 | 1:bad5121a35c7 | 3 | #include <string> |
shurjo_1234 | 0:684294feee71 | 4 | |
shurjo_1234 | 0:684294feee71 | 5 | SPI spi(p5, p6, p7); // mosi, miso, sclk |
shurjo_1234 | 1:bad5121a35c7 | 6 | SPI spi2(p11, p12, p13); |
shurjo_1234 | 1:bad5121a35c7 | 7 | |
shurjo_1234 | 1:bad5121a35c7 | 8 | Serial pc(USBTX, USBRX); // tx, rx |
shurjo_1234 | 0:684294feee71 | 9 | |
shurjo_1234 | 0:684294feee71 | 10 | LSM303D sensor1(spi,p15); |
shurjo_1234 | 0:684294feee71 | 11 | LSM303D sensor2(spi,p16); |
shurjo_1234 | 0:684294feee71 | 12 | LSM303D sensor3(spi,p17); |
shurjo_1234 | 0:684294feee71 | 13 | LSM303D sensor4(spi,p18); |
shurjo_1234 | 0:684294feee71 | 14 | |
shurjo_1234 | 1:bad5121a35c7 | 15 | LSM303D sensor5(spi2,p27); |
shurjo_1234 | 1:bad5121a35c7 | 16 | LSM303D sensor6(spi2,p28); |
shurjo_1234 | 1:bad5121a35c7 | 17 | LSM303D sensor7(spi2,p29); |
shurjo_1234 | 1:bad5121a35c7 | 18 | LSM303D sensor8(spi2,p30); |
shurjo_1234 | 0:684294feee71 | 19 | |
shurjo_1234 | 0:684294feee71 | 20 | int main() { |
shurjo_1234 | 0:684294feee71 | 21 | sensor1.initialize(); |
shurjo_1234 | 1:bad5121a35c7 | 22 | sensor2.initialize(); |
shurjo_1234 | 1:bad5121a35c7 | 23 | sensor3.initialize(); |
shurjo_1234 | 1:bad5121a35c7 | 24 | sensor4.initialize(); |
shurjo_1234 | 0:684294feee71 | 25 | |
shurjo_1234 | 1:bad5121a35c7 | 26 | sensor5.initialize(); |
shurjo_1234 | 1:bad5121a35c7 | 27 | sensor6.initialize(); |
shurjo_1234 | 1:bad5121a35c7 | 28 | sensor7.initialize(); |
shurjo_1234 | 1:bad5121a35c7 | 29 | sensor8.initialize(); |
shurjo_1234 | 1:bad5121a35c7 | 30 | |
shurjo_1234 | 0:684294feee71 | 31 | |
shurjo_1234 | 1:bad5121a35c7 | 32 | while (true) |
shurjo_1234 | 1:bad5121a35c7 | 33 | { |
shurjo_1234 | 1:bad5121a35c7 | 34 | char c = pc.getc(); |
shurjo_1234 | 1:bad5121a35c7 | 35 | |
shurjo_1234 | 0:684294feee71 | 36 | |
shurjo_1234 | 1:bad5121a35c7 | 37 | int a[] = {sensor1.magnitometer(0), sensor1.magnitometer(1), sensor1.magnitometer(2), |
shurjo_1234 | 1:bad5121a35c7 | 38 | sensor2.magnitometer(0), sensor2.magnitometer(1), sensor2.magnitometer(2), |
shurjo_1234 | 1:bad5121a35c7 | 39 | sensor3.magnitometer(0), sensor3.magnitometer(1), sensor3.magnitometer(2), |
shurjo_1234 | 1:bad5121a35c7 | 40 | sensor4.magnitometer(0), sensor4.magnitometer(1), sensor4.magnitometer(2), |
shurjo_1234 | 1:bad5121a35c7 | 41 | sensor5.magnitometer(0), sensor5.magnitometer(1), sensor5.magnitometer(2), |
shurjo_1234 | 1:bad5121a35c7 | 42 | sensor6.magnitometer(0), sensor6.magnitometer(1), sensor6.magnitometer(2), |
shurjo_1234 | 1:bad5121a35c7 | 43 | sensor7.magnitometer(0), sensor7.magnitometer(1), sensor7.magnitometer(2), |
shurjo_1234 | 1:bad5121a35c7 | 44 | sensor8.magnitometer(0), sensor8.magnitometer(1), sensor8.magnitometer(2)}; |
shurjo_1234 | 1:bad5121a35c7 | 45 | |
shurjo_1234 | 1:bad5121a35c7 | 46 | int t = a[c-'a']; |
shurjo_1234 | 1:bad5121a35c7 | 47 | pc.printf("%d",t); |
shurjo_1234 | 1:bad5121a35c7 | 48 | |
shurjo_1234 | 1:bad5121a35c7 | 49 | } |
shurjo_1234 | 0:684294feee71 | 50 | |
shurjo_1234 | 0:684294feee71 | 51 | |
shurjo_1234 | 0:684294feee71 | 52 | } |