Beispiel #1
0
        private void Write(Command command, IO_BITS dataPort)
        {
            //Populating the commands bits
            SetCommand(command);

            //Format: 0:Address, 1:Command, 2:Port Data
            byte[] data = { 0, 0 };
            data[0]  = m_cmdReg.ToUInt8();
            data[1] &= Convert.ToByte(dataPort);

            m_i2c.Write(m_slaveAddress, data);
        }
Beispiel #2
0
        public void SetIO(PORTS port, IO_BITS b)
        {
            switch (port)
            {
            case PORTS.PORT0:
            {
                Write(Command.OutputPort0, b);
            }
            break;

            case PORTS.PORT1:
                Write(Command.OutputPort1, b);
                break;

            default:
                break;
            }
        }
Beispiel #3
0
        public void SetIODirection(PORT_DIRECTION dir, PORTS port, IO_BITS bits)
        {
            switch (port)
            {
            case PORTS.PORT0:
                switch (dir)
                {
                case PORT_DIRECTION.OUTPUT:
                    Write(Command.OutputPort0, bits);
                    break;

                case PORT_DIRECTION.INPUT:
                    Write(Command.InputPort0, bits);
                    break;

                default:
                    break;
                }
                break;

            case PORTS.PORT1:
                switch (dir)
                {
                case PORT_DIRECTION.OUTPUT:
                    Write(Command.OutputPort1, bits);
                    break;

                case PORT_DIRECTION.INPUT:
                    Write(Command.InputPort1, bits);
                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }
        }
Beispiel #4
0
        public void WriteIO(PORTS port, IO_BITS b, bool val)
        {
            switch (port)
            {
            case PORTS.PORT0:
            {
                if (val == true)
                {
                    m_portVal[0] |= (byte)b;
                }
                else
                {
                    m_portVal[0] &= (byte)(~(byte)b);
                }
                Write(Command.OutputPort0, m_portVal[0]);
            }
            break;

            case PORTS.PORT1:
            {
                if (val == true)
                {
                    m_portVal[1] |= (byte)b;
                }
                else
                {
                    m_portVal[1] &= (byte)(~(byte)b);
                }
                Write(Command.OutputPort1, m_portVal[1]);
            }
            break;

            default:
                break;
            }
        }