PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
L3G gyroscope driver using SPI communication for the Parallax Propeller. More...
#include <PropWare/sensor/gyroscope/l3g.h>
Public Types | |
enum | Axis { X, Y, Z, AXES } |
enum | DPSMode { DPS_250 = 0x00, DPS_500 = 0x10, DPS_2000 = 0x20 } |
enum | Register { WHO_AM_I = 0x0F, CTRL_REG1 = 0x20, CTRL_REG2 = 0x21, CTRL_REG3 = 0x22, CTRL_REG4 = 0x23, CTRL_REG5 = 0x24, REFERENCE = 0x25, OUT_TEMP = 0x26, STATUS_REG = 0x27, OUT_X_L = 0x28, OUT_X_H = 0x29, OUT_Y_L = 0x2A, OUT_Y_H = 0x2B, OUT_Z_L = 0x2C, OUT_Z_H = 0x2D, FIFO_CTRL_REG = 0x2E, FIFO_SRC_REG = 0x2F, INT1_CFG = 0x30, INT1_SRC = 0x31, INT1_THS_XH = 0x32, INT1_THS_XL = 0x33, INT1_THS_YH = 0x34, INT1_THS_YL = 0x35, INT1_THS_ZH = 0x36, INT1_THS_ZL = 0x37, INT1_DURATION = 0x38 } |
Public Member Functions | |
L3G (SPI &spi, const Port::Mask cs, const bool alwaysSetMode=false) | |
void | always_set_spi_mode (const bool alwaysSetMode) |
Choose whether to always set the SPI mode and bitmode before reading or writing to the L3G module; Useful when multiple devices are connected to the SPI bus. More... | |
void | read (int16_t *values) const |
Read data from all three axes. More... | |
int16_t | read (const Axis axis) const |
Read a specific axis's data. More... | |
int16_t | read_x () const |
Read data from the X axis. More... | |
int16_t | read_y () const |
Read data from the Y axis. More... | |
int16_t | read_z () const |
Read data from the Z axis. More... | |
void | set_dps (const DPSMode dpsMode) const |
Modify the scale of L3G in units of degrees per second. More... | |
void | write (const Register address, const uint8_t registerValue) const |
Write one byte to the L3G module. More... | |
uint8_t | read (const Register address) const |
Read one byte from the L3G module. 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 | to_dps (const int rawValue, const DPSMode dpsMode) |
Convert the raw, integer value from the gyro into units of degrees-per-second. More... | |
Static Public Attributes | |
static const SPI::Mode | SPI_MODE = SPI::Mode::MODE_3 |
static const SPI::BitMode | SPI_BITMODE = SPI::BitMode::MSB_FIRST |
L3G gyroscope driver using SPI communication for the Parallax Propeller.
enum PropWare::L3G::Axis |
PropWare::L3G::L3G | ( | SPI & | spi, |
const Port::Mask | cs, | ||
const bool | alwaysSetMode = false |
||
) |
void PropWare::L3G::always_set_spi_mode | ( | const bool | alwaysSetMode | ) |
void PropWare::L3G::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 |
int16_t PropWare::L3G::read | ( | const Axis | axis | ) | const |
uint8_t PropWare::L3G::read | ( | const Register | address | ) | const |
void PropWare::L3G::read | ( | int16_t * | values | ) | const |
Read data from all three axes.
[out] | values | Starting address for data to be placed; 6 contiguous bytes of space are required for the read routine |
Definition at line 146 of file l3g.h.
int16_t PropWare::L3G::read_x | ( | ) | const |
int16_t PropWare::L3G::read_y | ( | ) | const |
int16_t PropWare::L3G::read_z | ( | ) | const |
void PropWare::L3G::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::L3G::set_dps | ( | const DPSMode | dpsMode | ) | const |
|
static |
void PropWare::L3G::write | ( | const Register | address, |
const uint8_t | registerValue | ||
) | const |
Write one byte to the L3G module.
[in] | address | Destination register address |
[in] | value | Data to be written to the destination register |
Definition at line 230 of file l3g.h.