AHTxx.h 710 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #ifndef _AHTxx_H_
  3. #define _AHTxx_H_
  4. #include <SmingCore.h>
  5. /* Status code */
  6. typedef enum {
  7. St_OK = 0,
  8. St_DataToLong = 1,
  9. St_NACK_Addr = 2,
  10. St_NACK_Data = 3,
  11. St_Error = 4,
  12. St_Timeout = 5
  13. } ahtxx_st_t;
  14. /* Data type */
  15. typedef struct {
  16. uint16_t Humidity;
  17. int16_t Temperature;
  18. ahtxx_st_t Error;
  19. } ahtxx_t;
  20. class AHTxx
  21. {
  22. public:
  23. AHTxx(void);
  24. void StartMeasure(void);
  25. void SoftReset(void);
  26. void GetData(ahtxx_t * data);
  27. bool IsReadyToRequest(void);
  28. private:
  29. static void Init(void);
  30. static ahtxx_st_t I2CWriteTo(uint8_t DataToSend);
  31. static uint8_t Calc_CRC8(uint8_t *message, uint8_t Num);
  32. static ahtxx_st_t JH_Reset_REG(uint8_t addr);
  33. };
  34. #endif /* _AHTxxH_ */