29 #define RM3100_ADDR_POLL 0x00
30 #define RM3100_ADDR_CMM 0x01
31 #define RM3100_ADDR_CCX 0x04
32 #define RM3100_ADDR_CCY 0x06
33 #define RM3100_ADDR_CCZ 0x08
34 #define RM3100_ADDR_TMRC 0x0B
35 #define RM3100_ADDR_MX 0x24
36 #define RM3100_ADDR_MY 0x27
37 #define RM3100_ADDR_MZ 0x2A
38 #define RM3100_ADDR_BIST 0x33
39 #define RM3100_ADDR_STATUS 0x34
40 #define RM3100_ADDR_HSHAKE 0x35
41 #define RM3100_ADDR_REVID 0x36
43 #define RM3100_CCX_DEFAULT_MSB 0x00
44 #define RM3100_CCX_DEFAULT_LSB 0xC8
45 #define RM3100_CCY_DEFAULT_MSB RM3100_CCX_DEFAULT_MSB
46 #define RM3100_CCY_DEFAULT_LSB RM3100_CCX_DEFAULT_LSB
47 #define RM3100_CCZ_DEFAULT_MSB RM3100_CCX_DEFAULT_MSB
48 #define RM3100_CCZ_DEFAULT_LSB RM3100_CCX_DEFAULT_LSB
49 #define RM3100_CMM_DEFAULT 0x70
50 #define RM3100_CONTINUOUS_MODE (1 << 0)
51 #define RM3100_POLLING_MODE (0 << 0)
52 #define RM3100_BIST_SELFTEST 0x8F
53 #define RM3100_BIST_DEFAULT 0x00
54 #define RM3100_BIST_XYZ_OK ((1 << 4) | (1 << 5) | (1 << 6))
55 #define RM3100_STATUS_DRDY (1 << 7)
56 #define RM3100_POLL_XYZ 0x70
57 #define RM3100_RM3100_REVID 0x22
149 return (
int32_t)(raw << shift) >> shift;
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
enum I2CTransactionStatus status
Transaction status.
uint8_t slave_addr
Slave address.
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
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.
@ I2CTransSuccess
transaction successfully finished by I2C driver
@ I2CTransFailed
transaction failed
@ I2CTransDone
transaction set to done by user level
#define RM3100_CCX_DEFAULT_LSB
void rm3100_init(struct Rm3100 *mag, struct i2c_periph *i2c_p, uint8_t addr, uint8_t data_rate)
#define RM3100_CCZ_DEFAULT_LSB
#define RM3100_CCY_DEFAULT_LSB
#define RM3100_CONTINUOUS_MODE
#define RM3100_CCX_DEFAULT_MSB
#define RM3100_CCY_DEFAULT_MSB
#define RM3100_CCZ_DEFAULT_MSB
void rm3100_read(struct Rm3100 *mag)
void rm3100_configure(struct Rm3100 *mag)
void rm3100_event(struct Rm3100 *mag)
static int32_t rm3100_get_raw_from_buf(const volatile uint8_t *buf, uint8_t idx)
PNI RM3100 3-axis magnetometer driver interface (I2C).
enum Rm3100Status status
init status
bool initialized
config done flag
struct i2c_transaction i2c_trans
i2c transaction
struct i2c_periph * i2c_p
peripheral used for communcation
volatile bool data_available
data ready flag
uint8_t data_rate
sensor data rate
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.