MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / analogRead4

Method analogRead4

libraries/PCF8591/PCF8591.cpp:143–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141
142
143uint8_t PCF8591::analogRead4()
144{
145 _control &= 0b01000100; // clear all except flags
146 uint8_t channel = 0;
147 _control |= channel;
148
149 enableINCR();
150 _wire->beginTransmission(_address);
151 _wire->write(_control);
152 _error = _wire->endTransmission(); // default == 0 == PCF8591_OK
153 if (_error != 0)
154 {
155 _error = PCF8591_I2C_ERROR;
156 disableINCR();
157 return _error;
158 }
159 if (_wire->requestFrom(_address, (uint8_t)5) != 5)
160 {
161 _error = PCF8591_I2C_ERROR;
162 disableINCR();
163 return _error;
164 }
165
166 _wire->read();
167 for (uint8_t i = 0; i < 4; i++)
168 {
169 _adc[i] = _wire->read();
170 }
171 _error = PCF8591_OK;
172 disableINCR();
173 return _error;
174}
175
176
177uint8_t PCF8591::lastRead(uint8_t channel)

Callers

nothing calls this directly

Calls 2

writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected