WPILib 2012
WPILibRoboticsLibraryforFRC
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes
ADXL345_SPI Class Reference

#include <ADXL345_SPI.h>

Inheritance diagram for ADXL345_SPI:
SensorBase ErrorBase

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.


Constructor & Destructor Documentation

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

Constructor.

Parameters:
clkThe GPIO the clock signal is wired to.
mosiThe GPIO the MOSI (Master Out Slave In) signal is wired to.
misoThe GPIO the MISO (Master In Slave Out) signal is wired to.
csThe GPIO the CS (Chip Select) signal is wired to.
rangeThe range (+ or -) that the accelerometer will measure.
ADXL345_SPI::ADXL345_SPI ( DigitalOutput clk,
DigitalOutput mosi,
DigitalInput miso,
DigitalOutput cs,
DataFormat_Range  range = kRange_2G 
)

Constructor.

Parameters:
clkThe GPIO the clock signal is wired to.
mosiThe GPIO the MOSI (Master Out Slave In) signal is wired to.
misoThe GPIO the MISO (Master In Slave Out) signal is wired to.
csThe GPIO the CS (Chip Select) signal is wired to.
rangeThe range (+ or -) that the accelerometer will measure.
ADXL345_SPI::ADXL345_SPI ( UINT8  moduleNumber,
UINT32  clk,
UINT32  mosi,
UINT32  miso,
UINT32  cs,
ADXL345_SPI::DataFormat_Range  range = kRange_2G 
)

Constructor.

Parameters:
moduleNumberThe digital module with the sensor attached.
clkThe GPIO the clock signal is wired to.
mosiThe GPIO the MOSI (Master Out Slave In) signal is wired to.
misoThe GPIO the MISO (Master In Slave Out) signal is wired to.
csThe GPIO the CS (Chip Select) signal is wired to.
rangeThe range (+ or -) that the accelerometer will measure.
ADXL345_SPI::~ADXL345_SPI ( ) [virtual]

Destructor.


Member Function Documentation

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

Get the acceleration of one axis in Gs.

Parameters:
axisThe axis to read from.
Returns:
Acceleration of the ADXL345 in Gs.
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.
void ADXL345_SPI::Init ( DigitalOutput clk,
DigitalOutput mosi,
DigitalInput miso,
DigitalOutput cs,
DataFormat_Range  range 
) [protected]

Internal common init function.


The documentation for this class was generated from the following files:
 All Classes Functions Variables