Hardware Reference
In-Depth Information
94 static unsigned
95 mcp23017_inputs(void) {
96 unsigned reg_addr = MCP_REGISTER(GPIO,GPIOA);
97
98
99 return i2c_read16(gpio_addr,reg_addr) & 0xF0F0;
100 }
101
102 /
103
Write 16 bits to outputs :
104
/
105 static void
106 mcp23017_outputs(int value) {
107 unsigned reg_addr = MCP_REGISTER(GPIO,GPIOA);
108
109 i2c_write16 (gpio_addr,reg_addr,value & 0x0F0F);
110 }
111
112 /
113
Read MCP23017 captured values (16-bits):
114
/
115 static unsigned
116 mcp23017_captured(void) {
117 unsigned reg_addr = MCP_REGISTER(INTCAP,GPIOA);
118
119 return i2c_read16(gpio_addr,reg_addr) & 0xF0F0;
120 }
121
122 /
123
Read interrupting input flags (16-bits) :
124
/
125 static unsigned
126 mcp23017_interrupts(void) {
127 unsigned reg_addr = MCP_REGISTER(INTF,GPIOA);
128
129 return i2c_read16(gpio_addr,reg_addr) & 0xF0F0;
130 }
131
132 /
133
Configure the MCP23017 GPIO Extender :
134
/
135 static void
136 mcp23017_init(void) {
137 int v, int_flags;
138
139 mcp23017_write_both(IOCON,0b01000100); /
MIRROR=1,ODR=1
/
140 mcp23017_write_both(GPINTEN,0x00); /
No interrupts enabled
/
Search WWH ::




Custom Search