fsfs

Dependencies:   4DGL-uLCD-SE LSM303D mbed

Fork of LSM303D_SPI by Shurjo Banerjee

main.cpp

Committer:
hassan_elahi
Date:
2015-03-23
Revision:
2:2a81657780dc
Parent:
1:bad5121a35c7

File content as of revision 2:2a81657780dc:

#include "mbed.h"
#include "LSM303D.h"
#include <string>
 
SPI spi(p5, p6, p7); // mosi, miso, sclk
SPI spi2(p11, p12, p13);

Serial pc(USBTX, USBRX); // tx, rx
//Serial device(p9, p10);

LSM303D sensor1(spi,p15);
LSM303D sensor2(spi,p16);
LSM303D sensor3(spi,p17);
LSM303D sensor4(spi,p18);

LSM303D sensor5(spi2,p27);
LSM303D sensor6(spi2,p28);
//LSM303D sensor7(spi2,p29);
//LSM303D sensor8(spi2,p30);
 DigitalOut myled(LED1);
 
 
int main() {
    //wait(2);
    pc.baud(115200);
    sensor1.initialize();
    sensor2.initialize();
    sensor3.initialize();
    sensor4.initialize();
    
    sensor5.initialize();
    sensor6.initialize();
  //  sensor7.initialize();
 //   sensor8.initialize();
    
    int i=0;
    char c = 'a';
    //c=c+1;
    //int m=0xAAAAAAAA;
    //pc.printf("%c",c);
    
    
    
    
    while (true)
    {
        //char c = pc.getc();
        
        
        int a[] = {sensor1.magnitometer(0), sensor1.magnitometer(1), sensor1.magnitometer(2),
                   sensor2.magnitometer(0), sensor2.magnitometer(1), sensor2.magnitometer(2),
                   sensor3.magnitometer(0), sensor3.magnitometer(1), sensor3.magnitometer(2),
                   sensor4.magnitometer(0), sensor4.magnitometer(1), sensor4.magnitometer(2),
                   sensor5.magnitometer(0), sensor5.magnitometer(1), sensor5.magnitometer(2),
                   sensor6.magnitometer(0), sensor6.magnitometer(1), sensor6.magnitometer(2)};/*,
                   sensor7.magnitometer(0), sensor7.magnitometer(1), sensor7.magnitometer(2),
                   sensor8.magnitometer(0), sensor8.magnitometer(1), sensor8.magnitometer(2)};*/
                   
              
        pc.printf("%c",' ');
        pc.printf("%c",'a');  
        pc.printf("%c",' ');
        pc.printf("%c",'b');
        
        for (i=0;i <18; i++)
        {
            int t = a[i]+32768;
            pc.printf("%c",' ');
            pc.printf("%d",t);
        }
        myled = !myled;
        /*if (i >17)
        {
            i=0;
            pc.printf("%c",' ');
            pc.printf("%c",'a');  
            pc.printf("%c",' ');
            pc.printf("%c",'b');  
            myled = !myled;                  
        }
        
        int t = a[i]+32768;
        
        pc.printf("%c",' ');
        pc.printf("%d",t);
        i=i+1;*/
        
                
    }       

    
}