MCPcopy Create free account
hub / github.com/WiringPi/WiringPi / digitalReadDeviceV2

Function digitalReadDeviceV2

wiringPi/wiringPi.c:2253–2273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2251 */
2252
2253int digitalReadDeviceV2(int pin) { // INPUT and OUTPUT should work
2254 struct gpio_v2_line_values lv;
2255 int ret;
2256
2257 if (lineFds[pin]<0) {
2258 // line not requested - auto request on first read as input
2259 pinModeDevice(pin, INPUT);
2260 }
2261 lv.mask = 0;
2262 lv.bits = 0;
2263 if (lineFds[pin]>=0) {
2264 gpiotools_set_bit(&lv.mask, 0);
2265 ret = ioctl(lineFds[pin], GPIO_V2_LINE_GET_VALUES_IOCTL, &lv);
2266 if (ret) {
2267 ReportDeviceError("get line values", pin, "digitalRead", ret);
2268 return LOW; // error
2269 }
2270 return gpiotools_test_bit(lv.bits, 0);
2271 }
2272 return LOW; // error , need to request line before
2273}
2274
2275
2276int digitalRead (int pin)

Callers 1

digitalReadFunction · 0.85

Calls 4

pinModeDeviceFunction · 0.85
gpiotools_set_bitFunction · 0.85
ReportDeviceErrorFunction · 0.85
gpiotools_test_bitFunction · 0.85

Tested by

no test coverage detected