Subversion Repositories group.electronics

Rev

Rev 171 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 171 Rev 184
Line 6... Line 6...
6
 
6
 
7
namespace nitdcscore {
7
namespace nitdcscore {
8
    public interface i2cmaster {
8
    public interface i2cmaster {
9
        int WriteI2cData(byte address, byte[] data, uint count);
9
        int WriteI2cData(byte address, byte[] data, uint count);
10
        int ReadI2CData(byte address, ref byte[] data, uint count);
10
        int ReadI2CData(byte address, ref byte[] data, uint count);
-
 
11
        void SetGpio(byte pin, byte data);
-
 
12
    }
-
 
13
 
-
 
14
    public class i2cUtils {
-
 
15
        public static byte addressToWrite(byte address) {
-
 
16
            byte write = (byte)(address << 1);
-
 
17
            return write;
-
 
18
        }
-
 
19
 
-
 
20
        public static byte addressToRead(byte address) {
-
 
21
            byte read = (byte)((address << 1) | 0x01);
-
 
22
            return read;
-
 
23
        }
11
    }
24
    }
12
 
25
 
13
    public class mcp23017 {
26
    public class mcp23017 {
14
        public byte address { get; set; }
27
        public byte address { get; set; }
15
        private i2cmaster dev;
28
        private i2cmaster dev;