- byte roms_onewire[1][3] =
- {
- {0x08, 0xC3, 0xC5},
- //{0xC5, 0xC3, 0x08},
- };
- void FirstDoorSwitchOneHandler(bool apply)
- {
- SetPIOStatus(0, 1, apply);
- }
- void FirstDoorSwitchTwoHandler(bool apply)
- {
- SetPIOStatus(0, 2, apply);
- }
- void SetPIOStatus(byte device, byte pin, bool apply)
- {
- if (selected_device_1wire == device)
- SendCommand(device, COMMAND_1WIRE_RESUME);
- SendCommand(device, COMMAND_1WIRE_PIO_WRITE);
- if (apply)
- {
- SendCommand(device, pin);
- SendCommand(device, ~pin);
- }
- else
- {
- SendCommand(device, 0x00);
- SendCommand(device, 0xFF);
- }
- }
- void SendCommand(byte device, byte command)
- {
- byte i;
- if (selected_device_1wire != device)
- {
- w1_init();
- w1_write(COMMAND_1WIRE_MATCH_ROM);
- w1_write(0x3A);
- w1_write(roms_onewire[device][0]);
- w1_write(roms_onewire[device][1]);
- w1_write(0x01);
- for (i = 0; i < 3; ++i)
- w1_write(0x00);
- w1_write(roms_onewire[device][2]);
- }
- selected_device_1wire = device;
- w1_write(command);
- }