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:

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_t moduleNumber, uint32_t clk, uint32_t mosi, uint32_t miso, uint32_t cs, DataFormat_Range range=kRange_2G)
 
virtual ~ADXL345_SPI ()
 
virtual double GetAcceleration (Axes axis)
 
virtual AllAxes GetAccelerations ()
 
- Public Member Functions inherited from SensorBase
 SensorBase ()
 
virtual ~SensorBase ()
 
- Public Member Functions inherited from ErrorBase
virtual ErrorGetError ()
 Retrieve the current error. Get the current error information associated with this sensor.
 
virtual const ErrorGetError () const
 
virtual void SetErrnoError (const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set error information associated with a C library call that set an error to the "errno" global variable. More...
 
virtual void SetImaqError (int success, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated from the nivision Imaq API. More...
 
virtual void SetError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void CloneError (ErrorBase *rhs) const
 
virtual void ClearError () const
 Clear the current error information associated with this sensor.
 
virtual bool StatusIsFatal () const
 Check if the current error code represents a fatal error. More...
 

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 Member Functions inherited from SensorBase
void AddToSingletonList ()
 
- Protected Member Functions inherited from ErrorBase
 ErrorBase ()
 Initialize the instance status to 0 for now.
 

Protected Attributes

DigitalOutputm_clk
 
DigitalOutputm_mosi
 
DigitalInputm_miso
 
DigitalOutputm_cs
 
SPIm_spi
 
- Protected Attributes inherited from ErrorBase
Error m_error
 

Static Protected Attributes

static const uint8_t kPowerCtlRegister = 0x2D
 
static const uint8_t kDataFormatRegister = 0x31
 
static const uint8_t kDataRegister = 0x32
 
static constexpr double kGsPerLSB = 0.00390625
 
- Static Protected Attributes inherited from ErrorBase
static SEM_ID _globalErrorMutex = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE)
 
static Error _globalError
 

Additional Inherited Members

- Static Public Member Functions inherited from SensorBase
static void DeleteSingletons ()
 
static uint32_t GetDefaultAnalogModule ()
 
static uint32_t GetDefaultDigitalModule ()
 
static uint32_t GetDefaultSolenoidModule ()
 
static bool CheckAnalogModule (uint8_t moduleNumber)
 
static bool CheckDigitalModule (uint8_t moduleNumber)
 
static bool CheckPWMModule (uint8_t moduleNumber)
 
static bool CheckRelayModule (uint8_t moduleNumber)
 
static bool CheckSolenoidModule (uint8_t moduleNumber)
 
static bool CheckDigitalChannel (uint32_t channel)
 
static bool CheckRelayChannel (uint32_t channel)
 
static bool CheckPWMChannel (uint32_t channel)
 
static bool CheckAnalogChannel (uint32_t channel)
 
static bool CheckSolenoidChannel (uint32_t channel)
 
- Static Public Member Functions inherited from ErrorBase
static void SetGlobalError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber)
 
static void SetGlobalWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber)
 
static ErrorGetGlobalError ()
 
- Static Public Attributes inherited from SensorBase
static const uint32_t kSystemClockTicksPerMicrosecond = 40
 
static const uint32_t kDigitalChannels = 14
 
static const uint32_t kAnalogChannels = 8
 
static const uint32_t kAnalogModules = 2
 
static const uint32_t kDigitalModules = 2
 
static const uint32_t kSolenoidChannels = 8
 
static const uint32_t kSolenoidModules = 2
 
static const uint32_t kPwmChannels = 10
 
static const uint32_t kRelayChannels = 8
 
static const uint32_t kChassisSlots = 8
 

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
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.

Definition at line 27 of file ADXL345_SPI.cpp.

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.

Definition at line 47 of file ADXL345_SPI.cpp.

ADXL345_SPI::ADXL345_SPI ( uint8_t  moduleNumber,
uint32_t  clk,
uint32_t  mosi,
uint32_t  miso,
uint32_t  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.

Definition at line 68 of file ADXL345_SPI.cpp.

ADXL345_SPI::~ADXL345_SPI ( )
virtual

Destructor.

Definition at line 119 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
axisThe axis to read from.
Returns
Acceleration of the ADXL345 in Gs.

Definition at line 139 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 158 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 86 of file ADXL345_SPI.cpp.


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

Generated on Sat Apr 26 2014 12:26:45 for WPILibC++ by doxygen 1.8.6