boards/nucleo-f446re: add SocketCAN example
This commit is contained in:
parent
3b1de327cd
commit
2aede9168b
71
boards/arm/stm32/nucleo-f446re/configs/cansock/defconfig
Normal file
71
boards/arm/stm32/nucleo-f446re/configs/cansock/defconfig
Normal file
@ -0,0 +1,71 @@
|
||||
#
|
||||
# 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_ARCH_FPU is not set
|
||||
# CONFIG_NET_ETHERNET is not set
|
||||
# CONFIG_NET_IPv4 is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
# CONFIG_STM32_FLASH_PREFETCH is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="nucleo-f446re"
|
||||
CONFIG_ARCH_BOARD_NUCLEO_F446RE=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F446R=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LATE_INITIALIZE=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=8499
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CAN_EXTID=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_IOB_BUFSIZE=16
|
||||
CONFIG_IOB_NBUFFERS=1024
|
||||
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_DISABLE_IFUPDOWN=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=131072
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_LPWORKPRIORITY=176
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_START_DAY=14
|
||||
CONFIG_START_MONTH=10
|
||||
CONFIG_START_YEAR=2014
|
||||
CONFIG_STM32_CAN1=y
|
||||
CONFIG_STM32_CAN_SOCKET=y
|
||||
CONFIG_STM32_CAN_TSEG1=13
|
||||
CONFIG_STM32_CAN_TSEG2=2
|
||||
CONFIG_STM32_CRC=y
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_OTGFS=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
@ -45,9 +45,14 @@ endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STM32_CAN),y)
|
||||
ifeq ($(CONFIG_STM32_CAN_CHARDRIVER),y)
|
||||
CSRCS += stm32_can.c
|
||||
endif
|
||||
ifeq ($(CONFIG_STM32_CAN_SOCKET),y)
|
||||
CSRCS += stm32_cansock.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STM32_PWM),y)
|
||||
CSRCS += stm32_pwm.c
|
||||
|
@ -324,6 +324,18 @@ int stm32_adc_setup(void);
|
||||
int stm32_can_setup(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_cansock_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize CAN socket interface
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32_CAN_SOCKET
|
||||
int stm32_cansock_setup(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_ajoy_initialize
|
||||
*
|
||||
|
@ -161,6 +161,16 @@ int stm32_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_CAN_SOCKET
|
||||
/* Initialize CAN socket interface */
|
||||
|
||||
ret = stm32_cansock_setup();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: stm32_cansock_setup failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_VIDEO_FB
|
||||
/* Initialize and register the framebuffer driver */
|
||||
|
||||
|
83
boards/arm/stm32/nucleo-f446re/src/stm32_cansock.c
Normal file
83
boards/arm/stm32/nucleo-f446re/src/stm32_cansock.c
Normal file
@ -0,0 +1,83 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/stm32/nucleo-f446re/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 <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include "stm32_can.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#if !defined(CONFIG_STM32_CAN1) && !defined(CONFIG_STM32_CAN2)
|
||||
# error "No CAN is enable. Please eneable at least one CAN device"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_cansock_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize CAN socket interface
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_cansock_setup(void)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
UNUSED(ret);
|
||||
|
||||
#ifdef CONFIG_STM32_CAN1
|
||||
/* Call stm32_caninitialize() to get an instance of the CAN interface */
|
||||
|
||||
ret = stm32_cansockinitialize(1);
|
||||
if (ret < 0)
|
||||
{
|
||||
canerr("ERROR: Failed to get CAN interface %d\n", ret);
|
||||
goto errout;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_CAN2
|
||||
/* Call stm32_caninitialize() to get an instance of the CAN interface */
|
||||
|
||||
ret = stm32_cansockinitialize(2);
|
||||
if (ret < 0)
|
||||
{
|
||||
canerr("ERROR: Failed to get CAN interface %d\n", ret);
|
||||
goto errout;
|
||||
}
|
||||
#endif
|
||||
|
||||
errout:
|
||||
return ret;
|
||||
}
|
Loading…
Reference in New Issue
Block a user