diff --git a/boards/arm/stm32/nucleo-g431rb/configs/cansock/defconfig b/boards/arm/stm32/nucleo-g431rb/configs/cansock/defconfig new file mode 100644 index 0000000000..44326688cc --- /dev/null +++ b/boards/arm/stm32/nucleo-g431rb/configs/cansock/defconfig @@ -0,0 +1,56 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_NET_ETHERNET is not set +# CONFIG_NET_IPv4 is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nucleo-g431rb" +CONFIG_ARCH_BOARD_NUCLEO_G431RB=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_CHIP="stm32" +CONFIG_ARCH_CHIP_STM32=y +CONFIG_ARCH_CHIP_STM32G431R=y +CONFIG_ARCH_INTERRUPTSTACK=1024 +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARD_LATE_INITIALIZE=y +CONFIG_BOARD_LOOPSPERMSEC=8499 +CONFIG_BOARD_NUCLEO_G431RB_USE_HSE=y +CONFIG_BUILTIN=y +CONFIG_DEFAULT_TASK_STACKSIZE=1024 +CONFIG_FS_PROCFS=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=2048 +CONFIG_INTELHEX_BINARY=y +CONFIG_IOB_BUFSIZE=128 +CONFIG_IOB_NBUFFERS=10 +CONFIG_NET=y +CONFIG_NETDEVICES=y +CONFIG_NETDEV_IFINDEX=y +CONFIG_NETDEV_LATEINIT=y +CONFIG_NET_CAN=y +CONFIG_NET_SOCKOPTS=y +CONFIG_NET_STATISTICS=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=22528 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=14 +CONFIG_START_MONTH=10 +CONFIG_START_YEAR=2014 +CONFIG_STM32_FDCAN1=y +CONFIG_STM32_FDCAN_SOCKET=y +CONFIG_STM32_JTAG_SW_ENABLE=y +CONFIG_STM32_USART2=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_USART2_SERIAL_CONSOLE=y diff --git a/boards/arm/stm32/nucleo-g431rb/src/Make.defs b/boards/arm/stm32/nucleo-g431rb/src/Make.defs index 7d3c4283a3..6401b82130 100644 --- a/boards/arm/stm32/nucleo-g431rb/src/Make.defs +++ b/boards/arm/stm32/nucleo-g431rb/src/Make.defs @@ -55,9 +55,14 @@ ifeq ($(CONFIG_MATH_CORDIC),y) CSRCS += stm32_cordic.c endif +ifeq ($(CONFIG_STM32_FDCAN),y) ifeq ($(CONFIG_STM32_FDCAN_CHARDRIVER),y) CSRCS += stm32_can.c endif +ifeq ($(CONFIG_STM32_FDCAN_SOCKET),y) +CSRCS += stm32_cansock.c +endif +endif DEPPATH += --dep-path board VPATH += :board diff --git a/boards/arm/stm32/nucleo-g431rb/src/nucleo-g431rb.h b/boards/arm/stm32/nucleo-g431rb/src/nucleo-g431rb.h index 26196b9d2d..553f655adb 100644 --- a/boards/arm/stm32/nucleo-g431rb/src/nucleo-g431rb.h +++ b/boards/arm/stm32/nucleo-g431rb/src/nucleo-g431rb.h @@ -31,6 +31,16 @@ * Pre-processor Definitions ****************************************************************************/ +/* procfs File System */ + +#ifdef CONFIG_FS_PROCFS +# ifdef CONFIG_NSH_PROC_MOUNTPOINT +# define STM32_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT +# else +# define STM32_PROCFS_MOUNTPOINT "/proc" +# endif +#endif + /* LED definitions **********************************************************/ /* LED definitions **********************************************************/ @@ -167,4 +177,16 @@ int stm32_cordic_setup(void); int stm32_can_setup(void); #endif +/**************************************************************************** + * Name: stm32_cansock_setup + * + * Description: + * Initialize CAN socket interface + * + ****************************************************************************/ + +#ifdef CONFIG_STM32_FDCAN_SOCKET +int stm32_cansock_setup(void); +#endif + #endif /* __BOARDS_ARM_STM32_NUCLEO_G431RB_SRC_NUCLEO_G431RB_H */ diff --git a/boards/arm/stm32/nucleo-g431rb/src/stm32_bringup.c b/boards/arm/stm32/nucleo-g431rb/src/stm32_bringup.c index f204587c97..cc2b19415e 100644 --- a/boards/arm/stm32/nucleo-g431rb/src/stm32_bringup.c +++ b/boards/arm/stm32/nucleo-g431rb/src/stm32_bringup.c @@ -28,6 +28,7 @@ #include #include +#include #ifdef CONFIG_USERLED # include @@ -75,6 +76,17 @@ int stm32_bringup(void) { int ret; +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to mount the PROC filesystem: %d\n", ret); + } +#endif /* CONFIG_FS_PROCFS */ + #ifdef CONFIG_INPUT_BUTTONS /* Register the BUTTON driver */ @@ -159,6 +171,16 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_STM32_FDCAN_SOCKET + /* Initialize CAN socket interface */ + + ret = stm32_cansock_setup(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_cansock_setup failed: %d\n", ret); + } +#endif + UNUSED(ret); return OK; } diff --git a/boards/arm/stm32/nucleo-g431rb/src/stm32_cansock.c b/boards/arm/stm32/nucleo-g431rb/src/stm32_cansock.c new file mode 100644 index 0000000000..e446a548e2 --- /dev/null +++ b/boards/arm/stm32/nucleo-g431rb/src/stm32_cansock.c @@ -0,0 +1,57 @@ +/**************************************************************************** + * boards/arm/stm32/nucleo-g431rb/src/stm32_cansock.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include "stm32_fdcan.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_cansock_setup + * + * Description: + * Initialize CAN socket interface + * + ****************************************************************************/ + +int stm32_cansock_setup(void) +{ + int ret; + + /* Call stm32_fdcaninitialize() to get an instance of the FDCAN interface */ + + ret = stm32_fdcansockinitialize(1); + if (ret < 0) + { + canerr("ERROR: Failed to get FDCAN interface %d\n", ret); + return ret; + } + + return OK; +}