818 device->present = DEVPRESENT_YES; |
818 device->present = DEVPRESENT_YES; |
819 #ifdef HAVE_WIRINGPI_H |
819 #ifdef HAVE_WIRINGPI_H |
820 piUnlock(LOCK_DEVICES); |
820 piUnlock(LOCK_DEVICES); |
821 #endif |
821 #endif |
822 } |
822 } |
|
823 /* |
|
824 * First make sure that if this device is configured as input |
|
825 * to drive the output high. |
|
826 */ |
|
827 if (device->direction == DEVDIR_IN_BIN) { |
|
828 uint8_t state, output; |
|
829 |
|
830 if ((rc = read_w1(device->address, (char *)"state")) >= 0) { |
|
831 state = (unsigned int)rc; |
|
832 output = ((state & 0x02) >> 1) + ((state & 0x08) >> 2); /* Both latch states */ |
|
833 if (device->subdevice == 0) { |
|
834 output = (output & 0xfe); |
|
835 output |= 0x01; |
|
836 } else if (device->subdevice == 1) { |
|
837 output = (output & 0xfd); |
|
838 output |= 0x02; |
|
839 } else { |
|
840 output = 0xff; |
|
841 } |
|
842 write_w1(device->address, (char *)"output", output); |
|
843 } |
|
844 } |
823 if ((rc = read_w1(device->address, (char *)"state")) >= 0) { |
845 if ((rc = read_w1(device->address, (char *)"state")) >= 0) { |
824 #ifdef HAVE_WIRINGPI_H |
846 #ifdef HAVE_WIRINGPI_H |
825 piLock(LOCK_DEVICES); |
847 piLock(LOCK_DEVICES); |
826 #endif |
848 #endif |
827 /* |
849 /* |