QuadroCopter  0.1.4
quadro::i2c::LSM303DLHC Class Reference

#include <LSM303DLHC.h>

Inheritance diagram for quadro::i2c::LSM303DLHC:
quadro::i2c::i2cDevice quadro::IDevice quadro::i2c::LSM303Accelerometer quadro::i2c::LSM303Magnetometer

Public Member Functions

 LSM303DLHC ()
 
 ~LSM303DLHC ()
 
void loadRecommendedFlightSettings ()
 
uint8_t getPowerSettings ()
 
uint8_t getHighPassSettings ()
 
uint8_t getInt1Settings ()
 
uint8_t getDataSettings ()
 
uint8_t getMemorySettings ()
 
uint8_t getInterruptSettings ()
 
uint8_t getFIFOSettings ()
 
uint8_t getInterrupt1CFGSettings ()
 
uint8_t getInterrupt2CFGSettings ()
 
uint8_t getClickCFGSettings ()
 
uint8_t getClickSRCSettings ()
 
uint8_t getCRARegMSettings ()
 
uint8_t getMRRegMSettings ()
 
void startSensorThread ()
 
- Public Member Functions inherited from quadro::i2c::i2cDevice
 ~i2cDevice ()
 
 i2cDevice ()
 
void initDevice () throw ( i2cSetupException& )
 
short getValueFromRegister (unsigned char _registerAddress)
 
void setRegisterValue (unsigned char _registerValue)
 
void setRegisterAddress (unsigned char _registerAddress)
 
int writeToDevice (size_t _bufferSize) throw ( i2cSetupException& )
 
int stop (pthread_t threadHandle)
 
- Public Member Functions inherited from quadro::IDevice
virtual ~IDevice ()
 

Public Attributes

unsigned int dataTimer
 set from the devices data rate settings More...
 

Protected Member Functions

void setDeviceAddress (unsigned char _deviceAddress)
 
void setBusId (int _busId)
 
- Protected Member Functions inherited from quadro::i2c::i2cDevice
int getStatus ()
 
void setStatus (deviceStatus _status)
 
int getDeviceFileHandle ()
 
const char * getFilePath ()
 
void setBusPaths ()
 
int validateBusId () throw ( i2cSetupException& )
 
char * validateBusPath (char *_busProposedPath) throw ( i2cSetupException& )
 
void selectABusPath ()
 
int connectToDevice ()
 
int openDevice () throw ( i2cSetupException& )
 
short readDevice (size_t _bufferSize) throw ( i2cSetupException& )
 

Additional Inherited Members

- Protected Types inherited from quadro::i2c::i2cDevice
enum  deviceStatus { On = 1, Off = 0, Error = 2 }
 
- Protected Attributes inherited from quadro::i2c::i2cDevice
const char * deviceBusPath
 
unsigned char deviceAddress
 
unsigned char registerValue
 
unsigned char registerAddress
 
char readAndWriteBuffer [TWO_BYTES]
 
char writeBufferOnly [ONE_BYTE]
 
char errMessage [MAX_BUFF]
 
int fileHandle
 
int busId
 
bool deviceInitialised
 

Detailed Description

LSM303DLHC : Base class that provides control of the LSM303DLHC, inherits I2C methods.

Constructor & Destructor Documentation

LSM303DLHC::LSM303DLHC ( )

LSM303DLHC : A class that provides control of the LSM303DLHC's accelerometer, magnetometer, temp and gyro.

183 {
184 
185 }
LSM303DLHC::~LSM303DLHC ( )

Runs the stopRecording method and attempts to cancel threads.

188 {
189  stopRecording();
190 }

Member Function Documentation

uint8_t quadro::i2c::LSM303DLHC::getClickCFGSettings ( )
inline

Returns the current binary value used on the click CFG settings.

See also
LSM303 Data sheet ( lib/docs/LSM303DLHC.PDF )
Returns
uint8_t Current sensor setting for click CFG settings
448 { return clickCFGSettings; }
uint8_t quadro::i2c::LSM303DLHC::getClickSRCSettings ( )
inline

Returns the current binary value used on the click SRC settings.

