Paparazzi UAS  v5.15_devel-47-g0391b4d
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
lis3mdl.h File Reference

ST LIS3MDL 3-axis magnetometer driver interface (I2C). More...

#include "std.h"
#include "mcu_periph/i2c.h"
#include "math/pprz_algebra_int.h"
+ Include dependency graph for lis3mdl.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Lis3mdl
 
union  Lis3mdl.data
 

Macros

#define LIS3MDL_ADDR1   (0b0011110 << 1)
 
#define LIS3MDL_ADDR2   (0b0011100 << 1)
 
#define LIS3MDL_PERFORMANCE_LOW_POWER   0b00
 
#define LIS3MDL_PERFORMANCE_MEDIUM   0b01
 
#define LIS3MDL_PERFORMANCE_HIGH   0b10
 
#define LIS3MDL_PERFORMANCE_ULTRA_HIGH   0b11
 
#define LIS3MDL_DATA_RATE_0_625_HZ   0b000
 
#define LIS3MDL_DATA_RATE_1_25_HZ   0b001
 
#define LIS3MDL_DATA_RATE_2_5_HZ   0b010
 
#define LIS3MDL_DATA_RATE_5_HZ   0b011
 
#define LIS3MDL_DATA_RATE_10_HZ   0b100
 
#define LIS3MDL_DATA_RATE_20_HZ   0b101
 
#define LIS3MDL_DATA_RATE_40_HZ   0b110
 
#define LIS3MDL_DATA_RATE_80_HZ   0b111
 
#define LIS3MDL_MODE_CONTINUOUS   0b00
 
#define LIS3MDL_MODE_SINGLE   0b01
 
#define LIS3MDL_MODE_POWER_DOWN   0b11
 
#define LIS3MDL_SCALE_4_GAUSS   0b00
 
#define LIS3MDL_SCALE_8_GAUSS   0b01
 
#define LIS3MDL_SCALE_12_GAUSS   0b10
 
#define LIS3MDL_SCALE_16_GAUSS   0b11
 

Enumerations

enum  Lis3mdlStatus { LIS3MDL_CONF_UNINIT, LIS3MDL_CONF_REG, LIS3MDL_STATUS_IDLE, LIS3MDL_STATUS_MEAS }
 config status states More...
 

Functions

void lis3mdl_init (struct Lis3mdl *mag, struct i2c_periph *i2c_p, uint8_t addr, uint8_t data_rate, uint8_t scale, uint8_t mode, uint8_t perf)
 
void lis3mdl_configure (struct Lis3mdl *mag)
 
void lis3mdl_event (struct Lis3mdl *mag)
 
void lis3mdl_read (struct Lis3mdl *mag)
 
static void lis3mdl_periodic (struct Lis3mdl *mag)
 convenience function: read or start configuration if not already initialized More...
 

Detailed Description

ST LIS3MDL 3-axis magnetometer driver interface (I2C).

Definition in file lis3mdl.h.


Data Structure Documentation

struct Lis3mdl

Definition at line 69 of file lis3mdl.h.

+ Collaboration diagram for Lis3mdl:
Data Fields
union Lis3mdl data
volatile bool data_available data ready flag
struct i2c_periph * i2c_p peripheral used for communcation
struct i2c_transaction i2c_trans i2c transaction
bool initialized config done flag
enum Lis3mdlStatus status init status
union Lis3mdl.data

Definition at line 75 of file lis3mdl.h.

Data Fields
int16_t value[3] data values accessible by channel index
struct Int16Vect3 vect data vector in mag coordinate system

Macro Definition Documentation

#define LIS3MDL_ADDR1   (0b0011110 << 1)

Definition at line 34 of file lis3mdl.h.

Referenced by mag_lis3mdl_module_init().

#define LIS3MDL_ADDR2   (0b0011100 << 1)

Definition at line 35 of file lis3mdl.h.

#define LIS3MDL_DATA_RATE_0_625_HZ   0b000

Definition at line 42 of file lis3mdl.h.

#define LIS3MDL_DATA_RATE_10_HZ   0b100

Definition at line 46 of file lis3mdl.h.

#define LIS3MDL_DATA_RATE_1_25_HZ   0b001

