dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

Driver for Bosch LIS3MDL IMU Sensor (part of BMX055) More...

Data Structures

struct  pios_lis3mdl_cfg
 

Macros

#define LIS_ADDRESS_READ   0x80
 
#define LIS_ADDRESS_AUTOINCREMENT   0x40
 
#define LIS_WHO_AM_I_VAL   0x3d
 
#define LIS_CTRL1_TEMPEN   0x80
 
#define LIS_CTRL1_OPMODE_MASK   0x60
 
#define LIS_CTRL1_OPMODE_UHP   0x60 /* Ultra high perofrmance */
 
#define LIS_CTRL1_ODR_MASK   0x1c
 
#define LIS_CTRL1_ODR_80   0x1c /* Mfr recommended */
 
#define LIS_CTRL1_ODR_40   0x18
 
#define LIS_CTRL1_ODR_20   0x14
 
#define LIS_CTRL1_FASTODR   0x02 /* generates 155Hz with UHP */
 
#define LIS_CTRL1_SELFTEST   0x01
 
#define LIS_CTRL2_FS_MASK   0x60
 
#define LIS_CTRL2_FS_16GAU   0x60
 
#define LIS_CTRL2_FS_12GAU
 
#define LIS_RANGE_12GAU_COUNTS_PER_MGAU   2.281f
 
#define LIS_CTRL2_FS_8GAU   0x20
 
#define LIS_CTRL2_FS_4GAU   0x00
 
#define LIS_CTRL2_REBOOT   0x04
 
#define LIS_CTRL2_SOFTRST   0x02
 
#define LIS_CTRL3_LP   0x20
 
#define LIS_CTRL3_SPITHREEWIRE   0x04
 
#define LIS_CTRL3_MODE_MASK   0x03
 
#define LIS_CTRL3_MODE_CONTINUOUS   0x00
 
#define LIS_CTRL3_MODE_SINGLE   0x01
 
#define LIS_CTRL3_MODE_POWERDOWN   0x03
 
#define LIS_CTRL4_OPMODEZ_MASK   0x0c
 
#define LIS_CTRL4_OPMODEZ_UHP   0x0c
 
#define LIS_CTRL5_FASTREAD   0x80
 
#define LIS_CTRL5_BDU   0x40
 
#define LIS_STATUS_ZYXOR   0x80
 
#define LIS_STATUS_ZOR   0x40
 
#define LIS_STATUS_YOR   0x20
 
#define LIS_STATUS_XOR   0x10
 
#define LIS_STATUS_ZYXDA   0x08
 
#define LIS_STATUS_ZDA   0x04
 
#define LIS_STATUS_YDA   0x02
 
#define LIS_STATUS_XDA   0x01
 

Typedefs

typedef struct lis3mdl_dev * lis3mdl_dev_t
 

Enumerations

enum  pios_lis3mdl_orientation {
  PIOS_LIS_TOP_0DEG = 0x00, PIOS_LIS_TOP_90DEG = 0x01, PIOS_LIS_TOP_180DEG = 0x02, PIOS_LIS_TOP_270DEG = 0x03,
  PIOS_LIS_BOTTOM_0DEG = 0x04, PIOS_LIS_BOTTOM_90DEG = 0x05, PIOS_LIS_BOTTOM_180DEG = 0x06, PIOS_LIS_BOTTOM_270DEG = 0x07
}
 
enum  pios_lis3_regs {
  LIS_REG_MAG_WHO_AM_I = 0x0f, LIS_REG_MAG_CTRL1 = 0x20, LIS_REG_MAG_CTRL2, LIS_REG_MAG_CTRL3,
  LIS_REG_MAG_CTRL4, LIS_REG_MAG_CTRL5, LIS_REG_MAG_STATUS = 0x27, LIS_REG_MAG_OUTX_L,
  LIS_REG_MAG_OUTX_H, LIS_REG_MAG_OUTY_L, LIS_REG_MAG_OUTY_H, LIS_REG_MAG_OUTZ_L,
  LIS_REG_MAG_OUTZ_H, LIS_REG_MAG_TEMPOUT_L, LIS_REG_MAG_TEMPOUT_H, LIS_REG_MAG_INT_CFG,
  LIS_REG_MAG_INT_SRC, LIS_REG_MAG_INT_THS_L, LIS_REG_MAG_INT_THS_H
}
 

