APM:Libraries
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
AP_Compass_LSM303D Class Reference

#include <AP_Compass_LSM303D.h>

Inheritance diagram for AP_Compass_LSM303D:
[legend]
Collaboration diagram for AP_Compass_LSM303D:
[legend]

Public Member Functions

void read () override
 
virtual ~AP_Compass_LSM303D ()
 
- Public Member Functions inherited from AP_Compass_Backend
 AP_Compass_Backend (Compass &compass)
 
virtual ~AP_Compass_Backend (void)
 
virtual void accumulate (void)
 
virtual void handle_mag_msg (Vector3f &mag)
 

Static Public Member Functions

static AP_Compass_Backendprobe (Compass &compass, AP_HAL::OwnPtr< AP_HAL::Device > dev, enum Rotation=ROTATION_NONE)
 

Static Public Attributes

static constexpr const char * name = "LSM303D"
 

Private Member Functions

 AP_Compass_LSM303D (Compass &compass, AP_HAL::OwnPtr< AP_HAL::Device > dev)
 
bool init (enum Rotation rotation)
 
uint8_t _register_read (uint8_t reg)
 
void _register_write (uint8_t reg, uint8_t val)
 
void _register_modify (uint8_t reg, uint8_t clearbits, uint8_t setbits)
 
bool _block_read (uint8_t reg, uint8_t *buf, uint32_t size)
 
bool _read_sample ()
 
bool _data_ready ()
 
bool _hardware_init ()
 
void _update ()
 
void _disable_i2c ()
 
bool _mag_set_range (uint8_t max_ga)
 
bool _mag_set_samplerate (uint16_t frequency)
 

Private Attributes

AP_HAL::DigitalSource_drdy_pin_m
 
AP_HAL::OwnPtr< AP_HAL::Device_dev
 
float _mag_range_scale
 
float _mag_x_accum
 
float _mag_y_accum
 
float _mag_z_accum
 
int16_t _mag_x
 
int16_t _mag_y
 
int16_t _mag_z
 
uint8_t _accum_count
 
uint8_t _compass_instance
 
bool _initialised
 
uint8_t _mag_range_ga
 
uint8_t _mag_samplerate
 
uint8_t _reg7_expected
 

Additional Inherited Members

- Public Types inherited from AP_Compass_Backend
enum  DevTypes {
  DEVTYPE_HMC5883_OLD = 0x01, DEVTYPE_HMC5883 = 0x07, DEVTYPE_LSM303D = 0x02, DEVTYPE_AK8963 = 0x04,
  DEVTYPE_BMM150 = 0x05, DEVTYPE_LSM9DS1 = 0x06, DEVTYPE_LIS3MDL = 0x08, DEVTYPE_AK09916 = 0x09,
  DEVTYPE_IST8310 = 0x0A, DEVTYPE_ICM20948 = 0x0B, DEVTYPE_MMC3416 = 0x0C, DEVTYPE_QMC5883L = 0x0D,
  DEVTYPE_MAG3110 = 0x0E
}
 
- Protected Member Functions inherited from AP_Compass_Backend
void rotate_field (Vector3f &mag, uint8_t instance)
 
void publish_raw_field (const Vector3f &mag, uint8_t instance)
 
void correct_field (Vector3f &mag, uint8_t i)
 
void publish_filtered_field (const Vector3f &mag, uint8_t instance)
 
void set_last_update_usec (uint32_t last_update, uint8_t instance)
 
uint8_t register_compass (void) const
 
void set_dev_id (uint8_t instance, uint32_t dev_id)
 
void set_external (uint8_t instance, bool external)
 
bool is_external (uint8_t instance)
 
void set_rotation (uint8_t instance, enum Rotation rotation)
 
bool field_ok (const Vector3f &field)
 
uint32_t get_error_count () const
 
- Protected Attributes inherited from AP_Compass_Backend
Compass_compass
 
AP_HAL::Semaphore_sem
 

Detailed Description

Definition at line 11 of file AP_Compass_LSM303D.h.

Constructor & Destructor Documentation

◆ ~AP_Compass_LSM303D()

virtual AP_Compass_LSM303D::~AP_Compass_LSM303D ( )
inlinevirtual

Definition at line 22 of file AP_Compass_LSM303D.h.

Here is the call graph for this function:

◆ AP_Compass_LSM303D()

AP_Compass_LSM303D::AP_Compass_LSM303D ( Compass compass,
AP_HAL::OwnPtr< AP_HAL::Device dev 
)
private

Definition at line 153 of file AP_Compass_LSM303D.cpp.

Referenced by probe(), and ~AP_Compass_LSM303D().

Here is the caller graph for this function:

Member Function Documentation

◆ _block_read()

bool AP_Compass_LSM303D::_block_read ( uint8_t  reg,
uint8_t *  buf,
uint32_t  size 
)
private

Definition at line 185 of file AP_Compass_LSM303D.cpp.

Referenced by _read_sample(), and ~AP_Compass_LSM303D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _data_ready()

bool AP_Compass_LSM303D::_data_ready ( )
private

Return true if the LSM303D has new data available for both the mag and the accels.

Definition at line 210 of file AP_Compass_LSM303D.cpp.

Referenced by _hardware_init(), _read_sample(), and ~AP_Compass_LSM303D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _disable_i2c()

void AP_Compass_LSM303D::_disable_i2c ( )
private

Definition at line 398 of file AP_Compass_LSM303D.cpp.

Referenced by _hardware_init(), and ~AP_Compass_LSM303D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _hardware_init()

bool AP_Compass_LSM303D::_hardware_init ( )
private

Definition at line 284 of file AP_Compass_LSM303D.cpp.

Referenced by init(), and ~AP_Compass_LSM303D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _mag_set_range()

