a

Dependencies:   ADXL345_I2C ITG3200 mbed

Fork of ADXL345 by James Allen

Files at this revision

API Documentation at this revision

Comitter:
s1210160
Date:
Fri Jul 31 10:24:10 2015 +0000
Parent:
0:75c7bfd01ea0
Commit message:
a

Changed in this revision

ADXL345_I2C.lib Show annotated file Show diff for this revision Revisions of this file
ITG3200.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 75c7bfd01ea0 -r 67703f5eab67 ADXL345_I2C.lib
--- a/ADXL345_I2C.lib	Fri Mar 11 15:54:40 2011 +0000
+++ b/ADXL345_I2C.lib	Fri Jul 31 10:24:10 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/nimbusgb/code/ADXL345_I2C/#92fa975dab32
+https://developer.mbed.org/teams/aigamozu/code/ADXL345_I2C/#475c5366629a
diff -r 75c7bfd01ea0 -r 67703f5eab67 ITG3200.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ITG3200.lib	Fri Jul 31 10:24:10 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Digixx/code/ITG3200/#8967cbe04d96
diff -r 75c7bfd01ea0 -r 67703f5eab67 main.cpp
--- a/main.cpp	Fri Mar 11 15:54:40 2011 +0000
+++ b/main.cpp	Fri Jul 31 10:24:10 2015 +0000
@@ -1,39 +1,52 @@
 #include "mbed.h"
 #include "ADXL345_I2C.h"
+
  
-//ADXL345 accelerometer(p5, p6, p7, p8);
-ADXL345_I2C accelerometer(p9, p10);
+ADXL345_I2C acc(p9, p10);
 Serial pc(USBTX, USBRX);
+
+void ADXL345_settings(){
+    //Go into standby mode to configure the device.
+    acc.setPowerControl(0x00);
+    wait(0.001);
+ 
+    //Full resolution, +/-16g, 4mg/LSB.
+    acc.setDataFormatControl(0x09);
+    wait(0.001);
+     
+    //3.2kHz data rate.
+    acc.setDataRate(ADXL345_800HZ);
+    wait(0.001);
+ 
+    //Measurement mode.
+    acc.setPowerControl(0x08);
+    wait(0.001);
+}
  
 int main()
 {
+    wait(3);
+    
+    pc.baud(9600);
  
     int readings[3] = {0, 0, 0};
-     
-    pc.printf("Starting ADXL345 test...\n");
-    pc.printf("Device ID is: 0x%02x\n", accelerometer.getDevId());
- 
-    //Go into standby mode to configure the device.
-    accelerometer.setPowerControl(0x00);
- 
-    //Full resolution, +/-16g, 4mg/LSB.
-    accelerometer.setDataFormatControl(0x0B);
+    
+    Timer acc_Timer;
+    const int acc_Time = 100;
+    
+    acc_Timer.start();
      
-    //3.2kHz data rate.
-    accelerometer.setDataRate(ADXL345_3200HZ);
- 
-    //Measurement mode.
-    accelerometer.setPowerControl(0x08);
- 
-    while (1) 
-    {
-     
-        wait(0.1);
-        
-        accelerometer.getOutput(readings);
-         
-        //13-bit, sign extended values.
-        pc.printf("%i, %i, %i\n", (int16_t)readings[0], (int16_t)readings[1], (int16_t)readings[2]);
+  pc.printf("Starting ADXL345 test...\n");
+    wait(0.001);
+    ADXL345_settings();        
+    wait(0.1);
+       
+    while(true){ 
+    
+    if(acc_Timer.read_ms() >= acc_Time){
+        acc_Timer.reset();
+        acc.getOutput(readings);
+        pc.printf("%i %i %i\n", (int16_t)readings[0], (int16_t)readings[1], (int16_t)readings[2]);   
     }
- 
+    }
 }
diff -r 75c7bfd01ea0 -r 67703f5eab67 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jul 31 10:24:10 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912