Skip to content
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

stm32h7/linum-stm32h753bi: fix fdcan configuration #15343

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -873,3 +873,23 @@ tone

This example demonstrates how to use PWM4 and Timer17 to play music using the Tone library and the board's buzzer.

socketcan
---------

This example demonstrates how to use the CAN-FD peripherals can0 and can1 with the SocketCAN protocol.::

# Configure the can0 and can1 to send messages
nsh> ifup can0
ifup can0...OK
nsh> ifup can1
ifup can1 ...OK
nsh> cansend can0 123#DEADBEEF
nsh> cansend can1 5A1#11.2233.44556677.88

# Reset the board and configure the can0 peripheral to receive messages
nsh> ifup can0
ifup can0...OK
nsh> candump can0
can0 051 [8] 00 11 22 33 44 55 66 77
can0 051 [16] 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ CONFIG_DEBUG_NET_ERROR=y
CONFIG_DEBUG_NET_INFO=y
CONFIG_DEBUG_NET_WARN=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_FDCAN1_ARBI_BITRATE=125000
CONFIG_FDCAN1_DATA_BITRATE=1000000
CONFIG_FDCAN2_ARBI_BITRATE=125000
CONFIG_FDCAN2_DATA_BITRATE=1000000
CONFIG_FS_PROCFS=y
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INTELHEX_BINARY=y
Expand Down
16 changes: 10 additions & 6 deletions boards/arm/stm32h7/linum-stm32h753bi/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@

/* RS485 DIR pin: PA15 */

# define GPIO_UART4_RS485_DIR (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_100MHz|\
GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN15)
# define GPIO_UART4_RS485_DIR (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_100MHz |\
GPIO_OUTPUT_CLEAR | GPIO_PORTA | GPIO_PIN15)

#endif

Expand Down Expand Up @@ -422,13 +422,17 @@

/* FDCAN1 */

#define GPIO_CAN1_RX (GPIO_CAN1_RX_3|GPIO_SPEED_50MHz) /* PD0 */
#define GPIO_CAN1_TX (GPIO_CAN1_TX_3|GPIO_SPEED_50MHz) /* PD1 */
#define GPIO_CAN1_RX (GPIO_CAN1_RX_4|GPIO_SPEED_50MHz) /* PH14 */
#define GPIO_CAN1_TX (GPIO_CAN1_TX_4|GPIO_SPEED_50MHz) /* PH13 */
#define GPIO_CAN1_STD (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_100MHz |\
GPIO_OUTPUT_CLEAR | GPIO_PORTI | GPIO_PIN2) /* PI2 */

/* FDCAN2 */

#define GPIO_CAN2_RX (GPIO_CAN2_RX_2|GPIO_SPEED_50MHz) /* PB5 - D11 */
#define GPIO_CAN2_TX (GPIO_CAN2_TX_2|GPIO_SPEED_50MHz) /* PB6 - D1 */
#define GPIO_CAN2_RX (GPIO_CAN2_RX_1|GPIO_SPEED_50MHz) /* PB12 */
#define GPIO_CAN2_TX (GPIO_CAN2_TX_1|GPIO_SPEED_50MHz) /* PB13 */
#define GPIO_CAN2_STD (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_100MHz |\
GPIO_OUTPUT_CLEAR | GPIO_PORTE | GPIO_PIN3) /* PE3 */

/* QSPI Mapping */

Expand Down
10 changes: 10 additions & 0 deletions boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,20 @@ int stm32_bringup(void)
#ifdef CONFIG_NETDEV_LATEINIT

# ifdef CONFIG_STM32H7_FDCAN1

/* Enable and configure CAN1 */

stm32_configgpio(GPIO_CAN1_STD);
stm32_gpiowrite(GPIO_CAN1_STD, false);
stm32_fdcansockinitialize(0);
# endif

# ifdef CONFIG_STM32H7_FDCAN2

/* Enable and configure CAN2 */

stm32_configgpio(GPIO_CAN2_STD);
stm32_gpiowrite(GPIO_CAN2_STD, false);
stm32_fdcansockinitialize(1);
# endif

Expand Down
Loading