Forked from Uwe Gartmann's ADXL345 library, customized as part of the 9DOF stick from Sparkfun.com

Fork of ADXL345 by Uwe Gartmann

ADXL345 is triple axis, digital interface, accelerometer.

This library is forked from Uwe Gartmann and Peter Swanson's work.

This library is for specific application using 9DoF-Stick.

Datasheet:

http://www.analog.com/static/imported-files/data_sheets/ADXL345.pdf

ADXL345は3軸のデジタルインターフェースを備えた加速度センサです。

このライブラリは 9DoF-Stick を使用した特定の企画のために保守しています。

mbed IDEが日本語をサポートするまでは英語でコメントを書いていきますが、サポートした後もきっと英語で書いていくでしょう。

Files at this revision

API Documentation at this revision

Comitter:
gltest26
Date:
Sat Sep 29 14:15:24 2012 +0000
Parent:
4:8046894b947e
Commit message:
Added a new constructor to accept an external I2C interface object.

Changed in this revision

ADXL345.cpp Show annotated file Show diff for this revision Revisions of this file
ADXL345.h Show annotated file Show diff for this revision Revisions of this file
--- a/ADXL345.cpp	Mon Sep 17 10:39:19 2012 +0000
+++ b/ADXL345.cpp	Sat Sep 29 14:15:24 2012 +0000
@@ -54,7 +54,16 @@
 
 //#include "mbed.h"
 
-ADXL345::ADXL345(PinName sda, PinName scl) : i2c_(sda, scl) {
+ADXL345::ADXL345(PinName sda, PinName scl) : i2c_(*(new I2C(sda, scl))) {
+    myI2c = &i2c_;
+}
+
+ADXL345::~ADXL345(){
+    delete myI2c;
+}
+
+
+void ADXL345::init(){
 
     //400kHz, allowing us to use the fastest data rates.
     //there are other chips on board, sorry
--- a/ADXL345.h	Mon Sep 17 10:39:19 2012 +0000
+++ b/ADXL345.h	Sat Sep 29 14:15:24 2012 +0000
@@ -134,6 +134,21 @@
      * @param sck mbed pin to use for SCL line of I2C interface.
      */
     ADXL345(PinName sda, PinName scl);
+    
+
+    /**
+     * Constructor that accepts external i2c interface object.
+     *
+     * @param i2c The I2C interface object to use.
+     */
+    ADXL345(I2C &i2c) : i2c_(i2c), myI2c(NULL){}
+    
+    /**
+     * Destructor that frees self-allocated I2C object.
+     */
+    ~ADXL345();
+    
+    void init();
 
     /**
      * Get the output of all three axes.
@@ -530,7 +545,9 @@
    
 private:
 
-    I2C i2c_;
+    I2C &i2c_;
+    
+    I2C *myI2c;
     
 
     /**