Functions

int32_t PIOS_LIS3MDL_SPI_Init (lis3mdl_dev_t *dev, pios_spi_t spi_id, uint32_t slave_mag, const struct pios_lis3mdl_cfg *cfg)
 Initialize the LIS3MDL mag. More...
 

Detailed Description

Driver for Bosch LIS3MDL IMU Sensor (part of BMX055)

Driver for LIS3MDL magnetometer.

Driver for ST LIS3MDL Magnetometer.

Macro Definition Documentation

#define LIS_ADDRESS_AUTOINCREMENT   0x40

Definition at line 54 of file pios_lis3mdl_priv.h.

#define LIS_ADDRESS_READ   0x80

Definition at line 53 of file pios_lis3mdl_priv.h.

#define LIS_CTRL1_FASTODR   0x02 /* generates 155Hz with UHP */

Definition at line 67 of file pios_lis3mdl_priv.h.

#define LIS_CTRL1_ODR_20   0x14

Definition at line 65 of file pios_lis3mdl_priv.h.

#define LIS_CTRL1_ODR_40   0x18

Definition at line 64 of file pios_lis3mdl_priv.h.

#define LIS_CTRL1_ODR_80   0x1c /* Mfr recommended */

Definition at line 63 of file pios_lis3mdl_priv.h.

#define LIS_CTRL1_ODR_MASK   0x1c

Definition at line 62 of file pios_lis3mdl_priv.h.

#define LIS_CTRL1_OPMODE_MASK   0x60

Definition at line 59 of file pios_lis3mdl_priv.h.

#define LIS_CTRL1_OPMODE_UHP   0x60 /* Ultra high perofrmance */

Definition at line 61 of file pios_lis3mdl_priv.h.

#define LIS_CTRL1_SELFTEST   0x01

Definition at line 68 of file pios_lis3mdl_priv.h.

#define LIS_CTRL1_TEMPEN   0x80

Definition at line 58 of file pios_lis3mdl_priv.h.

#define LIS_CTRL2_FS_12GAU
Value:
0x40 /* Mfr recommended; 2281
* counts/gauss. typ RMS
* noise seems to be about
* 3 milligauss or 7 counts
*/

Definition at line 72 of file pios_lis3mdl_priv.h.

#define LIS_CTRL2_FS_16GAU   0x60

Definition at line 71 of file pios_lis3mdl_priv.h.

#define LIS_CTRL2_FS_4GAU   0x00

Definition at line 80 of file pios_lis3mdl_priv.h.

#define LIS_CTRL2_FS_8GAU   0x20

Definition at line 79 of file pios_lis3mdl_priv.h.

#define LIS_CTRL2_FS_MASK   0x60

Definition at line 70 of file pios_lis3mdl_priv.h.

#define LIS_CTRL2_REBOOT   0x04

Definition at line 82 of file pios_lis3mdl_priv.h.

#define LIS_CTRL2_SOFTRST   0x02

Definition at line 83 of file pios_lis3mdl_priv.h.

#define LIS_CTRL3_LP   0x20

Definition at line 85 of file pios_lis3mdl_priv.h.

#define LIS_CTRL3_MODE_CONTINUOUS   0x00

Definition at line 89 of file pios_lis3mdl_priv.h.

#define LIS_CTRL3_MODE_MASK   0x03

Definition at line 87 of file pios_lis3mdl_priv.h.

#define LIS_CTRL3_MODE_POWERDOWN   0x03

Definition at line 91 of file pios_lis3mdl_priv.h.

#define LIS_CTRL3_MODE_SINGLE   0x01

