#ifndef SHT30_SIM_H__ #define SHT30_SIM_H__ #include #include #include "define.h" #ifdef __cplusplus extern "C" { #endif #define SHT30_DATA_MAXIDX 3 #ifdef SHT30_RST #define SHT30_RST_LOW nrf_gpio_pin_write(SHT30_RST, 0); #define SHT30_RST_HIGH nrf_gpio_pin_write(SHT30_RST, 1); #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<<1) //sht30 i2c地址,ADDR管脚接低电平时为0x44,接高电平为0x45 #define SHT30_ADDR1 (uint8_t)(0x44<<1) //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[SHT30_DATA_MAXIDX]; int16_t humi[SHT30_DATA_MAXIDX]; }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); #ifdef SHT30_RST void Sht30_Gpio_Init(void); void Sht30_Reset(void); #endif extern sht30_data_s sht30_data; #ifdef __cplusplus } #endif #endif // SHT30_H__ /** @} */