28 #define HMC58X3_ADDR 0x1E 29 #define HMC58X3_CRA 0x00 30 #define HMC58X3_CRB 0x01 31 #define HMC58X3_MODE 0x02 32 #define HMC58X3_DATA 0x03 33 #define HMC58X3_STATUS 0x09 34 #define HMC58X3_ID1 0x0A 35 #define HMC58X3_ID2 0x0B 36 #define HMC58X3_ID3 0x0C 38 #define HMC58X3_CRA_NO_AVG 0x00 39 #define HMC58X3_CRA_AVG_2_MEAS 0x20 40 #define HMC58X3_CRA_AVG_4_MEAS 0x40 41 #define HMC58X3_CRA_AVG_8_MEAS 0x60 43 #define HMC58X3_CRA_DO_0_75 0x00 44 #define HMC58X3_CRA_DO_1_5 0x04 45 #define HMC58X3_CRA_DO_3 0x08 46 #define HMC58X3_CRA_DO_7_5 0x0C 47 #define HMC58X3_CRA_DO_15 0x10 48 #define HMC58X3_CRA_DO_30 0x14 49 #define HMC58X3_CRA_DO_75 0x18 51 #define HMC58X3_CRA_MEAS_MODE_NORMAL 0x00 52 #define HMC58X3_CRA_MEAS_MODE_POS_BIAS 0x01 53 #define HMC58X3_CRA_MEAS_MODE_NEG_BIAS 0x02 55 #define HMC58X3_CRB_GN_1370 0x00 56 #define HMC58X3_CRB_GN_1090 0x20 57 #define HMC58X3_CRB_GN_820 0x40 58 #define HMC58X3_CRB_GN_660 0x60 59 #define HMC58X3_CRB_GN_440 0x80 60 #define HMC58X3_CRB_GN_390 0xA0 61 #define HMC58X3_CRB_GN_330 0xC0 62 #define HMC58X3_CRB_GN_230 0xE0 64 #define HMC58X3_MODE_HS 0x80 65 #define HMC58X3_MODE_CONTINUOUS 0x00 66 #define HMC58X3_MODE_SINGLE 0x01 67 #define HMC58X3_MODE_IDLE 0x02 69 #define HMC58X3_SR_LOCK 0x02 70 #define HMC58X3_SR_RDY 0x01 72 #define HMC58X3_TIMEOUT 30000 81 static void read_cb(uint8_t result);
140 mag_data[0] =
data_[0];
141 mag_data[1] =
data_[1];
142 mag_data[2] =
data_[2];
volatile uint32_t millis(void)
static uint32_t last_update_ms_
#define HMC58X3_CRA_MEAS_MODE_NORMAL
#define HMC58X3_CRA_DO_75
static uint8_t i2c_buf_[6]
#define HMC58X3_CRA_NO_AVG
void hmc5883l_async_read(float *mag_data)
bool i2cWrite(uint8_t addr_, uint8_t reg_, uint8_t data)
static uint32_t next_update_ms_
void i2c_queue_job(i2cJobType_t type, uint8_t addr_, uint8_t reg_, uint8_t *data, uint8_t length, volatile uint8_t *status_, void(*CB)(uint8_t))
#define HMC58X3_CRB_GN_390
static volatile float data_[3]
#define HMC58X3_MODE_CONTINUOUS
void hmc5883l_request_async_update()
static void read_cb(uint8_t result)