This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit a5aa7886ba4f78c2428664c7ae8af30e36a9d4e5 Author: raiden00pl <[email protected]> AuthorDate: Mon Mar 13 14:16:48 2023 +0100 boards/nrf5340-dk: add TIMER configuration --- .../nrf5340-dk/configs/timer_cpuapp/defconfig | 48 ++++++++++++++++ boards/arm/nrf53/nrf5340-dk/src/Makefile | 6 ++ boards/arm/nrf53/nrf5340-dk/src/nrf5340-dk.h | 12 ++++ boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c | 20 +++++++ .../src/{nrf53_bringup.c => nrf53_timer.c} | 67 ++++++---------------- 5 files changed, 102 insertions(+), 51 deletions(-) diff --git a/boards/arm/nrf53/nrf5340-dk/configs/timer_cpuapp/defconfig b/boards/arm/nrf53/nrf5340-dk/configs/timer_cpuapp/defconfig new file mode 100644 index 0000000000..08e45c141b --- /dev/null +++ b/boards/arm/nrf53/nrf5340-dk/configs/timer_cpuapp/defconfig @@ -0,0 +1,48 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nrf5340-dk" +CONFIG_ARCH_BOARD_NRF5340_DK=y +CONFIG_ARCH_CHIP="nrf53" +CONFIG_ARCH_CHIP_NRF5340=y +CONFIG_ARCH_CHIP_NRF5340_CPUAPP=y +CONFIG_ARCH_CHIP_NRF53=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_BUILTIN=y +CONFIG_EXAMPLES_TIMER=y +CONFIG_EXPERIMENTAL=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MM_REGIONS=2 +CONFIG_NRF53_TIMER0=y +CONFIG_NRF53_UART0=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=524288 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=26 +CONFIG_START_MONTH=3 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/nrf53/nrf5340-dk/src/Makefile b/boards/arm/nrf53/nrf5340-dk/src/Makefile index 3351a9d831..8e7fc5c975 100644 --- a/boards/arm/nrf53/nrf5340-dk/src/Makefile +++ b/boards/arm/nrf53/nrf5340-dk/src/Makefile @@ -36,4 +36,10 @@ else CSRCS += nrf53_userleds.c endif +ifeq ($(CONFIG_TIMER),y) +ifeq ($(CONFIG_NRF53_TIMER),y) +CSRCS += nrf53_timer.c +endif +endif + include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/nrf53/nrf5340-dk/src/nrf5340-dk.h b/boards/arm/nrf53/nrf5340-dk/src/nrf5340-dk.h index 1332f9d4a7..7548def7f1 100644 --- a/boards/arm/nrf53/nrf5340-dk/src/nrf5340-dk.h +++ b/boards/arm/nrf53/nrf5340-dk/src/nrf5340-dk.h @@ -82,5 +82,17 @@ int nrf53_bringup(void); +/**************************************************************************** + * Name: nrf53_timer_driver_setup + * + * Description: + * Initialize TIMER driver. + * + ****************************************************************************/ + +#ifdef CONFIG_TIMER +int nrf53_timer_driver_setup(const char *devpath, int timer); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __BOARDS_ARM_NRF53_NRF5340_DK_SRC_NRF53_NRF5340_DK_H */ diff --git a/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c b/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c index a7db7f5cf3..27b1061fee 100644 --- a/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c +++ b/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c @@ -39,6 +39,14 @@ # include "nrf53_rptun.h" #endif +#include "nrf5340-dk.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define NRF53_TIMER (0) + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -79,6 +87,18 @@ int nrf53_bringup(void) #endif #endif +#if defined(CONFIG_TIMER) && defined(CONFIG_NRF53_TIMER) + /* Configure TIMER driver */ + + ret = nrf53_timer_driver_setup("/dev/timer0", NRF53_TIMER); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to initialize timer driver: %d\n", + ret); + } +#endif + #ifdef CONFIG_NRF53_SOFTDEVICE_CONTROLLER ret = nrf53_sdc_initialize(); diff --git a/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c b/boards/arm/nrf53/nrf5340-dk/src/nrf53_timer.c similarity index 56% copy from boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c copy to boards/arm/nrf53/nrf5340-dk/src/nrf53_timer.c index a7db7f5cf3..c47c0b74c0 100644 --- a/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c +++ b/boards/arm/nrf53/nrf5340-dk/src/nrf53_timer.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c + * boards/arm/nrf53/nrf5340-dk/src/nrf53_timer.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -23,71 +23,36 @@ ****************************************************************************/ #include <nuttx/config.h> +#include <nuttx/timers/timer.h> -#include <sys/types.h> -#include <syslog.h> +#include <debug.h> -#ifdef CONFIG_USERLED -# include <nuttx/leds/userled.h> -#endif +#include "nrf53_tim_lowerhalf.h" -#ifdef CONFIG_NRF53_SOFTDEVICE_CONTROLLER -# include "nrf53_sdc.h" -#endif - -#ifdef CONFIG_RPTUN -# include "nrf53_rptun.h" -#endif +#include "nrf5340-dk.h" /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: nrf53_bringup + * Name: nrf53_timer_driver_setup * * Description: - * Perform architecture-specific initialization + * Configure the timer driver. * - * CONFIG_BOARD_LATE_INITIALIZE=y : - * Called from board_late_initialize(). + * Input Parameters: + * devpath - The full path to the timer device. This should be of the + * form /dev/timer0 + * timer - The timer's number. * - * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y : - * Called from the NSH library + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. * ****************************************************************************/ -int nrf53_bringup(void) +int nrf53_timer_driver_setup(const char *devpath, int timer) { - int ret; - -#ifdef CONFIG_USERLED - /* Register the LED driver */ - - ret = userled_lower_initialize(CONFIG_EXAMPLES_LEDS_DEVPATH); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret); - } -#endif - -#ifdef CONFIG_RPTUN -#ifdef CONFIG_NRF53_APPCORE - nrf53_rptun_init("nrf53-shmem", "appcore"); -#else - nrf53_rptun_init("nrf53-shmem", "netcore"); -#endif -#endif - -#ifdef CONFIG_NRF53_SOFTDEVICE_CONTROLLER - ret = nrf53_sdc_initialize(); - - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: nrf53_sdc_initialize() failed: %d\n", ret); - } -#endif - - UNUSED(ret); - return OK; + return nrf53_timer_initialize(devpath, timer); }
