From a0429bcb20254e6302686416037405eac6bf70ae Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Mon, 16 Dec 2019 18:35:45 +0000 Subject: [PATCH] Merged in raiden00/nuttx_nrf52 (pull request #1096) nrf52 updates board/arm/nrf52/nrf52832-dk: use the on-board virtual COM pins as default UART0 configuration board/arm/nrf52: initial support for the nrf52840-dk board board/arm/nrf52: initial support for the nrf52840-dk dongle board arch/arm/src/nrf52: add support for port 1 GPIO arch/arm/src/nrf52: initial support for UART1 arch/arm/src/nrf52: add UICR definitions Approved-by: Gregory Nutt --- arch/arm/src/nrf52/Kconfig | 27 ++- arch/arm/src/nrf52/Make.defs | 2 +- arch/arm/src/nrf52/hardware/nrf52_gpio.h | 11 ++ arch/arm/src/nrf52/hardware/nrf52_uicr.h | 90 ++++++++++ arch/arm/src/nrf52/nrf52_config.h | 14 ++ arch/arm/src/nrf52/nrf52_gpio.c | 77 ++++++-- arch/arm/src/nrf52/nrf52_lowputc.c | 26 ++- arch/arm/src/nrf52/nrf52_serial.c | 63 ++++++- boards/Kconfig | 46 +++-- boards/README.txt | 15 +- boards/arm/nrf52/nrf52-feather/Kconfig | 8 + .../README.txt | 48 +---- .../configs/nsh}/defconfig | 4 +- .../configs/userleds}/defconfig | 9 +- .../arm/nrf52/nrf52-feather/include/board.h | 109 ++++++++++++ .../scripts/Make.defs | 2 +- .../scripts/flash_config.ld | 2 +- .../src/.gitignore | 0 boards/arm/nrf52/nrf52-feather/src/Makefile | 51 ++++++ .../nrf52/nrf52-feather/src/nrf52-feather.h | 94 ++++++++++ .../src/nrf52_appinit.c | 4 +- .../nrf52/nrf52-feather/src/nrf52_autoleds.c | 147 ++++++++++++++++ .../src/nrf52_boot.c | 4 +- .../src/nrf52_bringup.c | 2 +- .../nrf52/nrf52-feather/src/nrf52_buttons.c | 0 .../nrf52/nrf52-feather/src/nrf52_userleds.c | 158 +++++++++++++++++ boards/arm/nrf52/nrf52-generic/Kconfig | 56 ------ boards/arm/nrf52/nrf52832-dk/Kconfig | 8 + boards/arm/nrf52/nrf52832-dk/README.txt | 108 ++++++++++++ .../configs/nsh}/defconfig | 10 +- .../configs/wdog}/defconfig | 4 +- .../include/board.h | 22 +-- .../arm/nrf52/nrf52832-dk/scripts/Make.defs | 116 +++++++++++++ .../nrf52/nrf52832-dk/scripts/flash_config.ld | 121 +++++++++++++ boards/arm/nrf52/nrf52832-dk/src/.gitignore | 2 + .../src/Makefile | 2 +- .../src/nrf52832-dk.h} | 24 +-- .../arm/nrf52/nrf52832-dk/src/nrf52_appinit.c | 89 ++++++++++ .../src/nrf52_autoleds.c | 19 +- boards/arm/nrf52/nrf52832-dk/src/nrf52_boot.c | 96 ++++++++++ .../arm/nrf52/nrf52832-dk/src/nrf52_bringup.c | 97 +++++++++++ .../src/nrf52_buttons.c | 6 +- .../src/nrf52_userleds.c | 9 +- boards/arm/nrf52/nrf52840-dk/Kconfig | 8 + boards/arm/nrf52/nrf52840-dk/README.txt | 8 + .../nrf52/nrf52840-dk/configs/nsh/defconfig | 49 ++++++ boards/arm/nrf52/nrf52840-dk/include/board.h | 125 +++++++++++++ .../arm/nrf52/nrf52840-dk/scripts/Make.defs | 116 +++++++++++++ .../nrf52/nrf52840-dk/scripts/flash_config.ld | 121 +++++++++++++ boards/arm/nrf52/nrf52840-dk/src/.gitignore | 2 + boards/arm/nrf52/nrf52840-dk/src/Makefile | 55 ++++++ .../arm/nrf52/nrf52840-dk/src/nrf52840-dk.h | 101 +++++++++++ .../arm/nrf52/nrf52840-dk/src/nrf52_appinit.c | 89 ++++++++++ .../nrf52/nrf52840-dk/src/nrf52_autoleds.c | 144 +++++++++++++++ boards/arm/nrf52/nrf52840-dk/src/nrf52_boot.c | 96 ++++++++++ .../arm/nrf52/nrf52840-dk/src/nrf52_bringup.c | 83 +++++++++ .../arm/nrf52/nrf52840-dk/src/nrf52_buttons.c | 164 ++++++++++++++++++ .../nrf52/nrf52840-dk/src/nrf52_userleds.c | 164 ++++++++++++++++++ boards/arm/nrf52/nrf52840-dongle/Kconfig | 8 + boards/arm/nrf52/nrf52840-dongle/README.txt | 8 + .../nrf52840-dongle/configs/nsh/defconfig | 49 ++++++ .../arm/nrf52/nrf52840-dongle/include/board.h | 112 ++++++++++++ .../nrf52/nrf52840-dongle/scripts/Make.defs | 116 +++++++++++++ .../nrf52840-dongle/scripts/flash_config.ld | 121 +++++++++++++ .../arm/nrf52/nrf52840-dongle/src/.gitignore | 2 + boards/arm/nrf52/nrf52840-dongle/src/Makefile | 51 ++++++ .../nrf52840-dongle/src/nrf52840-dongle.h | 101 +++++++++++ .../nrf52/nrf52840-dongle/src/nrf52_appinit.c | 89 ++++++++++ .../nrf52840-dongle/src/nrf52_autoleds.c | 144 +++++++++++++++ .../nrf52/nrf52840-dongle/src/nrf52_boot.c | 96 ++++++++++ .../nrf52/nrf52840-dongle/src/nrf52_bringup.c | 83 +++++++++ .../nrf52/nrf52840-dongle/src/nrf52_buttons.c | 0 .../nrf52840-dongle/src/nrf52_userleds.c | 164 ++++++++++++++++++ 73 files changed, 4052 insertions(+), 219 deletions(-) create mode 100644 arch/arm/src/nrf52/hardware/nrf52_uicr.h create mode 100644 boards/arm/nrf52/nrf52-feather/Kconfig rename boards/arm/nrf52/{nrf52-generic => nrf52-feather}/README.txt (72%) rename boards/arm/nrf52/{nrf52-generic/configs/pca10040-nsh => nrf52-feather/configs/nsh}/defconfig (94%) rename boards/arm/nrf52/{nrf52-generic/configs/feather-userleds => nrf52-feather/configs/userleds}/defconfig (84%) create mode 100644 boards/arm/nrf52/nrf52-feather/include/board.h rename boards/arm/nrf52/{nrf52-generic => nrf52-feather}/scripts/Make.defs (98%) rename boards/arm/nrf52/{nrf52-generic => nrf52-feather}/scripts/flash_config.ld (98%) rename boards/arm/nrf52/{nrf52-generic => nrf52-feather}/src/.gitignore (100%) create mode 100644 boards/arm/nrf52/nrf52-feather/src/Makefile create mode 100644 boards/arm/nrf52/nrf52-feather/src/nrf52-feather.h rename boards/arm/nrf52/{nrf52-generic => nrf52-feather}/src/nrf52_appinit.c (97%) create mode 100644 boards/arm/nrf52/nrf52-feather/src/nrf52_autoleds.c rename boards/arm/nrf52/{nrf52-generic => nrf52-feather}/src/nrf52_boot.c (97%) rename boards/arm/nrf52/{nrf52-generic => nrf52-feather}/src/nrf52_bringup.c (98%) create mode 100644 boards/arm/nrf52/nrf52-feather/src/nrf52_buttons.c create mode 100644 boards/arm/nrf52/nrf52-feather/src/nrf52_userleds.c delete mode 100644 boards/arm/nrf52/nrf52-generic/Kconfig create mode 100644 boards/arm/nrf52/nrf52832-dk/Kconfig create mode 100644 boards/arm/nrf52/nrf52832-dk/README.txt rename boards/arm/nrf52/{nrf52-generic/configs/feather-nsh => nrf52832-dk/configs/nsh}/defconfig (81%) rename boards/arm/nrf52/{nrf52-generic/configs/pca10040-wdog => nrf52832-dk/configs/wdog}/defconfig (95%) rename boards/arm/nrf52/{nrf52-generic => nrf52832-dk}/include/board.h (88%) create mode 100644 boards/arm/nrf52/nrf52832-dk/scripts/Make.defs create mode 100644 boards/arm/nrf52/nrf52832-dk/scripts/flash_config.ld create mode 100644 boards/arm/nrf52/nrf52832-dk/src/.gitignore rename boards/arm/nrf52/{nrf52-generic => nrf52832-dk}/src/Makefile (97%) rename boards/arm/nrf52/{nrf52-generic/src/nrf52-generic.h => nrf52832-dk/src/nrf52832-dk.h} (80%) create mode 100644 boards/arm/nrf52/nrf52832-dk/src/nrf52_appinit.c rename boards/arm/nrf52/{nrf52-generic => nrf52832-dk}/src/nrf52_autoleds.c (93%) create mode 100644 boards/arm/nrf52/nrf52832-dk/src/nrf52_boot.c create mode 100644 boards/arm/nrf52/nrf52832-dk/src/nrf52_bringup.c rename boards/arm/nrf52/{nrf52-generic => nrf52832-dk}/src/nrf52_buttons.c (97%) rename boards/arm/nrf52/{nrf52-generic => nrf52832-dk}/src/nrf52_userleds.c (96%) create mode 100644 boards/arm/nrf52/nrf52840-dk/Kconfig create mode 100644 boards/arm/nrf52/nrf52840-dk/README.txt create mode 100644 boards/arm/nrf52/nrf52840-dk/configs/nsh/defconfig create mode 100644 boards/arm/nrf52/nrf52840-dk/include/board.h create mode 100644 boards/arm/nrf52/nrf52840-dk/scripts/Make.defs create mode 100644 boards/arm/nrf52/nrf52840-dk/scripts/flash_config.ld create mode 100644 boards/arm/nrf52/nrf52840-dk/src/.gitignore create mode 100644 boards/arm/nrf52/nrf52840-dk/src/Makefile create mode 100644 boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h create mode 100644 boards/arm/nrf52/nrf52840-dk/src/nrf52_appinit.c create mode 100644 boards/arm/nrf52/nrf52840-dk/src/nrf52_autoleds.c create mode 100644 boards/arm/nrf52/nrf52840-dk/src/nrf52_boot.c create mode 100644 boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c create mode 100644 boards/arm/nrf52/nrf52840-dk/src/nrf52_buttons.c create mode 100644 boards/arm/nrf52/nrf52840-dk/src/nrf52_userleds.c create mode 100644 boards/arm/nrf52/nrf52840-dongle/Kconfig create mode 100644 boards/arm/nrf52/nrf52840-dongle/README.txt create mode 100644 boards/arm/nrf52/nrf52840-dongle/configs/nsh/defconfig create mode 100644 boards/arm/nrf52/nrf52840-dongle/include/board.h create mode 100644 boards/arm/nrf52/nrf52840-dongle/scripts/Make.defs create mode 100644 boards/arm/nrf52/nrf52840-dongle/scripts/flash_config.ld create mode 100644 boards/arm/nrf52/nrf52840-dongle/src/.gitignore create mode 100644 boards/arm/nrf52/nrf52840-dongle/src/Makefile create mode 100644 boards/arm/nrf52/nrf52840-dongle/src/nrf52840-dongle.h create mode 100644 boards/arm/nrf52/nrf52840-dongle/src/nrf52_appinit.c create mode 100644 boards/arm/nrf52/nrf52840-dongle/src/nrf52_autoleds.c create mode 100644 boards/arm/nrf52/nrf52840-dongle/src/nrf52_boot.c create mode 100644 boards/arm/nrf52/nrf52840-dongle/src/nrf52_bringup.c create mode 100644 boards/arm/nrf52/nrf52840-dongle/src/nrf52_buttons.c create mode 100644 boards/arm/nrf52/nrf52840-dongle/src/nrf52_userleds.c diff --git a/arch/arm/src/nrf52/Kconfig b/arch/arm/src/nrf52/Kconfig index a50e60bca4..d1fc2cd84d 100644 --- a/arch/arm/src/nrf52/Kconfig +++ b/arch/arm/src/nrf52/Kconfig @@ -15,14 +15,14 @@ config ARCH_CHIP_NRF52832 select ARCH_FAMILY_NRF52 select ARCH_FAMILY_NRF52832 #select NRF52_HAVE_I2C_MASTER - #select NRF52_HAVE_UART config ARCH_CHIP_NRF52840 bool "NRF52840" select ARCH_FAMILY_NRF52 select ARCH_FAMILY_NRF52840 #select NRF52_HAVE_I2C_MASTER - #select NRF52_HAVE_UART + select NRF52_HAVE_UART1 + select NRF52_HAVE_PORT1 endchoice # NRF52 Chip Selection @@ -42,8 +42,6 @@ config ARCH_FAMILY_NRF52840 # Peripheral support -# Peripheral Selection - config NRF52_HAVE_I2C_MASTER bool default n @@ -52,7 +50,17 @@ config NRF52_HAVE_SPI_MASTER bool default n -config NRF52_HAVE_UART +config NRF52_HAVE_UART1 + bool + default n + +config NRF52_HAVE_PORT1 + bool + default n + +# Peripheral Selection + +config NRF52_UART bool default n @@ -72,7 +80,14 @@ config NRF52_UART0 bool "UART0" default n select UART0_SERIALDRIVER - select NRF52_HAVE_UART + select NRF52_UART + +config NRF52_UART1 + bool "UART1" + default n + depends on NRF52_HAVE_UART1 + select UART1_SERIALDRIVER + select NRF52_UART config NRF52_RNG bool "Random Generator" diff --git a/arch/arm/src/nrf52/Make.defs b/arch/arm/src/nrf52/Make.defs index 51ca78d553..58ff7d6872 100644 --- a/arch/arm/src/nrf52/Make.defs +++ b/arch/arm/src/nrf52/Make.defs @@ -101,7 +101,7 @@ ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) CHIP_CSRCS += nrf52_idle.c endif -ifeq ($(CONFIG_NRF52_HAVE_UART),y) +ifeq ($(CONFIG_NRF52_UART),y) CHIP_CSRCS += nrf52_serial.c endif diff --git a/arch/arm/src/nrf52/hardware/nrf52_gpio.h b/arch/arm/src/nrf52/hardware/nrf52_gpio.h index 6c52462187..3fb29bc00d 100644 --- a/arch/arm/src/nrf52/hardware/nrf52_gpio.h +++ b/arch/arm/src/nrf52/hardware/nrf52_gpio.h @@ -76,6 +76,17 @@ #define NRF52_GPIO0_DIRCLR (NRF52_GPIO_P0_BASE + NRF52_GPIO_DIRCLR_OFFSET) #define NRF52_GPIO0_CNF(n) (NRF52_GPIO_P0_BASE + NRF52_GPIO_PIN_CNF_OFFSET(n)) +#ifdef CONFIG_NRF52_HAVE_PORT1 +# define NRF52_GPIO1_OUT (NRF52_GPIO_P1_BASE + NRF52_GPIO_OUT_OFFSET) +# define NRF52_GPIO1_OUTSET (NRF52_GPIO_P1_BASE + NRF52_GPIO_OUTSET_OFFSET) +# define NRF52_GPIO1_OUTCLR (NRF52_GPIO_P1_BASE + NRF52_GPIO_OUTCLR_OFFSET) +# define NRF52_GPIO1_IN (NRF52_GPIO_P1_BASE + NRF52_GPIO_IN_OFFSET) +# define NRF52_GPIO1_DIR (NRF52_GPIO_P1_BASE + NRF52_GPIO_DIR_OFFSET) +# define NRF52_GPIO1_DIRSET (NRF52_GPIO_P1_BASE + NRF52_GPIO_DIRSET_OFFSET) +# define NRF52_GPIO1_DIRCLR (NRF52_GPIO_P1_BASE + NRF52_GPIO_DIRCLR_OFFSET) +# define NRF52_GPIO1_CNF(n) (NRF52_GPIO_P1_BASE + NRF52_GPIO_PIN_CNF_OFFSET(n)) +#endif + /* Register bit definitions *********************************************************/ #define NRF52_GPIO_CNF_PULL_SHIFT (2) diff --git a/arch/arm/src/nrf52/hardware/nrf52_uicr.h b/arch/arm/src/nrf52/hardware/nrf52_uicr.h new file mode 100644 index 0000000000..39fc1551b3 --- /dev/null +++ b/arch/arm/src/nrf52/hardware/nrf52_uicr.h @@ -0,0 +1,90 @@ +/*************************************************************************************************** + * arch/arm/src/nrf52/hardware/nrf52_uicr.h + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Mateusz Szafoni + * + * 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. + * + ***************************************************************************************************/ + +#ifndef __ARCH_ARM_SRC_NRF52_HARDWARE_NRF52_UICR_H +#define __ARCH_ARM_SRC_NRF52_HARDWARE_NRF52_UICR_H + +/*************************************************************************************************** + * Included Files + ***************************************************************************************************/ + +#include +#include "hardware/nrf52_memorymap.h" + +/*************************************************************************************************** + * Pre-processor Definitions + ***************************************************************************************************/ + +/* UICR Register Offsets ****************************************************************************/ + +/* Registers for the UICR */ + + /* 0x000 - 0x010 : UNUSED */ +#define NRF52_UICR_NRFFW_OFFSET(x) (0x014 + ((x) * 0x4)) /* Reserved for Nordic firmware design */ +#define NRF52_UICR_NRFHW_OFFSET(x) (0x050 + ((x) * 0x4)) /* Reserved for Nordic hardware design */ +#define NRF52_UICR_CUSTOMER_OFFSET(x) (0x080 + ((x) * 0x4)) /* Reserved for customer */ +#define NRF52_UICR_PSELRESET0_OFFSET 0x200 /* Mapping of the nRESET function */ +#define NRF52_UICR_PSELRESET1_OFFSET 0x204 /* Mapping of the nRESET function */ +#define NRF52_UICR_APPROTECT_OFFSET 0x208 /* Access port protection */ +#define NRF52_UICR_NFCPINS_OFFSET 0x20c /* Setting of pins dedicated to NFC */ +#ifdef CONFIG_ARCH_CHIP_NRF52840 +# define NRF52_UICR_DEBUGCTRL_OFFSET 0x210 /* Setting of pins dedicated to NFC */ +# define NRF52_UICR_REGOUT0_OFFSET 0x304 /* GPIO reference voltage / external voltage */ +#endif + +/* UICR Register Addresses **************************************************************************/ + +#define NRF52_UICR_PSELRESET0 (NRF52_UICR_BASE + NRF52_UICR_PSELRESET0_OFFSET) +#define NRF52_UICR_PSELRESET1 (NRF52_UICR_BASE + NRF52_UICR_PSELRESET1_OFFSET) +#define NRF52_UICR_APPROTECT (NRF52_UICR_BASE + NRF52_UICR_APPROTECT_OFFSET) +#define NRF52_UICR_NFCPINS (NRF52_UICR_BASE + NRF52_UICR_NFCPINS_OFFSET) +#define NRF52_UICR_DEBUGCTRL (NRF52_UICR_BASE + NRF52_UICR_DEBUGCTRL_OFFSET) +#define NRF52_UICR_REGOUT0 (NRF52_UICR_BASE + NRF52_UICR_REGOUT0_OFFSET) + +/* UICR Register Bitfield Definitions **************************************************************/ + +/* REGOUT0 Register */ + +#define UICR_REGOUT0_VOUT_SHIFT (0) /* Bits 0-2: Output voltage from REG0 regulator stage */ +#define UICR_REGOUT0_VOUT_MASK (0x3 << UICR_REGOUT0_VOUT_SHIFT) +# define UICR_REGOUT0_VOUT_1V8 (0 << UICR_REGOUT0_VOUT_SHIFT) +# define UICR_REGOUT0_VOUT_2V1 (1 << UICR_REGOUT0_VOUT_SHIFT) +# define UICR_REGOUT0_VOUT_2V4 (2 << UICR_REGOUT0_VOUT_SHIFT) +# define UICR_REGOUT0_VOUT_2V7 (3 << UICR_REGOUT0_VOUT_SHIFT) +# define UICR_REGOUT0_VOUT_3V0 (4 << UICR_REGOUT0_VOUT_SHIFT) +# define UICR_REGOUT0_VOUT_3V3 (5 << UICR_REGOUT0_VOUT_SHIFT) +# define UICR_REGOUT0_VOUT_DEFAULT (7 << UICR_REGOUT0_VOUT_SHIFT) + +#endif /* __ARCH_ARM_SRC_NRF52_HARDWARE_NRF52_UICR_H */ diff --git a/arch/arm/src/nrf52/nrf52_config.h b/arch/arm/src/nrf52/nrf52_config.h index 75eda666bd..82d4377a00 100644 --- a/arch/arm/src/nrf52/nrf52_config.h +++ b/arch/arm/src/nrf52/nrf52_config.h @@ -57,11 +57,16 @@ /* Map logical UART names (Just for simplicity of naming) */ #undef HAVE_UART0 +#undef HAVE_UART1 #ifdef CONFIG_NRF52_UART0 # define HAVE_UART0 1 #endif +#ifdef CONFIG_NRF52_UART1 +# define HAVE_UART1 1 +#endif + /* Check if we have a UART device */ #undef CONFIG_NRF52_HAVE_UART @@ -71,6 +76,10 @@ # define HAVE_UART_DEVICE 1 #endif +#if defined(HAVE_UART1) +# define HAVE_UART_DEVICE 1 +#endif + /* Is there a serial console? There should be at most one defined. */ #undef HAVE_UART_CONSOLE @@ -80,6 +89,11 @@ # define HAVE_UART_CONSOLE 1 #endif +#if defined(CONFIG_UART1_SERIAL_CONSOLE) && defined(HAVE_UART1) +# undef CONFIG_UART0_SERIAL_CONSOLE +# define HAVE_UART_CONSOLE 1 +#endif + /************************************************************************************ * Public Functions ************************************************************************************/ diff --git a/arch/arm/src/nrf52/nrf52_gpio.c b/arch/arm/src/nrf52/nrf52_gpio.c index a5c0a88279..2704d6c58d 100644 --- a/arch/arm/src/nrf52/nrf52_gpio.c +++ b/arch/arm/src/nrf52/nrf52_gpio.c @@ -55,6 +55,34 @@ * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: nrf52_gpio_regget + * + * Description: + * Get a register address for given GPIO port and register offset + * + ****************************************************************************/ + +static inline uint32_t nrf52_gpio_regget(int port, uint32_t offset) +{ + uint32_t base = 0; + + /* Get base address for port */ + + if (port == 0) + { + base = NRF52_GPIO_P0_BASE; + } +#ifdef CONFIG_NRF52_HAVE_PORT1 + else if (port == 1) + { + base = NRF52_GPIO_P1_BASE; + } +#endif + + return (base + offset); +} + /**************************************************************************** * Name: nrf52_gpio_input * @@ -65,12 +93,13 @@ static inline void nrf52_gpio_input(unsigned int port, unsigned int pin) { - /* Set as input */ + uint32_t offset; - if (port == 0) - { - putreg32(1U << pin, NRF52_GPIO0_DIRCLR); - } + offset = nrf52_gpio_regget(port, NRF52_GPIO_DIRCLR_OFFSET); + + /* Configure the pin as an input */ + + putreg32(1U << pin, offset); } /**************************************************************************** @@ -84,14 +113,15 @@ static inline void nrf52_gpio_input(unsigned int port, unsigned int pin) static inline void nrf52_gpio_output(nrf52_pinset_t cfgset, unsigned int port, unsigned int pin) { + uint32_t offset; + + offset = nrf52_gpio_regget(port, NRF52_GPIO_DIRSET_OFFSET); + nrf52_gpio_write(cfgset, ((cfgset & GPIO_VALUE) != GPIO_VALUE_ZERO)); /* Configure the pin as an output */ - if (port == 0) - { - putreg32(1U << pin, NRF52_GPIO0_DIRSET); - } + putreg32(1U << pin, offset); } /**************************************************************************** @@ -107,10 +137,13 @@ static inline void nrf52_gpio_mode(nrf52_pinset_t cfgset, { uint32_t mode; uint32_t regval; + uint32_t offset; + + offset = nrf52_gpio_regget(port, NRF52_GPIO_PIN_CNF_OFFSET(pin)); mode = cfgset & GPIO_MODE_MASK; - regval = getreg32(NRF52_GPIO0_CNF(pin)); + regval = getreg32(offset); regval &= NRF52_GPIO_CNF_PULL_MASK; if (mode == GPIO_PULLUP) @@ -124,7 +157,7 @@ static inline void nrf52_gpio_mode(nrf52_pinset_t cfgset, regval |= NRF52_GPIO_CNF_PULL_DOWN; } - putreg32(regval, NRF52_GPIO0_CNF(pin)); + putreg32(regval, offset); } /**************************************************************************** @@ -205,16 +238,23 @@ int nrf52_gpio_config(nrf52_pinset_t cfgset) void nrf52_gpio_write(nrf52_pinset_t pinset, bool value) { - unsigned int pin = (pinset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT; + unsigned int pin; + unsigned int port; + uint32_t offset; if (value) { - putreg32(1 << pin, NRF52_GPIO0_OUTSET); + offset = nrf52_gpio_regget(port, NRF52_GPIO_OUTSET_OFFSET); } else { - putreg32(1 << pin, NRF52_GPIO0_OUTCLR); + offset = nrf52_gpio_regget(port, NRF52_GPIO_OUTCLR_OFFSET); } + + pin = (pinset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT; + port = (pinset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT; + + putreg32(1 << pin, offset); } /**************************************************************************** @@ -227,11 +267,16 @@ void nrf52_gpio_write(nrf52_pinset_t pinset, bool value) bool nrf52_gpio_read(nrf52_pinset_t pinset) { - uint32_t regval; + unsigned int port; unsigned int pin; + uint32_t regval; + uint32_t offset; + offset = nrf52_gpio_regget(port, NRF52_GPIO_IN_OFFSET); + + port = (pinset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT; pin = (pinset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT; - regval = getreg32(NRF52_GPIO0_IN); + regval = getreg32(offset); return (regval >> pin) & 1UL; } diff --git a/arch/arm/src/nrf52/nrf52_lowputc.c b/arch/arm/src/nrf52/nrf52_lowputc.c index c0b7cd40cb..37cba0ded5 100644 --- a/arch/arm/src/nrf52/nrf52_lowputc.c +++ b/arch/arm/src/nrf52/nrf52_lowputc.c @@ -60,11 +60,23 @@ #ifdef HAVE_UART_CONSOLE -#define CONSOLE_BASE NRF52_UART0_BASE -#define CONSOLE_BAUD CONFIG_UART0_BAUD -#define CONSOLE_BITS CONFIG_UART0_BITS -#define CONSOLE_PARITY CONFIG_UART0_PARITY -#define CONSOLE_2STOP CONFIG_UART0_2STOP +#ifdef CONFIG_UART0_SERIAL_CONSOLE +# define CONSOLE_BASE NRF52_UART0_BASE +# define CONSOLE_BAUD CONFIG_UART0_BAUD +# define CONSOLE_BITS CONFIG_UART0_BITS +# define CONSOLE_PARITY CONFIG_UART0_PARITY +# define CONSOLE_2STOP CONFIG_UART0_2STOP +# define CONSOLE_TX_PIN BOARD_UART0_TX_PIN +# define CONSOLE_RX_PIN BOARD_UART0_RX_PIN +#elif CONFIG_UART1_SERIAL_CONSOLE +# define CONSOLE_BASE NRF52_UART1_BASE +# define CONSOLE_BAUD CONFIG_UART1_BAUD +# define CONSOLE_BITS CONFIG_UART1_BITS +# define CONSOLE_PARITY CONFIG_UART1_PARITY +# define CONSOLE_2STOP CONFIG_UART1_2STOP +# define CONSOLE_TX_PIN BOARD_UART1_TX_PIN +# define CONSOLE_RX_PIN BOARD_UART1_RX_PIN +#endif /**************************************************************************** * Private Data @@ -84,8 +96,8 @@ static const struct uart_config_s g_console_config= #ifdef CONFIG_SERIAL_OFLOWCONTROL .oflow = CONSOLE_OFLOW, #endif - .txpin = BOARD_UART0_TX_PIN, - .rxpin = BOARD_UART0_RX_PIN, + .txpin = CONSOLE_TX_PIN, + .rxpin = CONSOLE_RX_PIN, }; #endif /* HAVE_UART_CONSOLE */ diff --git a/arch/arm/src/nrf52/nrf52_serial.c b/arch/arm/src/nrf52/nrf52_serial.c index f1e4f4324f..7114a1cf6f 100644 --- a/arch/arm/src/nrf52/nrf52_serial.c +++ b/arch/arm/src/nrf52/nrf52_serial.c @@ -152,6 +152,10 @@ static const struct uart_ops_s g_uart_ops = static char g_uart0rxbuffer[CONFIG_UART0_RXBUFSIZE]; static char g_uart0txbuffer[CONFIG_UART0_TXBUFSIZE]; #endif +#ifdef HAVE_UART1 +static char g_uart1rxbuffer[CONFIG_UART1_RXBUFSIZE]; +static char g_uart1txbuffer[CONFIG_UART1_TXBUFSIZE]; +#endif /* This describes the state of the NRF52 UART0 port. */ @@ -173,6 +177,8 @@ static struct nrf52_dev_s g_uart0priv = #ifdef CONFIG_UART0_OFLOWCONTROL .oflow = true, #endif + .txpin = BOARD_UART0_TX_PIN, + .rxpin = BOARD_UART0_RX_PIN, } }; @@ -193,8 +199,57 @@ static uart_dev_t g_uart0port = }; #endif -#define CONSOLE_DEV g_uart0port /* UART0 is console */ -#define TTYS0_DEV g_uart0port /* UART0 is ttyS0 */ +/* This describes the state of the NRF52 UART1 port. */ + +#ifdef HAVE_UART1 +static struct nrf52_dev_s g_uart1priv = +{ + .uartbase = NRF52_UART1_BASE, + .irq = NRF52_IRQ_UART1, + .rx_available = false, + .tx_gpio = BOARD_UART1_TX_PIN, + .rx_gpio = BOARD_UART1_RX_PIN, + .config = + { + .baud = CONFIG_UART1_BAUD, + .parity = CONFIG_UART1_PARITY, + .bits = CONFIG_UART1_BITS, + .stopbits2 = CONFIG_UART1_2STOP, +#ifdef CONFIG_UART1_IFLOWCONTROL + .iflow = true, +#endif +#ifdef CONFIG_UART1_OFLOWCONTROL + .oflow = true, +#endif + .txpin = BOARD_UART1_TX_PIN, + .rxpin = BOARD_UART1_RX_PIN, + } +}; + +static uart_dev_t g_uart1port = +{ + .recv = + { + .size = CONFIG_UART1_RXBUFSIZE, + .buffer = g_uart1rxbuffer, + }, + .xmit = + { + .size = CONFIG_UART1_TXBUFSIZE, + .buffer = g_uart1txbuffer, + }, + .ops = &g_uart_ops, + .priv = &g_uart1priv, +}; +#endif + +#ifdef CONFIG_UART0_SERIAL_CONSOLE +# define CONSOLE_DEV g_uart0port /* UART0 is console */ +# define TTYS0_DEV g_uart0port /* UART0 is ttyS0 */ +#elif CONFIG_UART1_SERIAL_CONSOLE +# define CONSOLE_DEV g_uart1port /* UART1 is console */ +# define TTYS0_DEV g_uart1port /* UART1 is ttyS0 */ +#endif /**************************************************************************** * Private Functions @@ -225,6 +280,8 @@ static int nrf52_setup(struct uart_dev_s *dev) #endif + /* TODO: configure UART if not selected as console */ + return OK; } @@ -241,6 +298,8 @@ static void nrf52_shutdown(struct uart_dev_s *dev) { struct nrf52_dev_s *priv = (struct nrf52_dev_s *)dev->priv; + /* TODO: release uart pins */ + /* Disable interrupts */ /* Reset hardware and disable Rx and Tx */ diff --git a/boards/Kconfig b/boards/Kconfig index 935e02ee14..0c71979d55 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -678,24 +678,37 @@ config ARCH_BOARD_NTOSD_DM320 STATUS: This port is code complete, verified, and included in the NuttX 0.2.1 release. -config ARCH_BOARD_NRF52_PCA10040 - bool "NRF52 PCA10040 eval board" +config ARCH_BOARD_NRF52832_DK + bool "Nordic nRF52832 Development Kit (PCA10040)" depends on ARCH_CHIP_NRF52 select ARCH_HAVE_LEDS select ARCH_HAVE_BUTTONS ---help--- - PCA10040 Evaluation board + This option selects the Nordic nRF52832 Development Kit (PCA10040) -config ARCH_BOARD_NRF52_GENERIC - bool "Generic NRF52832 board" +config ARCH_BOARD_NRF52_FEATHER + bool "Adafruit NRF52 Feather board" depends on ARCH_CHIP_NRF52 select ARCH_HAVE_LEDS select ARCH_HAVE_BUTTONS ---help--- - NuttX port to the a generic NRF52832 board. Support is in place for - the NRF PCA10040 board from Nordic Semiconductor or for the Adafruit - NRF52 feather and can be simply extended to other board based on the - NRF52832 MCU. + This option selects the Adafruit nRF52832 Feather board + +config ARCH_BOARD_NRF52840_DK + bool "Nordic nRF52840 Development Kit (PCA10056)" + depends on ARCH_CHIP_NRF52 + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + ---help--- + This option selects the Nordic nRF52840 Development Kit (PCA10056) + +config ARCH_BOARD_NRF52840_DONGLE + bool "Nordic nRF52840 Dongle (PCA10059)" + depends on ARCH_CHIP_NRF52 + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + ---help--- + This option selects the Nordic nRF52840 Dongle (PCA10059) config ARCH_BOARD_NUTINY_NUC120 bool "Nuvoton NuTiny NUC120" @@ -2041,7 +2054,10 @@ config ARCH_BOARD default "misoc" if ARCH_BOARD_MISOC_QEMU || ARCH_BOARD_MISOC_VERILATOR default "moteino-mega" if ARCH_BOARD_MOTEINO_MEGA default "ne64badge" if ARCH_BOARD_NE64BADGE - default "nrf52-generic" if ARCH_BOARD_NRF52_GENERIC + default "nrf52-feather" if ARCH_BOARD_NRF52_FEATHER + default "nrf52832-dk" if ARCH_BOARD_NRF52832_DK + default "nrf52840-dk" if ARCH_BOARD_NRF52840_DK + default "nrf52840-dongle" if ARCH_BOARD_NRF52840_DONGLE default "ntosd-dm320" if ARCH_BOARD_NTOSD_DM320 default "nucleo-144" if ARCH_BOARD_NUCLEO_144 default "nucleo-f072rb" if ARCH_BOARD_NUCLEO_F072RB @@ -2355,8 +2371,14 @@ endif if ARCH_BOARD_MOXA source "boards/arm/moxart/moxa/Kconfig" endif -if ARCH_BOARD_NRF52_GENERIC -source "boards/arm/nrf52/nrf52-generic/Kconfig" +if ARCH_BOARD_NRF52_FEATHER +source "boards/arm/nrf52/nrf52-feather/Kconfig" +endif +if ARCH_BOARD_NRF52832_DK +source "boards/arm/nrf52/nrf52832-dk/Kconfig" +endif +if ARCH_BOARD_NRF52840_DK +source "boards/arm/nrf52/nrf52840-dk/Kconfig" endif if ARCH_BOARD_NUTINY_NUC120 source "boards/arm/nuc1xx/nutiny-nuc120/Kconfig" diff --git a/boards/README.txt b/boards/README.txt index 094b5979d6..47d7781d22 100644 --- a/boards/README.txt +++ b/boards/README.txt @@ -435,10 +435,17 @@ boards/hc/mcs92s12ne6/ne64badge STATUS: Under development. The port is code-complete but has not yet been fully tested. -boards/arm/nrf52/nrf52-generic - NuttX port to the a generic NRF52. Support is in place for the NRF - PCA10040 board from Nordic Semiconductor or for the Adafruit NRF52 - feather, both featuring the NRF52832 MCU. +boards/arm/nrf52/nrf52-feather + Nuttx port to the Adafruit nRF52832 Feather board + +boards/arm/nrf52/nrf52832-dk + Nuttx port to the Nordic nRF52832 Development Kit (PCA10040) + +boards/arm/nrf52/nrf52840-dk + Nuttx port to the Nordic nRF52840 Development Kit (PCA10056) + +boards/arm/nrf52/nrf52840-dongle + Nuttx port to the Nordic nRF52840 Dongle (PCA10059) boards/arm/dm320/ntosd-dm320 This port uses the Neuros OSD v1.0 Dev Board with a GNU arm-nuttx-elf diff --git a/boards/arm/nrf52/nrf52-feather/Kconfig b/boards/arm/nrf52/nrf52-feather/Kconfig new file mode 100644 index 0000000000..57892baffa --- /dev/null +++ b/boards/arm/nrf52/nrf52-feather/Kconfig @@ -0,0 +1,8 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_NRF52_FEATHER + +endif diff --git a/boards/arm/nrf52/nrf52-generic/README.txt b/boards/arm/nrf52/nrf52-feather/README.txt similarity index 72% rename from boards/arm/nrf52/nrf52-generic/README.txt rename to boards/arm/nrf52/nrf52-feather/README.txt index 504facebe7..e7d8239ad9 100644 --- a/boards/arm/nrf52/nrf52-generic/README.txt +++ b/boards/arm/nrf52/nrf52-feather/README.txt @@ -1,13 +1,13 @@ README ====== -README for NuttX port to generic NRF52832 boards. +README for NuttX port to Adafruit NRF52 Feather boards. Contents ======== - Status - - PCA10040 development board + - Feather nRF52 board - Configurations Status @@ -19,39 +19,6 @@ Status are present and fully verified. This includes: SYSTICK system time, pin and GPIO configuration, and serial console support. -PCA10040 board -============== - - Console - ------- - - The PCA10040 default console is the UART0. - - The PCA10040 does not have RS-232 drivers or serial connectors on board. - UART0, is available on P4 as follows: - - -------- ----- - Signal PIN - -------- ----- - UART0-TX P0.24 - UART0-RX P0.23 - - LEDs - ---- - The PCA10040 has 4 user-controllable LEDs - - LED MCU - LED1 PIN-17 - LED2 PIN-18 - LED3 PIN-19 - LED4 PIN-20 - - A low output illuminates the LED. - - Pushbuttons - ----------- - To be provided - Feather nRF52 board =================== @@ -69,8 +36,8 @@ Feather nRF52 board The Feather has 2 user-controllable LEDs LED MCU - LED1 PIN-17 - LED2 PIN-19 + LED1 PIN0-17 + LED2 PIN0-19 A high output illuminates the LED. @@ -94,7 +61,7 @@ Configurations Each configuration is maintained in a sub-directory and can be selected as follow: - tools/configure.sh nrf52-generic: + tools/configure.sh nrf52-feather: Where is one of the following: @@ -113,11 +80,6 @@ Where is one of the following: b. Execute 'make menuconfig' in nuttx/ in order to start the reconfiguration process. - -wdog: - ------------ - This configuration is a simple NSH-based test of the nRF52 watchdog - timer driver using the test at apps/examples/watchdog. - CONFIG_ARCH_LEDS ---------------- If CONFIG_ARCH_LEDS is defined, the LED will be controlled as follows diff --git a/boards/arm/nrf52/nrf52-generic/configs/pca10040-nsh/defconfig b/boards/arm/nrf52/nrf52-feather/configs/nsh/defconfig similarity index 94% rename from boards/arm/nrf52/nrf52-generic/configs/pca10040-nsh/defconfig rename to boards/arm/nrf52/nrf52-feather/configs/nsh/defconfig index ec5c3b490b..f425dfd749 100644 --- a/boards/arm/nrf52/nrf52-generic/configs/pca10040-nsh/defconfig +++ b/boards/arm/nrf52/nrf52-feather/configs/nsh/defconfig @@ -9,8 +9,8 @@ # CONFIG_NSH_DISABLE_IFCONFIG is not set # CONFIG_NSH_DISABLE_PS is not set CONFIG_ARCH="arm" -CONFIG_ARCH_BOARD="nrf52-generic" -CONFIG_ARCH_BOARD_NRF52_GENERIC=y +CONFIG_ARCH_BOARD="nrf52-feather" +CONFIG_ARCH_BOARD_NRF52_FEATHER=y CONFIG_ARCH_CHIP="nrf52" CONFIG_ARCH_CHIP_NRF52832=y CONFIG_ARCH_CHIP_NRF52=y diff --git a/boards/arm/nrf52/nrf52-generic/configs/feather-userleds/defconfig b/boards/arm/nrf52/nrf52-feather/configs/userleds/defconfig similarity index 84% rename from boards/arm/nrf52/nrf52-generic/configs/feather-userleds/defconfig rename to boards/arm/nrf52/nrf52-feather/configs/userleds/defconfig index d3874c390b..b1a99a8f34 100644 --- a/boards/arm/nrf52/nrf52-generic/configs/feather-userleds/defconfig +++ b/boards/arm/nrf52/nrf52-feather/configs/userleds/defconfig @@ -7,12 +7,11 @@ # # CONFIG_ARCH_FPU is not set # CONFIG_ARCH_LEDS is not set -# CONFIG_NRF52_GENERIC_LED_ACTIVELOW is not set # CONFIG_NSH_DISABLE_IFCONFIG is not set # CONFIG_NSH_DISABLE_PS is not set CONFIG_ARCH="arm" -CONFIG_ARCH_BOARD="nrf52-generic" -CONFIG_ARCH_BOARD_NRF52_GENERIC=y +CONFIG_ARCH_BOARD="nrf52-feather" +CONFIG_ARCH_BOARD_NRF52_FEATHER=y CONFIG_ARCH_CHIP="nrf52" CONFIG_ARCH_CHIP_NRF52832=y CONFIG_ARCH_CHIP_NRF52=y @@ -29,10 +28,6 @@ CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_REGIONS=2 CONFIG_NFILE_DESCRIPTORS=8 CONFIG_NFILE_STREAMS=8 -CONFIG_NRF52_GENERIC_LED2_PIN=19 -CONFIG_NRF52_GENERIC_NUM_LEDS=2 -CONFIG_NRF52_GENERIC_UART0_RX_PIN=8 -CONFIG_NRF52_GENERIC_UART0_TX_PIN=6 CONFIG_NRF52_UART0=y CONFIG_NSH_ARCHINIT=y CONFIG_NSH_BUILTIN_APPS=y diff --git a/boards/arm/nrf52/nrf52-feather/include/board.h b/boards/arm/nrf52/nrf52-feather/include/board.h new file mode 100644 index 0000000000..b50587b0f0 --- /dev/null +++ b/boards/arm/nrf52/nrf52-feather/include/board.h @@ -0,0 +1,109 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52_feather/include/board.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Janne Rosberg + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_NRF52_NRF52_FEATHER_INCLUDE_BOARD_H +#define __BOARDS_ARM_NRF52_NRF52_FEATHER_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_NRF52_GPIO_IRQ) +# include +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking ****************************************************************/ + +#define BOARD_SYSTICK_CLOCK (64000000) + +/* LED definitions *********************************************************/ + +/* A low output illuminates the LED. + * + * LED index values for use with board_userled() + */ + +#define BOARD_LED1 0 +#define BOARD_LED2 1 +#define BOARD_NLEDS 2 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED1_BIT (1 << BOARD_LED1) +#define BOARD_LED2_BIT (1 << BOARD_LED2) + +/* If CONFIG_ARCH_LEDS is defined, the LED will be controlled as follows + * for NuttX debug functionality (where NC means "No Change"). + */ + +#define LED_STARTED 0 /* OFF */ +#define LED_HEAPALLOCATE 0 /* OFF */ +#define LED_IRQSENABLED 0 /* OFF */ +#define LED_STACKCREATED 1 /* ON */ +#define LED_INIRQ 2 /* NC */ +#define LED_SIGNAL 2 /* NC */ +#define LED_ASSERTION 2 /* NC */ +#define LED_PANIC 3 /* Flashing */ + +/* If CONFIG_ARCH_LEDS is not defined, then the LEDs are completely under + * control of the application. The following interfaces are then available + * for application control of the LEDs: + * + * void board_userled_initialize(void); + * void board_userled(int led, bool ledon); + * void board_userled_all(uint8_t ledset); + */ + +/* Button definitions *******************************************************/ + +/* No buttons on board */ + +/* UART Pins ****************************************************************/ + +/* The following definitions must be provided so that the NRF52 serial + * driver can set up the UART for the serial console properly. + */ + +#define BOARD_UART0_RX_PIN (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(8)) +#define BOARD_UART0_TX_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(6)) + +#endif /* __BOARDS_ARM_NRF52_NRF52_FEATHER_INCLUDE_BOARD_H */ diff --git a/boards/arm/nrf52/nrf52-generic/scripts/Make.defs b/boards/arm/nrf52/nrf52-feather/scripts/Make.defs similarity index 98% rename from boards/arm/nrf52/nrf52-generic/scripts/Make.defs rename to boards/arm/nrf52/nrf52-feather/scripts/Make.defs index b4c6646710..98166adc74 100644 --- a/boards/arm/nrf52/nrf52-generic/scripts/Make.defs +++ b/boards/arm/nrf52/nrf52-feather/scripts/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/nrf52/nrf52-generic/scripts/Make.defs +# boards/arm/nrf52/nrf52-feather/scripts/Make.defs # # Copyright (C) 2014, 2017, 2018 Gregory Nutt. All rights reserved. # Author: Gregory Nutt diff --git a/boards/arm/nrf52/nrf52-generic/scripts/flash_config.ld b/boards/arm/nrf52/nrf52-feather/scripts/flash_config.ld similarity index 98% rename from boards/arm/nrf52/nrf52-generic/scripts/flash_config.ld rename to boards/arm/nrf52/nrf52-feather/scripts/flash_config.ld index 62fbb11a92..c7935f3777 100644 --- a/boards/arm/nrf52/nrf52-generic/scripts/flash_config.ld +++ b/boards/arm/nrf52/nrf52-feather/scripts/flash_config.ld @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/nrf52/nrf52-generic/scripts/flash_config.ld + * boards/arm/nrf52/nrf52-feather/scripts/flash_config.ld * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Janne Rosberg diff --git a/boards/arm/nrf52/nrf52-generic/src/.gitignore b/boards/arm/nrf52/nrf52-feather/src/.gitignore similarity index 100% rename from boards/arm/nrf52/nrf52-generic/src/.gitignore rename to boards/arm/nrf52/nrf52-feather/src/.gitignore diff --git a/boards/arm/nrf52/nrf52-feather/src/Makefile b/boards/arm/nrf52/nrf52-feather/src/Makefile new file mode 100644 index 0000000000..39ea10f51b --- /dev/null +++ b/boards/arm/nrf52/nrf52-feather/src/Makefile @@ -0,0 +1,51 @@ +############################################################################ +# boards/arm/nrf52/nrf52-feather/src/Makefile +# +# Copyright (C) 2018 Gregory Nutt. All rights reserved. +# Author: Janne Rosberg +# +# 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. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +ASRCS = +CSRCS = nrf52_boot.c nrf52_bringup.c + +ifeq ($(CONFIG_LIB_BOARDCTL),y) +CSRCS += nrf52_appinit.c +endif + +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += nrf52_autoleds.c +else +CSRCS += nrf52_userleds.c +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/nrf52/nrf52-feather/src/nrf52-feather.h b/boards/arm/nrf52/nrf52-feather/src/nrf52-feather.h new file mode 100644 index 0000000000..db862d5d59 --- /dev/null +++ b/boards/arm/nrf52/nrf52-feather/src/nrf52-feather.h @@ -0,0 +1,94 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52-feather/src/nrf52-feather.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_NRF52_NRF52_FEATHER_SRC_NRF52_FEATHER_H +#define __BOARDS_ARM_NRF52_NRF52_FEATHER_SRC_NRF52_FEATHER_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "nrf52_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LED definitions **********************************************************/ + +/* Definitions to configure LED GPIO as outputs */ + +#define GPIO_LED1 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(17)) +#define GPIO_LED2 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(19)) + +/* Button definitions *******************************************************/ + +/* No buttons on board */ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf52_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y : + * Called from the NSH library + * + ****************************************************************************/ + +int nrf52_bringup(void); + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_NRF52_NRF52_FEATHER_SRC_NRF52_FEATHER_H */ diff --git a/boards/arm/nrf52/nrf52-generic/src/nrf52_appinit.c b/boards/arm/nrf52/nrf52-feather/src/nrf52_appinit.c similarity index 97% rename from boards/arm/nrf52/nrf52-generic/src/nrf52_appinit.c rename to boards/arm/nrf52/nrf52-feather/src/nrf52_appinit.c index e5858bed97..04f927a7e1 100644 --- a/boards/arm/nrf52/nrf52-generic/src/nrf52_appinit.c +++ b/boards/arm/nrf52/nrf52-feather/src/nrf52_appinit.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/nrf52/nrf52-generic/src/nrf52_appinit.c + * boards/arm/nrf52/nrf52-feather/src/nrf52_appinit.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Janne Rosberg @@ -46,7 +46,7 @@ #include #include "chip.h" -#include "nrf52-generic.h" +#include "nrf52-feather.h" /**************************************************************************** * Public Functions diff --git a/boards/arm/nrf52/nrf52-feather/src/nrf52_autoleds.c b/boards/arm/nrf52/nrf52-feather/src/nrf52_autoleds.c new file mode 100644 index 0000000000..59d88f6f01 --- /dev/null +++ b/boards/arm/nrf52/nrf52-feather/src/nrf52_autoleds.c @@ -0,0 +1,147 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52-feather/src/lpc43_autoleds.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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. + * + ****************************************************************************/ + +/* The NRF52 Feather board has 2 user-controllable LEDs: + * + * LED MCU + * LED1 PIN0-17 + * LED2 PIN0-19 + * + * A low output illuminates the LED. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "chip.h" +#include "up_arch.h" +#include "up_internal.h" + +#include "nrf52-feather.h" + +#ifdef CONFIG_ARCH_LEDS + +#define LED_ON 1 +#define LED_OFF 0 + +/* This array maps an LED number to GPIO pin configuration */ + +static const uint32_t g_ledcfg[BOARD_NLEDS] = +{ +#if 0 < BOARD_NLEDS + GPIO_LED1, +#endif +#if 1 < BOARD_NLEDS + GPIO_LED2 +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: led_dumppins + ****************************************************************************/ + +#ifdef LED_VERBOSE +static void led_dumppins(FAR const char *msg) +{ + nrf52_pin_dump(PINCONFIG_LED, msg); + nrf52_gpio_dump(GPIO_LED, msg); +} +#else +# define led_dumppins(m) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_autoled_initialize + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + int i; + + /* Configure LED pin as a GPIO outputs */ + + led_dumppins("board_autoled_initialize() Entry)"); + + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf52_gpio_config(g_ledcfg[i]); + } + + led_dumppins("board_autoled_initialize() Exit"); +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ + if ((unsigned)led < BOARD_NLEDS) + { + nrf52_gpio_write(g_ledcfg[led], LED_ON); + } +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ + if ((unsigned)led < BOARD_NLEDS) + { + nrf52_gpio_write(g_ledcfg[led], LED_OFF); + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/boards/arm/nrf52/nrf52-generic/src/nrf52_boot.c b/boards/arm/nrf52/nrf52-feather/src/nrf52_boot.c similarity index 97% rename from boards/arm/nrf52/nrf52-generic/src/nrf52_boot.c rename to boards/arm/nrf52/nrf52-feather/src/nrf52_boot.c index a94b9d1a10..f12ce6f34c 100644 --- a/boards/arm/nrf52/nrf52-generic/src/nrf52_boot.c +++ b/boards/arm/nrf52/nrf52-feather/src/nrf52_boot.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/nrf52/nrf52-generic/src/lpc43_boot.c + * boards/arm/nrf52/nrf52-feather/src/lpc43_boot.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -47,7 +47,7 @@ #include "up_arch.h" #include "up_internal.h" -#include "nrf52-generic.h" +#include "nrf52-feather.h" /**************************************************************************** * Public Functions diff --git a/boards/arm/nrf52/nrf52-generic/src/nrf52_bringup.c b/boards/arm/nrf52/nrf52-feather/src/nrf52_bringup.c similarity index 98% rename from boards/arm/nrf52/nrf52-generic/src/nrf52_bringup.c rename to boards/arm/nrf52/nrf52-feather/src/nrf52_bringup.c index 45d18db294..bc93eb9302 100644 --- a/boards/arm/nrf52/nrf52-generic/src/nrf52_bringup.c +++ b/boards/arm/nrf52/nrf52-feather/src/nrf52_bringup.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/nrf52/nrf52-generic/src/nrf53_bringup.c + * boards/arm/nrf52/nrf52-feather/src/nrf53_bringup.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/boards/arm/nrf52/nrf52-feather/src/nrf52_buttons.c b/boards/arm/nrf52/nrf52-feather/src/nrf52_buttons.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/boards/arm/nrf52/nrf52-feather/src/nrf52_userleds.c b/boards/arm/nrf52/nrf52-feather/src/nrf52_userleds.c new file mode 100644 index 0000000000..5d8c86f973 --- /dev/null +++ b/boards/arm/nrf52/nrf52-feather/src/nrf52_userleds.c @@ -0,0 +1,158 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52-feather/src/nrf52_userleds.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Janne Rosberg + * + * 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 + +#include + +#include "chip.h" +#include "up_arch.h" +#include "up_internal.h" + +#include "nrf52-feather.h" + +#ifndef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LED definitions **********************************************************/ + +/* If CONFIG_ARCH_LEDS is not defined, then the LEDs are completely under + * control of the application. The following interfaces are then available + * for application control of the LEDs: + * + * void board_userled_initialize(void); + * void board_userled(int led, bool ledon); + * void board_userled_all(uint8_t ledset); + */ + +#define LED_ON 1 +#define LED_OFF 0 + +/* This array maps an LED number to GPIO pin configuration */ + +static const uint32_t g_ledcfg[BOARD_NLEDS] = +{ +#if 0 < BOARD_NLEDS + GPIO_LED1, +#endif +#if 1 < BOARD_NLEDS + GPIO_LED2, +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: led_dumppins + ****************************************************************************/ + +#ifdef LED_VERBOSE +static void led_dumppins(FAR const char *msg) +{ + nrf52_pin_dump(PINCONFIG_LED, msg); + nrf52_gpio_dump(GPIO_LED, msg); +} +#else +# define led_dumppins(m) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +void board_userled_initialize(void) +{ + int i; + + /* Configure LED pin as a GPIO outputs */ + + led_dumppins("board_userled_initialize() Entry)"); + + /* Configure GPIO as an outputs */ + + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf52_gpio_config(g_ledcfg[i]); + } + + led_dumppins("board_userled_initialize() Exit"); +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + if ((unsigned)led < BOARD_NLEDS) + { + nrf52_gpio_write(g_ledcfg[led], ledon ? LED_ON : LED_OFF); + } +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint8_t ledset) +{ + int i; + + /* Configure LED1-8 GPIOs for output */ + + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf52_gpio_write(g_ledcfg[i], (ledset & (1 << i)) ? LED_ON : LED_OFF); + } +} + +#endif /* !CONFIG_ARCH_LEDS */ diff --git a/boards/arm/nrf52/nrf52-generic/Kconfig b/boards/arm/nrf52/nrf52-generic/Kconfig deleted file mode 100644 index afcb1e870e..0000000000 --- a/boards/arm/nrf52/nrf52-generic/Kconfig +++ /dev/null @@ -1,56 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see the file kconfig-language.txt in the NuttX tools repository. -# - -if ARCH_BOARD_NRF52_GENERIC - -config NRF52_GENERIC_UART0_RX_PIN - int "Pin select for UART0 TXD" - default 23 - ---help--- - Pin select for UART0 TXD - -config NRF52_GENERIC_UART0_TX_PIN - int "Pin select for UART0 TXD" - default 24 - ---help--- - Pin select for UART0 TXD - -config NRF52_GENERIC_NUM_LEDS - int "Number of LEDs" - default 4 - ---help--- - Number of LEDs - -config NRF52_GENERIC_LED_ACTIVELOW - bool "Board LEDs are 'active low'" - default y - ---help--- - Board LEDs are 'active low' - -config NRF52_GENERIC_LED1_PIN - int "Pin select for LED 1" - default 17 - ---help--- - Pin select for LED 1 - -config NRF52_GENERIC_LED2_PIN - int "Pin select for LED 2" - default 18 - ---help--- - Pin select for LED 2 - -config NRF52_GENERIC_LED3_PIN - int "Pin select for LED 3" - default 19 - ---help--- - Pin select for LED 3 - -config NRF52_GENERIC_LED4_PIN - int "Pin select for LED 4" - default 20 - ---help--- - Pin select for LED 4 - -endif diff --git a/boards/arm/nrf52/nrf52832-dk/Kconfig b/boards/arm/nrf52/nrf52832-dk/Kconfig new file mode 100644 index 0000000000..61f04cc972 --- /dev/null +++ b/boards/arm/nrf52/nrf52832-dk/Kconfig @@ -0,0 +1,8 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_NRF52832_DK + +endif diff --git a/boards/arm/nrf52/nrf52832-dk/README.txt b/boards/arm/nrf52/nrf52832-dk/README.txt new file mode 100644 index 0000000000..ce5f48f074 --- /dev/null +++ b/boards/arm/nrf52/nrf52832-dk/README.txt @@ -0,0 +1,108 @@ +README +====== + +README for NuttX port to NRF52832-DK (PCA10040) boards. + +Contents +======== + + - Status + - NRF52832 development kit (PCA10040) + - Configurations + +Status +====== + + This is the current status of the NRF52 port: + + - The basic OS test configuration and the basic NSH configurations + are present and fully verified. This includes: SYSTICK system time, + pin and GPIO configuration, and serial console support. + +NRF52832 development kit (PCA10040) +=================================== + + Console + ------- + + The PCA10040 default console is the UART0. + + The PCA10040 does not have RS-232 drivers or serial connectors on board. + UART0 is connected to the virtual COM port: + + -------- ----- + Signal PIN + -------- ----- + UART0-TX P0.06 + UART0-RX P0.08 + + LEDs + ---- + The PCA10040 has 4 user-controllable LEDs + + LED MCU + LED1 PIN0-17 + LED2 PIN0-18 + LED3 PIN0-19 + LED4 PIN0-20 + + A low output illuminates the LED. + + Pushbuttons + ----------- + To be provided + +Memory Map +========== + + Block Start Length + Name Address + --------------------- ---------- ------ + FLASH 0x00000000 512K + RAM 0x20000000 64K + +Configurations +============== + +Each configuration is maintained in a sub-directory and can be selected as +follow: + + tools/configure.sh nrf52832-dk: + +Where is one of the following: + + nsh: + ----------- + This configuration is the NuttShell (NSH) example at examples/nsh/. + + NOTES: + + 1. This configuration uses the mconf-based configuration tool. To + change this configurations using that tool, you should: + + a. Build and install the kconfig-mconf tool. See nuttx/README.txt + see additional README.txt files in the NuttX tools repository. + + b. Execute 'make menuconfig' in nuttx/ in order to start the + reconfiguration process. + + wdog: + ------------ + This configuration is a simple NSH-based test of the nRF52 watchdog + timer driver using the test at apps/examples/watchdog. + + CONFIG_ARCH_LEDS + ---------------- + If CONFIG_ARCH_LEDS is defined, the LED will be controlled as follows + for NuttX debug functionality (where NC means "No Change"). + + TBD! + + If CONFIG_ARCH_LEDS is not defined, then the LEDs are completely under + control of the application. The following interfaces are then available + for application control of the LEDs: + + void board_userled_initialize(void); + void board_userled(int led, bool ledon); + void board_userled_all(uint8_t ledset); + diff --git a/boards/arm/nrf52/nrf52-generic/configs/feather-nsh/defconfig b/boards/arm/nrf52/nrf52832-dk/configs/nsh/defconfig similarity index 81% rename from boards/arm/nrf52/nrf52-generic/configs/feather-nsh/defconfig rename to boards/arm/nrf52/nrf52832-dk/configs/nsh/defconfig index 62a4214525..c75f04bb27 100644 --- a/boards/arm/nrf52/nrf52-generic/configs/feather-nsh/defconfig +++ b/boards/arm/nrf52/nrf52832-dk/configs/nsh/defconfig @@ -9,8 +9,8 @@ # CONFIG_NSH_DISABLE_IFCONFIG is not set # CONFIG_NSH_DISABLE_PS is not set CONFIG_ARCH="arm" -CONFIG_ARCH_BOARD="nrf52-generic" -CONFIG_ARCH_BOARD_NRF52_GENERIC=y +CONFIG_ARCH_BOARD="nrf52832-dk" +CONFIG_ARCH_BOARD_NRF52832_DK=y CONFIG_ARCH_CHIP="nrf52" CONFIG_ARCH_CHIP_NRF52832=y CONFIG_ARCH_CHIP_NRF52=y @@ -45,11 +45,5 @@ CONFIG_SYMTAB_ORDEREDBYNAME=y CONFIG_SYSTEM_NSH=y CONFIG_TASK_NAME_SIZE=0 CONFIG_UART0_SERIAL_CONSOLE=y -CONFIG_NRF52_GENERIC_UART0_RX_PIN=8 -CONFIG_NRF52_GENERIC_UART0_TX_PIN=6 -CONFIG_NRF52_GENERIC_NUM_LEDS=2 -# CONFIG_NRF52_GENERIC_LED_ACTIVELOW is not set -CONFIG_NRF52_GENERIC_LED1_PIN=17 -CONFIG_NRF52_GENERIC_LED2_PIN=19 CONFIG_USER_ENTRYPOINT="nsh_main" CONFIG_WDOG_INTRESERVE=0 diff --git a/boards/arm/nrf52/nrf52-generic/configs/pca10040-wdog/defconfig b/boards/arm/nrf52/nrf52832-dk/configs/wdog/defconfig similarity index 95% rename from boards/arm/nrf52/nrf52-generic/configs/pca10040-wdog/defconfig rename to boards/arm/nrf52/nrf52832-dk/configs/wdog/defconfig index aec615b654..6cc84a69ca 100644 --- a/boards/arm/nrf52/nrf52-generic/configs/pca10040-wdog/defconfig +++ b/boards/arm/nrf52/nrf52832-dk/configs/wdog/defconfig @@ -9,8 +9,8 @@ # CONFIG_NSH_DISABLE_IFCONFIG is not set # CONFIG_NSH_DISABLE_PS is not set CONFIG_ARCH="arm" -CONFIG_ARCH_BOARD="nrf52-generic" -CONFIG_ARCH_BOARD_NRF52_GENERIC=y +CONFIG_ARCH_BOARD="nrf52832-dk" +CONFIG_ARCH_BOARD_NRF52832_DK=y CONFIG_ARCH_CHIP="nrf52" CONFIG_ARCH_CHIP_NRF52832=y CONFIG_ARCH_CHIP_NRF52=y diff --git a/boards/arm/nrf52/nrf52-generic/include/board.h b/boards/arm/nrf52/nrf52832-dk/include/board.h similarity index 88% rename from boards/arm/nrf52/nrf52-generic/include/board.h rename to boards/arm/nrf52/nrf52832-dk/include/board.h index 6fadbd26a9..6488aba2b6 100644 --- a/boards/arm/nrf52/nrf52-generic/include/board.h +++ b/boards/arm/nrf52/nrf52832-dk/include/board.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/nrf52/nrf52_generic/include/board.h + * boards/arm/nrf52/nrf52_feather/include/board.h * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Janne Rosberg @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_ARM_NRF52_NRF52_GENERIC_INCLUDE_BOARD_H -#define __BOARDS_ARM_NRF52_NRF52_GENERIC_INCLUDE_BOARD_H +#ifndef __BOARDS_ARM_NRF52_NRF52_FEATHER_INCLUDE_BOARD_H +#define __BOARDS_ARM_NRF52_NRF52_FEATHER_INCLUDE_BOARD_H /**************************************************************************** * Included Files @@ -66,7 +66,7 @@ #define BOARD_LED2 1 #define BOARD_LED3 2 #define BOARD_LED4 3 -#define BOARD_NLEDS CONFIG_NRF52_GENERIC_NUM_LEDS +#define BOARD_NLEDS 4 /* LED bits for use with board_userled_all() */ @@ -78,7 +78,7 @@ /* If CONFIG_ARCH_LEDS is defined, the LED will be controlled as follows * for NuttX debug functionality (where NC means "No Change"). */ - /* LED */ + #define LED_STARTED 0 /* OFF */ #define LED_HEAPALLOCATE 0 /* OFF */ #define LED_IRQSENABLED 0 /* OFF */ @@ -105,7 +105,6 @@ #define BUTTON_BTN2 1 #define BUTTON_BTN3 2 #define BUTTON_BTN4 3 - #define NUM_BUTTONS 4 #define BUTTON_BTN1_BIT (1 << BUTTON_BTN1) @@ -115,11 +114,12 @@ /* UART Pins ****************************************************************/ -/* The following definitions must be provided so that the NRF52 serial - * driver can set up the UART for the serial console properly. +/* UART0 is connected to the virtual COM port: + * UART0_RX - P0-8 + * UART0_TX - P0-6 */ -#define BOARD_UART0_RX_PIN (GPIO_INPUT | GPIO_PIN(CONFIG_NRF52_GENERIC_UART0_RX_PIN)) -#define BOARD_UART0_TX_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN(CONFIG_NRF52_GENERIC_UART0_TX_PIN)) +#define BOARD_UART0_RX_PIN (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(8)) +#define BOARD_UART0_TX_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(6)) -#endif /* __BOARDS_ARM_NRF52_NRF52_GENERIC_INCLUDE_BOARD_H */ +#endif /* __BOARDS_ARM_NRF52_NRF52_FEATHER_INCLUDE_BOARD_H */ diff --git a/boards/arm/nrf52/nrf52832-dk/scripts/Make.defs b/boards/arm/nrf52/nrf52832-dk/scripts/Make.defs new file mode 100644 index 0000000000..582887cfba --- /dev/null +++ b/boards/arm/nrf52/nrf52832-dk/scripts/Make.defs @@ -0,0 +1,116 @@ +############################################################################ +# boards/arm/nrf52/nrf52832-dk/scripts/Make.defs +# +# Copyright (C) 2014, 2017, 2018 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# 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. +# +############################################################################ + +include ${TOPDIR}/.config +include ${TOPDIR}/tools/Config.mk +include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs + +LDSCRIPT = flash_config.ld + +# Setup for Windows vs Linux/Cygwin/macOS environments + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/copydir.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mkwindeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) +endif + +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +STRIP = $(CROSSDEV)strip --strip-unneeded +AR = $(ARCROSSDEV)ar rcs +NM = $(ARCROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} +ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer +endif + +ARCHCFLAGS = -fno-builtin +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +ASMEXT = .S +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +ifneq ($(CROSSDEV),arm-nuttx-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe +HOSTLDFLAGS = + diff --git a/boards/arm/nrf52/nrf52832-dk/scripts/flash_config.ld b/boards/arm/nrf52/nrf52832-dk/scripts/flash_config.ld new file mode 100644 index 0000000000..dc1bb17358 --- /dev/null +++ b/boards/arm/nrf52/nrf52832-dk/scripts/flash_config.ld @@ -0,0 +1,121 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52832-dk/scripts/flash_config.ld + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Janne Rosberg + * + * 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. + * + ****************************************************************************/ + +MEMORY +{ + progmem (rx) : ORIGIN = 0x00000000, LENGTH = 512K + datamem (rwx) : ORIGIN = 0x20000000, LENGTH = 64K +} + +OUTPUT_ARCH(arm) +ENTRY(__start) /* Treat __start as the anchor for dead code stripping */ +EXTERN(_vectors) /* Force the vectors to be included in the output */ +SECTIONS +{ + .text : + { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > progmem + + .init_section : + { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > progmem + + .ARM.extab : + { + *(.ARM.extab*) + } > progmem + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : + { + *(.ARM.exidx*) + } > progmem + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > datamem AT > progmem + + /* BSS */ + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > datamem + + /* Stabs debugging sections. */ + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/nrf52/nrf52832-dk/src/.gitignore b/boards/arm/nrf52/nrf52832-dk/src/.gitignore new file mode 100644 index 0000000000..726d936e1e --- /dev/null +++ b/boards/arm/nrf52/nrf52832-dk/src/.gitignore @@ -0,0 +1,2 @@ +/.depend +/Make.dep diff --git a/boards/arm/nrf52/nrf52-generic/src/Makefile b/boards/arm/nrf52/nrf52832-dk/src/Makefile similarity index 97% rename from boards/arm/nrf52/nrf52-generic/src/Makefile rename to boards/arm/nrf52/nrf52832-dk/src/Makefile index ed5aedf83f..931a632bb8 100644 --- a/boards/arm/nrf52/nrf52-generic/src/Makefile +++ b/boards/arm/nrf52/nrf52832-dk/src/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/nrf52/nrf52-generic/src/Makefile +# boards/arm/nrf52/nrf52832-dk/src/Makefile # # Copyright (C) 2018 Gregory Nutt. All rights reserved. # Author: Janne Rosberg diff --git a/boards/arm/nrf52/nrf52-generic/src/nrf52-generic.h b/boards/arm/nrf52/nrf52832-dk/src/nrf52832-dk.h similarity index 80% rename from boards/arm/nrf52/nrf52-generic/src/nrf52-generic.h rename to boards/arm/nrf52/nrf52832-dk/src/nrf52832-dk.h index 6adcb10e34..534ea1e3ce 100644 --- a/boards/arm/nrf52/nrf52-generic/src/nrf52-generic.h +++ b/boards/arm/nrf52/nrf52832-dk/src/nrf52832-dk.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/nrf52/nrf52-generic/src/nrf52-generic.h + * boards/arm/nrf52/nrf52832-dk/src/nrf52832-dk.h * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_ARM_NRF52_NRF52GENERIC_SRC_NRF52GENERIC_H -#define __BOARDS_ARM_NRF52_NRF52GENERIC_SRC_NRF52GENERIC_H +#ifndef __BOARDS_ARM_NRF52_NRF52832_DK_SRC_NRF52832_DK_H +#define __BOARDS_ARM_NRF52_NRF52832_DK_SRC_NRF52832_DK_H /**************************************************************************** * Included Files @@ -53,19 +53,19 @@ /* Definitions to configure LED GPIO as outputs */ -#define GPIO_LED1 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN(CONFIG_NRF52_GENERIC_LED1_PIN)) -#define GPIO_LED2 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN(CONFIG_NRF52_GENERIC_LED2_PIN)) -#define GPIO_LED3 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN(CONFIG_NRF52_GENERIC_LED3_PIN)) -#define GPIO_LED4 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PIN(CONFIG_NRF52_GENERIC_LED4_PIN)) +#define GPIO_LED1 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(17)) +#define GPIO_LED2 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(18)) +#define GPIO_LED3 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(19)) +#define GPIO_LED4 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(20)) /* Button definitions *******************************************************/ /* Board supports four buttons. */ -#define GPIO_BUTTON1 (GPIO_INPUT | GPIO_PULLUP | GPIO_PIN13) -#define GPIO_BUTTON2 (GPIO_INPUT | GPIO_PULLUP | GPIO_PIN14) -#define GPIO_BUTTON3 (GPIO_INPUT | GPIO_PULLUP | GPIO_PIN15) -#define GPIO_BUTTON4 (GPIO_INPUT | GPIO_PULLUP | GPIO_PIN16) +#define GPIO_BUTTON1 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN(13)) +#define GPIO_BUTTON2 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN(14)) +#define GPIO_BUTTON3 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN(15)) +#define GPIO_BUTTON4 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN(16)) /**************************************************************************** * Public Types @@ -98,4 +98,4 @@ int nrf52_bringup(void); #endif /* __ASSEMBLY__ */ -#endif /* __BOARDS_ARM_NRF52_NRF52GENERIC_SRC_NRF52GENERIC_H */ +#endif /* __BOARDS_ARM_NRF52_NRF52832_DK_SRC_NRF52832_DK_H */ diff --git a/boards/arm/nrf52/nrf52832-dk/src/nrf52_appinit.c b/boards/arm/nrf52/nrf52832-dk/src/nrf52_appinit.c new file mode 100644 index 0000000000..2b87aab100 --- /dev/null +++ b/boards/arm/nrf52/nrf52832-dk/src/nrf52_appinit.c @@ -0,0 +1,89 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52832-dk/src/nrf52_appinit.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Janne Rosberg + * + * 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 + +#include + +#include "chip.h" +#include "nrf52832-dk.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform architecture specific initialization + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value cold be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ +#ifdef CONFIG_BOARD_LATE_INITIALIZE + /* Board initialization already performed by board_late_initialize() */ + + return OK; +#else + /* Perform board-specific initialization */ + + return nrf52_bringup(); +#endif +} diff --git a/boards/arm/nrf52/nrf52-generic/src/nrf52_autoleds.c b/boards/arm/nrf52/nrf52832-dk/src/nrf52_autoleds.c similarity index 93% rename from boards/arm/nrf52/nrf52-generic/src/nrf52_autoleds.c rename to boards/arm/nrf52/nrf52832-dk/src/nrf52_autoleds.c index 251eeb6831..51b42b0325 100644 --- a/boards/arm/nrf52/nrf52-generic/src/nrf52_autoleds.c +++ b/boards/arm/nrf52/nrf52832-dk/src/nrf52_autoleds.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/nrf52/nrf52-generic/src/lpc43_autoleds.c + * boards/arm/nrf52/nrf52832-dk/src/lpc43_autoleds.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -33,13 +33,13 @@ * ****************************************************************************/ -/* The PCA10040 has 4 user-controllable LEDs: +/* The Nordic nRF52832-DK has 4 user-controllable LEDs: * * LED MCU - * LED1 PIN-17 - * LED2 PIN-18 - * LED3 PIN-19 - * LED4 PIN-20 + * LED1 PIN0-17 + * LED2 PIN0-18 + * LED3 PIN0-19 + * LED4 PIN0-20 * * A low output illuminates the LED. */ @@ -61,17 +61,12 @@ #include "up_arch.h" #include "up_internal.h" -#include "nrf52-generic.h" +#include "nrf52832-dk.h" #ifdef CONFIG_ARCH_LEDS -#ifdef CONFIG_NRF52_GENERIC_LED_ACTIVELOW #define LED_ON 0 #define LED_OFF 1 -#else -#define LED_ON 1 -#define LED_OFF 0 -#endif /* This array maps an LED number to GPIO pin configuration */ diff --git a/boards/arm/nrf52/nrf52832-dk/src/nrf52_boot.c b/boards/arm/nrf52/nrf52832-dk/src/nrf52_boot.c new file mode 100644 index 0000000000..ac4059415f --- /dev/null +++ b/boards/arm/nrf52/nrf52832-dk/src/nrf52_boot.c @@ -0,0 +1,96 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52832-dk/src/lpc43_boot.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include "up_arch.h" +#include "up_internal.h" + +#include "nrf52832-dk.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf52_board_initialize + * + * Description: + * All NRF52xxx architectures must provide the following entry point. + * This entry point is called early in the initialization -- after all + * memory has been configured and mapped but before any devices have been + * initialized. + * + ****************************************************************************/ + +void nrf52_board_initialize(void) +{ + /* Configure on-board LEDs if LED support has been selected. */ + +#ifdef CONFIG_ARCH_LEDS + board_autoled_initialize(); +#endif +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() will be + * called immediately after up_initialize() is called and just before the + * initial application is started. This additional initialization phase + * may be used, for example, to initialize board-specific device drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board-specific initialization */ + + (void)nrf52_bringup(); +} +#endif diff --git a/boards/arm/nrf52/nrf52832-dk/src/nrf52_bringup.c b/boards/arm/nrf52/nrf52832-dk/src/nrf52_bringup.c new file mode 100644 index 0000000000..c56c5ac7a1 --- /dev/null +++ b/boards/arm/nrf52/nrf52832-dk/src/nrf52_bringup.c @@ -0,0 +1,97 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52832-dk/src/nrf53_bringup.c + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#ifdef CONFIG_NRF52_WDT +# include "nrf52_wdt.h" +#endif + +#ifdef CONFIG_USERLED +# include +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf52_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y : + * Called from the NSH library + * + ****************************************************************************/ + +int nrf52_bringup(void) +{ + int ret; + +#ifdef CONFIG_NRF52_WDT + /* Start Watchdog timer */ + + ret = nrf52_wdt_initialize(CONFIG_WATCHDOG_DEVPATH, 1, 1); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: nrf52_wdt_initialize failed: %d\n", ret); + } +#endif + +#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 + + UNUSED(ret); + return OK; +} diff --git a/boards/arm/nrf52/nrf52-generic/src/nrf52_buttons.c b/boards/arm/nrf52/nrf52832-dk/src/nrf52_buttons.c similarity index 97% rename from boards/arm/nrf52/nrf52-generic/src/nrf52_buttons.c rename to boards/arm/nrf52/nrf52832-dk/src/nrf52_buttons.c index 541c2c6e55..0b8e947144 100644 --- a/boards/arm/nrf52/nrf52-generic/src/nrf52_buttons.c +++ b/boards/arm/nrf52/nrf52832-dk/src/nrf52_buttons.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/nrf52/nrf52-generic/src/nrf52_buttons.c + * boards/arm/nrf52/nrf52832-dk/src/nrf52_buttons.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Janne Rosberg @@ -48,7 +48,7 @@ #include "nrf52_gpio.h" -#include "nrf52-generic.h" +#include "nrf52832-dk.h" #ifdef CONFIG_ARCH_BUTTONS @@ -56,7 +56,7 @@ * Private Data ****************************************************************************/ -/* Pin configuration for each PCA10040 button. This array is indexed by +/* Pin configuration for each nRF52832-DK button. This array is indexed by * the BUTTON_* definitions in board.h */ diff --git a/boards/arm/nrf52/nrf52-generic/src/nrf52_userleds.c b/boards/arm/nrf52/nrf52832-dk/src/nrf52_userleds.c similarity index 96% rename from boards/arm/nrf52/nrf52-generic/src/nrf52_userleds.c rename to boards/arm/nrf52/nrf52832-dk/src/nrf52_userleds.c index c6e98bf378..283fe2ba10 100644 --- a/boards/arm/nrf52/nrf52-generic/src/nrf52_userleds.c +++ b/boards/arm/nrf52/nrf52832-dk/src/nrf52_userleds.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/nrf52/nrf52-generic/src/nrf52_userleds.c + * boards/arm/nrf52/nrf52832-dk/src/nrf52_userleds.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Janne Rosberg @@ -49,7 +49,7 @@ #include "up_arch.h" #include "up_internal.h" -#include "nrf52-generic.h" +#include "nrf52832-dk.h" #ifndef CONFIG_ARCH_LEDS @@ -68,13 +68,8 @@ * void board_userled_all(uint8_t ledset); */ -#ifdef CONFIG_NRF52_GENERIC_LED_ACTIVELOW #define LED_ON 0 #define LED_OFF 1 -#else -#define LED_ON 1 -#define LED_OFF 0 -#endif /* This array maps an LED number to GPIO pin configuration */ diff --git a/boards/arm/nrf52/nrf52840-dk/Kconfig b/boards/arm/nrf52/nrf52840-dk/Kconfig new file mode 100644 index 0000000000..52b4e6b2eb --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/Kconfig @@ -0,0 +1,8 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_NRF52840_DK + +endif diff --git a/boards/arm/nrf52/nrf52840-dk/README.txt b/boards/arm/nrf52/nrf52840-dk/README.txt new file mode 100644 index 0000000000..ba9869ab02 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/README.txt @@ -0,0 +1,8 @@ +nRF52840-DK +=========== + +README for NuttX port to NRF52840-DK (PCA10056) boards. + +Status +====== + Only the basic NSH configuration is supported for now. diff --git a/boards/arm/nrf52/nrf52840-dk/configs/nsh/defconfig b/boards/arm/nrf52/nrf52840-dk/configs/nsh/defconfig new file mode 100644 index 0000000000..92dadc689d --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/configs/nsh/defconfig @@ -0,0 +1,49 @@ +# +# 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_ARCH_FPU is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nrf52840-dk" +CONFIG_ARCH_BOARD_NRF52840_DK=y +CONFIG_ARCH_CHIP="nrf52" +CONFIG_ARCH_CHIP_NRF52840=y +CONFIG_ARCH_CHIP_NRF52=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_MAX_TASKS=16 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_MM_REGIONS=2 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NRF52_UART0=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PREALLOC_WDOGS=4 +CONFIG_RAM_SIZE=65535 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=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 +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_WDOG_INTRESERVE=0 diff --git a/boards/arm/nrf52/nrf52840-dk/include/board.h b/boards/arm/nrf52/nrf52840-dk/include/board.h new file mode 100644 index 0000000000..da3f18fa96 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/include/board.h @@ -0,0 +1,125 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dk/include/board.h + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Mateusz Szafoni + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_NRF52_NRF52840_DK_INCLUDE_BOARD_H +#define __BOARDS_ARM_NRF52_NRF52840_DK_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_NRF52_GPIO_IRQ) +# include +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking ****************************************************************/ + +#define BOARD_SYSTICK_CLOCK (64000000) + +/* LED definitions *********************************************************/ + +/* A low output illuminates the LED. + * + * LED index values for use with board_userled() + */ + +#define BOARD_LED1 0 +#define BOARD_LED2 1 +#define BOARD_LED3 2 +#define BOARD_LED4 3 +#define BOARD_NLEDS 4 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED1_BIT (1 << BOARD_LED1) +#define BOARD_LED2_BIT (1 << BOARD_LED2) +#define BOARD_LED3_BIT (1 << BOARD_LED3) +#define BOARD_LED4_BIT (1 << BOARD_LED4) + +/* If CONFIG_ARCH_LEDS is defined, the LED will be controlled as follows + * for NuttX debug functionality (where NC means "No Change"). + */ + +#define LED_STARTED 0 /* OFF */ +#define LED_HEAPALLOCATE 0 /* OFF */ +#define LED_IRQSENABLED 0 /* OFF */ +#define LED_STACKCREATED 1 /* ON */ +#define LED_INIRQ 2 /* NC */ +#define LED_SIGNAL 2 /* NC */ +#define LED_ASSERTION 2 /* NC */ +#define LED_PANIC 3 /* Flashing */ + +/* If CONFIG_ARCH_LEDS is not defined, then the LEDs are completely under + * control of the application. The following interfaces are then available + * for application control of the LEDs: + * + * void board_userled_initialize(void); + * void board_userled(int led, bool ledon); + * void board_userled_all(uint8_t ledset); + */ + +/* Button definitions *******************************************************/ + +/* Board supports four buttons. */ + +#define BUTTON_BTN1 0 +#define BUTTON_BTN2 1 +#define BUTTON_BTN3 2 +#define BUTTON_BTN4 3 +#define NUM_BUTTONS 4 + +#define BUTTON_BTN1_BIT (1 << BUTTON_BTN1) +#define BUTTON_BTN2_BIT (1 << BUTTON_BTN2) +#define BUTTON_BTN3_BIT (1 << BUTTON_BTN3) +#define BUTTON_BTN4_BIT (1 << BUTTON_BTN4) + +/* UART Pins ****************************************************************/ + +/* UART0 is connected to the virtual COM port: + * UART0_RX - P0-8 + * UART0_TX - P0-6 + */ + +#define BOARD_UART0_RX_PIN (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(8)) +#define BOARD_UART0_TX_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(6)) + +#endif /* __BOARDS_ARM_NRF52_NRF52840_DK_INCLUDE_BOARD_H */ diff --git a/boards/arm/nrf52/nrf52840-dk/scripts/Make.defs b/boards/arm/nrf52/nrf52840-dk/scripts/Make.defs new file mode 100644 index 0000000000..ac2c80ce33 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/scripts/Make.defs @@ -0,0 +1,116 @@ +############################################################################ +# boards/arm/nrf52/nrf52840-dk/scripts/Make.defs +# +# Copyright (C) 2014, 2017, 2018 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# 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. +# +############################################################################ + +include ${TOPDIR}/.config +include ${TOPDIR}/tools/Config.mk +include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs + +LDSCRIPT = flash_config.ld + +# Setup for Windows vs Linux/Cygwin/macOS environments + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/copydir.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mkwindeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) +endif + +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +STRIP = $(CROSSDEV)strip --strip-unneeded +AR = $(ARCROSSDEV)ar rcs +NM = $(ARCROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} +ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer +endif + +ARCHCFLAGS = -fno-builtin +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +ASMEXT = .S +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +ifneq ($(CROSSDEV),arm-nuttx-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe +HOSTLDFLAGS = + diff --git a/boards/arm/nrf52/nrf52840-dk/scripts/flash_config.ld b/boards/arm/nrf52/nrf52840-dk/scripts/flash_config.ld new file mode 100644 index 0000000000..23acb1c685 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/scripts/flash_config.ld @@ -0,0 +1,121 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dk/scripts/flash_config.ld + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Mateusz Szafoni + * + * 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. + * + ****************************************************************************/ + +MEMORY +{ + progmem (rx) : ORIGIN = 0x00000000, LENGTH = 1024K + datamem (rwx) : ORIGIN = 0x20000000, LENGTH = 256K +} + +OUTPUT_ARCH(arm) +ENTRY(__start) /* Treat __start as the anchor for dead code stripping */ +EXTERN(_vectors) /* Force the vectors to be included in the output */ +SECTIONS +{ + .text : + { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > progmem + + .init_section : + { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > progmem + + .ARM.extab : + { + *(.ARM.extab*) + } > progmem + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : + { + *(.ARM.exidx*) + } > progmem + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > datamem AT > progmem + + /* BSS */ + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > datamem + + /* Stabs debugging sections. */ + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/nrf52/nrf52840-dk/src/.gitignore b/boards/arm/nrf52/nrf52840-dk/src/.gitignore new file mode 100644 index 0000000000..726d936e1e --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/src/.gitignore @@ -0,0 +1,2 @@ +/.depend +/Make.dep diff --git a/boards/arm/nrf52/nrf52840-dk/src/Makefile b/boards/arm/nrf52/nrf52840-dk/src/Makefile new file mode 100644 index 0000000000..b99bdec9f1 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/src/Makefile @@ -0,0 +1,55 @@ +############################################################################ +# boards/arm/nrf52/nrf52840-dk/src/Makefile +# +# Copyright (C) 2019 Gregory Nutt. All rights reserved. +# Author: Mateusz Szafoni +# +# 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. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +ASRCS = +CSRCS = nrf52_boot.c nrf52_bringup.c + +ifeq ($(CONFIG_LIB_BOARDCTL),y) +CSRCS += nrf52_appinit.c +endif + +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += nrf52_autoleds.c +else +CSRCS += nrf52_userleds.c +endif + +ifeq ($(CONFIG_ARCH_BUTTONS),y) +CSRCS += nrf52_buttons.c +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h b/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h new file mode 100644 index 0000000000..9744b8cea5 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h @@ -0,0 +1,101 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Mateusz Szafoni + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_NRF52_NRF52840_DK_SRC_NRF52840_DK_H +#define __BOARDS_ARM_NRF52_NRF52840_DK_SRC_NRF52840_DK_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "nrf52_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LED definitions **********************************************************/ + +/* Definitions to configure LED GPIO as outputs */ + +#define GPIO_LED1 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(13)) +#define GPIO_LED2 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(14)) +#define GPIO_LED3 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(15)) +#define GPIO_LED4 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(16)) + +/* Button definitions *******************************************************/ + +/* Board supports four buttons. */ + +#define GPIO_BUTTON1 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN(11)) +#define GPIO_BUTTON2 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN(12)) +#define GPIO_BUTTON3 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN(24)) +#define GPIO_BUTTON4 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN(25)) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf52_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y : + * Called from the NSH library + * + ****************************************************************************/ + +int nrf52_bringup(void); + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_NRF52_NRF52840_DK_SRC_NRF52840_DK_H */ diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52_appinit.c b/boards/arm/nrf52/nrf52840-dk/src/nrf52_appinit.c new file mode 100644 index 0000000000..1dac59ec82 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52_appinit.c @@ -0,0 +1,89 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dk/src/nrf52_appinit.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Mateusz Szafoni + * + * 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 + +#include + +#include "chip.h" +#include "nrf52840-dk.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform architecture specific initialization + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value cold be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ +#ifdef CONFIG_BOARD_LATE_INITIALIZE + /* Board initialization already performed by board_late_initialize() */ + + return OK; +#else + /* Perform board-specific initialization */ + + return nrf52_bringup(); +#endif +} diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52_autoleds.c b/boards/arm/nrf52/nrf52840-dk/src/nrf52_autoleds.c new file mode 100644 index 0000000000..41420f6699 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52_autoleds.c @@ -0,0 +1,144 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dk/src/nrf52_autoleds.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include + +#include "chip.h" +#include "up_arch.h" +#include "up_internal.h" + +#include "nrf52840-dk.h" + +#ifdef CONFIG_ARCH_LEDS + +#define LED_ON 0 +#define LED_OFF 1 + +/* This array maps an LED number to GPIO pin configuration */ + +static const uint32_t g_ledcfg[BOARD_NLEDS] = +{ +#if 0 < BOARD_NLEDS + GPIO_LED1, +#endif +#if 1 < BOARD_NLEDS + GPIO_LED2, +#endif +#if 2 < BOARD_NLEDS + GPIO_LED3, +#endif +#if 3 < BOARD_NLEDS + GPIO_LED4, +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: led_dumppins + ****************************************************************************/ + +#ifdef LED_VERBOSE +static void led_dumppins(FAR const char *msg) +{ + nrf52_pin_dump(PINCONFIG_LED, msg); + nrf52_gpio_dump(GPIO_LED, msg); +} +#else +# define led_dumppins(m) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_autoled_initialize + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + int i; + + /* Configure LED pin as a GPIO outputs */ + + led_dumppins("board_autoled_initialize() Entry)"); + + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf52_gpio_config(g_ledcfg[i]); + } + + led_dumppins("board_autoled_initialize() Exit"); +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ + if ((unsigned)led < BOARD_NLEDS) + { + nrf52_gpio_write(g_ledcfg[led], LED_ON); + } +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ + if ((unsigned)led < BOARD_NLEDS) + { + nrf52_gpio_write(g_ledcfg[led], LED_OFF); + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52_boot.c b/boards/arm/nrf52/nrf52840-dk/src/nrf52_boot.c new file mode 100644 index 0000000000..af1dca26c1 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52_boot.c @@ -0,0 +1,96 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dk/src/nrf52_boot.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include "up_arch.h" +#include "up_internal.h" + +#include "nrf52840-dk.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf52_board_initialize + * + * Description: + * All NRF52xxx architectures must provide the following entry point. + * This entry point is called early in the initialization -- after all + * memory has been configured and mapped but before any devices have been + * initialized. + * + ****************************************************************************/ + +void nrf52_board_initialize(void) +{ + /* Configure on-board LEDs if LED support has been selected. */ + +#ifdef CONFIG_ARCH_LEDS + board_autoled_initialize(); +#endif +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() will be + * called immediately after up_initialize() is called and just before the + * initial application is started. This additional initialization phase + * may be used, for example, to initialize board-specific device drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board-specific initialization */ + + (void)nrf52_bringup(); +} +#endif diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c b/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c new file mode 100644 index 0000000000..a5604a924d --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c @@ -0,0 +1,83 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#ifdef CONFIG_USERLED +# include +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf52_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y : + * Called from the NSH library + * + ****************************************************************************/ + +int nrf52_bringup(void) +{ + 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 + + UNUSED(ret); + return OK; +} diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52_buttons.c b/boards/arm/nrf52/nrf52840-dk/src/nrf52_buttons.c new file mode 100644 index 0000000000..6551ad0736 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52_buttons.c @@ -0,0 +1,164 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dk/src/nrf52_buttons.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Janne Rosberg + * + * 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 +#include +#include + +#include "nrf52_gpio.h" + +#include "nrf52840-dk.h" + +#ifdef CONFIG_ARCH_BUTTONS + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* Pin configuration for each nRF52840 button. This array is indexed by + * the BUTTON_* definitions in board.h + */ + +static const uint32_t g_buttons[NUM_BUTTONS] = +{ + GPIO_BUTTON1, + GPIO_BUTTON2, + GPIO_BUTTON3, + GPIO_BUTTON4 +}; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_button_initialize + * + * Description: + * board_button_initialize() must be called to initialize button resources. + * After that, board_buttons() may be called to collect the current state + * of all buttons or board_button_irq() may be called to register button + * interrupt handlers. + * + ****************************************************************************/ + +void board_button_initialize(void) +{ + int i; + + /* Configure the GPIO pins as inputs. */ + + for (i = 0; i < NUM_BUTTONS; i++) + { + nrf52_gpio_config(g_buttons[i]); + } +} + +/**************************************************************************** + * Name: board_buttons + ****************************************************************************/ + +uint32_t board_buttons(void) +{ + uint32_t ret = 0; + + /* Check that state of each key */ + + if (!nrf52_gpio_read(g_buttons[BUTTON_BTN1])) + { + ret |= BUTTON_BTN1_BIT; + } + + if (!nrf52_gpio_read(g_buttons[BUTTON_BTN2])) + { + ret |= BUTTON_BTN2_BIT; + } + + if (!nrf52_gpio_read(g_buttons[BUTTON_BTN3])) + { + ret |= BUTTON_BTN3_BIT; + } + + if (!nrf52_gpio_read(g_buttons[BUTTON_BTN4])) + { + ret |= BUTTON_BTN4_BIT; + } + + return ret; +} + +/**************************************************************************** + * Button support. + * + * Description: + * board_button_initialize() must be called to initialize button resources. + * After that, board_buttons() may be called to collect the current state + * of all buttons or board_button_irq() may be called to register button + * interrupt handlers. + * + * After board_button_initialize() has been called, board_buttons() may be + * called to collect the state of all buttons. board_buttons() returns an + * 32-bit bit set with each bit associated with a button. See the + * BUTTON_*_BIT definitions in board.h for the meaning of each bit. + * + * board_button_irq() may be called to register an interrupt handler that + * will be called when a button is depressed or released. The ID value is + * a button enumeration value that uniquely identifies a button resource. + * See the BUTTON_* definitions in board.h for the meaning of enumeration + * value. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_IRQBUTTONS +int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +{ + int ret = -ENOSYS; + +#warning Missing Implementation! + + return ret; +} +#endif + +#endif /* CONFIG_ARCH_BUTTONS */ diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52_userleds.c b/boards/arm/nrf52/nrf52840-dk/src/nrf52_userleds.c new file mode 100644 index 0000000000..8002211e44 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52_userleds.c @@ -0,0 +1,164 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dk/src/nrf52_userleds.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Janne Rosberg + * + * 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 + +#include + +#include "chip.h" +#include "up_arch.h" +#include "up_internal.h" + +#include "nrf52840-dk.h" + +#ifndef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LED definitions **********************************************************/ + +/* If CONFIG_ARCH_LEDS is not defined, then the LEDs are completely under + * control of the application. The following interfaces are then available + * for application control of the LEDs: + * + * void board_userled_initialize(void); + * void board_userled(int led, bool ledon); + * void board_userled_all(uint8_t ledset); + */ + +#define LED_ON 0 +#define LED_OFF 1 + +/* This array maps an LED number to GPIO pin configuration */ + +static const uint32_t g_ledcfg[BOARD_NLEDS] = +{ +#if 0 < BOARD_NLEDS + GPIO_LED1, +#endif +#if 1 < BOARD_NLEDS + GPIO_LED2, +#endif +#if 2 < BOARD_NLEDS + GPIO_LED3, +#endif +#if 3 < BOARD_NLEDS + GPIO_LED4, +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: led_dumppins + ****************************************************************************/ + +#ifdef LED_VERBOSE +static void led_dumppins(FAR const char *msg) +{ + nrf52_pin_dump(PINCONFIG_LED, msg); + nrf52_gpio_dump(GPIO_LED, msg); +} +#else +# define led_dumppins(m) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +void board_userled_initialize(void) +{ + int i; + + /* Configure LED pin as a GPIO outputs */ + + led_dumppins("board_userled_initialize() Entry)"); + + /* Configure GPIO as an outputs */ + + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf52_gpio_config(g_ledcfg[i]); + } + + led_dumppins("board_userled_initialize() Exit"); +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + if ((unsigned)led < BOARD_NLEDS) + { + nrf52_gpio_write(g_ledcfg[led], ledon ? LED_ON : LED_OFF); + } +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint8_t ledset) +{ + int i; + + /* Configure LED1-8 GPIOs for output */ + + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf52_gpio_write(g_ledcfg[i], (ledset & (1 << i)) ? LED_ON : LED_OFF); + } +} + +#endif /* !CONFIG_ARCH_LEDS */ diff --git a/boards/arm/nrf52/nrf52840-dongle/Kconfig b/boards/arm/nrf52/nrf52840-dongle/Kconfig new file mode 100644 index 0000000000..52b4e6b2eb --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/Kconfig @@ -0,0 +1,8 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_NRF52840_DK + +endif diff --git a/boards/arm/nrf52/nrf52840-dongle/README.txt b/boards/arm/nrf52/nrf52840-dongle/README.txt new file mode 100644 index 0000000000..cb1bdbcc0d --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/README.txt @@ -0,0 +1,8 @@ +nRF52840-DONGLE +=============== + +README for NuttX port to NRF52840-DONGLE (PCA10059) boards. + +Status +====== + Only the basic NSH configuration is supported for now. diff --git a/boards/arm/nrf52/nrf52840-dongle/configs/nsh/defconfig b/boards/arm/nrf52/nrf52840-dongle/configs/nsh/defconfig new file mode 100644 index 0000000000..991014df03 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/configs/nsh/defconfig @@ -0,0 +1,49 @@ +# +# 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_ARCH_FPU is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nrf52840-dongle" +CONFIG_ARCH_BOARD_NRF52840_DONGLE=y +CONFIG_ARCH_CHIP="nrf52" +CONFIG_ARCH_CHIP_NRF52840=y +CONFIG_ARCH_CHIP_NRF52=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_MAX_TASKS=16 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_MM_REGIONS=2 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NRF52_UART0=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PREALLOC_WDOGS=4 +CONFIG_RAM_SIZE=65535 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=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 +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_WDOG_INTRESERVE=0 diff --git a/boards/arm/nrf52/nrf52840-dongle/include/board.h b/boards/arm/nrf52/nrf52840-dongle/include/board.h new file mode 100644 index 0000000000..ebf2d348fb --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/include/board.h @@ -0,0 +1,112 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dongle/include/board.h + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Mateusz Szafoni + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_NRF52_NRF52840_DONGLE_INCLUDE_BOARD_H +#define __BOARDS_ARM_NRF52_NRF52840_DONGLE_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_NRF52_GPIO_IRQ) +# include +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking ****************************************************************/ + +#define BOARD_SYSTICK_CLOCK (64000000) + +/* LED definitions *********************************************************/ + +/* A low output illuminates the LED. + * + * LED index values for use with board_userled() + */ + +#define BOARD_LED1 0 +#define BOARD_NLEDS 1 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED1_BIT (1 << BOARD_LED1) + +/* If CONFIG_ARCH_LEDS is defined, the LED will be controlled as follows + * for NuttX debug functionality (where NC means "No Change"). + */ + +#define LED_STARTED 0 /* OFF */ +#define LED_HEAPALLOCATE 0 /* OFF */ +#define LED_IRQSENABLED 0 /* OFF */ +#define LED_STACKCREATED 1 /* ON */ +#define LED_INIRQ 2 /* NC */ +#define LED_SIGNAL 2 /* NC */ +#define LED_ASSERTION 2 /* NC */ +#define LED_PANIC 3 /* Flashing */ + +/* If CONFIG_ARCH_LEDS is not defined, then the LEDs are completely under + * control of the application. The following interfaces are then available + * for application control of the LEDs: + * + * void board_userled_initialize(void); + * void board_userled(int led, bool ledon); + * void board_userled_all(uint8_t ledset); + */ + +/* Button definitions *******************************************************/ + +/* Board supports one buttons. */ + +#define BUTTON_BTN1 0 +#define NUM_BUTTONS 1 + +#define BUTTON_BTN1_BIT (1 << BUTTON_BTN1) + +/* UART Pins ****************************************************************/ + +/* The following definitions must be provided so that the NRF52 serial + * driver can set up the UART for the serial console properly. + */ + +#define BOARD_UART0_RX_PIN (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(13)) +#define BOARD_UART0_TX_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(15)) + +#endif /* __BOARDS_ARM_NRF52_NRF52840_DONGLE_INCLUDE_BOARD_H */ diff --git a/boards/arm/nrf52/nrf52840-dongle/scripts/Make.defs b/boards/arm/nrf52/nrf52840-dongle/scripts/Make.defs new file mode 100644 index 0000000000..e7d4b764b3 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/scripts/Make.defs @@ -0,0 +1,116 @@ +############################################################################ +# boards/arm/nrf52/nrf52840-dongle/scripts/Make.defs +# +# Copyright (C) 2014, 2017, 2018 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# 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. +# +############################################################################ + +include ${TOPDIR}/.config +include ${TOPDIR}/tools/Config.mk +include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs + +LDSCRIPT = flash_config.ld + +# Setup for Windows vs Linux/Cygwin/macOS environments + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/copydir.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mkwindeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) +endif + +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +STRIP = $(CROSSDEV)strip --strip-unneeded +AR = $(ARCROSSDEV)ar rcs +NM = $(ARCROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} +ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer +endif + +ARCHCFLAGS = -fno-builtin +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +ASMEXT = .S +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +ifneq ($(CROSSDEV),arm-nuttx-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe +HOSTLDFLAGS = + diff --git a/boards/arm/nrf52/nrf52840-dongle/scripts/flash_config.ld b/boards/arm/nrf52/nrf52840-dongle/scripts/flash_config.ld new file mode 100644 index 0000000000..72c69c1505 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/scripts/flash_config.ld @@ -0,0 +1,121 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dongle/scripts/flash_config.ld + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Mateusz Szafoni + * + * 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. + * + ****************************************************************************/ + +MEMORY +{ + progmem (rx) : ORIGIN = 0x00000000, LENGTH = 1024K + datamem (rwx) : ORIGIN = 0x20000000, LENGTH = 256K +} + +OUTPUT_ARCH(arm) +ENTRY(__start) /* Treat __start as the anchor for dead code stripping */ +EXTERN(_vectors) /* Force the vectors to be included in the output */ +SECTIONS +{ + .text : + { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > progmem + + .init_section : + { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > progmem + + .ARM.extab : + { + *(.ARM.extab*) + } > progmem + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : + { + *(.ARM.exidx*) + } > progmem + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > datamem AT > progmem + + /* BSS */ + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > datamem + + /* Stabs debugging sections. */ + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/nrf52/nrf52840-dongle/src/.gitignore b/boards/arm/nrf52/nrf52840-dongle/src/.gitignore new file mode 100644 index 0000000000..726d936e1e --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/src/.gitignore @@ -0,0 +1,2 @@ +/.depend +/Make.dep diff --git a/boards/arm/nrf52/nrf52840-dongle/src/Makefile b/boards/arm/nrf52/nrf52840-dongle/src/Makefile new file mode 100644 index 0000000000..5e44e013ef --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/src/Makefile @@ -0,0 +1,51 @@ +############################################################################ +# boards/arm/nrf52/nrf52840-dongle/src/Makefile +# +# Copyright (C) 2019 Gregory Nutt. All rights reserved. +# Author: Mateusz Szafoni +# +# 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. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +ASRCS = +CSRCS = nrf52_boot.c nrf52_bringup.c + +ifeq ($(CONFIG_LIB_BOARDCTL),y) +CSRCS += nrf52_appinit.c +endif + +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += nrf52_autoleds.c +else +CSRCS += nrf52_userleds.c +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/nrf52/nrf52840-dongle/src/nrf52840-dongle.h b/boards/arm/nrf52/nrf52840-dongle/src/nrf52840-dongle.h new file mode 100644 index 0000000000..fa26ea3e40 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/src/nrf52840-dongle.h @@ -0,0 +1,101 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dongle/src/nrf52840-dongle.h + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Mateusz Szafoni + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_NRF52_NRF52840_DONGLE_SRC_NRF52840_DONGLE_H +#define __BOARDS_ARM_NRF52_NRF52840_DONGLE_SRC_NRF52840_DONGLE_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "nrf52_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LED definitions **********************************************************/ + +/* Definitions to configure LED GPIO as outputs */ + +#define GPIO_LED1 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(6)) + +/* RGB LED - LD2: + * RGB_RED - P0-8 + * RGB_GREEN - P1-9 + * RGB_BLUE - P0-12 + */ + +/* Button definitions *******************************************************/ + +/* Board supports four buttons. */ + +#define GPIO_BUTTON1 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT1 | GPIO_PIN(6)) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf52_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y : + * Called from the NSH library + * + ****************************************************************************/ + +int nrf52_bringup(void); + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_NRF52_NRF52840_DONGLE_SRC_NRF52840_DONGLE_H */ diff --git a/boards/arm/nrf52/nrf52840-dongle/src/nrf52_appinit.c b/boards/arm/nrf52/nrf52840-dongle/src/nrf52_appinit.c new file mode 100644 index 0000000000..64d252c827 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/src/nrf52_appinit.c @@ -0,0 +1,89 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dongle/src/nrf52_appinit.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Mateusz Szafoni + * + * 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 + +#include + +#include "chip.h" +#include "nrf52840-dongle.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform architecture specific initialization + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value cold be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ +#ifdef CONFIG_BOARD_LATE_INITIALIZE + /* Board initialization already performed by board_late_initialize() */ + + return OK; +#else + /* Perform board-specific initialization */ + + return nrf52_bringup(); +#endif +} diff --git a/boards/arm/nrf52/nrf52840-dongle/src/nrf52_autoleds.c b/boards/arm/nrf52/nrf52840-dongle/src/nrf52_autoleds.c new file mode 100644 index 0000000000..381e4d50fb --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/src/nrf52_autoleds.c @@ -0,0 +1,144 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dongle/src/nrf52_autoleds.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include + +#include "chip.h" +#include "up_arch.h" +#include "up_internal.h" + +#include "nrf52840-dongle.h" + +#ifdef CONFIG_ARCH_LEDS + +#define LED_ON 0 +#define LED_OFF 1 + +/* This array maps an LED number to GPIO pin configuration */ + +static const uint32_t g_ledcfg[BOARD_NLEDS] = +{ +#if 0 < BOARD_NLEDS + GPIO_LED1, +#endif +#if 1 < BOARD_NLEDS + GPIO_LED2, +#endif +#if 2 < BOARD_NLEDS + GPIO_LED3, +#endif +#if 3 < BOARD_NLEDS + GPIO_LED4, +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: led_dumppins + ****************************************************************************/ + +#ifdef LED_VERBOSE +static void led_dumppins(FAR const char *msg) +{ + nrf52_pin_dump(PINCONFIG_LED, msg); + nrf52_gpio_dump(GPIO_LED, msg); +} +#else +# define led_dumppins(m) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_autoled_initialize + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + int i; + + /* Configure LED pin as a GPIO outputs */ + + led_dumppins("board_autoled_initialize() Entry)"); + + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf52_gpio_config(g_ledcfg[i]); + } + + led_dumppins("board_autoled_initialize() Exit"); +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ + if ((unsigned)led < BOARD_NLEDS) + { + nrf52_gpio_write(g_ledcfg[led], LED_ON); + } +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ + if ((unsigned)led < BOARD_NLEDS) + { + nrf52_gpio_write(g_ledcfg[led], LED_OFF); + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/boards/arm/nrf52/nrf52840-dongle/src/nrf52_boot.c b/boards/arm/nrf52/nrf52840-dongle/src/nrf52_boot.c new file mode 100644 index 0000000000..e795bdefbf --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/src/nrf52_boot.c @@ -0,0 +1,96 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dongle/src/nrf52_boot.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include "up_arch.h" +#include "up_internal.h" + +#include "nrf52840-dongle.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf52_board_initialize + * + * Description: + * All NRF52xxx architectures must provide the following entry point. + * This entry point is called early in the initialization -- after all + * memory has been configured and mapped but before any devices have been + * initialized. + * + ****************************************************************************/ + +void nrf52_board_initialize(void) +{ + /* Configure on-board LEDs if LED support has been selected. */ + +#ifdef CONFIG_ARCH_LEDS + board_autoled_initialize(); +#endif +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() will be + * called immediately after up_initialize() is called and just before the + * initial application is started. This additional initialization phase + * may be used, for example, to initialize board-specific device drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board-specific initialization */ + + (void)nrf52_bringup(); +} +#endif diff --git a/boards/arm/nrf52/nrf52840-dongle/src/nrf52_bringup.c b/boards/arm/nrf52/nrf52840-dongle/src/nrf52_bringup.c new file mode 100644 index 0000000000..a7bfb1a6b4 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/src/nrf52_bringup.c @@ -0,0 +1,83 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dongle/src/nrf52_bringup.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#ifdef CONFIG_USERLED +# include +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf52_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y : + * Called from the NSH library + * + ****************************************************************************/ + +int nrf52_bringup(void) +{ + 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 + + UNUSED(ret); + return OK; +} diff --git a/boards/arm/nrf52/nrf52840-dongle/src/nrf52_buttons.c b/boards/arm/nrf52/nrf52840-dongle/src/nrf52_buttons.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/boards/arm/nrf52/nrf52840-dongle/src/nrf52_userleds.c b/boards/arm/nrf52/nrf52840-dongle/src/nrf52_userleds.c new file mode 100644 index 0000000000..cba180846b --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dongle/src/nrf52_userleds.c @@ -0,0 +1,164 @@ +/**************************************************************************** + * boards/arm/nrf52/nrf52840-dongle/src/nrf52_userleds.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Janne Rosberg + * + * 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 + +#include + +#include "chip.h" +#include "up_arch.h" +#include "up_internal.h" + +#include "nrf52840-dongle.h" + +#ifndef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LED definitions **********************************************************/ + +/* If CONFIG_ARCH_LEDS is not defined, then the LEDs are completely under + * control of the application. The following interfaces are then available + * for application control of the LEDs: + * + * void board_userled_initialize(void); + * void board_userled(int led, bool ledon); + * void board_userled_all(uint8_t ledset); + */ + +#define LED_ON 0 +#define LED_OFF 1 + +/* This array maps an LED number to GPIO pin configuration */ + +static const uint32_t g_ledcfg[BOARD_NLEDS] = +{ +#if 0 < BOARD_NLEDS + GPIO_LED1, +#endif +#if 1 < BOARD_NLEDS + GPIO_LED2, +#endif +#if 2 < BOARD_NLEDS + GPIO_LED3, +#endif +#if 3 < BOARD_NLEDS + GPIO_LED4, +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: led_dumppins + ****************************************************************************/ + +#ifdef LED_VERBOSE +static void led_dumppins(FAR const char *msg) +{ + nrf52_pin_dump(PINCONFIG_LED, msg); + nrf52_gpio_dump(GPIO_LED, msg); +} +#else +# define led_dumppins(m) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +void board_userled_initialize(void) +{ + int i; + + /* Configure LED pin as a GPIO outputs */ + + led_dumppins("board_userled_initialize() Entry)"); + + /* Configure GPIO as an outputs */ + + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf52_gpio_config(g_ledcfg[i]); + } + + led_dumppins("board_userled_initialize() Exit"); +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + if ((unsigned)led < BOARD_NLEDS) + { + nrf52_gpio_write(g_ledcfg[led], ledon ? LED_ON : LED_OFF); + } +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint8_t ledset) +{ + int i; + + /* Configure LED1-8 GPIOs for output */ + + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf52_gpio_write(g_ledcfg[i], (ledset & (1 << i)) ? LED_ON : LED_OFF); + } +} + +#endif /* !CONFIG_ARCH_LEDS */