bool AP_Compass_LSM303D::_mag_set_range ( uint8_t  max_ga)
private

Definition at line 411 of file AP_Compass_LSM303D.cpp.

Referenced by _hardware_init(), and ~AP_Compass_LSM303D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _mag_set_samplerate()

bool AP_Compass_LSM303D::_mag_set_samplerate ( uint16_t  frequency)
private

Definition at line 447 of file AP_Compass_LSM303D.cpp.

Referenced by _hardware_init(), and ~AP_Compass_LSM303D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _read_sample()

bool AP_Compass_LSM303D::_read_sample ( )
private

Definition at line 217 of file AP_Compass_LSM303D.cpp.

Referenced by _update(), and ~AP_Compass_LSM303D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _register_modify()

void AP_Compass_LSM303D::_register_modify ( uint8_t  reg,
uint8_t  clearbits,
uint8_t  setbits 
)
private

Definition at line 196 of file AP_Compass_LSM303D.cpp.

Referenced by _mag_set_range(), _mag_set_samplerate(), and ~AP_Compass_LSM303D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _register_read()

uint8_t AP_Compass_LSM303D::_register_read ( uint8_t  reg)
private

Definition at line 175 of file AP_Compass_LSM303D.cpp.

Referenced by _disable_i2c(), _hardware_init(), _read_sample(), _register_modify(), and ~AP_Compass_LSM303D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _register_write()

void AP_Compass_LSM303D::_register_write ( uint8_t  reg,
uint8_t  val 
)
private

Definition at line 191 of file AP_Compass_LSM303D.cpp.

Referenced by _disable_i2c(), _hardware_init(), _register_modify(), and ~AP_Compass_LSM303D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _update()

void AP_Compass_LSM303D::_update ( )
private

Definition at line 338 of file AP_Compass_LSM303D.cpp.

Referenced by init(), and ~AP_Compass_LSM303D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

bool AP_Compass_LSM303D::init ( enum Rotation  rotation)
private

Definition at line 255 of file AP_Compass_LSM303D.cpp.

Referenced by probe(), and ~AP_Compass_LSM303D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ probe()

AP_Compass_Backend * AP_Compass_LSM303D::probe ( Compass compass,
AP_HAL::OwnPtr< AP_HAL::Device dev,
enum Rotation  rotation = ROTATION_NONE 
)
static

Definition at line 159 of file AP_Compass_LSM303D.cpp.

Referenced by Compass::_detect_backends().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read()

void AP_Compass_LSM303D::read ( void  )
overridevirtual

Implements AP_Compass_Backend.

Definition at line 371 of file AP_Compass_LSM303D.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ _accum_count

uint8_t AP_Compass_LSM303D::_accum_count
private

Definition at line 52 of file AP_Compass_LSM303D.h.

Referenced by _update(), and read().

◆ _compass_instance

uint8_t AP_Compass_LSM303D::_compass_instance
private

Definition at line 54 of file AP_Compass_LSM303D.h.

Referenced by _update(), init(), and read().

◆ _dev

AP_HAL::OwnPtr<AP_HAL::Device> AP_Compass_LSM303D::_dev
private

◆ _drdy_pin_m

AP_HAL::DigitalSource* AP_Compass_LSM303D::_drdy_pin_m
private

Definition at line 42 of file AP_Compass_LSM303D.h.

Referenced by _data_ready(), and init().

◆ _initialised

bool AP_Compass_LSM303D::_initialised
private

Definition at line 55 of file AP_Compass_LSM303D.h.

Referenced by init(), and read().

◆ _mag_range_ga

uint8_t AP_Compass_LSM303D::_mag_range_ga
private

Definition at line 57 of file AP_Compass_LSM303D.h.

Referenced by _mag_set_range().

◆ _mag_range_scale

float AP_Compass_LSM303D::_mag_range_scale
private

Definition at line 45 of file AP_Compass_LSM303D.h.

Referenced by _mag_set_range(), and _update().

◆ _mag_samplerate

uint8_t AP_Compass_LSM303D::_mag_samplerate
private

Definition at line 58 of file AP_Compass_LSM303D.h.

Referenced by _mag_set_samplerate().

◆ _mag_x

int16_t AP_Compass_LSM303D::_mag_x
private

Definition at line 49 of file AP_Compass_LSM303D.h.

Referenced by _read_sample(), and _update().

◆ _mag_x_accum

float AP_Compass_LSM303D::_mag_x_accum
private

Definition at line 46 of file AP_Compass_LSM303D.h.

Referenced by _update(), and read().

◆ _mag_y

int16_t AP_Compass_LSM303D::_mag_y
private

Definition at line 50 of file AP_Compass_LSM303D.h.

Referenced by _read_sample(), and _update().

◆ _mag_y_accum

float AP_Compass_LSM303D::_mag_y_accum
private

Definition at line 47 of file AP_Compass_LSM303D.h.

Referenced by _update(), and read().

◆ _mag_z

int16_t AP_Compass_LSM303D::_mag_z
private

Definition at line 51 of file AP_Compass_LSM303D.h.

Referenced by _read_sample(), and _update().

◆ _mag_z_accum

float AP_Compass_LSM303D::_mag_z_accum
private

Definition at line 48 of file AP_Compass_LSM303D.h.

Referenced by _update(), and read().

◆ _reg7_expected

uint8_t AP_Compass_LSM303D::_reg7_expected
private

Definition at line 59 of file AP_Compass_LSM303D.h.

Referenced by _hardware_init(), and _read_sample().

◆ name

constexpr const char* AP_Compass_LSM303D::name = "LSM303D"
static

Definition at line 18 of file AP_Compass_LSM303D.h.

Referenced by Compass::_detect_backends().


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