Subversion Repositories group.electronics

Rev

Rev 164 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 164 Rev 171
Line 52... Line 52...
52
            byte[] cmd = new byte[] { 0x12, gpioa, gpiob };
52
            byte[] cmd = new byte[] { 0x12, gpioa, gpiob };
53
            rslt = dev.WriteI2cData(this.addressToWrite(), cmd, 3);
53
            rslt = dev.WriteI2cData(this.addressToWrite(), cmd, 3);
54
            return rslt;
54
            return rslt;
55
        }
55
        }
56
 
56
 
-
 
57
        public int SetBank(int bank, byte gpio) {
-
 
58
            int rslt = 0;
-
 
59
            if (bank == 0) {
-
 
60
                byte[] cmd = new byte[] { 0x12, gpio };
-
 
61
                rslt = dev.WriteI2cData(this.addressToWrite(), cmd, 2);
-
 
62
            } else if (bank == 1) {
-
 
63
                byte[] cmd = new byte[] { 0x13, gpio };
-
 
64
                rslt = dev.WriteI2cData(this.addressToWrite(), cmd, 2);
-
 
65
            }
-
 
66
            return rslt;
-
 
67
        }
-
 
68
 
-
 
69
        public int GetBank(int bank, byte gpio, out byte data) {
-
 
70
            int rslt = 0;
-
 
71
            byte[] tmpdata = { 0x00 };
-
 
72
            data = 0;
-
 
73
            if (bank == 0) {
-
 
74
                byte[] cmd = new byte[] { 0x12 };
-
 
75
                rslt = dev.WriteI2cData(this.addressToWrite(), cmd, 1);
-
 
76
 
-
 
77
                cmd = new byte[] { 0xff };
-
 
78
                rslt = dev.ReadI2CData(this.addressToRead(), ref tmpdata, 1);
-
 
79
                data = tmpdata[0];
-
 
80
            } else if (bank == 1) {
-
 
81
                byte[] cmd = new byte[] { 0x13 };
-
 
82
                rslt = dev.WriteI2cData(this.addressToWrite(), cmd, 1);
-
 
83
 
-
 
84
                cmd = new byte[] { 0xff };
-
 
85
                rslt = dev.ReadI2CData(this.addressToRead(), ref tmpdata, 1);
-
 
86
                data = tmpdata[0];
-
 
87
            }
-
 
88
            return rslt;
-
 
89
        }
-
 
90
 
57
        private byte addressToWrite() {
91
        private byte addressToWrite() {
58
            byte write = (byte)(this.address << 1);
92
            byte write = (byte)(this.address << 1);
59
            return write;
93
            return write;
60
        }
94
        }
61
 
95