42#define CHIP_NAME "QST QMC5883L"
43#define MANUFACTURER_NAME "QST"
44#define SUPPLY_VOLTAGE_MIN 2.16f
45#define SUPPLY_VOLTAGE_MAX 3.6f
46#define MAX_CURRENT 2.6f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 85.0f
49#define DRIVER_VERSION 1000
54#define QMC5883L_ADDRESS 0x1A
59#define QMC5883L_REG_X_LSB 0x00
60#define QMC5883L_REG_X_MSB 0x01
61#define QMC5883L_REG_Y_LSB 0x02
62#define QMC5883L_REG_Y_MSB 0x03
63#define QMC5883L_REG_Z_LSB 0x04
64#define QMC5883L_REG_Z_MSB 0x05
65#define QMC5883L_REG_STATUS 0x06
66#define QMC5883L_REG_TEMP_LSB 0x07
67#define QMC5883L_REG_TEMP_MSB 0x08
68#define QMC5883L_REG_CONTROL1 0x09
69#define QMC5883L_REG_CONTROL2 0x0A
70#define QMC5883L_REG_PERIOD 0x0B
71#define QMC5883L_REG_ID 0x0D
101 handle->
debug_print(
"qmc5883l: iic_init is null.\n");
107 handle->
debug_print(
"qmc5883l: iic_deinit is null.\n");
113 handle->
debug_print(
"qmc5883l: iic_read is null.\n");
119 handle->
debug_print(
"qmc5883l: iic_write is null.\n");
125 handle->
debug_print(
"qmc5883l: delay_ms is null.\n");
132 handle->
debug_print(
"qmc5883l: iic init failed.\n");
163 handle->
debug_print(
"qmc5883l: write control1.\n");
211 handle->
debug_print(
"qmc5883l: write control1.\n");
218 handle->
debug_print(
"qmc5883l: iic deinit failed.\n");
254 handle->
debug_print(
"qmc5883l: read status failed.\n");
293 handle->
debug_print(
"qmc5883l: read temp failed.\n");
297 *raw = (int16_t)(((uint16_t)(buf[1]) << 8) | buf[0]);
298 *deg = (float)(*raw) / 100.0f;
340 handle->
debug_print(
"qmc5883l: write control1.\n");
422 handle->
debug_print(
"qmc5883l: write control1.\n");
504 handle->
debug_print(
"qmc5883l: write control1.\n");
586 handle->
debug_print(
"qmc5883l: write control1.\n");
664 prev |= (!enable) << 0;
668 handle->
debug_print(
"qmc5883l: write control1.\n");
750 handle->
debug_print(
"qmc5883l: write control1.\n");
831 handle->
debug_print(
"qmc5883l: write control1.\n");
945 handle->
debug_print(
"qmc5883l: read control1 failed.\n");
954 resolution = 1000.0f / 12000.0f;
960 resolution = 1000.0f / 3000.0f;
980 if ((status & 0x01) != 0)
988 handle->
debug_print(
"qmc5883l: ready bit not be set.\n");
996 handle->
debug_print(
"qmc5883l: read data failed.\n");
1000 raw[0] = (int16_t)(((uint16_t)buf[1] << 8) | buf[0]);
1001 raw[1] = (int16_t)(((uint16_t)buf[3] << 8) | buf[2]);
1002 raw[2] = (int16_t)(((uint16_t)buf[5] << 8) | buf[4]);
1003 m_gauss[0] = (float)(raw[0]) * resolution;
1004 m_gauss[1] = (float)(raw[1]) * resolution;
1005 m_gauss[2] = (float)(raw[2]) * resolution;
#define QMC5883L_REG_PERIOD
#define SUPPLY_VOLTAGE_MAX
#define QMC5883L_REG_X_LSB
chip register definition
#define QMC5883L_REG_STATUS
#define QMC5883L_REG_CONTROL1
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define QMC5883L_REG_TEMP_LSB
#define QMC5883L_REG_CONTROL2
#define CHIP_NAME
chip information definition
#define QMC5883L_ADDRESS
iic address definition
driver qmc5883l header file
uint8_t qmc5883l_set_full_scale(qmc5883l_handle_t *handle, qmc5883l_full_scale_t scale)
set the full scale
uint8_t qmc5883l_read(qmc5883l_handle_t *handle, int16_t raw[3], float m_gauss[3])
read data
uint8_t qmc5883l_get_pointer_roll_over(qmc5883l_handle_t *handle, qmc5883l_bool_t *enable)
get pointer roll over status
uint8_t qmc5883l_get_over_sample(qmc5883l_handle_t *handle, qmc5883l_over_sample_t *sample)
get the over sample
uint8_t qmc5883l_get_full_scale(qmc5883l_handle_t *handle, qmc5883l_full_scale_t *scale)
get the full scale
uint8_t qmc5883l_get_period(qmc5883l_handle_t *handle, uint8_t *fbr)
get period
uint8_t qmc5883l_set_over_sample(qmc5883l_handle_t *handle, qmc5883l_over_sample_t sample)
set the over sample
uint8_t qmc5883l_get_interrupt(qmc5883l_handle_t *handle, qmc5883l_bool_t *enable)
get interrupt status
uint8_t qmc5883l_init(qmc5883l_handle_t *handle)
initialize the chip
qmc5883l_full_scale_t
qmc5883l full scale enumeration definition
uint8_t qmc5883l_set_pointer_roll_over(qmc5883l_handle_t *handle, qmc5883l_bool_t enable)
enable or disable pointer roll over
struct qmc5883l_handle_s qmc5883l_handle_t
qmc5883l handle structure definition
uint8_t qmc5883l_get_status(qmc5883l_handle_t *handle, uint8_t *status)
get status
uint8_t qmc5883l_set_interrupt(qmc5883l_handle_t *handle, qmc5883l_bool_t enable)
enable or disable interrupt
uint8_t qmc5883l_info(qmc5883l_info_t *info)
get chip's information
uint8_t qmc5883l_set_period(qmc5883l_handle_t *handle, uint8_t fbr)
set period
uint8_t qmc5883l_get_output_rate(qmc5883l_handle_t *handle, qmc5883l_output_rate_t *rate)
get the output rate
uint8_t qmc5883l_read_temperature(qmc5883l_handle_t *handle, int16_t *raw, float *deg)
read temperature
uint8_t qmc5883l_deinit(qmc5883l_handle_t *handle)
close the chip
uint8_t qmc5883l_set_output_rate(qmc5883l_handle_t *handle, qmc5883l_output_rate_t rate)
set the output rate
qmc5883l_bool_t
qmc5883l bool enumeration definition
struct qmc5883l_info_s qmc5883l_info_t
qmc5883l information structure definition
qmc5883l_output_rate_t
qmc5883l output rate enumeration definition
qmc5883l_mode_t
qmc5883l mode enumeration definition
qmc5883l_over_sample_t
qmc5883l over sample enumeration definition
uint8_t qmc5883l_soft_reset(qmc5883l_handle_t *handle)
soft reset
uint8_t qmc5883l_get_mode(qmc5883l_handle_t *handle, qmc5883l_mode_t *mode)
get the chip mode
uint8_t qmc5883l_set_mode(qmc5883l_handle_t *handle, qmc5883l_mode_t mode)
set the chip mode
uint8_t qmc5883l_set_reg(qmc5883l_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t qmc5883l_get_reg(qmc5883l_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v