diff --git a/arch/xtensa/src/esp32/Kconfig b/arch/xtensa/src/esp32/Kconfig index 7b8b8494e7..d7ae72fe81 100644 --- a/arch/xtensa/src/esp32/Kconfig +++ b/arch/xtensa/src/esp32/Kconfig @@ -47,7 +47,7 @@ config ESP32_TIMER bool default n -config ESP32_WTD +config ESP32_WDT bool default n @@ -211,7 +211,7 @@ config ESP32_TIMER3 config ESP32_MWDT0 bool "Main System Watchdog Timer (Group 0)" default n - select ESP32_WTD + select ESP32_WDT ---help--- Includes MWDT0. This watchdog timer is part of the Group 0 timer submodule. @@ -219,7 +219,7 @@ config ESP32_MWDT0 config ESP32_MWDT1 bool "Main System Watchdog Timer (Group 1)" default n - select ESP32_WTD + select ESP32_WDT ---help--- Includes MWDT1. This watchdog timer is part of the Group 0 timer submodule. diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs index b986485dd0..36ab6eb0e2 100644 --- a/arch/xtensa/src/esp32/Make.defs +++ b/arch/xtensa/src/esp32/Make.defs @@ -164,7 +164,7 @@ endif ifeq ($(CONFIG_WATCHDOG),y) CHIP_CSRCS += esp32_wtd_lowerhalf.c -ifeq ($(CONFIG_ESP32_WTD),y) +ifeq ($(CONFIG_ESP32_WDT),y) CHIP_CSRCS += esp32_wtd.c endif endif diff --git a/boards/xtensa/esp32/common/Kconfig b/boards/xtensa/esp32/common/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/xtensa/esp32/common/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/xtensa/esp32/common/Makefile b/boards/xtensa/esp32/common/Makefile new file mode 100644 index 0000000000..119ec47288 --- /dev/null +++ b/boards/xtensa/esp32/common/Makefile @@ -0,0 +1,33 @@ +############################################################################# +# boards/xtensa/esp32/common/Makefile +# +# 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. +# +############################################################################# + +include $(TOPDIR)/Make.defs + +include board/Make.defs +include src/Make.defs + +DEPPATH += --dep-path board +DEPPATH += --dep-path src + +include $(TOPDIR)/boards/Board.mk + +ARCHSRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src +BOARDDIR = $(ARCHSRCDIR)$(DELIM)board +CFLAGS += $(shell $(INCDIR) "$(CC)" $(BOARDDIR)$(DELIM)include) diff --git a/boards/xtensa/esp32/common/include/esp32_timer.h b/boards/xtensa/esp32/common/include/esp32_timer.h new file mode 100644 index 0000000000..b7ce3ee36c --- /dev/null +++ b/boards/xtensa/esp32/common/include/esp32_timer.h @@ -0,0 +1,78 @@ +/**************************************************************************** + * boards/xtensa/esp32/common/include/esp32_timer.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_TIMER_H +#define __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_TIMER_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef CONFIG_TIMER + +/**************************************************************************** + * Name: board_timer_init + * + * Description: + * Configure the timer driver. + * + * Input Parameters: + * devpath - The full path to the timer device. This should be of the + * form /dev/timerX + * timer - The timer's number. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +int board_timer_init(void); + +#endif /* CONFIG_TIMER */ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_TIMER_H */ diff --git a/boards/xtensa/esp32/common/include/esp32_wdt.h b/boards/xtensa/esp32/common/include/esp32_wdt.h new file mode 100644 index 0000000000..bcbaf32ae9 --- /dev/null +++ b/boards/xtensa/esp32/common/include/esp32_wdt.h @@ -0,0 +1,78 @@ +/**************************************************************************** + * boards/xtensa/esp32/common/include/esp32_wdt.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_WDT_H +#define __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_WDT_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef CONFIG_WATCHDOG + +/**************************************************************************** + * Name: board_wdt_init + * + * Description: + * Configure the timer driver. + * + * Input Parameters: + * devpath - The full path to the timer device. This should be of the + * form /dev/watchdogX + * wdt timer - The wdt timer's number. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +int board_wdt_init(void); + +#endif /* CONFIG_WATCHDOG */ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_WDT_H */ diff --git a/boards/xtensa/esp32/common/src/Make.defs b/boards/xtensa/esp32/common/src/Make.defs new file mode 100644 index 0000000000..782d9677f0 --- /dev/null +++ b/boards/xtensa/esp32/common/src/Make.defs @@ -0,0 +1,32 @@ +############################################################################# +# boards/xtensa/esp32/common/src/Make.defs +# +# 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. +# +############################################################################# + +ifeq ($(CONFIG_TIMER),y) + CSRCS += esp32_timer.c +endif + +ifeq ($(CONFIG_WDT),y) + CSRCS += esp32_wdt.c +endif + +DEPPATH += --dep-path src +VPATH += :src +CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src) + diff --git a/boards/xtensa/esp32/esp32-core/src/esp32_timer.c b/boards/xtensa/esp32/common/src/esp32_timer.c similarity index 92% rename from boards/xtensa/esp32/esp32-core/src/esp32_timer.c rename to boards/xtensa/esp32/common/src/esp32_timer.c index 20c3e5995f..1dec7dc3e6 100644 --- a/boards/xtensa/esp32/esp32-core/src/esp32_timer.c +++ b/boards/xtensa/esp32/common/src/esp32_timer.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/xtensa/esp32/esp32-core/src/esp32_timer.c + * boards/xtensa/esp32/common/src/esp32_timer.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -23,30 +23,31 @@ ****************************************************************************/ #include -#include + #include -#include "esp32_tim_lowerhalf.h" -#include "esp32-core.h" #include +#include + +#include "esp32_tim_lowerhalf.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ #ifdef CONFIG_ESP32_TIMER0 -#define ESP32_TIMER0 (0) +# define ESP32_TIMER0 (0) #endif #ifdef CONFIG_ESP32_TIMER1 -#define ESP32_TIMER1 (1) +# define ESP32_TIMER1 (1) #endif #ifdef CONFIG_ESP32_TIMER2 -#define ESP32_TIMER2 (2) +# define ESP32_TIMER2 (2) #endif #ifdef CONFIG_ESP32_TIMER3 -#define ESP32_TIMER3 (3) +# define ESP32_TIMER3 (3) #endif /**************************************************************************** @@ -54,7 +55,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: esp32_timer_driver_setup + * Name: board_timer_init * * Description: * Configure the timer driver. @@ -70,10 +71,11 @@ * ****************************************************************************/ -int esp32_timer_driver_init(void) +int board_timer_init(void) { int ret = OK; - #ifdef CONFIG_ESP32_TIMER0 + +#ifdef CONFIG_ESP32_TIMER0 ret = esp32_timer_initialize("/dev/timer0", ESP32_TIMER0); if (ret < 0) { @@ -120,3 +122,4 @@ int esp32_timer_driver_init(void) errout: return ret; } + diff --git a/boards/xtensa/esp32/esp32-core/src/esp32_wtd.c b/boards/xtensa/esp32/common/src/esp32_wdt.c similarity index 93% rename from boards/xtensa/esp32/esp32-core/src/esp32_wtd.c rename to boards/xtensa/esp32/common/src/esp32_wdt.c index 699704ab55..3daec64324 100644 --- a/boards/xtensa/esp32/esp32-core/src/esp32_wtd.c +++ b/boards/xtensa/esp32/common/src/esp32_wdt.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/xtensa/esp32/esp32-core/src/esp32_wtd.c + * boards/xtensa/esp32/common/src/esp32_wtd.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -23,25 +23,26 @@ ****************************************************************************/ #include -#include -#include "esp32_wtd_lowerhalf.h" -#include "esp32-core.h" + #include +#include + +#include "esp32_wtd_lowerhalf.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ #ifdef CONFIG_ESP32_MWDT0 -#define ESP32_MWDT0 (0) +# define ESP32_MWDT0 (0) #endif #ifdef CONFIG_ESP32_MWDT1 -#define ESP32_MWDT1 (1) +# define ESP32_MWDT1 (1) #endif #ifdef CONFIG_ESP32_RWDT -#define ESP32_RWDT (2) +# define ESP32_RWDT (2) #endif /**************************************************************************** @@ -49,7 +50,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: esp32_wtd_driver_init + * Name: board_wdt_init * * Description: * Configure the timer driver. @@ -65,7 +66,7 @@ * ****************************************************************************/ -int esp32_wtd_driver_init(void) +int board_wdt_init(void) { int ret = OK; @@ -78,7 +79,6 @@ int esp32_wtd_driver_init(void) ret); goto errout; } - #endif #ifdef CONFIG_ESP32_MWDT1 @@ -90,7 +90,6 @@ int esp32_wtd_driver_init(void) ret); goto errout; } - #endif #ifdef CONFIG_ESP32_RWDT @@ -102,9 +101,9 @@ int esp32_wtd_driver_init(void) ret); goto errout; } - #endif errout: return ret; } + diff --git a/boards/xtensa/esp32/drivers/Kconfig b/boards/xtensa/esp32/drivers/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/boards/xtensa/esp32/drivers/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/boards/xtensa/esp32/esp32-core/src/Makefile b/boards/xtensa/esp32/esp32-core/src/Make.defs similarity index 92% rename from boards/xtensa/esp32/esp32-core/src/Makefile rename to boards/xtensa/esp32/esp32-core/src/Make.defs index f8e3041d19..858ca443ca 100644 --- a/boards/xtensa/esp32/esp32-core/src/Makefile +++ b/boards/xtensa/esp32/esp32-core/src/Make.defs @@ -60,29 +60,15 @@ ifeq ($(CONFIG_ESP32_SPIFLASH),y) CSRCS += esp32_spiflash.c endif -ifeq ($(CONFIG_TIMER),y) -ifeq ($(CONFIG_ESP32_TIMER),y) -CSRCS += esp32_timer.c -endif -endif - ifeq ($(CONFIG_USERLED),y) CSRCS += esp32_userleds.c endif -ifeq ($(CONFIG_WATCHDOG),y) -ifeq ($(CONFIG_ESP32_WTD),y) -CSRCS += esp32_wtd.c -endif -endif - SCRIPTIN = $(SCRIPTDIR)$(DELIM)esp32.template.ld SCRIPTOUT = $(SCRIPTDIR)$(DELIM)esp32_out.ld .PHONY = context distclean -include $(TOPDIR)/boards/Board.mk - $(SCRIPTOUT): $(SCRIPTIN) $(CONFIGFILE) $(Q) $(CC) -isystem $(TOPDIR)/include -C -P -x c -E $(SCRIPTIN) -o $@ @@ -91,3 +77,7 @@ context:: $(SCRIPTOUT) distclean:: $(call DELFILE, $(SCRIPTOUT)) +DEPPATH += --dep-path board +VPATH += :board +CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board) + diff --git a/boards/xtensa/esp32/esp32-core/src/esp32-core.h b/boards/xtensa/esp32/esp32-core/src/esp32-core.h index 3627b2348f..1331c726b4 100644 --- a/boards/xtensa/esp32/esp32-core/src/esp32-core.h +++ b/boards/xtensa/esp32/esp32-core/src/esp32-core.h @@ -95,28 +95,6 @@ int esp32_mmcsd_initialize(int minor); ****************************************************************************/ int esp32_spiflash_init(void); -/**************************************************************************** - * Name: esp32_timer_driver_setup - * - * Description: - * Initialize TIMER driver. - * - ****************************************************************************/ - -#ifdef CONFIG_TIMER -int esp32_timer_driver_init(void); -#endif -/**************************************************************************** - * Name: esp32_wdt_driver_init - * - * Description: - * Initialize WATCHDOG driver. - * - ****************************************************************************/ - -#ifdef CONFIG_WATCHDOG -int esp32_wtd_driver_init(void); -#endif /**************************************************************************** * Name: esp32_spiflash_encrypt_test @@ -133,9 +111,7 @@ int esp32_wtd_driver_init(void); ****************************************************************************/ #ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST - void esp32_spiflash_encrypt_test(void); - #endif #endif /* __ASSEMBLY__ */ diff --git a/boards/xtensa/esp32/esp32-core/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-core/src/esp32_bringup.c index abdbb7ca71..d6ba4b070c 100644 --- a/boards/xtensa/esp32/esp32-core/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-core/src/esp32_bringup.c @@ -51,25 +51,30 @@ #include #include -#ifdef CONFIG_TIMER -# include -#endif - -#ifdef CONFIG_USERLED -# include -#endif - #include #include #include #include "esp32_procfs_imm.h" -#include "esp32-core.h" #include "esp32_wlan.h" #include "esp32_spiflash.h" #include "esp32_partition.h" +#ifdef CONFIG_USERLED +# include +#endif + +#ifdef CONFIG_ESP32_TIMER +# include "esp32_timer.h" +#endif + +#ifdef CONFIG_ESP32_WDT +# include "esp32_wdt.h" +#endif + +#include "esp32-core.h" + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -218,16 +223,15 @@ int esp32_bringup(void) #endif #ifdef CONFIG_TIMER - /* Configure TIMER driver */ + /* Configure timer driver */ - ret = esp32_timer_driver_init(); + ret = board_timer_init(); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to initialize timer drivers: %d\n", ret); } - #endif #ifdef CONFIG_USERLED @@ -241,16 +245,15 @@ int esp32_bringup(void) #endif #ifdef CONFIG_WATCHDOG - /* Configure WATCHDOG driver */ + /* Configure watchdog timer */ - ret = esp32_wtd_driver_init(); + ret = board_wdt_init(); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to initialize watchdog drivers: %d\n", ret); } - #endif /* If we got here then perhaps not all initialization was successful, but