-
Notifications
You must be signed in to change notification settings - Fork 620
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
Add miso pullup to spi configuration #2943
Conversation
Looks good. I'd like to suggest a few additions:
|
uhhh sorry for the confusion, I think this doesn't make sense. MOSI and SCK are always driven by the MCU, so the pull would never affect anything, right? |
If we think of the MCU as the Master and don't consider the other way, then yes. For the slave-case, one can imagine a Master that want's a pull-up on MISO in order to mimic some sort of chip and I can imagine adding an internal pull to the pins to avoid floating states, but I think we should think about this after #2750 is merged. So far I've only come accross chips that need a MISO pull-up. The aforementioned MCP33131-10 needs constant VDIO on MOSI as well (it's read-only), but I always solved this in hardware by hardwiring it until now. I guess it might be good to not think too much about these obscure cases, as they are irrelevant for 99.9% of users. But changing the bool to Pull even makes the code easier (eliminates two match statements), so this seems senible. |
SGTM. The SPI slave will probably have a different Config struct anyway. |
embassy-stm32/src/spi/mod.rs
Outdated
/// | ||
/// There are some ICs that require a pull-up on the MISO pin for some applications. | ||
/// If you are unsure, you probably don't need this. | ||
pub miso_pullup: Pull, |
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.
this shold be miso_pull
now.
lgtm, is there any reason this is still draft? |
Yes, I wanted to wait on #2996 being merged :) |
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.
ah cool cool
Wait, can you still abort the merge queue? I might have missed something. |
This modulo is wrong there I think: embassy/embassy-stm32/src/gpio.rs Line 702 in 5cba978
|
Closes #2798 by adding the MISO-pull-up as an option in the Config struct.
The only interesting bit is that in order for get_current_config to still work, I added a pull() function to the SealedPin trait:
I hope that I captured all the cases correctly there. Is it okay for the pull() function to reside inside the SealedPin?
Thje only missing thing (and why this is a draft currently) is that it relies on the MODE bits being set correctly for gpio v1, in order to determine whether the pin is an input or output and this is broken currently because of this bug: #2942
Since it needs changes in the same files, I also tried to mitigate #2942 in a quick way by introducing the Speed::Input so that the set_speed function does not overwrite the input. Speed::None might be a better name though, and I feel like this solution is not ideal, but it is non-invasive.-> Will be moved into separate PR.