PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Public Member Functions | |
ADXL345 (SPI &bus, const Pin::Mask csMask, const bool alwaysSetSPIMode=false) | |
Create an object which communicates over the given SPI bus. More... | |
ADXL345 (const Pin::Mask csMask, const bool alwaysSetSPIMode=true) | |
Create an object which communicates over the shared SPI bus. More... | |
void | always_set_spi_mode (const bool alwaysSetMode) |
Choose whether to always set the SPI mode before writing to the device; Useful when multiple devices with different SPI specifications are connected to the bus. More... | |
void | start (const bool autoSleep=false, const bool link=false, const bool sleep=false, const bool measure=true, const WakeupFrequency wakeupFrequency=WakeupFrequency::HZ_8) const |
Convenience function to start the device in a sane fashion for basic reading. More... | |
void | read (int16_t *values) const |
Retrieve the values from all 3 axes with a fast, 6-byte successive read. More... | |
int16_t | read_axis (const Axis axis) const |
Read data for all three axes and return only the requested axis. More... | |
int16_t | read_x () const |
Read data for all three axes and return only the x-axis. More... | |
int16_t | read_y () const |
Read data for all three axes and return only the y-axis. More... | |
int16_t | read_z () const |
Read data for all three axes and return only the z-axis. More... | |
void | write (const Register address, const uint8_t value) const |
Perform a manual write to the device. More... | |
uint8_t | read (const Register address) const |
Perform a single manual read from the device. More... | |
void | read (const Register startingAddress, const size_t words, int16_t *result) const |
Perform a manual, multi-byte read from the device. More... | |
void | set_bit (const Register address, const Bit bit) const |
Set a single bit in a register on the device. More... | |
void | clear_bit (const Register address, const Bit bit) const |
Clear a single bit in a register on the device. More... | |
Static Public Member Functions | |
static double | scale (const int value, const Range range) |
Scale the non-justified, raw accelerometer value to a human-readable number. More... | |
Static Public Attributes | |
static const SPI::Mode | SPI_MODE = SPI::Mode::MODE_3 |
static const uint8_t | DEVICE_ID = 0xE5 |
The ADXL345 is hardwired for a device ID of 0xE5 | |
static constexpr double | FULL_RESOLUTION_SCALE = 0.004 |
The highest resolution that the device is capable of. Resolution will become less precise (larger number) as Range increases. Use the ADXL345::scale method to get the human-readable value for acceleration. | |
union PropWare::ADXL345::ActivityDetection |
Bit-mapping for Register::ACT_INACT_CTL.
Class Members | ||
---|---|---|
struct ActivityDetection | fields | |
uint8_t | raw |
struct PropWare::ADXL345::ActivityDetection.fields |
union PropWare::ADXL345::DataFormat |
Bit-mapping for Register::DATA_FORMAT.
Class Members | ||
---|---|---|
struct DataFormat | fields | |
uint8_t | raw |
struct PropWare::ADXL345::DataFormat.fields |
Class Members | ||
---|---|---|
unsigned int | fullResolution: 1 |
When set high, the resolution will always be 4 mg/LSB no matter the range. When set low, the resolution will change with the range and the data will remain 10 bits wide. |
unsigned int | invertedInterrupts: 1 |
When set high, interrupts will be active high instead of active low. |
unsigned int | justify: 1 |
When set high, data will be left (MSB) justified. When cleared low, it will be right justified and sign extended. |
Range | range: 2 |
Data range of the device |
unsigned int | selfTest |
Setting high will enable self-test mode, causing a shift in the output data. Cleared low for normal operation. |
unsigned int | spiMode |
When set high, the device will work in 3-wire SPI mode. Cleared low for 4-wire SPI mode. |
union PropWare::ADXL345::FIFOControl |
Bit-mapping for Register::FIFO_CONTROL.
Class Members | ||
---|---|---|
struct FIFOControl | fields | |
uint8_t | raw |
struct PropWare::ADXL345::FIFOControl.fields |
Class Members | ||
---|---|---|
FIFOMode | fifoMode: 2 |
Set the mode that the FIFO will assume. |
unsigned int | samples: 5 |
The function of these bits depends on the FIFO mode selected via FIFOContro::fifoMode. Entering a value of 0 in the samples bits immediately sets the watermark status bit in Register::INTERRUPT_SOURCE, regardless of which FIFO mode is selected. Undesirable operation may occur if a value of 0 is used for the samples bits when trigger mode is used. |
unsigned int | trigger: 1 |
Clear low to link the trigger event of trigger mode to INT1, and set high to link the trigger event to INT2. |
union PropWare::ADXL345::FIFOStatus |
Bit-mapping for Register::FIFO_STATUS.
Class Members | ||
---|---|---|
struct FIFOStatus | fields | |
uint8_t | raw |
struct PropWare::ADXL345::FIFOStatus.fields |
union PropWare::ADXL345::InterruptEnable |
Bit-mapping for Register::INTERRUPT_ENABLE.
Class Members | ||
---|---|---|
struct InterruptEnable | fields | |
uint8_t | raw |
struct PropWare::ADXL345::InterruptEnable.fields |
union PropWare::ADXL345::InterruptMapping |
Bit-mapping for Register::INTERRUPT_MAPPING.
Class Members | ||
---|---|---|
struct InterruptMapping | fields | |
uint8_t | raw |
struct PropWare::ADXL345::InterruptMapping.fields |
union PropWare::ADXL345::InterruptSources |
Bit-mapping for Register::INTERRUPT_SOURCES.
Class Members | ||
---|---|---|
struct InterruptSources | fields | |
uint8_t | raw |
struct PropWare::ADXL345::InterruptSources.fields |
union PropWare::ADXL345::PowerControl |
Class Members | ||
---|---|---|
struct PowerControl | fields | |
uint8_t | raw |
struct PropWare::ADXL345::PowerControl.fields |
Class Members | ||
---|---|---|
unsigned int | autoSleep: 1 |
When set high, the device will automatically enter a low-power sleep mode any time the sampled activity dips below the threshold configured via Register::INACTIVITY_THRESHOLD for at least the amount of time configured via Register::INACTIVITY_TIME. Clearing the bit low will disable automatic sleep mode. When clearing the AUTO_SLEEP bit, it is recommended that the part be placed into standby mode and then set back to measurement mode with a subsequent write. This is done to ensure that the device is properly biased if sleep mode is manually disabled; otherwise, the first few samples of data after the AUTO_SLEEP bit is cleared may have additional noise, especially if the device was asleep when the bit was cleared. |
unsigned int | link: 1 |
Set high to enable linked mode and clear low for concurrent functionality of inactivity and activity functions. See the datasheet for a far more verbose explanation. |
unsigned int | measure: 1 |
Set high for normal operation and low for standby mode. When in standby mode, power consumption is at a minimum but now measurements can be made. The device is booted in standby mode. |
unsigned int | sleep: 1 |
When set high, the device will be put into sleep mode. Low for normal operation. While in sleep mode, the device's sample rate is set by PowerControl::wakeup. When clearing the sleep bit, it is recommended that the part be placed into standby mode and then set back to measurement mode with a subsequent write. This is done to ensure that the device is properly biased if sleep mode is manually disabled; otherwise, the first few samples of data after the sleep bit is cleared may have additional noise, especially if the device was asleep when the bit was cleared |
WakeupFrequency | wakeup: 2 |
Frequency of reading when in sleep mode |
union PropWare::ADXL345::RateAndPowerMode |
Bit-mapping for Register::RATE_AND_POWER_MODE.
Class Members | ||
---|---|---|
struct RateAndPowerMode | fields | |
uint8_t | raw |
struct PropWare::ADXL345::RateAndPowerMode.fields |
union PropWare::ADXL345::TapAxes |
Bit-mapping for Register::TAP_AXES.
Class Members | ||
---|---|---|
struct TapAxes | fields | |
uint8_t | raw |
struct PropWare::ADXL345::TapAxes.fields |
Class Members | ||
---|---|---|
unsigned int | suppress: 1 |
When set high, suppress double-tap detection for too high of an acceleration (as set per Register::TAP_THRESHOLD) |
unsigned int | tapXEnable: 1 |
Enable x-axis participation in tap detection |
unsigned int | tapYEnable: 1 |
Enable y-axis participation in tap detection |
unsigned int | tapZEnable: 1 |
Enable z-axis participation in tap detection |
union PropWare::ADXL345::TapSource |
Bit-mapping for Register::TAP_SOURCE.
Class Members | ||
---|---|---|
struct TapSource | fields | |
uint8_t | raw |
struct PropWare::ADXL345::TapSource.fields |
Data rate codes for the Register::RATE_AND_POWER_MODE register.
Enumeration names are based on the data rate with underscores representing decimal points for 6.25 and 12.5 Hz.
Data codes for the various modes of operation that the FIFO can assume.
|
strong |
Register map for all registers on the device.
Wakeup frequency codes for the Register::POWER_SAVINGS register.
PropWare::ADXL345::ADXL345 | ( | SPI & | bus, |
const Pin::Mask | csMask, | ||
const bool | alwaysSetSPIMode = false |
||
) |
Create an object which communicates over the given SPI bus.
[in] | bus | SPI bus for communication |
[in] | csMask | Chip-select's pin mask |
[in] | alwaysSetSPIMode | When true, the SPI bus's mode will always be set prior to communication |
Definition at line 615 of file adxl345.h.
PropWare::ADXL345::ADXL345 | ( | const Pin::Mask | csMask, |
const bool | alwaysSetSPIMode = true |
||
) |
void PropWare::ADXL345::always_set_spi_mode | ( | const bool | alwaysSetMode | ) |
void PropWare::ADXL345::clear_bit | ( | const Register | address, |
const Bit | bit | ||
) | const |
Clear a single bit in a register on the device.
This method is highly inefficient (runtime performance) for multi-bit modifications. Use this only when code size or code legibility is more important than runtime performance.
[in] | address | Address of the register to modify |
[in] | bit | Bit in the register that should be cleared low |
uint8_t PropWare::ADXL345::read | ( | const Register | address | ) | const |
void PropWare::ADXL345::read | ( | const Register | startingAddress, |
const size_t | words, | ||
int16_t * | result | ||
) | const |
void PropWare::ADXL345::read | ( | int16_t * | values | ) | const |
Retrieve the values from all 3 axes with a fast, 6-byte successive read.
[out] | values | Memory where 6-bytes can be stored. Note that this MUST be an array of 2-byte variables. DO NOT cast an array of 4-byte variables (such as an array of ints) and pass that address in. |
Definition at line 678 of file adxl345.h.
int16_t PropWare::ADXL345::read_axis | ( | const Axis | axis | ) | const |
int16_t PropWare::ADXL345::read_x | ( | ) | const |
int16_t PropWare::ADXL345::read_y | ( | ) | const |
int16_t PropWare::ADXL345::read_z | ( | ) | const |
|
static |
Scale the non-justified, raw accelerometer value to a human-readable number.
This method is only necessary when the fullResolution bit of ADXL345::DataFormat is cleared low. If it is high, simply multiply the raw value by ADXL345::FULL_RESOLUTION_SCALE to achieve the correct result.
[in] | value | Raw accelerometer |
[in] | range | The range that was selected at the time the reading was made. |
void PropWare::ADXL345::set_bit | ( | const Register | address, |
const Bit | bit | ||
) | const |
Set a single bit in a register on the device.
This method is highly inefficient (runtime performance) for multi-bit modifications. Use this only when code size or code legibility is more important than runtime performance.
[in] | address | Address of the register to modify |
[in] | bit | Bit in the register that should be set high |
void PropWare::ADXL345::start | ( | const bool | autoSleep = false , |
const bool | link = false , |
||
const bool | sleep = false , |
||
const bool | measure = true , |
||
const WakeupFrequency | wakeupFrequency = WakeupFrequency::HZ_8 |
||
) | const |
Convenience function to start the device in a sane fashion for basic reading.
See the documentation of PowerControl::fields for detailed descriptions of each parameter
[in] | autoSleep | Set the auto-sleep feature |
[in] | link | Set the link feature |
[in] | sleep | Set the sleep mode |
[in] | measure | Set the standby mode |
[in] | wakeupFrequency | Set the wakeup frequency |
Definition at line 660 of file adxl345.h.
void PropWare::ADXL345::write | ( | const Register | address, |
const uint8_t | value | ||
) | const |