public void RegisterInitialization(TestDevice testDevice) { // All pins should be set to output. Pcx857x device = testDevice.Device; if (device.PinCount == 8) { Assert.Equal(0x00, device.ReadByte()); } else { Assert.Equal(16, device.PinCount); Pcx8575 device16 = (Pcx8575)device; Assert.Equal(0x0000, device16.ReadUInt16()); } }
public void Write_GoodPin(TestDevice testDevice) { Pcx857x device = testDevice.Device; for (int pin = 0; pin < testDevice.Device.PinCount; pin++) { bool first = pin < 8; device.Write(pin, PinValue.High); byte expected = (byte)(1 << (first ? pin : pin - 8)); Assert.Equal(expected, first ? device.ReadByte() : (byte)(((Pcx8575)device).ReadUInt16() >> 8)); device.Write(pin, PinValue.Low); Assert.Equal(0, first ? device.ReadByte() : (byte)(((Pcx8575)device).ReadUInt16() >> 8)); } }
public void Read_GoodPin(TestDevice testDevice) { Pcx857x device = testDevice.Device; for (int pin = 0; pin < testDevice.Controller.PinCount; pin++) { // Set pin to input testDevice.Controller.OpenPin(pin, PinMode.Input); bool first = pin < 8; int register = first ? 0x00 : 0x01; // Flip the bit on (set the backing buffer directly to simulate incoming data) testDevice.ChipMock.Registers[register] = (byte)(1 << (first ? pin : pin - 8)); Assert.Equal(PinValue.High, testDevice.Controller.Read(pin)); // Clear the register testDevice.ChipMock.Registers[register] = 0x00; Assert.Equal(PinValue.Low, testDevice.Controller.Read(pin)); } }
public TestDevice(Pcx857x device, Pcx857xChipMock chipMock) { Device = device; ChipMock = chipMock; }
public TestDevice(Pcx857x device, Pcx857xChipMock chipMock) { Device = device; ChipMock = chipMock; Controller = new GpioController(PinNumberingScheme.Logical, Device); }