29 #define LIS3MDL_ENABLE_AUTO_INC (0x1<<7)
31 #define LIS3MDL_STATUS_ZYXOR 0b10000000
32 #define LIS3MDL_STATUS_ZOR 0b01000000
33 #define LIS3MDL_STATUS_YOR 0b00100000
34 #define LIS3MDL_STATUS_XOR 0b00010000
35 #define LIS3MDL_STATUS_ZYXDA 0b00001000
36 #define LIS3MDL_STATUS_ZDA 0b00000100
37 #define LIS3MDL_STATUS_YDA 0b00000010
38 #define LIS3MDL_STATUS_XDA 0b00000001
40 #define LIS3MDL_DEVICE_ID 0b00111101
42 #define LIS3MDL_REG_WHO_AM_I 0x0F
43 #define LIS3MDL_REG_CTL_1 0x20
44 #define LIS3MDL_REG_CTL_2 0x21
45 #define LIS3MDL_REG_CTL_3 0x22
46 #define LIS3MDL_REG_CTL_4 0x23
47 #define LIS3MDL_REG_STATUS 0x27
48 #define LIS3MDL_REG_OUT_X_L 0x28
49 #define LIS3MDL_REG_OUT_X_H 0x29
50 #define LIS3MDL_REG_OUT_Y_L 0x2A
51 #define LIS3MDL_REG_OUT_Y_H 0x2B
52 #define LIS3MDL_REG_OUT_Z_L 0x2C
53 #define LIS3MDL_REG_OUT_Z_H 0x2D
54 #define LIS3MDL_REG_OUT_TEMP_L 0x2E
55 #define LIS3MDL_REG_OUT_TEMP_H 0x2F
57 #define LIS3MDL_REG_CTL_1_TEMP_EN 0b10000000
58 #define LIS3MDL_REG_CTL_2_RESET 0b00000100
125 #define Int16FromBuf(_buf,_idx) ((int16_t)(_buf[_idx] | (_buf[_idx+1] << 8)))
struct i2c_transaction i2c_trans
i2c transaction
#define LIS3MDL_ENABLE_AUTO_INC
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
transaction successfully finished by I2C driver
void lis3mdl_read(struct Lis3mdl *mag)
#define Int16FromBuf(_buf, _idx)
struct i2c_periph * i2c_p
peripheral used for communcation
transaction set to done by user level
void lis3mdl_configure(struct Lis3mdl *mag)
bool i2c_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction.
ST LIS3MDL 3-axis magnetometer driver interface (I2C).
enum I2CTransactionStatus status
Transaction status.
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
#define LIS3MDL_REG_STATUS
static const float scale[]
uint8_t slave_addr
Slave address.
static uint8_t mode
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used...
enum Lis3mdlStatus status
init status
#define LIS3MDL_STATUS_ZYXDA
void lis3mdl_event(struct Lis3mdl *mag)
volatile bool data_available
data ready flag
bool initialized
config done flag
#define LIS3MDL_REG_CTL_1
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)