Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
lis3mdl.c File Reference
+ Include dependency graph for lis3mdl.c:

Go to the source code of this file.

Macros

#define LIS3MDL_ENABLE_AUTO_INC   (0x1<<7)
 
#define LIS3MDL_STATUS_ZYXOR   0b10000000
 
#define LIS3MDL_STATUS_ZOR   0b01000000
 
#define LIS3MDL_STATUS_YOR   0b00100000
 
#define LIS3MDL_STATUS_XOR   0b00010000
 
#define LIS3MDL_STATUS_ZYXDA   0b00001000
 
#define LIS3MDL_STATUS_ZDA   0b00000100
 
#define LIS3MDL_STATUS_YDA   0b00000010
 
#define LIS3MDL_STATUS_XDA   0b00000001
 
#define LIS3MDL_DEVICE_ID   0b00111101
 
#define LIS3MDL_REG_WHO_AM_I   0x0F
 
#define LIS3MDL_REG_CTL_1   0x20
 
#define LIS3MDL_REG_CTL_2   0x21
 
#define LIS3MDL_REG_CTL_3   0x22
 
#define LIS3MDL_REG_CTL_4   0x23
 
#define LIS3MDL_REG_STATUS   0x27
 
#define LIS3MDL_REG_OUT_X_L   0x28
 
#define LIS3MDL_REG_OUT_X_H   0x29
 
#define LIS3MDL_REG_OUT_Y_L   0x2A
 
#define LIS3MDL_REG_OUT_Y_H   0x2B
 
#define LIS3MDL_REG_OUT_Z_L   0x2C
 
#define LIS3MDL_REG_OUT_Z_H   0x2D
 
#define LIS3MDL_REG_OUT_TEMP_L   0x2E
 
#define LIS3MDL_REG_OUT_TEMP_H   0x2F
 
#define LIS3MDL_REG_CTL_1_TEMP_EN   0b10000000
 
#define LIS3MDL_REG_CTL_2_RESET   0b00000100
 
#define Int16FromBuf(_buf, _idx)   ((int16_t)(_buf[_idx] | (_buf[_idx+1] << 8)))
 

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_read (struct Lis3mdl *mag)
 
void lis3mdl_event (struct Lis3mdl *mag)
 

Detailed Description

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

Definition in file lis3mdl.c.

Macro Definition Documentation

◆ Int16FromBuf

#define Int16FromBuf (   _buf,
  _idx 
)    ((int16_t)(_buf[_idx] | (_buf[_idx+1] << 8)))

Definition at line 125 of file lis3mdl.c.

◆ LIS3MDL_DEVICE_ID

#define LIS3MDL_DEVICE_ID   0b00111101

Definition at line 40 of file lis3mdl.c.

◆ LIS3MDL_ENABLE_AUTO_INC

#define LIS3MDL_ENABLE_AUTO_INC   (0x1<<7)

Definition at line 29 of file lis3mdl.c.

◆ LIS3MDL_REG_CTL_1

#define LIS3MDL_REG_CTL_1   0x20

Definition at line 43 of file lis3mdl.c.

◆ LIS3MDL_REG_CTL_1_TEMP_EN

#define LIS3MDL_REG_CTL_1_TEMP_EN   0b10000000

Definition at line 57 of file lis3mdl.c.

◆ LIS3MDL_REG_CTL_2

#define LIS3MDL_REG_CTL_2   0x21

Definition at line 44 of file lis3mdl.c.

◆ LIS3MDL_REG_CTL_2_RESET

#define LIS3MDL_REG_CTL_2_RESET   0b00000100

Definition at line 58 of file lis3mdl.c.

◆ LIS3MDL_REG_CTL_3

#define LIS3MDL_REG_CTL_3   0x22

Definition at line 45 of file lis3mdl.c.

◆ LIS3MDL_REG_CTL_4

#define LIS3MDL_REG_CTL_4   0x23

Definition at line 46 of file lis3mdl.c.

◆ LIS3MDL_REG_OUT_TEMP_H

#define LIS3MDL_REG_OUT_TEMP_H   0x2F

Definition at line 55 of file lis3mdl.c.

◆ LIS3MDL_REG_OUT_TEMP_L

#define LIS3MDL_REG_OUT_TEMP_L   0x2E

Definition at line 54 of file lis3mdl.c.

◆ LIS3MDL_REG_OUT_X_H

#define LIS3MDL_REG_OUT_X_H   0x29

Definition at line 49 of file lis3mdl.c.

◆ LIS3MDL_REG_OUT_X_L

#define LIS3MDL_REG_OUT_X_L   0x28

Definition at line 48 of file lis3mdl.c.

◆ LIS3MDL_REG_OUT_Y_H

#define LIS3MDL_REG_OUT_Y_H   0x2B

Definition at line 51 of file lis3mdl.c.

◆ LIS3MDL_REG_OUT_Y_L

#define LIS3MDL_REG_OUT_Y_L   0x2A

Definition at line 50 of file lis3mdl.c.

◆ LIS3MDL_REG_OUT_Z_H

#define LIS3MDL_REG_OUT_Z_H   0x2D

Definition at line 53 of file lis3mdl.c.

◆ LIS3MDL_REG_OUT_Z_L

#define LIS3MDL_REG_OUT_Z_L   0x2C

Definition at line 52 of file lis3mdl.c.

◆ LIS3MDL_REG_STATUS

#define LIS3MDL_REG_STATUS   0x27

Definition at line 47 of file lis3mdl.c.

◆ LIS3MDL_REG_WHO_AM_I

#define LIS3MDL_REG_WHO_AM_I   0x0F

Definition at line 42 of file lis3mdl.c.

◆ LIS3MDL_STATUS_XDA

#define LIS3MDL_STATUS_XDA   0b00000001

Definition at line 38 of file lis3mdl.c.

◆ LIS3MDL_STATUS_XOR

#define LIS3MDL_STATUS_XOR   0b00010000

Definition at line 34 of file lis3mdl.c.

◆ LIS3MDL_STATUS_YDA

#define LIS3MDL_STATUS_YDA   0b00000010

Definition at line 37 of file lis3mdl.c.

◆ LIS3MDL_STATUS_YOR

#define LIS3MDL_STATUS_YOR   0b00100000

Definition at line 33 of file lis3mdl.c.

◆ LIS3MDL_STATUS_ZDA

#define LIS3MDL_STATUS_ZDA   0b00000100

Definition at line 36 of file lis3mdl.c.

◆ LIS3MDL_STATUS_ZOR

#define LIS3MDL_STATUS_ZOR   0b01000000

Definition at line 32 of file lis3mdl.c.

◆ LIS3MDL_STATUS_ZYXDA

#define LIS3MDL_STATUS_ZYXDA   0b00001000

Definition at line 35 of file lis3mdl.c.

◆ LIS3MDL_STATUS_ZYXOR

#define LIS3MDL_STATUS_ZYXOR   0b10000000

Definition at line 31 of file lis3mdl.c.

Function Documentation

◆ lis3mdl_configure()

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:

◆ lis3mdl_event()

◆ lis3mdl_init()

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 
)

◆ lis3mdl_read()

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: