Skip to content

Commit

Permalink
stm32h7/linum-stm32h753bi: fix fdcan configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Guzman <[email protected]>
  • Loading branch information
JorgeGzm authored and xiaoxiang781216 committed Dec 26, 2024
1 parent 3093b28 commit d4acd69
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
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

0 comments on commit d4acd69

Please sign in to comment.