COSA
An Object-Oriented Platform for Arduino Programming
L3G4200D Class Reference

#include <L3G4200D.hh>

Inheritance diagram for L3G4200D:
Inheritance graph
Collaboration diagram for L3G4200D:
Collaboration graph

Classes

union  ctrl_reg1_t
 
union  ctrl_reg2_t
 
union  ctrl_reg3_t
 
union  ctrl_reg4_t
 
union  ctrl_reg5_t
 
union  fifo_ctrl_reg_t
 
union  fifo_src_reg_t
 
union  int1_cfg_t
 
struct  int1_duration_t
 
struct  int1_src_t
 
struct  sample_t
 
union  status_reg_t
 

Public Member Functions

 L3G4200D (uint8_t subaddr=0)
 
bool begin ()
 
bool end ()
 
void sample (sample_t &s)
 

Protected Types

enum  Register {
  WHO_A_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 = 0x28, OUT_X = 0x28, OUT_X_L = 0x28,
  OUT_X_H = 0x29, OUT_Y = 0x2A, OUT_Y_L = 0x2A, OUT_Y_H = 0x2B,
  OUT_Z = 0x2C, OUT_Z_L = 0x2C, OUT_Z_H = 0x2D, FIFO_CTRL_REG = 0x2E,
  FIFO_SRC_REG = 0x2F, INT1_CFG = 0x30, INT1_SRC = 0x31, INT1_TSH = 0x32,
  INT1_TSH_XH = 0x32, INT1_TSH_XL = 0x33, INT1_TSH_YH = 0x34, INT1_TSH_YL = 0x35,
  INT1_TSH_ZH = 0x36, INT1_TSH_ZL = 0x37, INT1_DURATION = 0x38
}
 
enum  { DR_100_HZ, DR_200_HZ, DR_400_HZ, DR_800_HZ }
 
enum  { BW_12_5, BW_25, BW_50, BW_110 }
 
enum  { HPM_NORMAL = 0, HPM_MODE = 1, HPM_AUTORESET = 3 }
 
enum  {
  FM_BYPASS, FM_FIFO, FM_STREAM, FM_STREAM_TO_FIFO,
  FM_BYPASS_TO_STREAM
}
 

Protected Member Functions

void write (Register reg, uint8_t value)
 
void write (Register reg, void *buffer, uint8_t count)
 
uint8_t read (Register reg)
 
void read (Register reg, void *buffer, uint8_t count)
 

Static Protected Attributes

static const uint8_t AUTO_INC = 0x80
 

Private Member Functions

bool is_async () const
 
void sync_request ()
 
void async_request ()
 
virtual void on_completion (uint8_t type, int count)
 

Private Attributes

uint8_t m_addr
 
bool m_async
 

Detailed Description

Cosa TWI driver for STMicroelectronics, L3G4200D, MEMS motion sensor: ultra-stable three-axis digital output gyroscope. Doc ID 17116 Rev 3.

Circuit

The GY-80 10DOF module with pull-up resistors (4K7) for TWI signals and 3V3 internal voltage converter.

GY-80
+------------+
(VCC)---------------1-|VCC |
2-|3V3 |
(GND)---------------3-|GND |
(A5/SCL)------------4-|SCL |
(A4/SDA)------------5-|SDA |
6-|M-DRDY |
7-|A-INT1 |
(Dn/EXTn)-----------8-|T-INT1 |
9-|P-XCLR |
10-|P-EOC |
+------------+

References

  1. http://www.st.com/st-web-ui/static/active/en/resource/technical/ document/datasheet/CD00265057.pdf

Definition at line 55 of file L3G4200D.hh.

Member Enumeration Documentation

anonymous enum
protected
Enumerator
DR_100_HZ 

Data rate (table 22).

100 Hz.

DR_200_HZ 

200 Hz.

DR_400_HZ 

400 Hz.

DR_800_HZ 

800 Hz.

Definition at line 159 of file L3G4200D.hh.

anonymous enum
protected
Enumerator
BW_12_5 

Bandwidth selection (table 22).

Note: Higher with 800 Hz.

BW_25 
BW_50 
BW_110 

Definition at line 165 of file L3G4200D.hh.

anonymous enum
protected
Enumerator
HPM_NORMAL 

High pass filter mode (table 26).

