Rev 5 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5 | Rev 6 | ||
---|---|---|---|
Line 13... | Line 13... | ||
13 | // just contact techsupport@e-radionica.com |
13 | // just contact techsupport@e-radionica.com |
14 | //============================================================================== |
14 | //============================================================================== |
15 | 15 | ||
16 | #ifndef SHT21_H |
16 | #ifndef SHT21_H |
17 | #define SHT21_H |
17 | #define SHT21_H |
- | 18 | #include "ch.h" |
|
- | 19 | #include "hal.h" |
|
18 | 20 | ||
19 | //---------- Defines ----------------------------------------------------------- |
21 | //---------- Defines ----------------------------------------------------------- |
20 | #define I2C_ADD 0x40 // I2C device address |
22 | #define I2C_ADD 0x40 // I2C device address |
21 | 23 | ||
22 | const uint16_t POLYNOMIAL = 0x131; // P(x)=x^8+x^5+x^4+1 = 100110001 |
24 | const uint16_t POLYNOMIAL = 0x131; // P(x)=x^8+x^5+x^4+1 = 100110001 |
Line 69... | Line 71... | ||
69 | // checksum expected checksum |
71 | // checksum expected checksum |
70 | // return: 1 = checksum does not match |
72 | // return: 1 = checksum does not match |
71 | // 0 = checksum matches |
73 | // 0 = checksum matches |
72 | 74 | ||
73 | 75 | ||
- | 76 | ||
- | 77 | const I2CDriver * m_driver; |
|
- | 78 | ||
74 | public: |
79 | public: |
75 | // I2C config for this chip |
80 | SHT21(I2CDriver * driver) { m_driver = driver; }; |
76 | static const I2CConfig i2ccfg = { OPMODE_I2C, 400000, FAST_DUTY_CYCLE_2, }; |
- | |
77 | 81 | ||
- | 82 | // I2C config for this chip |
|
- | 83 | static I2CConfig constexpr i2ccfg = { OPMODE_I2C, 400000, FAST_DUTY_CYCLE_2, }; |
|
78 | 84 | ||
79 | 85 | ||
80 | //============================================================================== |
86 | //============================================================================== |
81 | float getHumidity(void); |
87 | float getHumidity(void); |
82 | //============================================================================== |
88 | //============================================================================== |
Line 91... | Line 97... | ||
91 | void reset(); |
97 | void reset(); |
92 | //============================================================================== |
98 | //============================================================================== |
93 | // performs a soft reset, delays 15ms |
99 | // performs a soft reset, delays 15ms |
94 | 100 | ||
95 | //============================================================================== |
101 | //============================================================================== |
96 | uint8_t getSerialNumber(uint8_t return_sn); |
102 | msg_t getSerialNumber(uint8_t * serialNumber ); |
97 | //============================================================================== |
103 | //============================================================================== |
- | 104 | // requires pointer to 8 byte buffer to return serial number |
|
98 | // returns electronical identification code depending of selected memory |
105 | // returns electronical identification code depending of selected memory |
99 | // location |
106 | // location |
100 | 107 | ||
101 | }; |
108 | }; |
102 | 109 |