LibDriver HMC5883L
Loading...
Searching...
No Matches
driver_hmc5883l.h
Go to the documentation of this file.
1
37
38#ifndef DRIVER_HMC5883L_H
39#define DRIVER_HMC5883L_H
40
41#include <stdio.h>
42#include <stdint.h>
43#include <string.h>
44
45#ifdef __cplusplus
46extern "C"{
47#endif
48
54
59
70
84
94
109
113typedef struct hmc5883l_handle_s
114{
115 uint8_t (*iic_init)(void);
116 uint8_t (*iic_deinit)(void);
117 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
118 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
119 void (*delay_ms)(uint32_t ms);
120 void (*debug_print)(const char *const fmt, ...);
121 uint8_t inited;
123
139
143
150
157#define DRIVER_HMC5883L_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
158
165#define DRIVER_HMC5883L_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
166
173#define DRIVER_HMC5883L_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
174
181#define DRIVER_HMC5883L_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
182
189#define DRIVER_HMC5883L_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
190
197#define DRIVER_HMC5883L_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
198
205#define DRIVER_HMC5883L_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
206
210
217
226uint8_t hmc5883l_info(hmc5883l_info_t *info);
227
238uint8_t hmc5883l_init(hmc5883l_handle_t *handle);
239
251uint8_t hmc5883l_deinit(hmc5883l_handle_t *handle);
252
265uint8_t hmc5883l_single_read(hmc5883l_handle_t *handle, int16_t raw[3], float m_gauss[3]);
266
278
290
303uint8_t hmc5883l_continuous_read(hmc5883l_handle_t *handle, int16_t raw[3], float m_gauss[3]);
304
317
330
343
356
369
382
395
408
420
432
436
443
457uint8_t hmc5883l_set_reg(hmc5883l_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
458
472uint8_t hmc5883l_get_reg(hmc5883l_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
473
477
481
482#ifdef __cplusplus
483}
484#endif
485
486#endif
uint8_t hmc5883l_set_mode(hmc5883l_handle_t *handle, hmc5883l_mode_t mode)
set the chip mode
hmc5883l_average_sample_t
hmc5883l average sample enumeration definition
hmc5883l_mode_t
hmc5883l mode enumeration definition
uint8_t hmc5883l_disable_high_speed_iic(hmc5883l_handle_t *handle)
disable the high speed iic
uint8_t hmc5883l_get_mode(hmc5883l_handle_t *handle, hmc5883l_mode_t *mode)
get the chip mode
uint8_t hmc5883l_set_gain(hmc5883l_handle_t *handle, hmc5883l_gain_t gain)
set the chip gain
uint8_t hmc5883l_set_average_sample(hmc5883l_handle_t *handle, hmc5883l_average_sample_t average_sample)
set the average sample rate
uint8_t hmc5883l_init(hmc5883l_handle_t *handle)
initialize the chip
uint8_t hmc5883l_continuous_read(hmc5883l_handle_t *handle, int16_t raw[3], float m_gauss[3])
read data continuously
uint8_t hmc5883l_set_data_output_rate(hmc5883l_handle_t *handle, hmc5883l_data_output_rate_t data_rate)
set the data output rate
uint8_t hmc5883l_info(hmc5883l_info_t *info)
get chip's information
uint8_t hmc5883l_deinit(hmc5883l_handle_t *handle)
close the chip
struct hmc5883l_handle_s hmc5883l_handle_t
hmc5883l handle structure definition
struct hmc5883l_info_s hmc5883l_info_t
hmc5883l information structure definition
hmc5883l_gain_t
hmc5883l gain enumeration definition
uint8_t hmc5883l_get_gain(hmc5883l_handle_t *handle, hmc5883l_gain_t *gain)
get the chip gain
hmc5883l_data_output_rate_t
hmc5883l data output rate enumeration definition
uint8_t hmc5883l_get_average_sample(hmc5883l_handle_t *handle, hmc5883l_average_sample_t *average_sample)
get the average sample rate
uint8_t hmc5883l_single_read(hmc5883l_handle_t *handle, int16_t raw[3], float m_gauss[3])
read data once
uint8_t hmc5883l_get_data_output_rate(hmc5883l_handle_t *handle, hmc5883l_data_output_rate_t *data_rate)
get the data output rate
uint8_t hmc5883l_start_continuous_read(hmc5883l_handle_t *handle)
start reading data
uint8_t hmc5883l_enable_high_speed_iic(hmc5883l_handle_t *handle)
enable the high speed iic
uint8_t hmc5883l_stop_continuous_read(hmc5883l_handle_t *handle)
stop reading data
@ HMC5883L_AVERAGE_SAMPLE_2
@ HMC5883L_AVERAGE_SAMPLE_1
@ HMC5883L_AVERAGE_SAMPLE_8
@ HMC5883L_AVERAGE_SAMPLE_4
@ HMC5883L_MODE_NEGATIVE_BIAS
@ HMC5883L_MODE_NORMAL
@ HMC5883L_MODE_POSITIVE_BIAS
@ HMC5883L_GAIN_390
@ HMC5883L_GAIN_330
@ HMC5883L_GAIN_1090
@ HMC5883L_GAIN_1370
@ HMC5883L_GAIN_820
@ HMC5883L_GAIN_230
@ HMC5883L_GAIN_440
@ HMC5883L_GAIN_660
@ HMC5883L_DATA_OUTPUT_RATE_15
@ HMC5883L_DATA_OUTPUT_RATE_0P75
@ HMC5883L_DATA_OUTPUT_RATE_1P5
@ HMC5883L_DATA_OUTPUT_RATE_3
@ HMC5883L_DATA_OUTPUT_RATE_30
@ HMC5883L_DATA_OUTPUT_RATE_75
@ HMC5883L_DATA_OUTPUT_RATE_7P5
uint8_t hmc5883l_get_reg(hmc5883l_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t hmc5883l_set_reg(hmc5883l_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
hmc5883l handle structure definition
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)
hmc5883l information structure definition
char manufacturer_name[32]