From f646664cfb918971c25080a8a2f84d9094eef44f Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Mon, 22 May 2023 14:02:04 +0200 Subject: [PATCH] boards/nrf52: introduce common folder This is an initial step towards moving common logic for NRF52 boards into one place. At this point, only initialization of the TIMER has been moved. --- boards/Kconfig | 3 + boards/arm/nrf52/common/Kconfig | 4 ++ boards/arm/nrf52/common/Makefile | 33 +++++++++++ boards/arm/nrf52/common/include/nrf52_timer.h | 55 +++++++++++++++++++ boards/arm/nrf52/common/src/Make.defs | 31 +++++++++++ boards/arm/nrf52/common/src/nrf52_timer.c | 55 +++++++++++++++++++ .../nrf52-feather/src/{Makefile => Make.defs} | 6 +- .../nrf52832-dk/src/{Makefile => Make.defs} | 6 +- .../nrf52832-mdk/src/{Makefile => Make.defs} | 6 +- .../src/{Makefile => Make.defs} | 6 +- .../nrf52/nrf52840-dk/configs/timer/defconfig | 1 + .../nrf52840-dk/src/{Makefile => Make.defs} | 12 ++-- .../arm/nrf52/nrf52840-dk/src/nrf52840-dk.h | 12 ---- .../arm/nrf52/nrf52840-dk/src/nrf52_bringup.c | 4 ++ .../src/{Makefile => Make.defs} | 6 +- .../thingy52/src/{Makefile => Make.defs} | 6 +- 16 files changed, 214 insertions(+), 32 deletions(-) create mode 100644 boards/arm/nrf52/common/Kconfig create mode 100644 boards/arm/nrf52/common/Makefile create mode 100644 boards/arm/nrf52/common/include/nrf52_timer.h create mode 100644 boards/arm/nrf52/common/src/Make.defs create mode 100644 boards/arm/nrf52/common/src/nrf52_timer.c rename boards/arm/nrf52/nrf52-feather/src/{Makefile => Make.defs} (85%) rename boards/arm/nrf52/nrf52832-dk/src/{Makefile => Make.defs} (85%) rename boards/arm/nrf52/nrf52832-mdk/src/{Makefile => Make.defs} (84%) rename boards/arm/nrf52/nrf52832-sparkfun/src/{Makefile => Make.defs} (84%) rename boards/arm/nrf52/nrf52840-dk/src/{Makefile => Make.defs} (90%) rename boards/arm/nrf52/nrf52840-dongle/src/{Makefile => Make.defs} (84%) rename boards/arm/nrf52/thingy52/src/{Makefile => Make.defs} (84%) diff --git a/boards/Kconfig b/boards/Kconfig index ee2b176451..b78a54b538 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -4009,6 +4009,9 @@ endif if ARCH_CHIP_RP2040 source "boards/arm/rp2040/common/Kconfig" endif +if ARCH_CHIP_NRF52 +source "boards/arm/nrf52/common/Kconfig" +endif endif config BOARD_CRASHDUMP diff --git a/boards/arm/nrf52/common/Kconfig b/boards/arm/nrf52/common/Kconfig new file mode 100644 index 0000000000..ce537d0af2 --- /dev/null +++ b/boards/arm/nrf52/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. +# \ No newline at end of file diff --git a/boards/arm/nrf52/common/Makefile b/boards/arm/nrf52/common/Makefile new file mode 100644 index 0000000000..b60ef410ef --- /dev/null +++ b/boards/arm/nrf52/common/Makefile @@ -0,0 +1,33 @@ +############################################################################# +# boards/arm/nrf52/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/arm/nrf52/common/include/nrf52_timer.h b/boards/arm/nrf52/common/include/nrf52_timer.h new file mode 100644 index 0000000000..09f6d54c24 --- /dev/null +++ b/boards/arm/nrf52/common/include/nrf52_timer.h @@ -0,0 +1,55 @@ +/**************************************************************************** + * boards/arm/nrf52/common/include/nrf52_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_ARM_NRF52_COMMON_INCLUDE_NRF52_TIMER_H +#define __BOARDS_ARM_NRF52_COMMON_INCLUDE_NRF52_TIMER_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +/**************************************************************************** + * Public Functions Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf52_timer_driver_setup + * + * Description: + * Configure the timer driver. + * + * Input Parameters: + * devpath - The full path to the timer device. This should be of the + * form /dev/timer0 + * 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 nrf52_timer_driver_setup(const char *devpath, int timer); + +#endif /* __BOARDS_ARM_NRF52_COMMON_INCLUDE_NRF52_TIMER_H */ diff --git a/boards/arm/nrf52/common/src/Make.defs b/boards/arm/nrf52/common/src/Make.defs new file mode 100644 index 0000000000..22ba399142 --- /dev/null +++ b/boards/arm/nrf52/common/src/Make.defs @@ -0,0 +1,31 @@ +############################################################################# +# boards/arm/nrf52/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_ARCH_BOARD_COMMON),y) + +ifeq ($(CONFIG_NRF52_TIMER),y) + CSRCS += nrf52_timer.c +endif + +DEPPATH += --dep-path src +VPATH += :src +CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src) + +endif diff --git a/boards/arm/nrf52/common/src/nrf52_timer.c b/boards/arm/nrf52/common/src/nrf52_timer.c new file mode 100644 index 0000000000..15e0ef6793 --- /dev/null +++ b/boards/arm/nrf52/common/src/nrf52_timer.c @@ -0,0 +1,55 @@ +/**************************************************************************** + * boards/arm/nrf52/common/src/nrf52_timer.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 "nrf52_tim_lowerhalf.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf52_timer_driver_setup + * + * Description: + * Configure the timer driver. + * + * Input Parameters: + * devpath - The full path to the timer device. This should be of the + * form /dev/timer0 + * 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 nrf52_timer_driver_setup(const char *devpath, int timer) +{ + return nrf52_timer_initialize(devpath, timer); +} diff --git a/boards/arm/nrf52/nrf52-feather/src/Makefile b/boards/arm/nrf52/nrf52-feather/src/Make.defs similarity index 85% rename from boards/arm/nrf52/nrf52-feather/src/Makefile rename to boards/arm/nrf52/nrf52-feather/src/Make.defs index 5a478e5249..bcc490b945 100644 --- a/boards/arm/nrf52/nrf52-feather/src/Makefile +++ b/boards/arm/nrf52/nrf52-feather/src/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/nrf52/nrf52-feather/src/Makefile +# boards/arm/nrf52/nrf52-feather/src/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -36,4 +36,6 @@ ifeq ($(CONFIG_I2C),y) CSRCS += nrf52_i2c.c endif -include $(TOPDIR)/boards/Board.mk +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/arm/nrf52/nrf52832-dk/src/Makefile b/boards/arm/nrf52/nrf52832-dk/src/Make.defs similarity index 85% rename from boards/arm/nrf52/nrf52832-dk/src/Makefile rename to boards/arm/nrf52/nrf52832-dk/src/Make.defs index b92e452c57..1edc618c3c 100644 --- a/boards/arm/nrf52/nrf52832-dk/src/Makefile +++ b/boards/arm/nrf52/nrf52832-dk/src/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/nrf52/nrf52832-dk/src/Makefile +# boards/arm/nrf52/nrf52832-dk/src/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -36,4 +36,6 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y) CSRCS += nrf52_buttons.c endif -include $(TOPDIR)/boards/Board.mk +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/arm/nrf52/nrf52832-mdk/src/Makefile b/boards/arm/nrf52/nrf52832-mdk/src/Make.defs similarity index 84% rename from boards/arm/nrf52/nrf52832-mdk/src/Makefile rename to boards/arm/nrf52/nrf52832-mdk/src/Make.defs index 0ecfda0fad..d014cbe328 100644 --- a/boards/arm/nrf52/nrf52832-mdk/src/Makefile +++ b/boards/arm/nrf52/nrf52832-mdk/src/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/nrf52/nrf52832-mdk/src/Makefile +# boards/arm/nrf52/nrf52832-mdk/src/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -30,4 +30,6 @@ ifeq ($(CONFIG_ARCH_LEDS),y) CSRCS += nrf52_autoleds.c endif -include $(TOPDIR)/boards/Board.mk +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/arm/nrf52/nrf52832-sparkfun/src/Makefile b/boards/arm/nrf52/nrf52832-sparkfun/src/Make.defs similarity index 84% rename from boards/arm/nrf52/nrf52832-sparkfun/src/Makefile rename to boards/arm/nrf52/nrf52832-sparkfun/src/Make.defs index 0f273bc7cf..0949ce675b 100644 --- a/boards/arm/nrf52/nrf52832-sparkfun/src/Makefile +++ b/boards/arm/nrf52/nrf52832-sparkfun/src/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/nrf52/nrf52832-sparkfun/src/Makefile +# boards/arm/nrf52/nrf52832-sparkfun/src/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -30,4 +30,6 @@ ifeq ($(CONFIG_ARCH_LEDS),y) CSRCS += nrf52_autoleds.c endif -include $(TOPDIR)/boards/Board.mk +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/arm/nrf52/nrf52840-dk/configs/timer/defconfig b/boards/arm/nrf52/nrf52840-dk/configs/timer/defconfig index a539ea8109..f65bb14ed8 100644 --- a/boards/arm/nrf52/nrf52840-dk/configs/timer/defconfig +++ b/boards/arm/nrf52/nrf52840-dk/configs/timer/defconfig @@ -10,6 +10,7 @@ # CONFIG_NSH_DISABLE_PS is not set CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="nrf52840-dk" +CONFIG_ARCH_BOARD_COMMON=y CONFIG_ARCH_BOARD_NRF52840_DK=y CONFIG_ARCH_CHIP="nrf52" CONFIG_ARCH_CHIP_NRF52840=y diff --git a/boards/arm/nrf52/nrf52840-dk/src/Makefile b/boards/arm/nrf52/nrf52840-dk/src/Make.defs similarity index 90% rename from boards/arm/nrf52/nrf52840-dk/src/Makefile rename to boards/arm/nrf52/nrf52840-dk/src/Make.defs index dffc657f4c..6da8e7195c 100644 --- a/boards/arm/nrf52/nrf52840-dk/src/Makefile +++ b/boards/arm/nrf52/nrf52840-dk/src/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/nrf52/nrf52840-dk/src/Makefile +# boards/arm/nrf52/nrf52840-dk/src/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -60,12 +60,6 @@ ifeq ($(CONFIG_NRF52840DK_HIGHPRI),y) CSRCS += nrf52_highpri.c endif -ifeq ($(CONFIG_TIMER),y) -ifeq ($(CONFIG_NRF52_TIMER),y) -CSRCS += nrf52_timer.c -endif -endif - ifeq ($(CONFIG_PWM),y) CSRCS += nrf52_pwm.c endif @@ -86,4 +80,6 @@ ifeq ($(CONFIG_NRF52_QSPI),y) CSRCS += nrf52_mx25.c endif -include $(TOPDIR)/boards/Board.mk +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/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h b/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h index db9095a494..21ffa42589 100644 --- a/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h +++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h @@ -165,18 +165,6 @@ int nrf52_hts221_initialize(char *devpath); int nrf52_lpwaninitialize(void); #endif -/**************************************************************************** - * Name: nrf52_timer_driver_setup - * - * Description: - * Initialize TIMER driver. - * - ****************************************************************************/ - -#ifdef CONFIG_TIMER -int nrf52_timer_driver_setup(const char *devpath, int timer); -#endif - /**************************************************************************** * Name: nrf52_pwm_setup * diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c b/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c index 38257d68ce..cf44336ee7 100644 --- a/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c +++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c @@ -45,6 +45,10 @@ # include #endif +#ifdef CONFIG_TIMER +# include "nrf52_timer.h" +#endif + #ifdef CONFIG_NRF52_SOFTDEVICE_CONTROLLER # include "nrf52_sdc.h" #endif diff --git a/boards/arm/nrf52/nrf52840-dongle/src/Makefile b/boards/arm/nrf52/nrf52840-dongle/src/Make.defs similarity index 84% rename from boards/arm/nrf52/nrf52840-dongle/src/Makefile rename to boards/arm/nrf52/nrf52840-dongle/src/Make.defs index 7a809a66b9..fc0f5486c2 100644 --- a/boards/arm/nrf52/nrf52840-dongle/src/Makefile +++ b/boards/arm/nrf52/nrf52840-dongle/src/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/nrf52/nrf52840-dongle/src/Makefile +# boards/arm/nrf52/nrf52840-dongle/src/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -32,4 +32,6 @@ else CSRCS += nrf52_userleds.c endif -include $(TOPDIR)/boards/Board.mk +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/arm/nrf52/thingy52/src/Makefile b/boards/arm/nrf52/thingy52/src/Make.defs similarity index 84% rename from boards/arm/nrf52/thingy52/src/Makefile rename to boards/arm/nrf52/thingy52/src/Make.defs index 49f43e02e8..aca7f11059 100644 --- a/boards/arm/nrf52/thingy52/src/Makefile +++ b/boards/arm/nrf52/thingy52/src/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/nrf52/thingy52/src/Makefile +# boards/arm/nrf52/thingy52/src/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -30,4 +30,6 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y) CSRCS += nrf52_buttons.c endif -include $(TOPDIR)/boards/Board.mk +DEPPATH += --dep-path board +VPATH += :board +CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)