Skip to content

Commit 102ee2a

Browse files
raiden00plJacobCrabill
authored andcommitted
[BACKPORT] boards/nucleo-g431rb: add SocketCAN example
1 parent f5af52e commit 102ee2a

File tree

5 files changed

+162
-0
lines changed

5 files changed

+162
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#
2+
# This file is autogenerated: PLEASE DO NOT EDIT IT.
3+
#
4+
# You can use "make menuconfig" to make any modifications to the installed .config file.
5+
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
6+
# modifications.
7+
#
8+
# CONFIG_NET_ETHERNET is not set
9+
# CONFIG_NET_IPv4 is not set
10+
CONFIG_ARCH="arm"
11+
CONFIG_ARCH_BOARD="nucleo-g431rb"
12+
CONFIG_ARCH_BOARD_NUCLEO_G431RB=y
13+
CONFIG_ARCH_BUTTONS=y
14+
CONFIG_ARCH_CHIP="stm32"
15+
CONFIG_ARCH_CHIP_STM32=y
16+
CONFIG_ARCH_CHIP_STM32G431R=y
17+
CONFIG_ARCH_INTERRUPTSTACK=1024
18+
CONFIG_ARCH_STACKDUMP=y
19+
CONFIG_BOARD_LATE_INITIALIZE=y
20+
CONFIG_BOARD_LOOPSPERMSEC=8499
21+
CONFIG_BOARD_NUCLEO_G431RB_USE_HSE=y
22+
CONFIG_BUILTIN=y
23+
CONFIG_DEFAULT_TASK_STACKSIZE=1024
24+
CONFIG_FS_PROCFS=y
25+
CONFIG_INIT_ENTRYPOINT="nsh_main"
26+
CONFIG_INIT_STACKSIZE=2048
27+
CONFIG_INTELHEX_BINARY=y
28+
CONFIG_IOB_BUFSIZE=128
29+
CONFIG_IOB_NBUFFERS=10
30+
CONFIG_NET=y
31+
CONFIG_NETDEVICES=y
32+
CONFIG_NETDEV_IFINDEX=y
33+
CONFIG_NETDEV_LATEINIT=y
34+
CONFIG_NET_CAN=y
35+
CONFIG_NET_SOCKOPTS=y
36+
CONFIG_NET_STATISTICS=y
37+
CONFIG_NSH_BUILTIN_APPS=y
38+
CONFIG_NSH_FILEIOSIZE=512
39+
CONFIG_NSH_LINELEN=64
40+
CONFIG_NSH_READLINE=y
41+
CONFIG_RAM_SIZE=22528
42+
CONFIG_RAM_START=0x20000000
43+
CONFIG_RAW_BINARY=y
44+
CONFIG_RR_INTERVAL=200
45+
CONFIG_SCHED_LPWORK=y
46+
CONFIG_SCHED_WAITPID=y
47+
CONFIG_START_DAY=14
48+
CONFIG_START_MONTH=10
49+
CONFIG_START_YEAR=2014
50+
CONFIG_STM32_FDCAN1=y
51+
CONFIG_STM32_FDCAN_SOCKET=y
52+
CONFIG_STM32_JTAG_SW_ENABLE=y
53+
CONFIG_STM32_USART2=y
54+
CONFIG_SYSTEM_NSH=y
55+
CONFIG_TASK_NAME_SIZE=0
56+
CONFIG_USART2_SERIAL_CONSOLE=y

boards/arm/stm32/nucleo-g431rb/src/Make.defs

+5
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ ifeq ($(CONFIG_BOARD_STM32_IHM16M1),y)
5151
CSRCS += stm32_foc_ihm16m1.c
5252
endif
5353

54+
ifeq ($(CONFIG_STM32_FDCAN),y)
5455
ifeq ($(CONFIG_STM32_FDCAN_CHARDRIVER),y)
5556
CSRCS += stm32_can.c
5657
endif
58+
ifeq ($(CONFIG_STM32_FDCAN_SOCKET),y)
59+
CSRCS += stm32_cansock.c
60+
endif
61+
endif
5762

