L3G4200D SPI driver. Runs at 10mhz vs I2C 400khz. High pass filtered data sets a INT1 pin high when a reference threshold is reached on an axis. Returns the axis that reached the threshold and the DPS of that threshold. Threshold levels can be tweaked by editing void setupL3G4200D()

Dependencies:   mbed

main.cpp

Committer:
Spilly
Date:
2014-11-25
Revision:
0:66fe7a32bd59

File content as of revision 0:66fe7a32bd59:

/***********************************************************************************************/
//Ryan Spillman 
//11/23/2014
//
//This is a small piece of a Dead Reckoning robotics project
//
//High pass filtered, bias corrected, L3G4200D SPI driver
//
//In a later revision, will integrate DPS to approximate position
//
//FRDM-K64F Connections
//MOSI, MISO, SCK,  CS,   INT1
//PTD6, PTD7, PTD5, PTD4, PTC16
/***********************************************************************************************/

#include "L3G4200D.h"

//Serial pc(USBTX, USBRX);



//Prototype function
void checkGyro();

int main()
{
    pc.baud(115200);
    
    wait(1);
    
    setupL3G4200D();  // Configure L3G4200
    
    wait(1);
    
    setRef();
    //getGyroBias();      //Device must be stationary while calculating bias
    
    while(1)
    {
        //Wait until INT1 pin goes active before reading gyro
        while(!INT1);
        /*
        getGyroValues();
    
        for(int i = 0; i < 3; i++)
        {
            pc.printf("%i\t", gyro[i]);
        }
        
        
        pc.printf("\n");
        */
        checkGyro();
        
    }
}