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

Function digitalWriteDeviceV2

wiringPi/wiringPi.c:2330–2357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2328 */
2329
2330void digitalWriteDeviceV2(int pin, int value) {
2331 int ret;
2332 struct gpio_v2_line_values values;
2333
2334 if (wiringPiDebug)
2335 printf ("digitalWriteDeviceV2: ioctl pin:%d value: %d\n", pin, value) ;
2336
2337 if (lineFds[pin]<0) {
2338 // line not requested - auto request on first write as output
2339 pinModeDevice(pin, OUTPUT);
2340 }
2341
2342 if (lineFds[pin]>=0 && (lineFlags[pin] & GPIO_V2_LINE_FLAG_OUTPUT)>0) {
2343 values.mask = 0;
2344 values.bits = 0;
2345 gpiotools_set_bit(&values.mask, 0);
2346 gpiotools_assign_bit(&values.bits, 0, !!value);
2347
2348 ret = ioctl(lineFds[pin], GPIO_V2_LINE_SET_VALUES_IOCTL, &values);
2349 if (ret == -1) {
2350 ReportDeviceError("digitalWriteDeviceV2", pin, "GPIO_V2_LINE_SET_VALUES_IOCTL", ret);
2351 return; // error
2352 }
2353 } else {
2354 fprintf(stderr, "digitalWriteDeviceV2: no output (%d)\n", lineFlags[pin]);
2355 }
2356 return; // error
2357}
2358
2359
2360void digitalWrite (int pin, int value)

Callers 1

digitalWriteFunction · 0.85

Calls 4

pinModeDeviceFunction · 0.85
gpiotools_set_bitFunction · 0.85
gpiotools_assign_bitFunction · 0.85
ReportDeviceErrorFunction · 0.85

Tested by

no test coverage detected