42#define CHIP_NAME                 "ASAIR AGS02MA"       
   43#define MANUFACTURER_NAME         "ASAIR"               
   44#define SUPPLY_VOLTAGE_MIN        3.3f                  
   45#define SUPPLY_VOLTAGE_MAX        5.5f                  
   46#define MAX_CURRENT               33.0f                 
   47#define TEMPERATURE_MIN           0.0f                  
   48#define TEMPERATURE_MAX           50.0f                 
   49#define DRIVER_VERSION            1000                  
   54#define AGS02MA_ADDRESS             (0x1A << 1)           
   59#define AGS02MA_REG_DATA                0x00         
   60#define AGS02MA_REG_CALIBRATION         0x01         
   61#define AGS02MA_REG_VERSION             0x11         
   62#define AGS02MA_REG_RESISTANCE          0x20         
   63#define AGS02MA_REG_SLAVE_ADDR          0x21         
   76static uint8_t a_ags02ma_iic_read(
ags02ma_handle_t *handle, uint8_t reg, uint8_t *data, uint16_t len)
 
  102static uint8_t a_ags02ma_iic_write(
ags02ma_handle_t *handle, uint8_t reg, uint8_t *data, uint16_t len)
 
  119static uint8_t a_ags02ma_calc_crc(uint8_t *data, uint8_t len)
 
  125    for (
byte = 0; 
byte < len; 
byte++)          
 
  128        for (i = 0; i < 8; i++)                 
 
  130            if ((crc & 0x80) != 0)              
 
  132                crc = (crc << 1) ^ 0x31;        
 
  166        handle->
debug_print(
"ags02ma: iic_init is null.\n");           
 
  172        handle->
debug_print(
"ags02ma: iic_deinit is null.\n");         
 
  178        handle->
debug_print(
"ags02ma: iic_read_cmd is null.\n");       
 
  184        handle->
debug_print(
"ags02ma: iic_write_cmd is null.\n");      
 
  190        handle->
debug_print(
"ags02ma: iic_write is null.\n");          
 
  196        handle->
debug_print(
"ags02ma: delay_ms is null.\n");           
 
  203        handle->
debug_print(
"ags02ma: iic init failed.\n");            
 
 
  236        handle->
debug_print(
"ags02ma: iic deinit failed.\n");      
 
 
  328        handle->
debug_print(
"ags02ma: read tvoc failed.\n");          
 
  332    if (a_ags02ma_calc_crc(buf, 4) != buf[4])                         
 
  338    if ((buf[0] & 0x01) != 0)                                         
 
  344    *raw = (uint32_t)(buf[1]) << 16 |
 
  345           (uint32_t)(buf[2]) << 8 |
 
  346           (uint32_t)(buf[3]) << 0;                                   
 
 
  380    buf[4] = a_ags02ma_calc_crc(buf, 4);                                   
 
  384        handle->
debug_print(
"ags02ma: write calibration failed.\n");       
 
 
  423        handle->
debug_print(
"ags02ma: read resistance failed.\n");       
 
  427    if (a_ags02ma_calc_crc(buf, 4) != buf[4])                            
 
  433    *raw = (uint32_t)(buf[0]) << 24 |
 
  434           (uint32_t)(buf[1]) << 16 |
 
  435           (uint32_t)(buf[2]) << 8 |
 
  436           (uint32_t)(buf[3]) << 0;                                      
 
  437    *ohm = (double)(*raw) * 100.0;                                       
 
 
  471        handle->
debug_print(
"ags02ma: read version failed.\n");       
 
  475    if (a_ags02ma_calc_crc(buf, 4) != buf[4])                         
 
 
  516    buf[4] = a_ags02ma_calc_crc(buf, 4);                                     
 
  520        handle->
debug_print(
"ags02ma: modify slave address failed.\n");      
 
 
  554    if (a_ags02ma_iic_write(handle, reg, buf, len) != 0)   
 
 
  586    if (a_ags02ma_iic_read(handle, reg, buf, len) != 0)   
 
 
#define AGS02MA_REG_VERSION
#define AGS02MA_REG_DATA
chip register definition
#define SUPPLY_VOLTAGE_MAX
#define AGS02MA_REG_RESISTANCE
#define AGS02MA_ADDRESS
chip address definition
#define AGS02MA_REG_SLAVE_ADDR
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define AGS02MA_REG_CALIBRATION
#define CHIP_NAME
chip information definition
driver ags02ma header file
uint8_t ags02ma_info(ags02ma_info_t *info)
get chip's information
uint8_t ags02ma_set_slave_address(ags02ma_handle_t *handle, uint8_t addr)
set slave address
uint8_t ags02ma_modify_slave_address(ags02ma_handle_t *handle, uint8_t addr_7bit)
modify slave address
uint8_t ags02ma_get_version(ags02ma_handle_t *handle, uint8_t *version)
get version
uint8_t ags02ma_read_tvoc(ags02ma_handle_t *handle, uint32_t *raw, uint32_t *ppb)
read tvoc
uint8_t ags02ma_get_slave_address(ags02ma_handle_t *handle, uint8_t *addr)
get slave address
struct ags02ma_info_s ags02ma_info_t
ags02ma information structure definition
uint8_t ags02ma_deinit(ags02ma_handle_t *handle)
close the chip
uint8_t ags02ma_get_resistance(ags02ma_handle_t *handle, uint32_t *raw, double *ohm)
get resistance
uint8_t ags02ma_init(ags02ma_handle_t *handle)
initialize the chip
uint8_t ags02ma_zero_point_calibration(ags02ma_handle_t *handle)
zero point calibration
struct ags02ma_handle_s ags02ma_handle_t
ags02ma handle structure definition
uint8_t ags02ma_set_reg(ags02ma_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t ags02ma_get_reg(ags02ma_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register