5863
DEPPATH += --dep-path board
5964
VPATH += :board

boards/arm/stm32/nucleo-g431rb/src/nucleo-g431rb.h

+22
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@
3131
* Pre-processor Definitions
3232
****************************************************************************/
3333

34+
/* procfs File System */
35+
36+
#ifdef CONFIG_FS_PROCFS
37+
# ifdef CONFIG_NSH_PROC_MOUNTPOINT
38+
# define STM32_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT
39+
# else
40+
# define STM32_PROCFS_MOUNTPOINT "/proc"
41+
# endif
42+
#endif
43+
3444
/* LED definitions **********************************************************/
3545

3646
/* LED definitions **********************************************************/
@@ -155,4 +165,16 @@ int stm32_foc_setup(void);
155165
int stm32_can_setup(void);
156166
#endif
157167

168+
/****************************************************************************
169+
* Name: stm32_cansock_setup
170+
*
171+
* Description:
172+
* Initialize CAN socket interface
173+
*
174+
****************************************************************************/
175+
176+
#ifdef CONFIG_STM32_FDCAN_SOCKET
177+
int stm32_cansock_setup(void);
178+
#endif
179+
158180
#endif /* __BOARDS_ARM_STM32_NUCLEO_G431RB_SRC_NUCLEO_G431RB_H */

boards/arm/stm32/nucleo-g431rb/src/stm32_bringup.c

+22
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <syslog.h>
2929

3030
#include <nuttx/board.h>
31+
#include <nuttx/fs/fs.h>
3132

3233
#ifdef CONFIG_USERLED
3334
# include <nuttx/leds/userled.h>
@@ -71,6 +72,17 @@ int stm32_bringup(void)
7172
{
7273
int ret;
7374

75+
#ifdef CONFIG_FS_PROCFS
76+
/* Mount the procfs file system */
77+
78+
ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
79+
if (ret < 0)
80+
{
81+
syslog(LOG_ERR,
82+
"ERROR: Failed to mount the PROC filesystem: %d\n", ret);
83+
}
84+
#endif /* CONFIG_FS_PROCFS */
85+
7486
#ifdef CONFIG_INPUT_BUTTONS
7587
/* Register the BUTTON driver */
7688

@@ -132,6 +144,16 @@ int stm32_bringup(void)
132144
}
133145
#endif
134146

147+
#ifdef CONFIG_STM32_FDCAN_SOCKET
148+
/* Initialize CAN socket interface */
149+
150+
ret = stm32_cansock_setup();
151+
if (ret < 0)
152+
{
153+
syslog(LOG_ERR, "ERROR: stm32_cansock_setup failed: %d\n", ret);
154+
}
155+
#endif
156+
135157
UNUSED(ret);
136158
return OK;
137159
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/****************************************************************************
2+
* boards/arm/stm32/nucleo-g431rb/src/stm32_cansock.c
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
*
19+
****************************************************************************/
20+
21+
/****************************************************************************
22+
* Included Files
23+
****************************************************************************/
24+
25+
#include <nuttx/config.h>
26+
27+
#include <debug.h>
28+
29+
#include "stm32_fdcan.h"
30+
31+
/****************************************************************************
32+
* Public Functions
33+
****************************************************************************/
34+
35+
/****************************************************************************
36+
* Name: stm32_cansock_setup
37+
*
38+
* Description:
39+
* Initialize CAN socket interface
40+
*
41+
****************************************************************************/
42+
43+
int stm32_cansock_setup(void)
44+
{
45+
int ret;
46+
47+
/* Call stm32_fdcaninitialize() to get an instance of the FDCAN interface */
48+
49+
ret = stm32_fdcansockinitialize(1);
50+
if (ret < 0)
51+
{
52+
canerr("ERROR: Failed to get FDCAN interface %d\n", ret);
53+
return ret;
54+
}
55+
56+
return OK;
57+
}

0 commit comments

Comments
 (0)