LibDriver MS5837
Loading...
Searching...
No Matches
driver_ms5837.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_MS5837_H
38#define DRIVER_MS5837_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
68
81
85typedef struct ms5837_handle_s
86{
87 uint8_t (*iic_init)(void);
88 uint8_t (*iic_deinit)(void);
89 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
90 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
91 void (*delay_ms)(uint32_t ms);
92 void (*debug_print)(const char *const fmt, ...);
93 uint8_t prom[16];
94 uint16_t c[6];
95 uint8_t temp_osr;
96 uint8_t press_osr;
97 uint8_t type;
98 uint8_t inited;
100
116
120
127
134#define DRIVER_MS5837_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
135
142#define DRIVER_MS5837_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
143
150#define DRIVER_MS5837_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
151
158#define DRIVER_MS5837_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
159
166#define DRIVER_MS5837_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
167
174#define DRIVER_MS5837_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
175
182#define DRIVER_MS5837_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
183
187
194
203uint8_t ms5837_info(ms5837_info_t *info);
204
219uint8_t ms5837_init(ms5837_handle_t *handle);
220
232uint8_t ms5837_deinit(ms5837_handle_t *handle);
233
248uint8_t ms5837_read_temperature_pressure(ms5837_handle_t *handle, uint32_t *temperature_raw, float *temperature_c,
249 uint32_t *pressure_raw, float *pressure_mbar);
250
263uint8_t ms5837_read_pressure(ms5837_handle_t *handle, uint32_t *pressure_raw, float *pressure_mbar);
264
277uint8_t ms5837_read_temperature(ms5837_handle_t *handle, uint32_t *temperature_raw, float *temperature_c);
278
289uint8_t ms5837_set_type(ms5837_handle_t *handle, ms5837_type_t type);
290
301uint8_t ms5837_get_type(ms5837_handle_t *handle, ms5837_type_t *type);
302
315
327
340
352
363uint8_t ms5837_reset(ms5837_handle_t *handle);
364
368
375
389uint8_t ms5837_set_reg(ms5837_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
390
404uint8_t ms5837_get_reg(ms5837_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
405
409
413
414#ifdef __cplusplus
415}
416#endif
417
418#endif
ms5837_type_t
ms5837 type enumeration definition
uint8_t ms5837_read_temperature_pressure(ms5837_handle_t *handle, uint32_t *temperature_raw, float *temperature_c, uint32_t *pressure_raw, float *pressure_mbar)
read the temperature and pressure
uint8_t ms5837_deinit(ms5837_handle_t *handle)
close the chip
uint8_t ms5837_get_type(ms5837_handle_t *handle, ms5837_type_t *type)
get the device type
uint8_t ms5837_reset(ms5837_handle_t *handle)
reset the device
uint8_t ms5837_set_pressure_osr(ms5837_handle_t *handle, ms5837_osr_t osr)
set the adc pressure osr
struct ms5837_handle_s ms5837_handle_t
ms5837 handle structure definition
uint8_t ms5837_get_temperature_osr(ms5837_handle_t *handle, ms5837_osr_t *osr)
get the adc temperature osr
uint8_t ms5837_info(ms5837_info_t *info)
get chip's information
uint8_t ms5837_set_type(ms5837_handle_t *handle, ms5837_type_t type)
set the device type
uint8_t ms5837_read_temperature(ms5837_handle_t *handle, uint32_t *temperature_raw, float *temperature_c)
read the temperature
ms5837_osr_t
ms5837 osr enumeration definition
uint8_t ms5837_get_pressure_osr(ms5837_handle_t *handle, ms5837_osr_t *osr)
get the adc pressure osr
uint8_t ms5837_read_pressure(ms5837_handle_t *handle, uint32_t *pressure_raw, float *pressure_mbar)
read the pressure
struct ms5837_info_s ms5837_info_t
ms5837 information structure definition
uint8_t ms5837_init(ms5837_handle_t *handle)
initialize the chip
uint8_t ms5837_set_temperature_osr(ms5837_handle_t *handle, ms5837_osr_t osr)
set the adc temperature osr
@ MS5837_TYPE_02BA21
@ MS5837_TYPE_02BA01
@ MS5837_TYPE_30BA26
@ MS5837_OSR_8192
@ MS5837_OSR_256
@ MS5837_OSR_1024
@ MS5837_OSR_4096
@ MS5837_OSR_512
@ MS5837_OSR_2048
uint8_t ms5837_get_reg(ms5837_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t ms5837_set_reg(ms5837_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
ms5837 handle structure definition
void(* delay_ms)(uint32_t ms)
uint16_t c[6]
uint8_t prom[16]
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)
ms5837 information structure definition
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]