See also
LSM303 Data sheet ( lib/docs/LSM303DLHC.PDF )
Returns
uint8_t Current sensor setting for click SRC settings
456 { return clickSRCSettings; }
uint8_t quadro::i2c::LSM303DLHC::getCRARegMSettings ( )
inline

Returns the current binary value used on the CRARegM settings.

See also
LSM303 Data sheet ( lib/docs/LSM303DLHC.PDF )
Returns
uint8_t Current sensor setting for CRARegM settings
464 { return CRARegMSettings; }
uint8_t quadro::i2c::LSM303DLHC::getDataSettings ( )
inline

Returns the current binary value used on the data rate settings.

See also
LSM303 Data sheet ( lib/docs/LSM303DLHC.PDF )
Returns
uint8_t Current sensor settings for the date rate
400 { return dataSettings; }
uint8_t quadro::i2c::LSM303DLHC::getFIFOSettings ( )
inline

Returns the current binary value used on the FirstIn FirstOut settings.

See also
LSM303 Data sheet ( lib/docs/LSM303DLHC.PDF )
Returns
uint8_t Current sensor settings for FIFO
424 { return FIFOSettings; }
uint8_t quadro::i2c::LSM303DLHC::getHighPassSettings ( )
inline

Returns the current binary value used on the high pass settings.

See also
LSM303 Data sheet ( lib/docs/LSM303DLHC.PDF )
Returns
uint8_t Current sensor settings for high pass
384 { return highPassSettings; }
uint8_t quadro::i2c::LSM303DLHC::getInt1Settings ( )
inline

Returns the current binary value used on the interrupt 1 settings.

See also
LSM303 Data sheet ( lib/docs/LSM303DLHC.PDF )
Returns
uint8_t Current sensor settings for interrupt 1
392 { return int1Settings; }
uint8_t quadro::i2c::LSM303DLHC::getInterrupt1CFGSettings ( )
inline

Returns the current binary value used on the interrupt 1 CFG settings.

See also
LSM303 Data sheet ( lib/docs/LSM303DLHC.PDF )
Returns
uint8_t Current sensor setting for interrupt 1 CFG settings
432 { return interrupt1CFGSettings; }
uint8_t quadro::i2c::LSM303DLHC::getInterrupt2CFGSettings ( )
inline

Returns the current binary value used on the interrupt 2 CFG settings.

See also
LSM303 Data sheet ( lib/docs/LSM303DLHC.PDF )
Returns
uint8_t Current sensor setting for interrupt 2 CFG settings
440 { return interrupt2CFGSettings; }
uint8_t quadro::i2c::LSM303DLHC::getInterruptSettings ( )
inline

Returns the current binary value used on the interrupt settings.

See also
LSM303 Data sheet ( lib/docs/LSM303DLHC.PDF )
Returns
uint8_t Current sensor settings for interrupt events
416 { return interruptSettings; }
uint8_t quadro::i2c::LSM303DLHC::getMemorySettings ( )
inline

Returns the current binary value used on the memory settings.

See also
LSM303 Data sheet ( lib/docs/LSM303DLHC.PDF )
Returns
uint8_t Current sensor settings for memory
408 { return memorySettings; }
uint8_t quadro::i2c::LSM303DLHC::getMRRegMSettings ( )
inline

Returns the current binary value used on the MRRegM settings.

See also
LSM303 Data sheet ( lib/docs/LSM303DLHC.PDF )
Returns
uint8_t Current sensor setting for MRRegM settings
472 { return MRRegMSettings; }
uint8_t quadro::i2c::LSM303DLHC::getPowerSettings ( )
inline

Returns the current binary value used on the power settings.

See also
LSM303 Data sheet ( lib/docs/LSM303DLHC.PDF )
Returns
uint8_t Current sensor settings for power
376 { return powerSettings; }
void LSM303DLHC::loadRecommendedFlightSettings ( )

Loads default settings suitable for flight on the LSM303DLHC.

