|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Go to the documentation of this file.
302 unsigned int inactiveZEnable: 1;
304 unsigned int inactiveYEnable: 1;
306 unsigned int inactiveXEnable: 1;
308 unsigned int inactiveAcDc: 1;
310 unsigned int activeZEnable: 1;
312 unsigned int activeYEnable: 1;
314 unsigned int activeXEnable: 1;
316 unsigned int activeAcDc: 1;
327 unsigned int tapZEnable: 1;
329 unsigned int tapYEnable: 1;
331 unsigned int tapXEnable: 1;
336 unsigned int suppress: 1;
347 unsigned int zTapped: 1;
349 unsigned int yTapped: 1;
351 unsigned int xTapped: 1;
353 unsigned int asleep: 1;
355 unsigned int zActivity: 1;
357 unsigned int yActivity: 1;
359 unsigned int xActivity: 1;
377 unsigned int lowPowerMode: 1;
401 unsigned int sleep: 1;
406 unsigned int measure: 1;
419 unsigned int autoSleep: 1;
424 unsigned int link: 1;
433 struct {
unsigned int overrun: 1;
unsigned int watermark: 1;
unsigned int freeFall: 1;
unsigned int inactivity: 1;
unsigned int activity: 1;
unsigned int doubleTap: 1;
unsigned int singleTap: 1;
unsigned int dataReady: 1;
450 struct {
unsigned int
454 overrun: 1;
unsigned int
458 watermark: 1;
unsigned int
462 freeFall: 1;
unsigned int
466 inactivity: 1;
unsigned int
470 activity: 1;
unsigned int
474 doubleTap: 1;
unsigned int
478 singleTap: 1;
unsigned int
491 struct {
unsigned int overrun: 1;
unsigned int watermark: 1;
unsigned int freeFall: 1;
unsigned int inactivity: 1;
unsigned int activity: 1;
unsigned int doubleTap: 1;
unsigned int singleTap: 1;
unsigned int dataReady: 1;
522 unsigned int fullResolution: 1;
526 unsigned int invertedInterrupts: 1;
530 unsigned int spiMode;
535 unsigned int selfTest;
551 unsigned int samples: 5;
556 unsigned int trigger: 1;
569 struct {
unsigned int entries: 6;
unsigned int unused: 1;
unsigned int fifoTrigger: 1;
617 m_cs(csMask,
Pin::Dir::OUT),
618 m_alwaysSetMode(alwaysSetSPIMode) {
619 if (!alwaysSetSPIMode)
631 : m_bus(&
SPI::get_instance()),
632 m_cs(csMask,
Pin::Dir::OUT),
633 m_alwaysSetMode(alwaysSetSPIMode) {
634 if (!alwaysSetSPIMode)
646 this->m_alwaysSetMode = alwaysSetMode;
660 void start (
const bool autoSleep =
false,
const bool link =
false,
const bool sleep =
false,
661 const bool measure =
true,
const WakeupFrequency wakeupFrequency = WakeupFrequency::HZ_8)
const {
663 wakeup: wakeupFrequency,
664 sleep:
static_cast<unsigned int>(sleep),
665 measure:
static_cast<unsigned int>(measure),
666 autoSleep:
static_cast<unsigned int>(autoSleep),
667 link:
static_cast<unsigned int>(link)
678 void read (int16_t *values)
const {
692 return temp[
static_cast<size_t>(axis)];
729 if (this->m_alwaysSetMode)
733 this->m_bus->
shift_out(8,
static_cast<uint32_t
>(address));
746 if (this->m_alwaysSetMode)
750 this->m_bus->
shift_out(8, BIT_7 |
static_cast<uint32_t
>(address));
751 const uint8_t result =
static_cast<const uint8_t
>(this->m_bus->
shift_in(8));
763 void read (
const Register startingAddress,
const size_t words, int16_t *result)
const {
764 if (this->m_alwaysSetMode)
768 this->m_bus->
shift_out(8, BIT_7 | BIT_6 |
static_cast<uint32_t
>(startingAddress));
769 for (
size_t i = 0; i < words; ++i) {
770 const uint8_t lowByte =
static_cast<const uint8_t
>(this->m_bus->
shift_in(8));
771 const uint8_t highByte =
static_cast<const uint8_t
>(this->m_bus->
shift_in(8));
772 result[i] = highByte << 8 | lowByte;
787 const auto startingValue = this->
read(address);
788 this->
write(address, bit | startingValue);
801 const auto startingValue = this->
read(address);
802 this->
write(address, ~bit & startingValue);
808 bool m_alwaysSetMode;
void write(const Register address, const uint8_t value) const
Perform a manual write to the device.
@ INTERRUPT_SOURCES
Source of interrupts.
uint8_t read(const Register address) const
Perform a single manual read from the device.
Bit-mapping for Register::FIFO_CONTROL.
@ INACTIVITY_THRESHOLD
Inactivity threshold.
Bit-mapping for Register::POWER_SAVINGS.
int16_t read_x() const
Read data for all three axes and return only the x-axis.
@ TAP_AXES
Axis control for tap/double tap.
@ INTERRUPT_MAPPING
Interrupt mapping control.
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.
@ Y_AXIS_OFFSET
Y-axis offset.
Axis
Convenience enumeration for selecting axes via the ADXL345::read_axis() method.
void read(const Register startingAddress, const size_t words, int16_t *result) const
Perform a manual, multi-byte read from the device.
SPI serial communications library; Core functionality comes from a dedicated assembly cog.
@ TAP_LATENCY
Tap latency.
uint32_t shift_in(const unsigned int bits) const
Read a value from the MISO line.
@ ACT_INACT_CTL
Axis enable control for activity and inactivity detection.
Bit-mapping for Register::ACT_INACT_CTL.
static constexpr double FULL_RESOLUTION_SCALE
The highest resolution that the device is capable of. Resolution will become less precise (larger num...
Bit-mapping for Register::FIFO_STATUS.
void read(int16_t *values) const
Retrieve the values from all 3 axes with a fast, 6-byte successive read.
@ X_AXIS_OFFSET
X-axis offset.
@ RATE_AND_POWER_MODE
Data rate and power mode control.
@ TAP_THRESHOLD
Tap threshold.
static const uint8_t DEVICE_ID
The ADXL345 is hardwired for a device ID of 0xE5
@ POWER_CONTROL
Control of the power-saving features.
Bit-mapping for Register::INTERRUPT_ENABLE.
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 ...
int16_t read_axis(const Axis axis) const
Read data for all three axes and return only the requested axis.
@ INTERRUPT_ENABLE
Interrupt enable control.
@ DATA_FORMAT
Data format control.
Utility class to handle general purpose I/O pins.
Bit-mapping for Register::TAP_AXES.
void justify(char *string_ptr, uint32_t *justptr)
FIFOMode
Data codes for the various modes of operation that the FIFO can assume.
void shift_out(uint8_t bits, uint32_t value) const
Send a value out to a peripheral device.
void set() const
Set selected output port high (set all pins to 1)
void clear_bit(const Register address, const Bit bit) const
Clear a single bit in a register on the device.
int16_t read_y() const
Read data for all three axes and return only the y-axis.
ADXL345(const Pin::Mask csMask, const bool alwaysSetSPIMode=true)
Create an object which communicates over the shared SPI bus.
void set_mode(const Mode mode)
Set the mode of SPI communication.
ADXL345(SPI &bus, const Pin::Mask csMask, const bool alwaysSetSPIMode=false)
Create an object which communicates over the given SPI bus.
Bit-mapping for Register::INTERRUPT_SOURCES.
DataRate
Data rate codes for the Register::RATE_AND_POWER_MODE register.
@ TAP_DURATION
Tap duration.
Bit-mapping for Register::RATE_AND_POWER_MODE.
Bit-mapping for Register::TAP_SOURCE.
@ INACTIVITY_TIME
Inactivity time.
int16_t read_z() const
Read data for all three axes and return only the z-axis.
@ Z_AXIS_OFFSET
Z-axis offset.
Register
Register map for all registers on the device.
void set_bit(const Register address, const Bit bit) const
Set a single bit in a register on the device.
@ FREE_FALL_TIME
Free-fall time Name: TIME_FF, Access: read/write, Reset value: 0
@ TAP_SOURCE
Source of tap/double tap.
@ FIFO_CONTROL
FIFO control.
Generic definitions and functions for the Parallax Propeller.
void clear() const
Clear selected output port (set it to 0)
@ FIFO_STATUS
FIFO status.
Range
Selection of data ranges.
Bit-mapping for Register::INTERRUPT_MAPPING.
@ FREE_FALL_THRESHOLD
Free-fall threshold.
WakeupFrequency
Wakeup frequency codes for the Register::POWER_SAVINGS register.
static double scale(const int value, const Range range)
Scale the non-justified, raw accelerometer value to a human-readable number.
Mode
Descriptor for SPI signal as defined by Motorola modes.
@ ACTIVITY_THRESHOLD
Activity threshold.