-
Notifications
You must be signed in to change notification settings - Fork 0
Add support for MCP23017 (I2C GPIO expander). #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: driver_tidy
Are you sure you want to change the base?
Conversation
| int i2c = gpio_i2c_mcp_alloc(address); | ||
| if (i2c >= 0) { | ||
| i2c_gpio_set_pin_config(&i2c_gpio, i2c, index, gpio_type); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | |
| } else { | |
| printf("Error ..."); | |
| } |
src/rp2040/gpio.c
Outdated
| //uint32_t gpio_i2c_mcp_indexes[MAX_I2C_MCP] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}; | ||
| uint32_t gpio_i2c_mcp_indexes[MAX_I2C_MCP] = {0, 0, 0, 0}; | ||
| uint8_t gpio_i2c_mcp_addresses[MAX_I2C_MCP] = {0xff, 0xff, 0xff, 0xff}; | ||
| uint8_t gpio_last_type[32 * MAX_I2C_MCP]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see this being set but never used.
|
|
||
|
|
||
| //uint32_t gpio_i2c_mcp_indexes[MAX_I2C_MCP] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}; | ||
| uint32_t gpio_i2c_mcp_indexes[MAX_I2C_MCP] = {0, 0, 0, 0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gpio_i2c_mcp_indexes not used any more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used, by gpio_i2c_mcp_alloc.
mrdunk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i left a couple of minor comments.
but LGTM.
you are more familiar with this code than me at the moment so feel free to merge.
This adds support for the MCP23017 GPIO expander - I2C connected, 14 GPIO pins with optional pullup, 2 GPO pins (7 and 15, a silicon bug makes those pins unreliable as inputs).
The ports are polled while waiting for the packet and after updating the motion values. However, this normally shouldn't be the problem, because the polling code is guaranteed to finish quickly, except for the printf after a communication error.