nrf_sht30.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef SHT30_H__
  2. #define SHT30_H__
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "boards.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. typedef enum
  10. {
  11. SHT30_QUEUE_TIME=0,
  12. SHT30_QUEUE_INT=1,
  13. SHT30_QUEUE_TIMEOUT=2,
  14. }SHT30_QUEUE_TYPE;
  15. typedef enum{
  16. SHT30_NULL,
  17. SHT30_WR,
  18. SHT30_RD,
  19. SHT30_DATA
  20. }sht30_work_stat;
  21. #define SHT30_ADDR0 (uint8_t)(0x45) //sht30 i2c地址,ADDR管脚接低电平时为0x44,接高电平为0x45
  22. #define SHT30_ADDR1 (uint8_t)(0x44) //sht30 i2c地址,ADDR管脚接低电平时为0x44,接高电平为0x45
  23. //SHT30命令
  24. #define SHT30_READ_HUMITURE (uint16_t)0x2c06 //读温湿度
  25. //CRC多项式
  26. #define POLYNOMIAL_CXDZ 0x31 // X^8 + X^5 + X^4 + 1
  27. typedef void (*sht30_finish_func)(bool stat);
  28. typedef struct SHT30_STRUCT_t{
  29. sht30_finish_func finish_func;
  30. sht30_work_stat sht30_stat;
  31. bool addr_pin;
  32. uint8_t sht30_timeout;
  33. uint8_t idx;
  34. uint8_t buff[6];
  35. int16_t temperature[10];
  36. int16_t humi[10];
  37. }sht30_work_s;
  38. typedef struct{
  39. bool sht30_stat;
  40. int16_t temperature_value;
  41. int16_t humi_value;
  42. }sht30_data_s;
  43. void sht30_timers_init(void);
  44. void Sht30_Start(void);
  45. void sht30_i2c_init(void);
  46. void sht30_i2c_uinit(void);
  47. void set_Sht30_finish_func(sht30_finish_func func);
  48. void Set_Sht30_Queue(SHT30_QUEUE_TYPE type);
  49. void Sht30_Switch_Addr(bool stat);
  50. extern sht30_data_s sht30_data;
  51. #ifdef __cplusplus
  52. }
  53. #endif
  54. #endif // SHT30_H__
  55. /** @} */