Now you can download a copy of these docs so you can use them offline! Download now

#include <ADXL345_SPI.h>

Inheritance diagram for ADXL345_SPI:
Collaboration diagram for ADXL345_SPI:

List of all members.

Classes

struct  AllAxes

Public Types

enum  DataFormat_Range { kRange_2G = 0x00, kRange_4G = 0x01, kRange_8G = 0x02, kRange_16G = 0x03 }
enum  Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 }

Public Member Functions

 ADXL345_SPI (DigitalOutput &clk, DigitalOutput &mosi, DigitalInput &miso, DigitalOutput &cs, DataFormat_Range range=kRange_2G)
 ADXL345_SPI (DigitalOutput *clk, DigitalOutput *mosi, DigitalInput *miso, DigitalOutput *cs, DataFormat_Range range=kRange_2G)
 ADXL345_SPI (UINT8 moduleNumber, UINT32 clk, UINT32 mosi, UINT32 miso, UINT32 cs, DataFormat_Range range=kRange_2G)
virtual ~ADXL345_SPI ()
virtual double GetAcceleration (Axes axis)
virtual AllAxes GetAccelerations ()

Protected Types

enum  SPIAddressFields { kAddress_Read = 0x80, kAddress_MultiByte = 0x40 }
enum  PowerCtlFields { kPowerCtl_Link = 0x20, kPowerCtl_AutoSleep = 0x10, kPowerCtl_Measure = 0x08, kPowerCtl_Sleep = 0x04 }
enum  DataFormatFields {
  kDataFormat_SelfTest = 0x80, kDataFormat_SPI = 0x40, kDataFormat_IntInvert = 0x20, kDataFormat_FullRes = 0x08,
  kDataFormat_Justify = 0x04
}

Protected Member Functions

void Init (DigitalOutput *clk, DigitalOutput *mosi, DigitalInput *miso, DigitalOutput *cs, DataFormat_Range range)

Protected Attributes

DigitalOutputm_clk
DigitalOutputm_mosi
DigitalInputm_miso
DigitalOutputm_cs
SPIm_spi

Static Protected Attributes

static const UINT8 kPowerCtlRegister = 0x2D
static const UINT8 kDataFormatRegister = 0x31
static const UINT8 kDataRegister = 0x32
static const double kGsPerLSB = 0.00390625

Detailed Description

ADXL345 Accelerometer on SPI.

This class alows access to an Analog Devices ADXL345 3-axis accelerometer via SPI. This class assumes the sensor is wired in 4-wire SPI mode.

Definition at line 22 of file ADXL345_SPI.h.


Constructor & Destructor Documentation

ADXL345_SPI::ADXL345_SPI ( DigitalOutput clk,
DigitalOutput mosi,
DigitalInput miso,
DigitalOutput cs,
DataFormat_Range  range = kRange_2G 
)

Constructor.

Parameters:
clk The GPIO the clock signal is wired to.
mosi The GPIO the MOSI (Master Out Slave In) signal is wired to.
miso The GPIO the MISO (Master In Slave Out) signal is wired to.
cs The GPIO the CS (Chip Select) signal is wired to.
range The range (+ or -) that the accelerometer will measure.

Definition at line 26 of file ADXL345_SPI.cpp.

ADXL345_SPI::ADXL345_SPI ( DigitalOutput clk,
DigitalOutput mosi,
DigitalInput miso,
DigitalOutput cs,
DataFormat_Range  range = kRange_2G 
)

Constructor.

Parameters:
clk The GPIO the clock signal is wired to.
mosi The GPIO the MOSI (Master Out Slave In) signal is wired to.
miso The GPIO the MISO (Master In Slave Out) signal is wired to.
cs The GPIO the CS (Chip Select) signal is wired to.
range The range (+ or -) that the accelerometer will measure.

Definition at line 46 of file ADXL345_SPI.cpp.

ADXL345_SPI::ADXL345_SPI ( UINT8  moduleNumber,
UINT32  clk,
UINT32  mosi,
UINT32  miso,
UINT32  cs,
ADXL345_SPI::DataFormat_Range  range = kRange_2G 
)

Constructor.

Parameters:
moduleNumber The digital module with the sensor attached.
clk The GPIO the clock signal is wired to.
mosi The GPIO the MOSI (Master Out Slave In) signal is wired to.
miso The GPIO the MISO (Master In Slave Out) signal is wired to.
cs The GPIO the CS (Chip Select) signal is wired to.
range The range (+ or -) that the accelerometer will measure.

Definition at line 67 of file ADXL345_SPI.cpp.

ADXL345_SPI::~ADXL345_SPI (  )  [virtual]

Destructor.

Definition at line 116 of file ADXL345_SPI.cpp.


Member Function Documentation

double ADXL345_SPI::GetAcceleration ( ADXL345_SPI::Axes  axis  )  [virtual]

Get the acceleration of one axis in Gs.

Parameters:
axis The axis to read from.
Returns:
Acceleration of the ADXL345 in Gs.

Definition at line 136 of file ADXL345_SPI.cpp.

ADXL345_SPI::AllAxes ADXL345_SPI::GetAccelerations (  )  [virtual]

Get the acceleration of all axes in Gs.

Returns:
Acceleration measured on all axes of the ADXL345 in Gs.

Definition at line 155 of file ADXL345_SPI.cpp.

void ADXL345_SPI::Init ( DigitalOutput clk,
DigitalOutput mosi,
DigitalInput miso,
DigitalOutput cs,
DataFormat_Range  range 
) [protected]

Internal common init function.

Definition at line 85 of file ADXL345_SPI.cpp.


The documentation for this class was generated from the following files:

Generated on Thu Jan 12 2012 22:35:26 for WPILibC++ by doxygen 1.7.1