MCP23017 I2C Drive by direction

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
dvv854
New user
Posts: 2
Joined: 10 Sep 2016, 08:55

MCP23017 I2C Drive by direction

#1 Post by dvv854 » 10 Sep 2016, 11:37

Hi

I would like to have and `mcpdir` control command to control pin role: say, mcpdir,1,1 would turn pin#1 low-output, mcpdir,1,0 would reset pin#1 to initial state (pulled-up-input, I believe).
I tried this chunk (in purely naive way, compiled from parts of mcpgpio command and PLUGIN_INIT of _P009_MCP.ino)

Code: Select all

if (event->Par2) {
  Plugin_009_Write(event->Par1, 0);
  setPinState(PLUGIN_ID_009, event->Par1, PIN_MODE_OUTPUT, 0);
} else {
  Plugin_009_Config(event->Par1, 1);
  setPinState(PLUGIN_ID_009, event->Par1, PIN_MODE_INPUT, 0);
}
This does set pin as low-output (first branch), but does not reset it (second branch).

Wonder how to reliably reset pin?

TIA,
--Vladimir

Post Reply

Who is online

Users browsing this forum: No registered users and 49 guests