Now you can download a copy of these docs so you can use them offline! Download now
#include <ADXL345_SPI.h>
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 Error & | GetError () |
Retrieve the current error. Get the current error information associated with this sensor. | |
virtual const Error & | GetError () 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 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 | |
DigitalOutput * | m_clk |
DigitalOutput * | m_mosi |
DigitalInput * | m_miso |
DigitalOutput * | m_cs |
SPI * | m_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 Error & | GetGlobalError () |
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 |
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.
ADXL345_SPI::ADXL345_SPI | ( | DigitalOutput & | clk, |
DigitalOutput & | mosi, | ||
DigitalInput & | miso, | ||
DigitalOutput & | cs, | ||
DataFormat_Range | range = kRange_2G |
||
) |
Constructor.
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 27 of file ADXL345_SPI.cpp.
ADXL345_SPI::ADXL345_SPI | ( | DigitalOutput * | clk, |
DigitalOutput * | mosi, | ||
DigitalInput * | miso, | ||
DigitalOutput * | cs, | ||
DataFormat_Range | range = kRange_2G |
||
) |
Constructor.
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 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.
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 68 of file ADXL345_SPI.cpp.
|
virtual |
Destructor.
Definition at line 119 of file ADXL345_SPI.cpp.
|
virtual |
Get the acceleration of one axis in Gs.
axis | The axis to read from. |
Definition at line 139 of file ADXL345_SPI.cpp.
|
virtual |
Get the acceleration of all axes in Gs.
Definition at line 158 of file ADXL345_SPI.cpp.
|
protected |
Internal common init function.
Definition at line 86 of file ADXL345_SPI.cpp.