// Esse programa ainda não foi testado. // É uma adaptação para utilizar vários acelerômetros utilizando a classe // BUSOUT ligado no CS dos acelerômetros; //Baseado na biblioteca de aaronn berek

Dependencies:   ADXL345 mbed

Fork of ADXLHELLOWORD by Thiago .

Files at this revision

API Documentation at this revision

Comitter:
Jamess
Date:
Thu Apr 23 17:41:39 2015 +0000
Child:
1:b54671e37e54
Commit message:
Primeira comunica??o com o aceler?metro utilizando a biblioteca pronta do aceler?metro adxl345 do aaron berek;

Changed in this revision

ADXL345.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADXL345.lib	Thu Apr 23 17:41:39 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/aberk/code/ADXL345/#bd8f0f20f433
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Apr 23 17:41:39 2015 +0000
@@ -0,0 +1,51 @@
+//Arquivo exemplo de se como utilizar a SPI em com a biblioteca do mbed feita por aaron.
+//Programa temporario. logo será republicado
+
+// TO do:
+        //Verificar se é possível utilizar esta biblioteca para se comunicar com vários acelerômetros-> Provavelmente não;
+        //Ver o tempo em que leva para realizar cada função.
+        //Trocar o printf pelo putc
+        //Sair da biblioteca... na verdade... Não permite muita coisa..
+        
+//DONE:
+        //Instalação do acc na protoboard.
+        
+#include "ADXL345.h"
+
+ADXL345 accelerometer(PTD2,PTD3,PTD1,PTD0);//PinName mosi, PinName miso, PinName sck,     PinName cs)
+Serial pc(USBTX, USBRX);
+DigitalOut PIN(PTA13);
+ 
+int main() {
+ 
+    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);
+    
+    //3.2kHz data rate.
+    accelerometer.setDataRate(ADXL345_3200HZ);
+ 
+    //Measurement mode.
+    accelerometer.setPowerControl(0x08);
+ 
+    while (1) {
+    
+        wait(0.1);
+        
+        accelerometer.getOutput(readings);
+        
+        PIN = '1';
+        //13-bit, sign extended values.
+        pc.printf("%i, %i, %i\n", (int16_t)readings[0], (int16_t)readings[1], (int16_t)readings[2]);
+        PIN = '0';
+    }
+ 
+}
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Apr 23 17:41:39 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/433970e64889
\ No newline at end of file