Definition at line 90 of file pios_lis3mdl_priv.h.

#define LIS_CTRL3_SPITHREEWIRE   0x04

Definition at line 86 of file pios_lis3mdl_priv.h.

#define LIS_CTRL4_OPMODEZ_MASK   0x0c

Definition at line 93 of file pios_lis3mdl_priv.h.

#define LIS_CTRL4_OPMODEZ_UHP   0x0c

Definition at line 94 of file pios_lis3mdl_priv.h.

#define LIS_CTRL5_BDU   0x40

Definition at line 100 of file pios_lis3mdl_priv.h.

#define LIS_CTRL5_FASTREAD   0x80

Definition at line 99 of file pios_lis3mdl_priv.h.

#define LIS_RANGE_12GAU_COUNTS_PER_MGAU   2.281f

Definition at line 77 of file pios_lis3mdl_priv.h.

#define LIS_STATUS_XDA   0x01

Definition at line 109 of file pios_lis3mdl_priv.h.

#define LIS_STATUS_XOR   0x10

Definition at line 105 of file pios_lis3mdl_priv.h.

#define LIS_STATUS_YDA   0x02

Definition at line 108 of file pios_lis3mdl_priv.h.

#define LIS_STATUS_YOR   0x20

Definition at line 104 of file pios_lis3mdl_priv.h.

#define LIS_STATUS_ZDA   0x04

Definition at line 107 of file pios_lis3mdl_priv.h.

#define LIS_STATUS_ZOR   0x40

Definition at line 103 of file pios_lis3mdl_priv.h.

#define LIS_STATUS_ZYXDA   0x08

Definition at line 106 of file pios_lis3mdl_priv.h.

#define LIS_STATUS_ZYXOR   0x80

Definition at line 102 of file pios_lis3mdl_priv.h.

#define LIS_WHO_AM_I_VAL   0x3d

Definition at line 56 of file pios_lis3mdl_priv.h.

Typedef Documentation

typedef struct lis3mdl_dev* lis3mdl_dev_t

Definition at line 50 of file pios_lis3mdl.h.

Enumeration Type Documentation

Enumerator
LIS_REG_MAG_WHO_AM_I 
LIS_REG_MAG_CTRL1 
LIS_REG_MAG_CTRL2 
LIS_REG_MAG_CTRL3 
LIS_REG_MAG_CTRL4 
LIS_REG_MAG_CTRL5 
LIS_REG_MAG_STATUS 
LIS_REG_MAG_OUTX_L 
LIS_REG_MAG_OUTX_H 
LIS_REG_MAG_OUTY_L 
LIS_REG_MAG_OUTY_H 
LIS_REG_MAG_OUTZ_L 
LIS_REG_MAG_OUTZ_H 
LIS_REG_MAG_TEMPOUT_L 
LIS_REG_MAG_TEMPOUT_H 
LIS_REG_MAG_INT_CFG 
LIS_REG_MAG_INT_SRC 
LIS_REG_MAG_INT_THS_L 
LIS_REG_MAG_INT_THS_H 

Definition at line 31 of file pios_lis3mdl_priv.h.

Enumerator
PIOS_LIS_TOP_0DEG 
PIOS_LIS_TOP_90DEG 
PIOS_LIS_TOP_180DEG 
PIOS_LIS_TOP_270DEG 
PIOS_LIS_BOTTOM_0DEG 
PIOS_LIS_BOTTOM_90DEG 
PIOS_LIS_BOTTOM_180DEG 
PIOS_LIS_BOTTOM_270DEG 

Definition at line 35 of file pios_lis3mdl.h.

Function Documentation

int32_t PIOS_LIS3MDL_SPI_Init ( lis3mdl_dev_t dev,
pios_spi_t  spi_id,
uint32_t  slave_mag,
const struct pios_lis3mdl_cfg cfg 
)

Initialize the LIS3MDL mag.

Returns
0 for success, -1 for failure to allocate, -10 for failure to get irq