// ******************************************************************************************* // // // Author: Roman Lysecky // Date: November 18, 2010 // // Basic set of software routines for accessing the ADLX345 acclerometer using an SPI // interface. // // NOTE: This library of routine is incompelte, and only supports a small subset of // commands. // // ******************************************************************************************* // #define SPI_WRITE 0x0000 #define SPI_READ 0x8000 // ******************************************************************************************* // #define ADXL_BW_RATE_ADDR 0x2C00 #define ADXL_PWR_CTL_ADDR 0x2D00 #define ADXL_MEASURE_MODE 0x0008 #define ADXL_STANDYBY_MODE 0x0000 #define ADXL_X_AXIS_ADDR 0x3200 #define ADXL_Y_AXIS_ADDR 0x3400 #define ADXL_Z_AXIS_ADDR 0x3600 #define ADXL_AXIS0 0x0000 #define ADXL_AXIS1 0x0100 // ******************************************************************************************* // #define ADXL_BW_400 0x000C // ******************************************************************************************* // #define ADXL_SHAKE_THRESHOLD 150 #define ADXL_SHAKE_TIMEOUT 20 // ******************************************************************************************* // void ADXLInitialize(); void ADXLSetMode(int mode); void ADXLSetBandwidth(int bw); int ADXLReadAxis(int axis); int ADXLDetectShake(int axisVal, int threshold, int timeout); // ******************************************************************************************* //