![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fsfs
Dependencies: 4DGL-uLCD-SE LSM303D mbed
Fork of LSM303D_SPI by
main.cpp@2:2a81657780dc, 2015-03-23 (annotated)
- Committer:
- hassan_elahi
- Date:
- Mon Mar 23 19:19:26 2015 +0000
- Revision:
- 2:2a81657780dc
- Parent:
- 1:bad5121a35c7
fsfs
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 |
hassan_elahi | 2:2a81657780dc | 9 | //Serial device(p9, p10); |
shurjo_1234 | 0:684294feee71 | 10 | |
shurjo_1234 | 0:684294feee71 | 11 | LSM303D sensor1(spi,p15); |
shurjo_1234 | 0:684294feee71 | 12 | LSM303D sensor2(spi,p16); |
shurjo_1234 | 0:684294feee71 | 13 | LSM303D sensor3(spi,p17); |
shurjo_1234 | 0:684294feee71 | 14 | LSM303D sensor4(spi,p18); |
shurjo_1234 | 0:684294feee71 | 15 | |
shurjo_1234 | 1:bad5121a35c7 | 16 | LSM303D sensor5(spi2,p27); |
shurjo_1234 | 1:bad5121a35c7 | 17 | LSM303D sensor6(spi2,p28); |
hassan_elahi | 2:2a81657780dc | 18 | //LSM303D sensor7(spi2,p29); |
hassan_elahi | 2:2a81657780dc | 19 | //LSM303D sensor8(spi2,p30); |
hassan_elahi | 2:2a81657780dc | 20 | DigitalOut myled(LED1); |
hassan_elahi | 2:2a81657780dc | 21 | |
shurjo_1234 | 0:684294feee71 | 22 | |
shurjo_1234 | 0:684294feee71 | 23 | int main() { |
hassan_elahi | 2:2a81657780dc | 24 | //wait(2); |
hassan_elahi | 2:2a81657780dc | 25 | pc.baud(115200); |
shurjo_1234 | 0:684294feee71 | 26 | sensor1.initialize(); |
shurjo_1234 | 1:bad5121a35c7 | 27 | sensor2.initialize(); |
shurjo_1234 | 1:bad5121a35c7 | 28 | sensor3.initialize(); |
shurjo_1234 | 1:bad5121a35c7 | 29 | sensor4.initialize(); |
shurjo_1234 | 0:684294feee71 | 30 | |
shurjo_1234 | 1:bad5121a35c7 | 31 | sensor5.initialize(); |
shurjo_1234 | 1:bad5121a35c7 | 32 | sensor6.initialize(); |
hassan_elahi | 2:2a81657780dc | 33 | // sensor7.initialize(); |
hassan_elahi | 2:2a81657780dc | 34 | // sensor8.initialize(); |
hassan_elahi | 2:2a81657780dc | 35 | |
hassan_elahi | 2:2a81657780dc | 36 | int i=0; |
hassan_elahi | 2:2a81657780dc | 37 | char c = 'a'; |
hassan_elahi | 2:2a81657780dc | 38 | //c=c+1; |
hassan_elahi | 2:2a81657780dc | 39 | //int m=0xAAAAAAAA; |
hassan_elahi | 2:2a81657780dc | 40 | //pc.printf("%c",c); |
hassan_elahi | 2:2a81657780dc | 41 | |
hassan_elahi | 2:2a81657780dc | 42 | |
shurjo_1234 | 1:bad5121a35c7 | 43 | |
shurjo_1234 | 0:684294feee71 | 44 | |
shurjo_1234 | 1:bad5121a35c7 | 45 | while (true) |
shurjo_1234 | 1:bad5121a35c7 | 46 | { |
hassan_elahi | 2:2a81657780dc | 47 | //char c = pc.getc(); |
shurjo_1234 | 1:bad5121a35c7 | 48 | |
shurjo_1234 | 0:684294feee71 | 49 | |
shurjo_1234 | 1:bad5121a35c7 | 50 | int a[] = {sensor1.magnitometer(0), sensor1.magnitometer(1), sensor1.magnitometer(2), |
shurjo_1234 | 1:bad5121a35c7 | 51 | sensor2.magnitometer(0), sensor2.magnitometer(1), sensor2.magnitometer(2), |
shurjo_1234 | 1:bad5121a35c7 | 52 | sensor3.magnitometer(0), sensor3.magnitometer(1), sensor3.magnitometer(2), |
shurjo_1234 | 1:bad5121a35c7 | 53 | sensor4.magnitometer(0), sensor4.magnitometer(1), sensor4.magnitometer(2), |
shurjo_1234 | 1:bad5121a35c7 | 54 | sensor5.magnitometer(0), sensor5.magnitometer(1), sensor5.magnitometer(2), |
hassan_elahi | 2:2a81657780dc | 55 | sensor6.magnitometer(0), sensor6.magnitometer(1), sensor6.magnitometer(2)};/*, |
shurjo_1234 | 1:bad5121a35c7 | 56 | sensor7.magnitometer(0), sensor7.magnitometer(1), sensor7.magnitometer(2), |
hassan_elahi | 2:2a81657780dc | 57 | sensor8.magnitometer(0), sensor8.magnitometer(1), sensor8.magnitometer(2)};*/ |
shurjo_1234 | 1:bad5121a35c7 | 58 | |
hassan_elahi | 2:2a81657780dc | 59 | |
hassan_elahi | 2:2a81657780dc | 60 | pc.printf("%c",' '); |
hassan_elahi | 2:2a81657780dc | 61 | pc.printf("%c",'a'); |
hassan_elahi | 2:2a81657780dc | 62 | pc.printf("%c",' '); |
hassan_elahi | 2:2a81657780dc | 63 | pc.printf("%c",'b'); |
hassan_elahi | 2:2a81657780dc | 64 | |
hassan_elahi | 2:2a81657780dc | 65 | for (i=0;i <18; i++) |
hassan_elahi | 2:2a81657780dc | 66 | { |
hassan_elahi | 2:2a81657780dc | 67 | int t = a[i]+32768; |
hassan_elahi | 2:2a81657780dc | 68 | pc.printf("%c",' '); |
hassan_elahi | 2:2a81657780dc | 69 | pc.printf("%d",t); |
hassan_elahi | 2:2a81657780dc | 70 | } |
hassan_elahi | 2:2a81657780dc | 71 | myled = !myled; |
hassan_elahi | 2:2a81657780dc | 72 | /*if (i >17) |
hassan_elahi | 2:2a81657780dc | 73 | { |
hassan_elahi | 2:2a81657780dc | 74 | i=0; |
hassan_elahi | 2:2a81657780dc | 75 | pc.printf("%c",' '); |
hassan_elahi | 2:2a81657780dc | 76 | pc.printf("%c",'a'); |
hassan_elahi | 2:2a81657780dc | 77 | pc.printf("%c",' '); |
hassan_elahi | 2:2a81657780dc | 78 | pc.printf("%c",'b'); |
hassan_elahi | 2:2a81657780dc | 79 | myled = !myled; |
hassan_elahi | 2:2a81657780dc | 80 | } |
hassan_elahi | 2:2a81657780dc | 81 | |
hassan_elahi | 2:2a81657780dc | 82 | int t = a[i]+32768; |
hassan_elahi | 2:2a81657780dc | 83 | |
hassan_elahi | 2:2a81657780dc | 84 | pc.printf("%c",' '); |
shurjo_1234 | 1:bad5121a35c7 | 85 | pc.printf("%d",t); |
hassan_elahi | 2:2a81657780dc | 86 | i=i+1;*/ |
hassan_elahi | 2:2a81657780dc | 87 | |
shurjo_1234 | 1:bad5121a35c7 | 88 | |
shurjo_1234 | 1:bad5121a35c7 | 89 | } |
shurjo_1234 | 0:684294feee71 | 90 | |
shurjo_1234 | 0:684294feee71 | 91 | |
shurjo_1234 | 0:684294feee71 | 92 | } |