toshi mura
/
NRP2020_main
gjyrjyykkudt
Diff: MCP/MCP.cpp
- Revision:
- 2:32d2cd7d744b
- Parent:
- 1:5b0303768126
- Child:
- 6:cd2671c141cc
diff -r 5b0303768126 -r 32d2cd7d744b MCP/MCP.cpp --- a/MCP/MCP.cpp Tue Jan 21 11:10:33 2020 +0000 +++ b/MCP/MCP.cpp Thu Jan 23 09:16:38 2020 +0000 @@ -6,7 +6,7 @@ :i2c(sda, scl), mcp(i2c, device_address) { _iodir_data.all = 0xffff; - _pull_data.all = 0x0000; + _pull_data.all = 0xffff; _read_data.all = 0x0000; _write_data.all = 0x0000; } @@ -37,14 +37,20 @@ return (_read_data.all >> pin) & 0x01; } -void MCP::Update(void) -{ +void MCP::Update(void) { + char data[2] = {GPPUA, 0xff}; + int lost = i2c.write(0x40, data, 2); + if(lost) { + i2c.start(); + } mcp.direction(PORT_A, _iodir_data.port.port_A); mcp.direction(PORT_B, _iodir_data.port.port_B); mcp.configurePullUps(PORT_A, _pull_data.port.port_A); mcp.configurePullUps(PORT_B, _pull_data.port.port_B); _read_data.port.port_A = mcp.read(PORT_A); _read_data.port.port_B = mcp.read(PORT_B); - // mcp.write(PORT_A, _write_data.port_A); - // mcp.write(PORT_B, _write_data.port_B); + mcp.write(PORT_A, _write_data.port.port_A); + mcp.write(PORT_B, _write_data.port.port_B); + } + \ No newline at end of file