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

Method digitalRead

libraries/MCP23017_RT/MCP23017.cpp:181–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179
180
181uint8_t MCP23017::digitalRead(uint8_t pin)
182{
183 if (pin > 15)
184 {
185 _error = MCP23017_PIN_ERROR;
186 return MCP23017_INVALID_READ;
187 }
188 uint8_t IOR = MCP23017_GPIO_A;
189 if (pin > 7)
190 {
191 IOR = MCP23017_GPIO_B;
192 pin -= 8;
193 }
194
195 uint8_t val = readReg(IOR);
196 if (_error != MCP23017_OK)
197 {
198 return MCP23017_INVALID_READ;
199 }
200 uint8_t mask = 1 << pin;
201 if (val & mask) return HIGH;
202 return LOW;
203}
204
205
206// pin = 0..15

Callers 1

unittestFunction · 0.45

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.36