1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #pragma once
- #ifndef _AHTxx_H_
- #define _AHTxx_H_
- #include <SmingCore.h>
- /* Status code */
- typedef enum {
- St_OK = 0,
- St_DataToLong = 1,
- St_NACK_Addr = 2,
- St_NACK_Data = 3,
- St_Error = 4,
- St_Timeout = 5
- } ahtxx_st_t;
- /* Data type */
- typedef struct {
- uint16_t Humidity;
- int16_t Temperature;
- ahtxx_st_t Error;
- } ahtxx_t;
- class AHTxx
- {
- public:
- AHTxx(void);
- void StartMeasure(void);
- void SoftReset(void);
- void GetData(ahtxx_t * data);
- bool IsReadyToRequest(void);
- bool IsDataReady(void);
- private:
- static void Init(void);
- static ahtxx_st_t I2CWriteTo(uint8_t DataToSend);
- static uint8_t Calc_CRC8(uint8_t *message, uint8_t Num);
- static ahtxx_st_t JH_Reset_REG(uint8_t addr);
- };
- #endif /* _AHTxxH_ */
|