Add HW DTR support (port of #2994) - #3796
Conversation
bugadani
left a comment
There was a problem hiding this comment.
It's somewhat unclear to me what we are supposed to do with ESP32 :/
| } | ||
|
|
||
| /// Enable RS485 mode | ||
| pub fn with_rs485(self) -> Self { |
There was a problem hiding this comment.
- needs to be
unstable(if you keep it) - should be called
into_rs485and there is no way to disable it, either (if you keep it). - Maybe this function should be turned into a Config struct field? All other configuration is set there.
- I'm still not sure we want to shoehorn RS485 into the main UART driver. Given that this is pretty minor and also unstable, maybe we can, for now.
There was a problem hiding this comment.
Maybe this function should be turned into a Config struct field? All other configuration is set there.
I don't know nearly enough about rs485, but I think I agree here. Especially when you think about how to turn it off. We already have options, like hardware flow control, which have a config setting and require pins to be passed. I think we should follow this pattern.
I'm still not sure we want to shoehorn RS485 into the main UART driver. Given that this is pretty minor and also unstable, maybe we can, for now.
I agree, that we can experiment with this as an unstable API and figure out if it needs to be a separate driver.
There was a problem hiding this comment.
Okay apparently DTR/DSR are not available in the hardware
There was a problem hiding this comment.
All fair points, I'm currently still testing it out after porting #2994. I think putting it in the Uart driver makes sense given the reference manual, but I'm not against something like an Rs485<'a, T: Uart> but either way you need to access the Uart registers.
|
New commits in main has made this PR unmergable. Please resolve the conflicts. |
|
Hey, I am very interested in reviving this branch or exposing this feature anyhow, RS485 with a decent baudrate (like a standard 115200) is basically unusable without hardware direction control when using it within embassy. I tried a bunch of stuff, like:
the window to change direction is about 100us for 115200 baudrate and it is not uncommon to run smaller RS485 buses with a 1Mbit and more. Given my prior experience with RS485 on much older chips, I guess this can also be done in software if the bare interrupt handler takes responsibility for the direction (this could be any GPIO instead of DTR then), if that's the only way to create a uniform behavior across the chip family. I'd be happy to implement this feature in my spare time as I need this for my hobby project but let me know if it should be a config or a builder. I am leaning slightly towards the builder pattern as you need to asign the (not that this is a big argument, but in fact I had a small LLM ideation session on how to hotfix my issue and it hallucinated that this method is already there) |
Submission Checklist 📝
cargo xtask fmt-packagescommand to ensure that all changed code is formatted correctly.CHANGELOG.mdin the proper section.Extra:
Pull Request Details 📖
Description
This is a port of #2994 for mainline (1.0.0-beta1).
Testing
Currently test it on a board to control an RS485 transceiver chip