示例#1
0
        public static void testSetGpio3v3PinLevel([Values((UInt16)0x01, (UInt16)0x10)] UInt16 gpio3v3PinLevel)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            byte   spiData1  = 0x0;
            byte   spiData2  = 0x0;
            UInt16 gpio3v3Oe = 0xFF;
            ushort gpio3v3SetLevelReadback = 0x0;

            Mykonos.GPIO3V3_MODE gpio3v3Mode3_0  = Mykonos.GPIO3V3_MODE.GPIO3V3_BITBANG_MODE;
            Mykonos.GPIO3V3_MODE gpio3v3Mode7_4  = Mykonos.GPIO3V3_MODE.GPIO3V3_BITBANG_MODE;
            Mykonos.GPIO3V3_MODE gpio3v3Mode11_8 = Mykonos.GPIO3V3_MODE.GPIO3V3_BITBANG_MODE;
            Link.Mykonos.setupGpio3v3(gpio3v3Oe, gpio3v3Mode3_0, gpio3v3Mode7_4, gpio3v3Mode11_8);
            Link.Mykonos.setGpio3v3PinLevel(gpio3v3PinLevel);
            Link.Mykonos.getGpio3v3SetLevel(ref gpio3v3SetLevelReadback);

            spiData1 = Link.spiRead(0xB02); Console.WriteLine("0xB02: " + spiData1.ToString("X"));
            spiData2 = Link.spiRead(0xB03); Console.WriteLine("0xB03: " + spiData2.ToString("X"));
            Assert.AreEqual(gpio3v3PinLevel & 0xFF, spiData1, "GPIO3v3 7-0 not as expected");
            Assert.AreEqual((gpio3v3PinLevel >> 8) & 0x0F, spiData2, "GPIO3v3 15-8 not as expected");
            Assert.AreEqual(gpio3v3PinLevel, gpio3v3SetLevelReadback, "GPIO3v3 set level readback not as expexted");

            Link.Disconnect();
        }
示例#2
0
        public static void testSetupGpio3v3([Values(Mykonos.GPIO3V3_MODE.GPIO3V3_LEVELTRANSLATE_MODE, Mykonos.GPIO3V3_MODE.GPIO3V3_INVLEVELTRANSLATE_MODE, Mykonos.GPIO3V3_MODE.GPIO3V3_BITBANG_MODE, Mykonos.GPIO3V3_MODE.GPIO3V3_EXTATTEN_LUT_MODE)] Mykonos.GPIO3V3_MODE gpio3v3Mode3_0,
                                            [Values(Mykonos.GPIO3V3_MODE.GPIO3V3_LEVELTRANSLATE_MODE, Mykonos.GPIO3V3_MODE.GPIO3V3_INVLEVELTRANSLATE_MODE, Mykonos.GPIO3V3_MODE.GPIO3V3_BITBANG_MODE, Mykonos.GPIO3V3_MODE.GPIO3V3_EXTATTEN_LUT_MODE)] Mykonos.GPIO3V3_MODE gpio3v3Mode7_4,
                                            [Values(Mykonos.GPIO3V3_MODE.GPIO3V3_LEVELTRANSLATE_MODE, Mykonos.GPIO3V3_MODE.GPIO3V3_INVLEVELTRANSLATE_MODE, Mykonos.GPIO3V3_MODE.GPIO3V3_BITBANG_MODE, Mykonos.GPIO3V3_MODE.GPIO3V3_EXTATTEN_LUT_MODE)] Mykonos.GPIO3V3_MODE gpio3v3Mode11_8)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            byte   spiData1  = 0x0;
            byte   spiData2  = 0x0;
            UInt16 gpio3v3Oe = 0xFF;

            Link.Mykonos.setupGpio3v3(gpio3v3Oe, gpio3v3Mode3_0, gpio3v3Mode7_4, gpio3v3Mode11_8);

            //Check GPIO3v3 direction control bit
            spiData1 = Link.spiRead(0xB00); Console.WriteLine("0xB00: " + spiData1.ToString("X"));
            Assert.AreEqual(gpio3v3Oe & 0xFF, spiData1, "GPIO3v3 direction control bit 7-0 not as expected");
            spiData1 = Link.spiRead(0xB01); Console.WriteLine("0xB01: " + spiData1.ToString("X"));
            Assert.AreEqual((gpio3v3Oe >> 8) & 0x0F, spiData1, "GPIO3v3 direction control bit 15-8 not as expected");

            //Check GPIO3v3
            spiData1 = Link.spiRead(0xB06); Console.WriteLine("0xB06: " + spiData1.ToString("X"));
            spiData2 = Link.spiRead(0xB07); Console.WriteLine("0xB07: " + spiData2.ToString("X"));
            Assert.AreEqual(((((byte)gpio3v3Mode7_4) << 4) | (byte)gpio3v3Mode3_0), spiData1, "GPIO3v3 LSB not as expected");
            Assert.AreEqual(((byte)gpio3v3Mode11_8 & 0x0F), spiData2, "GPIO3v3 MSB not as expected");

            Link.Disconnect();
        }
示例#3
0
        public static void testReadGpio3v3PinLevel([Values((UInt16)0x01, (UInt16)0x20)] UInt16 gpio3v3PinLevel)
        {
            AdiCommandServerClient Link = AdiCommandServerClient.Instance;

            Link.hw.Connect(TestSetupConfig.ipAddr, TestSetupConfig.port);
            byte   spiData1  = 0x0;
            byte   spiData2  = 0x0;
            UInt16 gpio3v3Oe = 0x3F;
            UInt16 gpio3v3PinLevelReadback = 0x0;

            Mykonos.GPIO3V3_MODE gpio3v3Mode3_0  = Mykonos.GPIO3V3_MODE.GPIO3V3_BITBANG_MODE;
            Mykonos.GPIO3V3_MODE gpio3v3Mode7_4  = Mykonos.GPIO3V3_MODE.GPIO3V3_BITBANG_MODE;
            Mykonos.GPIO3V3_MODE gpio3v3Mode11_8 = Mykonos.GPIO3V3_MODE.GPIO3V3_BITBANG_MODE;
            Link.Mykonos.setupGpio3v3(gpio3v3Oe, gpio3v3Mode3_0, gpio3v3Mode7_4, gpio3v3Mode11_8);
            Link.Mykonos.setGpio3v3PinLevel(gpio3v3PinLevel);
            Link.Mykonos.getGpio3v3PinLevel(ref gpio3v3PinLevelReadback);
            Console.WriteLine(gpio3v3PinLevelReadback);
            spiData1 = Link.spiRead(0xB04); Console.WriteLine("0xB04: " + spiData1.ToString("X"));
            spiData2 = Link.spiRead(0xB05); Console.WriteLine("0xB05: " + spiData2.ToString("X"));
            Assert.AreEqual(gpio3v3PinLevelReadback, ((spiData2 & 0x0F) << 8) | spiData1, "GPIO3v3 readback not as expected");
            switch (gpio3v3PinLevel)
            {
            case 0x01:
                Assert.AreEqual(gpio3v3PinLevelReadback, 2048, "GPIO input read not as expected");
                break;

            case 0x20:
                Assert.AreEqual(gpio3v3PinLevelReadback, 64, "GPIO input read not as expected");
                break;

            default:
                Assert.Fail("output GPIO level not defined in test code");
                break;
            }
            Link.Disconnect();
        }