-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
ports/stm32/uart: Add an option to disable UART RX pull-up. #15798
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
Conversation
3261e88
to
8ba3db3
Compare
Code size report:
|
I think that's a slightly better way to do it. Because otherwise we have to agree on the changes to the API which may then be used by other ports. And probably it should default to no pull-ups, because that's what most (all?) other ports have. And with a compile-time config option, the user doesn't have to worry about which UART needs the pull up enabled/disabled. I'm assuming that your board itself has the RS485 transceiver installed on a fixed UART instance, and so a static configuration would suffice? Also note that both RX and CTS are pulled high. CTS is more important to pull high than RX, otherwise transmission can get blocked if the other side doesn't do the right thing with CTS (it's RTS). Did you intend for this option to apply to both RX and CTS, or just RX? |
Instead of using |
mimxrt seems to enable some default pull-ups on all lines (even TX and RTS). I'm not sure if any of them is needed though.
Yes exactly. This is for the OPTA's board which is currently being added upstream. So I think I should get this done first because it will require changes to the board config file.
We didn't test them separately, but without the pull-up on both modbus started working. Would you like to still use |
38b0e0e
to
1cad516
Compare
I think they need to be individually configurable... even if that does increase the configuration options by a lot. I don't like negatives like "NO" in config options because it makes it harder to understand when it's in logic like So, it would be |
Looking at the original code again, it seems to be configuring a pull-up on all pins not just RX/CTS, am I right ? If so then for (uint i = 0; i < 4; i++) {
if (pins[i] != NULL) {
// Configure pull-up on RX and CTS (the input pins).
uint32_t pull = (i & 1) ? MP_HAL_PIN_PULL_UP : MP_HAL_PIN_PULL_NONE;
bool ret = mp_hal_pin_config_alt(pins[i], mode, pull, uart_fn, uart_unit);
if (!ret) {
return false;
}
}
} EDIT ah I see the |
This will just complicate the logic above, not sure if fine-grained control over this is really needed: you either need the pull-ups or not, but I can try. |
1cad516
to
f041eb9
Compare
Okay, how about now with an array solution ? |
Yes, that looks good! Does it work for the OPTA? |
I'm confident it will, we just needed to disable the RX pull on UART3. I can't test it right now, but will ask someone else to test it after this and the Opta support are merged. |
The UART driver enables a pull-up on RX/CTS pins by default. This can cause UART to fail to receive in certain situations, eg with RS485 transceivers. This commit adds compile-time configuration options to set the pull mode on the RX and CTS pins of each UART. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
f041eb9
to
eec5eb4
Compare
Summary
We're using an RS485 transceiver and UART fails to receive if this pull-up is enabled.
Testing
We've tested this new arg, and it works. It shouldn't have any side-effects as it's set to true by default, so old behavior is maintained by default.
Trade-offs and Alternatives
An alternative would be to add a compile-time config option (vs the runtime arg). This will result in less changes to the APIs, especially
machine_uart
. The changes will be inuart.c
and will look like this:However we need one for every UART/LPUART instance. It's fine with me either way.