AHTxx.h 736 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. bool IsDataReady(void);
  29. private:
  30. static void Init(void);
  31. static ahtxx_st_t I2CWriteTo(uint8_t DataToSend);
  32. static uint8_t Calc_CRC8(uint8_t *message, uint8_t Num);
  33. static ahtxx_st_t JH_Reset_REG(uint8_t addr);
  34. };
  35. #endif /* _AHTxxH_ */