Skip to content

Commit d9ee02b

Browse files
raiden00plxiaoxiang781216
authored andcommitted
boards/nucleo-f302r8: add rs485 support
add rs485 support for nucleo-f302r8 based on RS485 CAN Waveshare shield. Signed-off-by: raiden00pl <[email protected]>
1 parent 6443b33 commit d9ee02b

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

boards/arm/stm32/nucleo-f302r8/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ config NUCLEOF302R8_HIGHPRI
99
bool "High priority interrupt test"
1010
default n
1111

12+
config NUCLEOF302R8_RS485_WAVESHARE
13+
bool "Map USART1 pins to match RS485 CAN Waveshare shield"
14+
default n
15+
1216
if SENSORS_QENCODER
1317

1418
config NUCLEO_F302R8_QETIMER

boards/arm/stm32/nucleo-f302r8/include/board.h

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,31 @@
206206
#define GPIO_USART2_RX GPIO_USART2_RX_2 /* PA3 */
207207
#define GPIO_USART2_TX GPIO_USART2_TX_2 /* PA2 */
208208

209-
/* USART1 */
209+
/* USART1
210+
*
211+
* At default use:
212+
* USART1_RX - PB7
213+
* USART1_TX - PB6
214+
*
215+
* If CONFIG_NUCLEOF302R8_RS485_WAVESHARE=y use configuration to match RS485
216+
* shield from Waveshare:
217+
*
218+
* USART1_RX - PA10
219+
* USART1_TX - PA9
220+
* RS485_DIR - PA8 (arduino D7)
221+
*
222+
*/
210223

211-
#define GPIO_USART1_RX GPIO_USART1_RX_2 /* PB7 */
212-
#define GPIO_USART1_TX GPIO_USART1_TX_2 /* PB6 */
224+
#ifdef CONFIG_NUCLEOF302R8_RS485_WAVESHARE
225+
# define GPIO_USART1_RX GPIO_USART1_RX_1 /* PA10 */
226+
# define GPIO_USART1_TX GPIO_USART1_TX_1 /* PA9 */
227+
# define GPIO_USART1_RS485_DIR (GPIO_OUTPUT | GPIO_PUSHPULL | \
228+
GPIO_SPEED_50MHz | GPIO_OUTPUT_CLEAR | \
229+
GPIO_PORTA | GPIO_PIN8)
230+
#else
231+
# define GPIO_USART1_RX GPIO_USART1_RX_2 /* PB7 */
232+
# define GPIO_USART1_TX GPIO_USART1_TX_2 /* PB6 */
233+
#endif
213234

214235
/* CAN */
215236

0 commit comments

Comments
 (0)