Skip to content

Commit f646664

Browse files
raiden00plxiaoxiang781216
authored andcommitted
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.
1 parent d9ea874 commit f646664

File tree

16 files changed

+214
-32
lines changed

16 files changed

+214
-32
lines changed

boards/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4009,6 +4009,9 @@ endif
40094009
if ARCH_CHIP_RP2040
40104010
source "boards/arm/rp2040/common/Kconfig"
40114011
endif
4012+
if ARCH_CHIP_NRF52
4013+
source "boards/arm/nrf52/common/Kconfig"
4014+
endif
40124015
endif
40134016

40144017
config BOARD_CRASHDUMP

boards/arm/nrf52/common/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#

boards/arm/nrf52/common/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#############################################################################
2+
# boards/arm/nrf52/common/Makefile
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
#############################################################################
20+
21+
include $(TOPDIR)/Make.defs
22+
23+
include board/Make.defs
24+
include src/Make.defs
25+
26+
DEPPATH += --dep-path board
27+
DEPPATH += --dep-path src
28+
29+
include $(TOPDIR)/boards/Board.mk
30+
31+
ARCHSRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src
32+
BOARDDIR = $(ARCHSRCDIR)$(DELIM)board
33+
CFLAGS += $(shell $(INCDIR) "$(CC)" $(BOARDDIR)$(DELIM)include)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/****************************************************************************
2+
* boards/arm/nrf52/common/include/nrf52_timer.h
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
*
19+
****************************************************************************/
20+
21+
#ifndef __BOARDS_ARM_NRF52_COMMON_INCLUDE_NRF52_TIMER_H
22+
#define __BOARDS_ARM_NRF52_COMMON_INCLUDE_NRF52_TIMER_H
23+
24+
/****************************************************************************
25+
* Included Files
26+
****************************************************************************/
27+
28+
#include <nuttx/config.h>
29+
30+
#include <nuttx/timers/timer.h>
31+
32+
/****************************************************************************
33+
* Public Functions Prototypes
34+
****************************************************************************/
35+
36+
/****************************************************************************
37+
* Name: nrf52_timer_driver_setup
38+
*
39+
* Description:
40+
* Configure the timer driver.
41+
*
42+
* Input Parameters:
43+
* devpath - The full path to the timer device. This should be of the
44+
* form /dev/timer0
45+
* timer - The timer's number.
46+
*
47+
* Returned Value:
48+
* Zero (OK) is returned on success; A negated errno value is returned
49+
* to indicate the nature of any failure.
50+
*
51+
****************************************************************************/
52+
53+
int nrf52_timer_driver_setup(const char *devpath, int timer);
54+
55+
#endif /* __BOARDS_ARM_NRF52_COMMON_INCLUDE_NRF52_TIMER_H */

boards/arm/nrf52/common/src/Make.defs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#############################################################################
2+
# boards/arm/nrf52/common/src/Make.defs
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
#############################################################################
20+
21+
ifeq ($(CONFIG_ARCH_BOARD_COMMON),y)
22+
23+
ifeq ($(CONFIG_NRF52_TIMER),y)
24+
CSRCS += nrf52_timer.c
25+
endif
26+
27+
DEPPATH += --dep-path src
28+
VPATH += :src
29+
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
30+
31+
endif
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/****************************************************************************
2+
* boards/arm/nrf52/common/src/nrf52_timer.c
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
*
19+
****************************************************************************/
20+
21+
/****************************************************************************
22+
* Included Files
23+
****************************************************************************/
24+
25+
#include <nuttx/config.h>
26+
27+
#include <nuttx/timers/timer.h>
28+
29+
#include "nrf52_tim_lowerhalf.h"
30+
31+
/****************************************************************************
32+
* Public Functions
33+
****************************************************************************/
34+
35+
/****************************************************************************
36+
* Name: nrf52_timer_driver_setup
37+
*
38+
* Description:
39+
* Configure the timer driver.
40+
*
41+
* Input Parameters:
42+
* devpath - The full path to the timer device. This should be of the
43+
* form /dev/timer0
44+
* timer - The timer's number.
45+
*
46+
* Returned Value:
47+
* Zero (OK) is returned on success; A negated errno value is returned
48+
* to indicate the nature of any failure.
49+
*
50+
****************************************************************************/
51+
52+
int nrf52_timer_driver_setup(const char *devpath, int timer)
53+
{
54+
return nrf52_timer_initialize(devpath, timer);
55+
}

boards/arm/nrf52/nrf52-feather/src/Makefile renamed to boards/arm/nrf52/nrf52-feather/src/Make.defs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
############################################################################
2-
# boards/arm/nrf52/nrf52-feather/src/Makefile
2+
# boards/arm/nrf52/nrf52-feather/src/Make.defs
33
#
44
# Licensed to the Apache Software Foundation (ASF) under one or more
55
# contributor license agreements. See the NOTICE file distributed with
@@ -36,4 +36,6 @@ ifeq ($(CONFIG_I2C),y)
3636
CSRCS += nrf52_i2c.c
3737
endif
3838

39-
include $(TOPDIR)/boards/Board.mk
39+
DEPPATH += --dep-path board
40+
VPATH += :board
41+
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)

boards/arm/nrf52/nrf52832-dk/src/Makefile renamed to boards/arm/nrf52/nrf52832-dk/src/Make.defs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
############################################################################
2-
# boards/arm/nrf52/nrf52832-dk/src/Makefile
2+
# boards/arm/nrf52/nrf52832-dk/src/Make.defs
33
#
44
# Licensed to the Apache Software Foundation (ASF) under one or more
55
# contributor license agreements. See the NOTICE file distributed with
@@ -36,4 +36,6 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y)
3636
CSRCS += nrf52_buttons.c
3737
endif
3838

39-
include $(TOPDIR)/boards/Board.mk
39+
DEPPATH += --dep-path board
40+
VPATH += :board
41+
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)

boards/arm/nrf52/nrf52832-mdk/src/Makefile renamed to boards/arm/nrf52/nrf52832-mdk/src/Make.defs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
############################################################################
2-
# boards/arm/nrf52/nrf52832-mdk/src/Makefile
2+
# boards/arm/nrf52/nrf52832-mdk/src/Make.defs
33
#
44
# Licensed to the Apache Software Foundation (ASF) under one or more
55
# contributor license agreements. See the NOTICE file distributed with
@@ -30,4 +30,6 @@ ifeq ($(CONFIG_ARCH_LEDS),y)
3030
CSRCS += nrf52_autoleds.c
3131
endif
3232

33-
include $(TOPDIR)/boards/Board.mk
33+
DEPPATH += --dep-path board
34+
VPATH += :board
35+
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)

boards/arm/nrf52/nrf52832-sparkfun/src/Makefile renamed to boards/arm/nrf52/nrf52832-sparkfun/src/Make.defs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
############################################################################
2-
# boards/arm/nrf52/nrf52832-sparkfun/src/Makefile
2+
# boards/arm/nrf52/nrf52832-sparkfun/src/Make.defs
33
#
44
# Licensed to the Apache Software Foundation (ASF) under one or more
55
# contributor license agreements. See the NOTICE file distributed with
@@ -30,4 +30,6 @@ ifeq ($(CONFIG_ARCH_LEDS),y)
3030
CSRCS += nrf52_autoleds.c
3131
endif
3232

33-
include $(TOPDIR)/boards/Board.mk
33+
DEPPATH += --dep-path board
34+
VPATH += :board
35+
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)

0 commit comments

Comments
 (0)