From dd468add8a22806468edc0c8e8318ba78be9ffd4 Mon Sep 17 00:00:00 2001 From: "Paul A. Patience" Date: Thu, 8 Oct 2015 13:05:06 -0400 Subject: [PATCH 1/2] Nucleo F303RE and STM32F4-Discovery: Configure CAN GPIOs in stm32_boardinitialize() instead of in board_app_initialize() --- .../nucleo-f303re/src/stm32_appinitialize.c | 8 +- configs/nucleo-f303re/src/stm32_boot.c | 5 ++ configs/nucleo-f303re/src/stm32_ssd1351.c | 1 + configs/nucleo-f303re/uavcan/defconfig | 8 +- configs/stm32f4discovery/src/Makefile | 4 - .../src/stm32_appinitialize.c | 73 ------------------- configs/stm32f4discovery/src/stm32_boot.c | 5 ++ configs/stm32f4discovery/uavcan/defconfig | 8 +- 8 files changed, 15 insertions(+), 97 deletions(-) delete mode 100644 configs/stm32f4discovery/src/stm32_appinitialize.c diff --git a/configs/nucleo-f303re/src/stm32_appinitialize.c b/configs/nucleo-f303re/src/stm32_appinitialize.c index 41423a4489..dce4fd5090 100644 --- a/configs/nucleo-f303re/src/stm32_appinitialize.c +++ b/configs/nucleo-f303re/src/stm32_appinitialize.c @@ -41,8 +41,9 @@ #include +#include + #include -#include /**************************************************************************** * Pre-processor Definitions @@ -64,10 +65,5 @@ int board_app_initialize(void) { -#ifdef CONFIG_CANUTILS_UAVCAN - (void)stm32_configgpio(GPIO_CAN1_RX); - (void)stm32_configgpio(GPIO_CAN1_TX); -#endif - return OK; } diff --git a/configs/nucleo-f303re/src/stm32_boot.c b/configs/nucleo-f303re/src/stm32_boot.c index 97cac120a1..1bd8390f8a 100644 --- a/configs/nucleo-f303re/src/stm32_boot.c +++ b/configs/nucleo-f303re/src/stm32_boot.c @@ -86,6 +86,11 @@ void stm32_boardinitialize(void) } #endif +#ifdef CONFIG_CANUTILS_UAVCAN + (void)stm32_configgpio(GPIO_CAN1_RX); + (void)stm32_configgpio(GPIO_CAN1_TX); +#endif + /* Configure on-board LEDs if LED support has been selected. */ #ifdef CONFIG_ARCH_LEDS diff --git a/configs/nucleo-f303re/src/stm32_ssd1351.c b/configs/nucleo-f303re/src/stm32_ssd1351.c index ef39a8711f..f4ccf495e6 100644 --- a/configs/nucleo-f303re/src/stm32_ssd1351.c +++ b/configs/nucleo-f303re/src/stm32_ssd1351.c @@ -136,4 +136,5 @@ FAR struct lcd_dev_s *board_graphics_setup(unsigned int devno) return NULL; } + #endif /* CONFIG_LCD_SSD1351 */ diff --git a/configs/nucleo-f303re/uavcan/defconfig b/configs/nucleo-f303re/uavcan/defconfig index f98e0145f1..d16d6a21d4 100644 --- a/configs/nucleo-f303re/uavcan/defconfig +++ b/configs/nucleo-f303re/uavcan/defconfig @@ -471,13 +471,7 @@ CONFIG_ARCH_HAVE_IRQBUTTONS=y # # Board-Specific Options # -CONFIG_LIB_BOARDCTL=y -# CONFIG_BOARDCTL_RESET is not set -# CONFIG_BOARDCTL_TSCTEST is not set -# CONFIG_BOARDCTL_ADCTEST is not set -# CONFIG_BOARDCTL_PWMTEST is not set -# CONFIG_BOARDCTL_GRAPHICS is not set -# CONFIG_BOARDCTL_IOCTL is not set +# CONFIG_LIB_BOARDCTL is not set # # RTOS Features diff --git a/configs/stm32f4discovery/src/Makefile b/configs/stm32f4discovery/src/Makefile index ec029b1ea1..31a8f3dd23 100644 --- a/configs/stm32f4discovery/src/Makefile +++ b/configs/stm32f4discovery/src/Makefile @@ -48,10 +48,6 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y) CSRCS += stm32_buttons.c endif -ifeq ($(CONFIG_LIB_BOARDCTL),y) -CSRCS += stm32_appinitialize.c -endif - ifeq ($(CONFIG_STM32_OTGFS),y) CSRCS += stm32_usb.c endif diff --git a/configs/stm32f4discovery/src/stm32_appinitialize.c b/configs/stm32f4discovery/src/stm32_appinitialize.c deleted file mode 100644 index a9ff218e96..0000000000 --- a/configs/stm32f4discovery/src/stm32_appinitialize.c +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** - * configs/stm32f4discovery/src/stm32_appinitialize.c - * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. - * Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved. - * Authors: Gregory Nutt - * Paul Alexander Patience - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: board_app_initialize - * - * Description: - * Perform application specific initialization. This function is never - * called directly from application code, but only indirectly via the - * (non-standard) boardctl() interface using the command BOARDIOC_INIT. - * - ****************************************************************************/ - -int board_app_initialize(void) -{ -#ifdef CONFIG_CANUTILS_UAVCAN - (void)stm32_configgpio(GPIO_CAN1_RX); - (void)stm32_configgpio(GPIO_CAN1_TX); -#endif - - return OK; -} diff --git a/configs/stm32f4discovery/src/stm32_boot.c b/configs/stm32f4discovery/src/stm32_boot.c index 2f1a431ae7..fd4840da2d 100644 --- a/configs/stm32f4discovery/src/stm32_boot.c +++ b/configs/stm32f4discovery/src/stm32_boot.c @@ -104,6 +104,11 @@ void stm32_boardinitialize(void) } #endif +#ifdef CONFIG_CANUTILS_UAVCAN + (void)stm32_configgpio(GPIO_CAN1_RX); + (void)stm32_configgpio(GPIO_CAN1_TX); +#endif + #ifdef CONFIG_ARCH_LEDS /* Configure on-board LEDs if LED support has been selected. */ diff --git a/configs/stm32f4discovery/uavcan/defconfig b/configs/stm32f4discovery/uavcan/defconfig index becda00937..d59cde3627 100644 --- a/configs/stm32f4discovery/uavcan/defconfig +++ b/configs/stm32f4discovery/uavcan/defconfig @@ -492,13 +492,7 @@ CONFIG_ARCH_HAVE_IRQBUTTONS=y # Board-Specific Options # # CONFIG_STM32F4DISBB is not set -CONFIG_LIB_BOARDCTL=y -# CONFIG_BOARDCTL_RESET is not set -# CONFIG_BOARDCTL_TSCTEST is not set -# CONFIG_BOARDCTL_ADCTEST is not set -# CONFIG_BOARDCTL_PWMTEST is not set -# CONFIG_BOARDCTL_GRAPHICS is not set -# CONFIG_BOARDCTL_IOCTL is not set +# CONFIG_LIB_BOARDCTL is not set # # RTOS Features From a778cb3a49597228573e9f98e935145735e9ad37 Mon Sep 17 00:00:00 2001 From: "Paul A. Patience" Date: Thu, 8 Oct 2015 15:38:01 -0400 Subject: [PATCH 2/2] STM32F4-Discovery: Configure CAN2 GPIOs if UAVCAN uses two interfaces --- configs/stm32f4discovery/include/board.h | 7 ++++++- configs/stm32f4discovery/src/stm32_boot.c | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/configs/stm32f4discovery/include/board.h b/configs/stm32f4discovery/include/board.h index e63a4455be..4d0720fa36 100644 --- a/configs/stm32f4discovery/include/board.h +++ b/configs/stm32f4discovery/include/board.h @@ -237,13 +237,18 @@ #define BUTTON_USER_BIT (1 << BUTTON_USER) /* Alternate function pin selections ************************************************/ -/* CAN1 */ +/* CAN */ #ifndef CONFIG_STM32_FSMC # define GPIO_CAN1_RX GPIO_CAN1_RX_3 # define GPIO_CAN1_TX GPIO_CAN1_TX_3 #endif +#ifndef CONFIG_STM32_ETHMAC +# define GPIO_CAN2_RX GPIO_CAN2_RX_1 +# define GPIO_CAN2_TX GPIO_CAN2_TX_1 +#endif + /* UART2: * * The STM32F4 Discovery has no on-board serial devices, but the console is diff --git a/configs/stm32f4discovery/src/stm32_boot.c b/configs/stm32f4discovery/src/stm32_boot.c index fd4840da2d..44c3b71188 100644 --- a/configs/stm32f4discovery/src/stm32_boot.c +++ b/configs/stm32f4discovery/src/stm32_boot.c @@ -107,6 +107,10 @@ void stm32_boardinitialize(void) #ifdef CONFIG_CANUTILS_UAVCAN (void)stm32_configgpio(GPIO_CAN1_RX); (void)stm32_configgpio(GPIO_CAN1_TX); +# if CONFIG_UAVCAN_STM32_NUM_IFACES > 1 + (void)stm32_configgpio(GPIO_CAN2_RX); + (void)stm32_configgpio(GPIO_CAN2_TX); +# endif #endif #ifdef CONFIG_ARCH_LEDS