23 {
24  if ( deviceAddress == ACCEL_ADDRESS ) {
25  powerSettings =
26  commitSetting(
34  )
35  );
36 
37  highPassSettings =
38  commitSetting(
46  )
47  );
48 
49  int1Settings =
50  commitSetting(
60  )
61  );
62 
63  dataSettings =
64  commitSetting(
72  )
73  );
74 
75  memorySettings =
76  commitSetting(
85  )
86  );
87  interruptSettings =
88  commitSetting(
97  )
98  );
99 
100  FIFOSettings =
101  commitSetting(
106  )
107  );
108 
109  interrupt1CFGSettings =
110  commitSetting(
111  INT1_CFG_A,
120  )
121  );
122 
123  interrupt2CFGSettings =
124  commitSetting(
125  INT2_CFG_A,
134  )
135  );
136 
137  clickCFGSettings =
138  commitSetting(
139  CLICK_CFG_A,
147  )
148  );
149 
150  clickSRCSettings =
151  commitSetting(
152  CLICK_SRC_A,
157  )
158  );
159  }
160  else if ( deviceAddress == MAG_ADDRESS ) {
161 
162  CRARegMSettings =
163  commitSetting(
164  CRA_REG_M,
166  TEMP_ENABLED,
167  DO2_220Hz
168  )
169  );
170 
171  MRRegMSettings =
172  commitSetting(
173  MR_REG_M,
174  SET_MR_REG_M(
176  )
177  );
178  }
179 
180 }
#define FIFO_DISABLED
Definition: LSM303DLHC.h:181
#define XHIE_INTERRUPT_ON_X_HIGH_DISABLED
Definition: LSM303DLHC.h:248
#define SET_CTRL6_REG_A(I2_CLICK, I2_INT1, I2_INT2, BOOT_I1, P2_ACT, H_LACTIVE)
Definition: LSM303DLHC.h:212
#define DRDY1_INTERRUPT_ON_INT1_DISABLED
Definition: LSM303DLHC.h:141
#define FM_BYPASS_MODE
Definition: LSM303DLHC.h:220
#define FIFO_CTRL_REG_A
Read/Write (FIFO mode selection) : Default - 0.
Definition: LSM303DLHC.h:44
#define HIGHPASS_FILTER_DISABLED_FOR_CLICK
Definition: LSM303DLHC.h:120
#define SET_CLICK_CFG_A(ZD, ZS, YD, YS, XD, XS)
Definition: LSM303DLHC.h:274
#define XLIE_INTERRUPT_ON_X_LOW_DISABLED
Definition: LSM303DLHC.h:250
#define AOI1_INTERRUPT_ON_INT1_DISABLED
Definition: LSM303DLHC.h:137
#define XS_SINGLECLICK_ON_X_AXIS_DISABLED
Definition: LSM303DLHC.h:272
#define SET_CLICK_SRC_A(DCLICK, SCLICK, SIGN)
Definition: LSM303DLHC.h:291
#define HR_HI_RES_ENABLED
Definition: LSM303DLHC.h:165
#define HIGHPASS_FILTER_DISABLED_AOI_INT2
Definition: LSM303DLHC.h:121
#define SET_INT2_CFG_A(AOI, ZHIE, ZLIE, YHIE, YLIE, XHIE, XLIE)
Definition: LSM303DLHC.h:253
#define YLIE_INTERRUPT_ON_Y_LOW_DISABLED
Definition: LSM303DLHC.h:246
#define ZHIE_INTERRUPT_ON_Z_HIGH_DISABLED
Definition: LSM303DLHC.h:240
#define CTRL_REG1_A
Read/Write (power control) : Default - 00111.
Definition: LSM303DLHC.h:30
#define SET_CRA_REG_M(TEMP_EN, DO2)
Definition: LSM303DLHC.h:310
#define LP_LOW_POWER_DISABLED
Definition: LSM303DLHC.h:93
#define H_LACTIVE_INTERRUPT_ACTIVE_HIGH
Definition: LSM303DLHC.h:209
#define HIGHPASS_MODE_NORMAL_WITH_RESET
Definition: LSM303DLHC.h:110
#define I2_INTERRUPT_2_DISABLED
Definition: LSM303DLHC.h:204
#define BOOT_REBOOT_MEM_CONTENT_DISABLED
Definition: LSM303DLHC.h:179
#define LIR_INT2_NOT_LATCHED
Definition: LSM303DLHC.h:187
#define LIR_INT1_NOT_LATCHED
Definition: LSM303DLHC.h:183
#define YHIE_INTERRUPT_ON_Y_HIGH_DISABLED
Definition: LSM303DLHC.h:244
#define DRDY2_INTERRUPT_ON_INT1_DISABLED
Definition: LSM303DLHC.h:143
#define SET_CTRL_REG4_A(BDU, BLE, FS, HR, SIM)
Definition: LSM303DLHC.h:170
#define ZD_DOUBLECLICK_ON_Z_AXIS_DISABLED
Definition: LSM303DLHC.h:262
#define CLICK_SRC_A
Read/Write (interrupt double CLICK settings)
Definition: LSM303DLHC.h:55
#define DO2_220Hz
Definition: LSM303DLHC.h:308
unsigned char deviceAddress
Definition: i2cDevice.h:223
#define FS_SCALE_AT_PLUS_MINUS_16G
Definition: LSM303DLHC.h:164
#define INT1_CFG_A
Read/Write (interrupt 1 settings)
Definition: LSM303DLHC.h:46
#define MAG_ADDRESS
I2C Address of the magnetometer device.
Definition: LSM303DLHC.h:61
#define YD_DOUBLECLICK_ON_Y_AXIS_DISABLED
Definition: LSM303DLHC.h:266
#define FIFO_OVERRUN_INTERRUPT_ON_INT1_DISABLED
Definition: LSM303DLHC.h:147
#define MR_REG_M
Read/Write (0x00 or 00000000 Continuous conversion mode.)
Definition: LSM303DLHC.h:64
#define CTRL_REG3_A
Read/Write (interrupt settings) : Default - 0.
Definition: LSM303DLHC.h:32
#define CRA_REG_M
Read/Write (0x94 or 10010100 Temp sensor on and 30 hz refresh rate.)
Definition: LSM303DLHC.h:62
#define CTRL_REG6_A
Read/Write (CLICK interrupt setting) : Default - 0.
Definition: LSM303DLHC.h:35
#define TEMP_ENABLED
Definition: LSM303DLHC.h:299
#define SET_FIFO_CTRL_REG_A(FM, TR)
Definition: LSM303DLHC.h:227
#define YS_SINGLECLICK_ON_Y_AXIS_DISABLED
Definition: LSM303DLHC.h:268
#define CTRL_REG4_A
Read/Write (range/resolution settings) : Default - 0.
Definition: LSM303DLHC.h:33
#define SCLICK_SINGLE_CLICK_DETECTION_DISABLED
Definition: LSM303DLHC.h:287
#define ZS_SINGLECLICK_ON_Z_AXIS_DISABLED
Definition: LSM303DLHC.h:264
#define Z_AXIS_ENABLED
Definition: LSM303DLHC.h:95
#define SIGN_POSITIVE_DETECTION
Definition: LSM303DLHC.h:288
#define SET_INT1_CFG_A(AOI, ZHIE, ZLIE, YHIE, YLIE, XHIE, XLIE)
Definition: LSM303DLHC.h:252
#define ACCEL_ADDRESS
I2C Address of the accelerometer device.
Definition: LSM303DLHC.h:29
#define SIM_SERIAL_INTERFACE_4_WIRE
Definition: LSM303DLHC.h:167
#define P2_ACT_ACTIVE_FUNCTION_ON_PAD2_DISABLED
Definition: LSM303DLHC.h:208
#define XD_DOUBLECLICK_ON_X_AXIS_DISABLED
Definition: LSM303DLHC.h:270
#define HIGHPASS_FDS_INTERNAL_BYPASSED_DISABLED
Definition: LSM303DLHC.h:118
#define SET_MR_REG_M(MD)
Definition: LSM303DLHC.h:339
#define ZLIE_INTERRUPT_ON_Z_LOW_DISABLED
Definition: LSM303DLHC.h:242
#define SET_CTRL_REG1_A(ODR, LPEN, ZEN, YEN, XEN)
Definition: LSM303DLHC.h:102
#define CTRL_REG2_A
Read/Write (filter selection) : Default - 0.
Definition: LSM303DLHC.h:31
#define D4D_INT2_4D_DISABLED
Definition: LSM303DLHC.h:189
#define SET_CTRL_REG2_A(HIGHPASS_MODE, HIGHPASS_FDS, HIGHPASS_CLICK_FILTER, HIGHPASS_AOI_INT2, HIGHPASS_AOI_INT1)
Definition: LSM303DLHC.h:126
#define DCLICK_DOUBLE_CLICK_DETECTION_DISABLED
Definition: LSM303DLHC.h:285
#define BDU_UPDATE_REGISTERS_CONTINUOUSLY
Definition: LSM303DLHC.h:157
#define BLE_DATA_LSB_AT_LOWER_ADDRESS
Definition: LSM303DLHC.h:159
#define BOOT_I1_REBOOT_MEMORY_DISABLED
Definition: LSM303DLHC.h:206
#define CTRL_REG5_A
Read/Write (FIFO setting | internal memory) : Default - 0.
Definition: LSM303DLHC.h:34
#define AOI2_INTERRUPT_ON_INT1_DISABLED
Definition: LSM303DLHC.h:139
#define SET_CTRL_REG5_A(BOOT, FIFO_EN, LIR_INT1, D4D_INT1, LIR_INT2, D4D_INT2)
Definition: LSM303DLHC.h:191
#define CLICK_CFG_A
Read/Write (interrupt double CLICK on Z axis) : Default - 0.
Definition: LSM303DLHC.h:54
#define I2_CLICK_INTERRUPT_ON_PAD2_DISABLED
Definition: LSM303DLHC.h:200
#define FIFO_WTM_INTERRUPT_ON_INT1_DISABLED
Definition: LSM303DLHC.h:145
#define SET_CTRL_REG3_A(CLICK, AOI1, AOI2, DRDY1, DRDY2, WTM, OVERRUN)
Definition: LSM303DLHC.h:149
#define D4D_INT1_4D_DISABLED
Definition: LSM303DLHC.h:185
#define INT2_CFG_A
Read/Write (interrupt 2 settings)
Definition: LSM303DLHC.h:50
#define CLICK_INTERRUPT_ON_INT1_DISABLED
Definition: LSM303DLHC.h:135
#define Y_AXIS_ENABLED
Definition: LSM303DLHC.h:97
#define ODR_1344KHZ
Definition: LSM303DLHC.h:92
#define X_AXIS_ENABLED
Definition: LSM303DLHC.h:99
#define I2_INTERRUPT_1_DISABLED
Definition: LSM303DLHC.h:202
#define AOI_OR_COMBINATION
Definition: LSM303DLHC.h:235
#define TR_TRIGGER_LINKED_TO_INTERRUPT2
Definition: LSM303DLHC.h:225
#define MD_CONTINUOUS_CONVERSION_MODE
Definition: LSM303DLHC.h:334
#define HIGHPASS_FILTER_DISABLED_AOI_INT1
Definition: LSM303DLHC.h:124
void quadro::i2c::LSM303DLHC::setBusId ( int  _busId)
inlineprotectedvirtual

