Is it possible to emulate a MCP23017 with a stm32f103c8? #558
-
|
In my esp32c3 project, I ran out of GPIO pins so I need a GPIO expander. I decided to use a stm32f103c8 instead of a MCP23017. To make my project more flexible I want to code the stm32 to act just like a MCP23017, so I can use an actual MCP23017 if I want. Is it possible to actually emulate a MCP23017 with 400 KHz I2C? One thing that I'm not sure about is if the processor is fast enough to respond to the I2C command as soon as it receives it. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
I don't see any reason it shouldn't work. If you are using interrupts to react to I2C messages it should be more then fast enough, probably a lot faster then the MCP23017 is anyways. We currently don't have a good I2C slave abstraction. You could also have a look at Embassy. They do have one and and an example (that uses the an F4 but it's largely identical for an F1, that one just uses different pins and DMA channels) https://github.com/embassy-rs/embassy/blob/main/examples/stm32f4/src/bin/i2c_slave_async.rs |
Beta Was this translation helpful? Give feedback.
I don't see any reason it shouldn't work. If you are using interrupts to react to I2C messages it should be more then fast enough, probably a lot faster then the MCP23017 is anyways. We currently don't have a good I2C slave abstraction.
You could also have a look at Embassy. They do have one and and an example (that uses the an F4 but it's largely identical for an F1, that one just uses different pins and DMA channels) https://github.com/embassy-rs/embassy/blob/main/examples/stm32f4/src/bin/i2c_slave_async.rs