Esempio n. 1
0
        public byte GetHighGpio()
        {
            _mpsse.Enqueue(MpsseCommand.ReadDataBitsHighByte());
            _mpsse.ExecuteBuffer();

            // Result
            var result = _mpsse.read(1);

            return(result[0]);
        }
Esempio n. 2
0
        public Gpio(MpsseDevice mpsse)
        {
            _mpsse = mpsse;

            _mpsse.AdBusDirection.Mask(false, false, true, true, true, null, null, null);
            _mpsse.AdBusValue.Set((byte)0x0);
            _mpsse.Enqueue(MpsseCommand.SetDataBitsLowByte(_mpsse.AdBusValue, _mpsse.AdBusDirection));
            _mpsse.ExecuteBuffer();
        }
Esempio n. 3
0
        public I2cBus(MpsseDevice mpsse)
        {
            _mpsse = mpsse;

            _mpsse.Enqueue(MpsseCommand.DisableClkDivideBy5());
            _mpsse.Enqueue(MpsseCommand.TurnOffAdaptiveClocking());
            _mpsse.Enqueue(MpsseCommand.Enable3PhaseDataClocking());
            _mpsse.Enqueue(MpsseCommand.SetClkDivisor(mpsse.ClkDivisor));
            _mpsse.Enqueue(MpsseCommand.DisconnectTdiTdoLoopback());
            _mpsse.Enqueue(MpsseCommand.SetIoToOnlyDriveOn0andTristateOn1(FtdiPin.DO | FtdiPin.DI | FtdiPin.CK, FtdiPin.None));

            _mpsse.AdBusDirection.SetBit(0).SetBit(1);
            _mpsse.AdBusValue.SetBit(0).SetBit(1);
            _mpsse.Enqueue(MpsseCommand.SetDataBitsLowByte(_mpsse.AdBusValue, _mpsse.AdBusDirection));
            _mpsse.ExecuteBuffer();
        }
Esempio n. 4
0
        public byte ReceiveByte(bool ACK)
        {
            // Clock in one data byte
            MpsseCommand.BytesInOnPlusEdgeWithMsbFirst(1);
            _mpsse.Enqueue(CommandCode.BytesInOnPlusEdgeWithMsbFirst, 0x00, 0x00);

            // clock out one bit as ack/nak bit
            var ack = ACK ? 0x00 : 0xFF;

            _mpsse.Enqueue(CommandCode.BitsOutOnMinusEdgeWithMsbFirst, 0x00, (byte)ack);

            // I2C lines back to idle state
            _mpsse.AdBusValue.SetBit(1).UnsetBit(0);
            _mpsse.AdBusDirection.SetBit(1).SetBit(1);
            _mpsse.Enqueue(MpsseCommand.SetDataBitsLowByte(_mpsse.AdBusValue, _mpsse.AdBusDirection));

            // This command then tells the MPSSE to send any results gathered back immediately
            _mpsse.Enqueue(MpsseCommand.SendImmediate());

            // Execute
            _mpsse.ExecuteBuffer();

            // Result
            var result = _mpsse.read(1);

            return(result[0]);
        }