Normal moden (reset reading).

HPM_MODE 

Reference signal for filtering.

HPM_AUTORESET 

Autoreset on interrupt event.

Definition at line 191 of file L3G4200D.hh.

anonymous enum
protected
Enumerator
FM_BYPASS 

FIFO mode configuration (table 45).

Bypass mode.

FM_FIFO 

FIFO mode.

FM_STREAM 

Stream.

FM_STREAM_TO_FIFO 

Stream-to-FIFO.

FM_BYPASS_TO_STREAM 

Bypass-to-Stream.

Definition at line 310 of file L3G4200D.hh.

enum L3G4200D::Register
protected

Register address map (See tab. 18, pp. 27).

Enumerator
WHO_A_I 

Device identification register.

CTRL_REG1 

Control register#1.

CTRL_REG2 

Control register#2.

CTRL_REG3 

Control register#3.

CTRL_REG4 

Control register#4.

CTRL_REG5 

Control register#5.

REFERENCE 

Reference value for interrupt generation.

OUT_TEMP 

Temperature data.

STATUS_REG 

Status register.

OUT 

X,Y,Z-axis angular rate data.

OUT_X 

X axis angular rate data.

OUT_X_L 

X low byte.

OUT_X_H 

X high byte.

OUT_Y 

Y axis angular rate data.

OUT_Y_L 

Y low byte.

OUT_Y_H 

Y high byte.

OUT_Z 

Y axis angular rate data.

OUT_Z_L 

Z low byte.

OUT_Z_H 

Z high byte.

FIFO_CTRL_REG 

FIFO control register.

FIFO_SRC_REG 

FIFO status register.

INT1_CFG 

Interrupt configuration.

INT1_SRC 

Interrupt source register.

INT1_TSH 

Interrupt threshold.

INT1_TSH_XH 

X high threshold.

INT1_TSH_XL 

X low threshold.

INT1_TSH_YH 

Y high threshold.

INT1_TSH_YL 

Y low threshold.

INT1_TSH_ZH 

Z high threshold.

INT1_TSH_ZL 

Z low threshold.

INT1_DURATION 

Wait duration.

Definition at line 100 of file L3G4200D.hh.

Constructor & Destructor Documentation

L3G4200D::L3G4200D ( uint8_t  subaddr = 0)
inline

Construct L3G4200D digital gyroscope driver with given sub-address. Default is zero(0).

Parameters
[in]subaddrsub-address (0..1, default 0)

Definition at line 62 of file L3G4200D.hh.

Member Function Documentation

bool L3G4200D::begin ( )

Start interaction with device. Turn on measurements.

Returns
true(1) if successful otherwise false(0)

Definition at line 24 of file L3G4200D.cpp.

bool L3G4200D::end ( )

Stop sequence of interaction with device. Turn off measurements and power down.

Returns
true(1) if successful otherwise false(0)

Definition at line 36 of file L3G4200D.cpp.

uint8_t L3G4200D::read ( Register  reg)
protected

Read contents of register.

Parameters
[in]regregister address.
Returns
register value.

Definition at line 59 of file L3G4200D.cpp.

void L3G4200D::read ( Register  reg,
void *  buffer,
uint8_t  count 
)
protected

Read contents of registers, multiple values from give address.

Parameters
[in]regregister address.
[in]bufferstorage.
[in]countnumber of bytes.

Definition at line 70 of file L3G4200D.cpp.

void L3G4200D::sample ( sample_t s)
inline

Sample gyroscope and return values in given data structure

Parameters
[in]ssample storage.

Definition at line 90 of file L3G4200D.hh.

void L3G4200D::write ( Register  reg,
uint8_t  value 
)
protected

Write given value to register.

Parameters
[in]regregister address.
[in]valueregister value.

Definition at line 43 of file L3G4200D.cpp.

void L3G4200D::write ( Register  reg,
void *  buffer,
uint8_t  count 
)
protected

Write multiple registers with values from give address.

Parameters
[in]regregister address.
[in]bufferstorage.
[in]countnumber of bytes.

Definition at line 51 of file L3G4200D.cpp.

Member Data Documentation

const uint8_t L3G4200D::AUTO_INC = 0x80
staticprotected

Auto increment address.

Definition at line 135 of file L3G4200D.hh.


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