LibDriver AHT30  1.0.0
AHT30 full-featured driver
driver_aht30.h
Go to the documentation of this file.
1 
37 #ifndef DRIVER_AHT30_H
38 #define DRIVER_AHT30_H
39 
40 #include <stdio.h>
41 #include <stdint.h>
42 #include <string.h>
43 
44 #ifdef __cplusplus
45 extern "C"{
46 #endif
47 
62 typedef enum
63 {
64  AHT30_STATUS_BUSY = (1 << 7),
65  AHT30_STATUS_NOR_MODE = (0 << 5),
66  AHT30_STATUS_CYC_MODE = (1 << 5),
67  AHT30_STATUS_CMD_MODE = (2 << 5),
68  AHT30_STATUS_CRC_FLAG = (1 << 4),
70  AHT30_STATUS_CMP_INT = (1 << 2),
72 
76 typedef struct aht30_handle_s
77 {
78  uint8_t (*iic_init)(void);
79  uint8_t (*iic_deinit)(void);
80  uint8_t (*iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
81  uint8_t (*iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
82  void (*delay_ms)(uint32_t ms);
83  void (*debug_print)(const char *const fmt, ...);
84  uint8_t inited;
86 
90 typedef struct aht30_info_s
91 {
92  char chip_name[32];
93  char manufacturer_name[32];
94  char interface[8];
100  uint32_t driver_version;
102 
120 #define DRIVER_AHT30_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
121 
128 #define DRIVER_AHT30_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
129 
136 #define DRIVER_AHT30_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
137 
144 #define DRIVER_AHT30_LINK_IIC_READ_CMD(HANDLE, FUC) (HANDLE)->iic_read_cmd = FUC
145 
152 #define DRIVER_AHT30_LINK_IIC_WRITE_CMD(HANDLE, FUC) (HANDLE)->iic_write_cmd = FUC
153 
160 #define DRIVER_AHT30_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
161 
168 #define DRIVER_AHT30_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
169 
189 uint8_t aht30_info(aht30_info_t *info);
190 
203 uint8_t aht30_init(aht30_handle_t *handle);
204 
215 uint8_t aht30_deinit(aht30_handle_t *handle);
216 
233 uint8_t aht30_read_temperature_humidity(aht30_handle_t *handle, uint32_t *temperature_raw, float *temperature_s,
234  uint32_t *humidity_raw, uint8_t *humidity_s);
235 
250 uint8_t aht30_read_temperature(aht30_handle_t *handle, uint32_t *temperature_raw, float *temperature_s);
251 
266 uint8_t aht30_read_humidity(aht30_handle_t *handle, uint32_t *humidity_raw, uint8_t *humidity_s);
267 
279 uint8_t aht30_get_status(aht30_handle_t *handle, uint8_t *status);
280 
304 uint8_t aht30_set_reg(aht30_handle_t *handle, uint8_t *buf, uint16_t len);
305 
318 uint8_t aht30_get_reg(aht30_handle_t *handle, uint8_t *buf, uint16_t len);
319 
328 #ifdef __cplusplus
329 }
330 #endif
331 
332 #endif
uint8_t aht30_deinit(aht30_handle_t *handle)
close the chip
Definition: driver_aht30.c:279
uint8_t aht30_read_humidity(aht30_handle_t *handle, uint32_t *humidity_raw, uint8_t *humidity_s)
read the humidity data
Definition: driver_aht30.c:458
uint8_t aht30_read_temperature(aht30_handle_t *handle, uint32_t *temperature_raw, float *temperature_s)
read the temperature
Definition: driver_aht30.c:391
uint8_t aht30_init(aht30_handle_t *handle)
initialize the chip
Definition: driver_aht30.c:182
uint8_t aht30_read_temperature_humidity(aht30_handle_t *handle, uint32_t *temperature_raw, float *temperature_s, uint32_t *humidity_raw, uint8_t *humidity_s)
read the temperature and humidity data
Definition: driver_aht30.c:317
aht30_status_t
aht30 status enumeration definition
Definition: driver_aht30.h:63
struct aht30_handle_s aht30_handle_t
aht30 handle structure definition
uint8_t aht30_info(aht30_info_t *info)
get chip's information
Definition: driver_aht30.c:616
uint8_t aht30_get_status(aht30_handle_t *handle, uint8_t *status)
get status
Definition: driver_aht30.c:521
struct aht30_info_s aht30_info_t
aht30 information structure definition
@ AHT30_STATUS_BUSY
Definition: driver_aht30.h:64
@ AHT30_STATUS_CMP_INT
Definition: driver_aht30.h:70
@ AHT30_STATUS_CYC_MODE
Definition: driver_aht30.h:66
@ AHT30_STATUS_CRC_FLAG
Definition: driver_aht30.h:68
@ AHT30_STATUS_CMD_MODE
Definition: driver_aht30.h:67
@ AHT30_STATUS_CALIBRATION_ENABLE
Definition: driver_aht30.h:69
@ AHT30_STATUS_NOR_MODE
Definition: driver_aht30.h:65
uint8_t aht30_get_reg(aht30_handle_t *handle, uint8_t *buf, uint16_t len)
get the chip register
Definition: driver_aht30.c:587
uint8_t aht30_set_reg(aht30_handle_t *handle, uint8_t *buf, uint16_t len)
set the chip register
Definition: driver_aht30.c:554
aht30 handle structure definition
Definition: driver_aht30.h:77
uint8_t inited
Definition: driver_aht30.h:84
void(* delay_ms)(uint32_t ms)
Definition: driver_aht30.h:82
void(* debug_print)(const char *const fmt,...)
Definition: driver_aht30.h:83
uint8_t(* iic_init)(void)
Definition: driver_aht30.h:78
uint8_t(* iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
Definition: driver_aht30.h:80
uint8_t(* iic_deinit)(void)
Definition: driver_aht30.h:79
uint8_t(* iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
Definition: driver_aht30.h:81
aht30 information structure definition
Definition: driver_aht30.h:91
float temperature_max
Definition: driver_aht30.h:99
float supply_voltage_max_v
Definition: driver_aht30.h:96
uint32_t driver_version
Definition: driver_aht30.h:100
float temperature_min
Definition: driver_aht30.h:98
float max_current_ma
Definition: driver_aht30.h:97
char manufacturer_name[32]
Definition: driver_aht30.h:93
float supply_voltage_min_v
Definition: driver_aht30.h:95
char interface[8]
Definition: driver_aht30.h:94
char chip_name[32]
Definition: driver_aht30.h:92