Beispiel #1
0
        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());
            }
        }
Beispiel #2
0
        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));
            }
        }
Beispiel #3
0
        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));
            }
        }
Beispiel #4
0
 public TestDevice(Pcx857x device, Pcx857xChipMock chipMock)
 {
     Device   = device;
     ChipMock = chipMock;
 }
Beispiel #5
0
 public TestDevice(Pcx857x device, Pcx857xChipMock chipMock)
 {
     Device     = device;
     ChipMock   = chipMock;
     Controller = new GpioController(PinNumberingScheme.Logical, Device);
 }