From c9ecb3c378955e82aec4b8bb6498ddc4ae44b071 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Sat, 11 Mar 2017 15:35:03 +0000 Subject: [PATCH 1/5] As discovered by dcabecinhas. This fix assume the 8 byte alignment options for size stack size or this will overwrite the first word after TOS See https://github.com/PX4/Firmware/issues/6613#issuecomment-285869778 --- arch/arm/src/common/up_initialize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/src/common/up_initialize.c b/arch/arm/src/common/up_initialize.c index 5182598246a..aeee1aaf503 100644 --- a/arch/arm/src/common/up_initialize.c +++ b/arch/arm/src/common/up_initialize.c @@ -106,7 +106,7 @@ static inline void up_color_intstack(void) uint32_t *ptr = (uint32_t *)&g_intstackalloc; ssize_t size; - for (size = (CONFIG_ARCH_INTERRUPTSTACK & ~3); + for (size = (CONFIG_ARCH_INTERRUPTSTACK & ~7); size > 0; size -= sizeof(uint32_t)) { From cdfc158f90968a6eed2bf4dc9cd4fb0ed79cb200 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Sat, 11 Mar 2017 15:40:48 +0000 Subject: [PATCH 2/5] up_initialize.c edited online with Bitbucket --- arch/arm/src/common/up_initialize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/src/common/up_initialize.c b/arch/arm/src/common/up_initialize.c index aeee1aaf503..267f5e1c594 100644 --- a/arch/arm/src/common/up_initialize.c +++ b/arch/arm/src/common/up_initialize.c @@ -100,7 +100,7 @@ static void up_calibratedelay(void) * ****************************************************************************/ -#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3 +#if defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 7 static inline void up_color_intstack(void) { uint32_t *ptr = (uint32_t *)&g_intstackalloc; From 70d8f0189d722c8cd7115a6648cdafa5257f99b4 Mon Sep 17 00:00:00 2001 From: Simon Piriou Date: Sat, 11 Mar 2017 18:15:18 +0100 Subject: [PATCH 3/5] stm32f20xxx: add BOARD_DISABLE_USBOTG_HSULPI flag --- arch/arm/src/stm32/stm32f20xxx_rcc.c | 6 ++++++ configs/photon/include/board.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/arch/arm/src/stm32/stm32f20xxx_rcc.c b/arch/arm/src/stm32/stm32f20xxx_rcc.c index a45241ed85b..ad71714a803 100644 --- a/arch/arm/src/stm32/stm32f20xxx_rcc.c +++ b/arch/arm/src/stm32/stm32f20xxx_rcc.c @@ -195,7 +195,13 @@ static inline void rcc_enableahb1(void) #ifdef CONFIG_STM32_OTGHS /* USB OTG HS */ +#ifndef BOARD_DISABLE_USBOTG_HSULPI + /* Enable clocking for OTG and external PHY */ + regval |= (RCC_AHB1ENR_OTGHSEN | RCC_AHB1ENR_OTGHSULPIEN); +#else + regval |= (RCC_AHB1ENR_OTGHSEN); +#endif #endif putreg32(regval, STM32_RCC_AHB1ENR); /* Enable peripherals */ diff --git a/configs/photon/include/board.h b/configs/photon/include/board.h index ac5faed041e..efce6731152 100644 --- a/configs/photon/include/board.h +++ b/configs/photon/include/board.h @@ -146,6 +146,10 @@ #define STM32_APB2_TIM10_CLKIN (2*STM32_PCLK2_FREQUENCY) #define STM32_APB2_TIM11_CLKIN (2*STM32_PCLK2_FREQUENCY) +/* USB OTG HS definitions ***********************************************************/ +/* Do not enable external PHY clock or OTG_HS module will not work */ +#define BOARD_DISABLE_USBOTG_HSULPI 1 + /* Alternate function pin selections ************************************************/ /* UART1 */ From ef0fe50ae6803e996bbbb32359cac20d49a8a6f7 Mon Sep 17 00:00:00 2001 From: Simon Piriou Date: Sat, 11 Mar 2017 17:51:45 +0100 Subject: [PATCH 4/5] photon: add LEDs and BUTTONS support --- configs/Kconfig | 3 + configs/photon/include/board.h | 12 ++++ configs/photon/src/Makefile | 8 +++ configs/photon/src/photon.h | 13 ++++ configs/photon/src/photon_buttons.c | 101 ++++++++++++++++++++++++++++ configs/photon/src/photon_leds.c | 86 +++++++++++++++++++++++ configs/photon/src/stm32_appinit.c | 40 +++++++++-- 7 files changed, 258 insertions(+), 5 deletions(-) create mode 100644 configs/photon/src/photon_buttons.c create mode 100644 configs/photon/src/photon_leds.c diff --git a/configs/Kconfig b/configs/Kconfig index e91e262499d..d5016d9b7ce 100644 --- a/configs/Kconfig +++ b/configs/Kconfig @@ -959,6 +959,9 @@ config ARCH_BOARD_SPARK config ARCH_BOARD_PHOTON bool "Photon wifi board" depends on ARCH_CHIP_STM32F205RG + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS ---help--- A configuration for the Photon from Particle Devices (https://www.particle.io). This board features the STM32F205RGY6 diff --git a/configs/photon/include/board.h b/configs/photon/include/board.h index efce6731152..15ee036088e 100644 --- a/configs/photon/include/board.h +++ b/configs/photon/include/board.h @@ -150,6 +150,18 @@ /* Do not enable external PHY clock or OTG_HS module will not work */ #define BOARD_DISABLE_USBOTG_HSULPI 1 +/* LED definitions ******************************************************************/ + +#define BOARD_LED1 0 +#define BOARD_NLEDS 1 +#define BOARD_LED1_BIT (1 << BOARD_LED1) + +/* Button definitions ***************************************************************/ + +#define BOARD_BUTTON1 0 +#define NUM_BUTTONS 1 +#define BOARD_BUTTON1_BIT (1 << BOARD_BUTTON1) + /* Alternate function pin selections ************************************************/ /* UART1 */ diff --git a/configs/photon/src/Makefile b/configs/photon/src/Makefile index ae24c7d4c03..f834e2c7fa0 100644 --- a/configs/photon/src/Makefile +++ b/configs/photon/src/Makefile @@ -41,6 +41,14 @@ ifeq ($(CONFIG_PHOTON_DFU_BOOTLOADER),y) CSRCS += dfu_signature.c endif +ifeq ($(CONFIG_BUTTONS),y) +CSRCS += photon_buttons.c +endif + +ifeq ($(CONFIG_USERLED),y) +CSRCS += photon_leds.c +endif + ifeq ($(CONFIG_PHOTON_WDG),y) CSRCS += photon_wdt.c endif diff --git a/configs/photon/src/photon.h b/configs/photon/src/photon.h index 5678dc7c1fe..ec160684f65 100644 --- a/configs/photon/src/photon.h +++ b/configs/photon/src/photon.h @@ -48,6 +48,19 @@ * Pre-processor Definitions ****************************************************************************/ +/* LEDs */ + +#define GPIO_LED1 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\ + GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN13) + +/* BUTTONS -- EXTI interrupts are available on Photon board button */ + +#define MIN_IRQBUTTON BOARD_BUTTON1 +#define MAX_IRQBUTTON BOARD_BUTTON1 +#define NUM_IRQBUTTONS 1 + +#define GPIO_BUTTON1 (GPIO_INPUT|GPIO_PULLUP|GPIO_EXTI|GPIO_PORTC|GPIO_PIN7) + /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/configs/photon/src/photon_buttons.c b/configs/photon/src/photon_buttons.c new file mode 100644 index 00000000000..bca373bf752 --- /dev/null +++ b/configs/photon/src/photon_buttons.c @@ -0,0 +1,101 @@ +/**************************************************************************** + * configs/photon/src/photon_buttons.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Simon Piriou + * + * 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 +#include "photon.h" + +#include "stm32_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_button_initialize + ****************************************************************************/ + +void board_button_initialize(void) +{ + /* Configure Photon button gpio as input */ + + stm32_configgpio(GPIO_BUTTON1); +} + +/**************************************************************************** + * Name: board_buttons + ****************************************************************************/ + +uint8_t board_buttons(void) +{ + /* Check the state of the only button */ + + if (stm32_gpioread(GPIO_BUTTON1)) + { + return BOARD_BUTTON1_BIT; + } + + return 0; +} + +#ifdef CONFIG_ARCH_IRQBUTTONS + +/**************************************************************************** + * Name: board_button_irq + ****************************************************************************/ + +int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +{ + if (id != BOARD_BUTTON1) { + /* Invalid button id */ + return ERROR; + } + + /* Configure interrupt on falling edge only */ + + return stm32_gpiosetevent(GPIO_BUTTON1, false, true, false, irqhandler, arg); +} + +#endif /* CONFIG_ARCH_IRQBUTTONS */ diff --git a/configs/photon/src/photon_leds.c b/configs/photon/src/photon_leds.c new file mode 100644 index 00000000000..070d6d6455d --- /dev/null +++ b/configs/photon/src/photon_leds.c @@ -0,0 +1,86 @@ +/**************************************************************************** + * configs/photon/src/photon_leds.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Simon Piriou + * + * 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 +#include "photon.h" + +#include "stm32_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +void board_userled_initialize(void) +{ + /* Configure Photon LED gpio as output */ + + stm32_configgpio(GPIO_LED1); +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + if (led == BOARD_LED1) + { + stm32_gpiowrite(GPIO_LED1, ledon); + } +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint8_t ledset) +{ + stm32_gpiowrite(GPIO_LED1, !!(ledset & BOARD_LED1_BIT)); +} diff --git a/configs/photon/src/stm32_appinit.c b/configs/photon/src/stm32_appinit.c index 40ac5e3fa72..7952e4ea0fa 100644 --- a/configs/photon/src/stm32_appinit.c +++ b/configs/photon/src/stm32_appinit.c @@ -38,15 +38,15 @@ ****************************************************************************/ #include - #include #include -#include "photon.h" -#include -#include +#include +#include "photon.h" #include "stm32_wdg.h" +#include +#include /**************************************************************************** * Pre-processor Definitions @@ -89,6 +89,36 @@ int board_app_initialize(uintptr_t arg) { int ret = OK; +#ifdef CONFIG_USERLED +#ifdef CONFIG_USERLED_LOWER + /* Register the LED driver */ + + ret = userled_lower_initialize("/dev/userleds"); + if (ret != OK) + { + syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret); + return ret; + } +#else + board_userled_initialize(); +#endif /* CONFIG_USERLED_LOWER */ +#endif /* CONFIG_USERLED */ + +#ifdef CONFIG_BUTTONS +#ifdef CONFIG_BUTTONS_LOWER + /* Register the BUTTON driver */ + + ret = btn_lower_initialize("/dev/buttons"); + if (ret != OK) + { + syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret); + return ret; + } +#else + board_button_initialize(); +#endif /* CONFIG_BUTTONS_LOWER */ +#endif /* CONFIG_BUTTONS */ + #ifdef CONFIG_STM32_IWDG stm32_iwdginitialize("/dev/watchdog0", STM32_LSI_FREQUENCY); #endif @@ -100,7 +130,7 @@ int board_app_initialize(uintptr_t arg) ret = photon_watchdog_initialize(); if (ret != OK) { - serr("Failed to start watchdog thread: %d\n", errno); + syslog(LOG_ERR, "Failed to start watchdog thread: %d\n", ret); return ret; } #endif From e0f7b9582a24ac83c17baf361aac9a18a30f8c0d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 11 Mar 2017 16:31:11 -0600 Subject: [PATCH 5/5] STM32: Review of last STM32 F2 PR. Progate changes to STM32 F4 and F7 OTGHS. Rename some configs/photon/src files. Naming can be either photon_ or stm32_ but must be consistent. --- arch/arm/src/stm32/stm32_otghsdev.c | 6 ++--- arch/arm/src/stm32/stm32f20xxx_rcc.c | 6 +++-- arch/arm/src/stm32/stm32f40xxx_rcc.c | 9 +++++-- arch/arm/src/stm32f7/stm32f74xx75xx_rcc.c | 9 +++++-- arch/arm/src/stm32f7/stm32f76xx77xx_rcc.c | 9 +++++-- configs/photon/include/board.h | 1 + configs/photon/src/Makefile | 6 ++--- configs/photon/src/stm32_appinit.c | 1 + .../src/{photon_buttons.c => stm32_buttons.c} | 25 +++++++++---------- .../src/{photon_leds.c => stm32_leds.c} | 6 +---- .../photon/src/{photon_wdt.c => stm32_wdt.c} | 2 +- 11 files changed, 47 insertions(+), 33 deletions(-) rename configs/photon/src/{photon_buttons.c => stm32_buttons.c} (89%) rename configs/photon/src/{photon_leds.c => stm32_leds.c} (93%) rename configs/photon/src/{photon_wdt.c => stm32_wdt.c} (99%) diff --git a/arch/arm/src/stm32/stm32_otghsdev.c b/arch/arm/src/stm32/stm32_otghsdev.c index 97474f2f435..c6fc64349ed 100644 --- a/arch/arm/src/stm32/stm32_otghsdev.c +++ b/arch/arm/src/stm32/stm32_otghsdev.c @@ -5325,14 +5325,14 @@ static void stm32_hwinitialize(FAR struct stm32_usbdev_s *priv) * some bug / errata in the chip. */ - regval = stm32_getreg(STM32_RCC_AHB1LPENR); + regval = stm32_getreg(STM32_RCC_AHB1LPENR); regval &= ~RCC_AHB1ENR_OTGHSULPIEN; stm32_putreg(regval, STM32_RCC_AHB1LPENR); /* Enable the interrupts in the INTMSK */ - regval = (OTGHS_GINT_RXFLVL | OTGHS_GINT_USBSUSP | OTGHS_GINT_ENUMDNE | - OTGHS_GINT_IEP | OTGHS_GINT_OEP | OTGHS_GINT_USBRST); + regval = (OTGHS_GINT_RXFLVL | OTGHS_GINT_USBSUSP | OTGHS_GINT_ENUMDNE | + OTGHS_GINT_IEP | OTGHS_GINT_OEP | OTGHS_GINT_USBRST); #ifdef CONFIG_USBDEV_ISOCHRONOUS regval |= (OTGHS_GINT_IISOIXFR | OTGHS_GINT_IISOOXFR); diff --git a/arch/arm/src/stm32/stm32f20xxx_rcc.c b/arch/arm/src/stm32/stm32f20xxx_rcc.c index ad71714a803..4a7fd857405 100644 --- a/arch/arm/src/stm32/stm32f20xxx_rcc.c +++ b/arch/arm/src/stm32/stm32f20xxx_rcc.c @@ -196,13 +196,15 @@ static inline void rcc_enableahb1(void) /* USB OTG HS */ #ifndef BOARD_DISABLE_USBOTG_HSULPI - /* Enable clocking for OTG and external PHY */ + /* Enable clocking for USB OTG HS and external PHY */ regval |= (RCC_AHB1ENR_OTGHSEN | RCC_AHB1ENR_OTGHSULPIEN); #else + /* Enable only clocking for USB OTG HS */ + regval |= (RCC_AHB1ENR_OTGHSEN); #endif -#endif +#endif /* CONFIG_STM32_OTGHS */ putreg32(regval, STM32_RCC_AHB1ENR); /* Enable peripherals */ } diff --git a/arch/arm/src/stm32/stm32f40xxx_rcc.c b/arch/arm/src/stm32/stm32f40xxx_rcc.c index adda863ccae..e83d4f2573e 100644 --- a/arch/arm/src/stm32/stm32f40xxx_rcc.c +++ b/arch/arm/src/stm32/stm32f40xxx_rcc.c @@ -215,10 +215,15 @@ static inline void rcc_enableahb1(void) #endif #ifdef CONFIG_STM32_OTGHS - /* USB OTG HS */ +#if 0 /* ifndef BOARD_DISABLE_USBOTG_HSULPI */ + /* Enable clocking for USB OTG HS and external PHY */ + + regval |= (RCC_AHB1ENR_OTGHSEN | RCC_AHB1ENR_OTGHSULPIEN); +#else + /* Enable only clocking for USB OTG HS */ regval |= RCC_AHB1ENR_OTGHSEN; - +#endif #endif /* CONFIG_STM32_OTGHS */ #ifdef CONFIG_STM32_DMA2D diff --git a/arch/arm/src/stm32f7/stm32f74xx75xx_rcc.c b/arch/arm/src/stm32f7/stm32f74xx75xx_rcc.c index a10c399f887..4ce433efd78 100644 --- a/arch/arm/src/stm32f7/stm32f74xx75xx_rcc.c +++ b/arch/arm/src/stm32f7/stm32f74xx75xx_rcc.c @@ -225,10 +225,15 @@ static inline void rcc_enableahb1(void) #endif #ifdef CONFIG_STM32F7_OTGHS - /* USB OTG HS */ +#if 0 /* ifndef BOARD_DISABLE_USBOTG_HSULPI */ + /* Enable clocking for USB OTG HS and external PHY */ + + regval |= (RCC_AHB1ENR_OTGHSEN | RCC_AHB1ENR_OTGHSULPIEN); +#else + /* Enable only clocking for USB OTG HS */ regval |= RCC_AHB1ENR_OTGHSEN; - +#endif #endif /* CONFIG_STM32F7_OTGHS */ putreg32(regval, STM32_RCC_AHB1ENR); /* Enable peripherals */ diff --git a/arch/arm/src/stm32f7/stm32f76xx77xx_rcc.c b/arch/arm/src/stm32f7/stm32f76xx77xx_rcc.c index b390d422b4d..42080ebb160 100644 --- a/arch/arm/src/stm32f7/stm32f76xx77xx_rcc.c +++ b/arch/arm/src/stm32f7/stm32f76xx77xx_rcc.c @@ -221,10 +221,15 @@ static inline void rcc_enableahb1(void) #endif #ifdef CONFIG_STM32F7_OTGHS - /* USB OTG HS */ +#if 0 /* ifndef BOARD_DISABLE_USBOTG_HSULPI */ + /* Enable clocking for USB OTG HS and external PHY */ + + regval |= (RCC_AHB1ENR_OTGHSEN | RCC_AHB1ENR_OTGHSULPIEN); +#else + /* Enable only clocking for USB OTG HS */ regval |= RCC_AHB1ENR_OTGHSEN; - +#endif #endif /* CONFIG_STM32F7_OTGHS */ putreg32(regval, STM32_RCC_AHB1ENR); /* Enable peripherals */ diff --git a/configs/photon/include/board.h b/configs/photon/include/board.h index 15ee036088e..08b62d125b4 100644 --- a/configs/photon/include/board.h +++ b/configs/photon/include/board.h @@ -148,6 +148,7 @@ /* USB OTG HS definitions ***********************************************************/ /* Do not enable external PHY clock or OTG_HS module will not work */ + #define BOARD_DISABLE_USBOTG_HSULPI 1 /* LED definitions ******************************************************************/ diff --git a/configs/photon/src/Makefile b/configs/photon/src/Makefile index f834e2c7fa0..98a11afdc09 100644 --- a/configs/photon/src/Makefile +++ b/configs/photon/src/Makefile @@ -42,15 +42,15 @@ CSRCS += dfu_signature.c endif ifeq ($(CONFIG_BUTTONS),y) -CSRCS += photon_buttons.c +CSRCS += stm32_buttons.c endif ifeq ($(CONFIG_USERLED),y) -CSRCS += photon_leds.c +CSRCS += stm32_leds.c endif ifeq ($(CONFIG_PHOTON_WDG),y) -CSRCS += photon_wdt.c +CSRCS += stm32_wdt.c endif ifeq ($(CONFIG_STM32_OTGHS),y) diff --git a/configs/photon/src/stm32_appinit.c b/configs/photon/src/stm32_appinit.c index 7952e4ea0fa..d2fcdf699cf 100644 --- a/configs/photon/src/stm32_appinit.c +++ b/configs/photon/src/stm32_appinit.c @@ -134,5 +134,6 @@ int board_app_initialize(uintptr_t arg) return ret; } #endif + return ret; } diff --git a/configs/photon/src/photon_buttons.c b/configs/photon/src/stm32_buttons.c similarity index 89% rename from configs/photon/src/photon_buttons.c rename to configs/photon/src/stm32_buttons.c index bca373bf752..7c695dd5efa 100644 --- a/configs/photon/src/photon_buttons.c +++ b/configs/photon/src/stm32_buttons.c @@ -1,5 +1,5 @@ /**************************************************************************** - * configs/photon/src/photon_buttons.c + * configs/photon/src/stm32_buttons.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Simon Piriou @@ -38,17 +38,15 @@ ****************************************************************************/ #include + #include +#include #include #include "photon.h" #include "stm32_gpio.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -80,22 +78,23 @@ uint8_t board_buttons(void) return 0; } -#ifdef CONFIG_ARCH_IRQBUTTONS - /**************************************************************************** * Name: board_button_irq ****************************************************************************/ +#ifdef CONFIG_ARCH_IRQBUTTONS int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) { - if (id != BOARD_BUTTON1) { - /* Invalid button id */ - return ERROR; - } + if (id != BOARD_BUTTON1) + { + /* Invalid button id */ + + return -EINVAL; + } /* Configure interrupt on falling edge only */ - return stm32_gpiosetevent(GPIO_BUTTON1, false, true, false, irqhandler, arg); + return stm32_gpiosetevent(GPIO_BUTTON1, false, true, false, + irqhandler, arg); } - #endif /* CONFIG_ARCH_IRQBUTTONS */ diff --git a/configs/photon/src/photon_leds.c b/configs/photon/src/stm32_leds.c similarity index 93% rename from configs/photon/src/photon_leds.c rename to configs/photon/src/stm32_leds.c index 070d6d6455d..076df40ad6c 100644 --- a/configs/photon/src/photon_leds.c +++ b/configs/photon/src/stm32_leds.c @@ -1,5 +1,5 @@ /**************************************************************************** - * configs/photon/src/photon_leds.c + * configs/photon/src/stm32_leds.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Simon Piriou @@ -45,10 +45,6 @@ #include "stm32_gpio.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/configs/photon/src/photon_wdt.c b/configs/photon/src/stm32_wdt.c similarity index 99% rename from configs/photon/src/photon_wdt.c rename to configs/photon/src/stm32_wdt.c index beee501404c..1df96707c6d 100644 --- a/configs/photon/src/photon_wdt.c +++ b/configs/photon/src/stm32_wdt.c @@ -1,5 +1,5 @@ /************************************************************************************ - * configs/photon/src/photon_wdt.c + * configs/photon/src/stm32_wdt.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Simon Piriou