#ifndef SHT30_H__ #define SHT30_H__ #include #include #include "boards.h" #ifdef __cplusplus extern "C" { #endif typedef enum { SHT30_QUEUE_TIME=0, SHT30_QUEUE_INT=1, SHT30_QUEUE_TIMEOUT=2, }SHT30_QUEUE_TYPE; typedef enum{ SHT30_NULL, SHT30_WR, SHT30_RD, SHT30_DATA }sht30_work_stat; #define SHT30_ADDR0 (uint8_t)(0x45) //sht30 i2c地址,ADDR管脚接低电平时为0x44,接高电平为0x45 #define SHT30_ADDR1 (uint8_t)(0x44) //sht30 i2c地址,ADDR管脚接低电平时为0x44,接高电平为0x45 //SHT30命令 #define SHT30_READ_HUMITURE (uint16_t)0x2c06 //读温湿度 //CRC多项式 #define POLYNOMIAL_CXDZ 0x31 // X^8 + X^5 + X^4 + 1 typedef void (*sht30_finish_func)(bool stat); typedef struct SHT30_STRUCT_t{ sht30_finish_func finish_func; sht30_work_stat sht30_stat; bool addr_pin; uint8_t sht30_timeout; uint8_t idx; uint8_t buff[6]; int16_t temperature[10]; int16_t humi[10]; }sht30_work_s; typedef struct{ bool sht30_stat; int16_t temperature_value; int16_t humi_value; }sht30_data_s; void sht30_timers_init(void); void Sht30_Start(void); void sht30_i2c_init(void); void sht30_i2c_uinit(void); void set_Sht30_finish_func(sht30_finish_func func); void Set_Sht30_Queue(SHT30_QUEUE_TYPE type); void Sht30_Switch_Addr(bool stat); extern sht30_data_s sht30_data; #ifdef __cplusplus } #endif #endif // SHT30_H__ /** @} */