42#define CHIP_NAME                 "ASAIR AHT10"         
   43#define MANUFACTURER_NAME         "ASAIR"               
   44#define SUPPLY_VOLTAGE_MIN        1.8f                  
   45#define SUPPLY_VOLTAGE_MAX        3.6f                  
   46#define MAX_CURRENT               10.0f                 
   47#define TEMPERATURE_MIN           -40.0f                
   48#define TEMPERATURE_MAX           85.0f                 
   49#define DRIVER_VERSION            1000                  
   54#define AHT10_ADDRESS             0x70         
   66static uint8_t a_aht10_iic_read(
aht10_handle_t *handle, uint8_t *data, uint16_t len)
 
   86static uint8_t a_aht10_iic_write(
aht10_handle_t *handle, uint8_t *data, uint16_t len)
 
  111    uint8_t soft_reset = 0xBA;
 
  129        handle->
debug_print(
"aht10: iic_deinit is null.\n");           
 
  135        handle->
debug_print(
"aht10: iic_read_cmd is null.\n");         
 
  141        handle->
debug_print(
"aht10: iic_write_cmd is null.\n");        
 
  159    if (a_aht10_iic_write(handle, &soft_reset, 1) != 0)                
 
  167    if (a_aht10_iic_read(handle, &status, 1) != 0)                     
 
  169        handle->
debug_print(
"aht10: read status failed.\n");           
 
  174    if ((status & (1 << 3)) == 0)                                      
 
  176        uint8_t cmd[] = {0xE1, 0x08, 0x00};
 
  178        if (a_aht10_iic_write(handle, cmd, 3) != 0)                    
 
 
  215        handle->
debug_print(
"aht10: iic deinit failed.\n");        
 
 
  240                                        uint32_t *humidity_raw, uint8_t *humidity_s)
 
  256    if (a_aht10_iic_write(handle, buf, 3) != 0)                       
 
  258        handle->
debug_print(
"aht10: sent command failed.\n");         
 
  263    if (a_aht10_iic_read(handle, buf, 6) != 0)                        
 
  269    if ((buf[0] & 0x80) == 0)                                         
 
  271        *humidity_raw = (((uint32_t)buf[1]) << 16) |
 
  272                        (((uint32_t)buf[2]) << 8) |
 
  273                        (((uint32_t)buf[3]) << 0);                    
 
  274        *humidity_raw = (*humidity_raw) >> 4;                         
 
  275        *humidity_s = (uint8_t)((
float)(*humidity_raw)
 
  276                                / 1048576.0f * 100.0f);               
 
  277        *temperature_raw = (((uint32_t)buf[3]) << 16) |
 
  278                           (((uint32_t)buf[4]) << 8) |
 
  279                           (((uint32_t)buf[5]) << 0);                 
 
  280        *temperature_raw = (*temperature_raw) & 0xFFFFF;              
 
  281        *temperature_s = (float)(*temperature_raw) 
 
  282                                 / 1048576.0f * 200.0f
 
  289        handle->
debug_print(
"aht10: data is not ready.\n");           
 
 
  324    if (a_aht10_iic_write(handle, buf, 3) != 0)                       
 
  326        handle->
debug_print(
"aht10: sent command failed.\n");         
 
  331    if (a_aht10_iic_read(handle, buf, 6) != 0)                        
 
  337    if ((buf[0] & 0x80) == 0)                                         
 
  339        *temperature_raw = (((uint32_t)buf[3]) << 16) |
 
  340                           (((uint32_t)buf[4]) << 8) |
 
  341                           (((uint32_t)buf[5]) << 0);                 
 
  342        *temperature_raw = (*temperature_raw) & 0xFFFFF;              
 
  343        *temperature_s = (float)(*temperature_raw) 
 
  344                                 / 1048576.0f * 200.0f
 
  351        handle->
debug_print(
"aht10: data is not ready.\n");           
 
 
  386    if (a_aht10_iic_write(handle, buf, 3) != 0)                       
 
  388        handle->
debug_print(
"aht10: sent command failed.\n");         
 
  393    if (a_aht10_iic_read(handle, buf, 6) != 0)                        
 
  399    if ((buf[0] & 0x80) == 0)                                         
 
  401        *humidity_raw = (((uint32_t)buf[1]) << 16) |
 
  402                        (((uint32_t)buf[2]) << 8) |
 
  403                        (((uint32_t)buf[3]) << 0);                    
 
  404        *humidity_raw = (*humidity_raw) >> 4;                         
 
  405        *humidity_s = (uint8_t)((
float)(*humidity_raw)
 
  406                                / 1048576.0f * 100.0f);               
 
  412        handle->
debug_print(
"aht10: data is not ready.\n");           
 
 
  441    if (a_aht10_iic_write(handle, buf, len) != 0)        
 
 
  474    if (a_aht10_iic_read(handle, buf, len) != 0)        
 
 
#define AHT10_ADDRESS
chip address definition
#define SUPPLY_VOLTAGE_MAX
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define CHIP_NAME
chip information definition
struct aht10_handle_s aht10_handle_t
aht10 handle structure definition
struct aht10_info_s aht10_info_t
aht10 information structure definition
uint8_t aht10_read_temperature(aht10_handle_t *handle, uint32_t *temperature_raw, float *temperature_s)
read the temperature
uint8_t aht10_init(aht10_handle_t *handle)
initialize the chip
uint8_t aht10_read_humidity(aht10_handle_t *handle, uint32_t *humidity_raw, uint8_t *humidity_s)
read the humidity data
uint8_t aht10_deinit(aht10_handle_t *handle)
close the chip
uint8_t aht10_read_temperature_humidity(aht10_handle_t *handle, uint32_t *temperature_raw, float *temperature_s, uint32_t *humidity_raw, uint8_t *humidity_s)
read the temperature and humidity data
uint8_t aht10_info(aht10_info_t *info)
get chip's information
uint8_t aht10_set_reg(aht10_handle_t *handle, uint8_t *buf, uint16_t len)
set the chip register
uint8_t aht10_get_reg(aht10_handle_t *handle, 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_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
uint8_t(* iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v