cpu/stm32: added optional RS485 module to uart periph
Contribution description
added optional RS485 module to uart periph, to leverage DE pin capabilities
Testing procedure
Updated a board that has a UART with the optional extra data, update the board's makefile to have FEATURES_REQUIRED += periph_uart_rs485 and verify that the DE pin toggles as expected using a logic analyzer.
Issues/PRs references
@benpicco from the reference manual:
this allows the MCU to interact with an RS-485 transceiver like this TI chip - the DE and RE inputs there can be tied to the DE line out of the MCU. DE means driver enable, RE I believe means Read Enable - basically allows for a half-duplex connection to the RS-485 bus. I will take a cut at adding the FEATURES_PROVIDED entry and HAS_PERIPH_RS485 as requested.
@benpicco with the updates I just pushed, if I run the following command on tests/periph_uart:
FEATURES_REQUIRED=periph_uart_rs485 make BOARD=nucleo-g070rb, and then use arm-none-eabi-objdump to check for the conditional code, I see it:
arm-none-eabi-objdump -S bin/nucleo-g070rb/tests_periph_uart.elf | grep de_pin
if (uart_config[uart].de_pin != GPIO_UNDEF) {
gpio_init(uart_config[uart].de_pin, GPIO_IN);
gpio_init_af(uart_config[uart].de_pin, uart_config[uart].de_af);
whereas if I omit the FEATURES_REQUIRED variable from the call to make, I do not see those symbols included. I believe this should address your questions.
@benpicco checking in - is anything still needed here?
Can you add
FEATURES_OPTIONAL += periph_uart_rs485
to tests/periph_uart so this is compile-tested?
And is the DE pin really all that's needed for RS485 operation?
Added it to tests/periph_uart. and yes, the DE pin is enough to get the MCU communicating on RS-485, as long as it is routed to an RS485 transceiver, as linked above.
@david-vankampen Kconfig needs an update to match the feature changes!
@fjmolinas hows that?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.