Definition at line 43 of file lis3mdl.h.

#define LIS3MDL_DATA_RATE_20_HZ   0b101

Definition at line 47 of file lis3mdl.h.

#define LIS3MDL_DATA_RATE_2_5_HZ   0b010

Definition at line 44 of file lis3mdl.h.

#define LIS3MDL_DATA_RATE_40_HZ   0b110

Definition at line 48 of file lis3mdl.h.

#define LIS3MDL_DATA_RATE_5_HZ   0b011

Definition at line 45 of file lis3mdl.h.

#define LIS3MDL_DATA_RATE_80_HZ   0b111

Definition at line 49 of file lis3mdl.h.

Referenced by mag_lis3mdl_module_init().

#define LIS3MDL_MODE_CONTINUOUS   0b00

Definition at line 51 of file lis3mdl.h.

Referenced by mag_lis3mdl_module_init().

#define LIS3MDL_MODE_POWER_DOWN   0b11

Definition at line 53 of file lis3mdl.h.

#define LIS3MDL_MODE_SINGLE   0b01

Definition at line 52 of file lis3mdl.h.

#define LIS3MDL_PERFORMANCE_HIGH   0b10

Definition at line 39 of file lis3mdl.h.

#define LIS3MDL_PERFORMANCE_LOW_POWER   0b00

Definition at line 37 of file lis3mdl.h.

#define LIS3MDL_PERFORMANCE_MEDIUM   0b01

Definition at line 38 of file lis3mdl.h.

#define LIS3MDL_PERFORMANCE_ULTRA_HIGH   0b11

Definition at line 40 of file lis3mdl.h.

Referenced by mag_lis3mdl_module_init().

#define LIS3MDL_SCALE_12_GAUSS   0b10

Definition at line 57 of file lis3mdl.h.

#define LIS3MDL_SCALE_16_GAUSS   0b11

Definition at line 58 of file lis3mdl.h.

#define LIS3MDL_SCALE_4_GAUSS   0b00

Definition at line 55 of file lis3mdl.h.

Referenced by mag_lis3mdl_module_init().

#define LIS3MDL_SCALE_8_GAUSS   0b01

Definition at line 56 of file lis3mdl.h.

Enumeration Type Documentation

config status states

Enumerator
LIS3MDL_CONF_UNINIT 
LIS3MDL_CONF_REG 
LIS3MDL_STATUS_IDLE 
LIS3MDL_STATUS_MEAS 

Definition at line 61 of file lis3mdl.h.

Function Documentation

void lis3mdl_configure ( struct Lis3mdl mag)

Definition at line 82 of file lis3mdl.c.

References Lis3mdl::i2c_p, Lis3mdl::i2c_trans, i2c_transmit(), I2CTransDone, I2CTransFailed, I2CTransSuccess, Lis3mdl::initialized, LIS3MDL_CONF_REG, LIS3MDL_CONF_UNINIT, LIS3MDL_STATUS_IDLE, i2c_transaction::slave_addr, Lis3mdl::status, and i2c_transaction::status.

Referenced by lis3mdl_periodic().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void lis3mdl_init ( struct Lis3mdl mag,
struct i2c_periph i2c_p,
uint8_t  addr,
uint8_t  data_rate,
uint8_t  scale,
uint8_t  mode,
uint8_t  perf 
)
static void lis3mdl_periodic ( struct Lis3mdl mag)
inlinestatic

convenience function: read or start configuration if not already initialized

Definition at line 88 of file lis3mdl.h.

References Lis3mdl::initialized, lis3mdl_configure(), and lis3mdl_read().

Referenced by mag_lis3mdl_module_periodic().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void lis3mdl_read ( struct Lis3mdl mag)

Definition at line 113 of file lis3mdl.c.

References i2c_transaction::buf, Lis3mdl::i2c_p, Lis3mdl::i2c_trans, i2c_transceive(), LIS3MDL_ENABLE_AUTO_INC, LIS3MDL_REG_STATUS, LIS3MDL_STATUS_IDLE, LIS3MDL_STATUS_MEAS, i2c_transaction::slave_addr, and Lis3mdl::status.

Referenced by lis3mdl_periodic().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: