RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

cpu/stm32: added optional RS485 module to uart periph

Open david-vankampen opened this issue 4 years ago • 8 comments

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

david-vankampen avatar Sep 28 '21 12:09 david-vankampen

@benpicco from the reference manual: image 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.

david-vankampen avatar Oct 04 '21 23:10 david-vankampen

@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.

david-vankampen avatar Oct 04 '21 23:10 david-vankampen

@benpicco checking in - is anything still needed here?

david-vankampen avatar Oct 13 '21 22:10 david-vankampen

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?

benpicco avatar Oct 14 '21 10:10 benpicco

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 avatar Oct 14 '21 11:10 david-vankampen

@david-vankampen Kconfig needs an update to match the feature changes!

fjmolinas avatar Nov 18 '21 10:11 fjmolinas

@fjmolinas hows that?

david-vankampen avatar Nov 19 '21 13:11 david-vankampen

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.

stale[bot] avatar Jul 10 '22 11:07 stale[bot]