Set the I2C Bus ID

Parameters
_busId

Implements quadro::i2c::i2cDevice.

502 { busId = _busId; }
int busId
Definition: i2cDevice.h:232
void quadro::i2c::LSM303DLHC::setDeviceAddress ( unsigned char  _deviceAddress)
inlineprotectedvirtual

Sets the I2C device address, pass as hex value

Parameters
_deviceAddress

Implements quadro::i2c::i2cDevice.

495 { deviceAddress = _deviceAddress; }
unsigned char deviceAddress
Definition: i2cDevice.h:223
void LSM303DLHC::startSensorThread ( )

startSensorThread() - Allows the independent control to start the thread that updates the raw sensor readings.

Parameters
none
Exceptions
i2cSetupException
Returns
int deviceStatus : 1 = on, 0 = off or 2 = error
193 {
194  if ( deviceAddress == ACCEL_ADDRESS ) {
195  getOutputDataRate();
196  }
197  else if ( deviceAddress == MAG_ADDRESS ) {
198  getDataOutputRate();
199  }
200 
201  setDataTimer();
202  startRecording();
203 }
unsigned char deviceAddress
Definition: i2cDevice.h:223
#define MAG_ADDRESS
I2C Address of the magnetometer device.
Definition: LSM303DLHC.h:61
#define ACCEL_ADDRESS
I2C Address of the accelerometer device.
Definition: LSM303DLHC.h:29

Member Data Documentation

unsigned int quadro::i2c::LSM303DLHC::dataTimer

set from the devices data rate settings


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