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 <gnutt@nuttx.org>
This commit is contained in:
raiden00pl 2019-12-16 18:35:45 +00:00 committed by Gregory Nutt
parent bc7566a83f
commit a0429bcb20
73 changed files with 4052 additions and 219 deletions

View File

@ -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"

View File

@ -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

View File

@ -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)

View File

@ -0,0 +1,90 @@
/***************************************************************************************************
* arch/arm/src/nrf52/hardware/nrf52_uicr.h
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* 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 <nuttx/config.h>
#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 */

View File

@ -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
************************************************************************************/

View File

@ -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;
}

View File

@ -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 */

View File

@ -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 */

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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:<subdir>
tools/configure.sh nrf52-feather:<subdir>
Where <subdir> is one of the following:
@ -113,11 +80,6 @@ Where <subdir> is one of the following:
b. Execute 'make menuconfig' in nuttx/ in order to start the
reconfiguration process.
<board>-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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,109 @@
/****************************************************************************
* boards/arm/nrf52/nrf52_feather/include/board.h
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Janne Rosberg <janne@offcode.fi>
*
* 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 <nuttx/config.h>
#include <stdbool.h>
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_NRF52_GPIO_IRQ)
# include <nuttx/irq.h>
#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 */

View File

@ -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 <gnutt@nuttx.org>

View File

@ -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 <janne@offcode.fi>

View File

@ -0,0 +1,51 @@
############################################################################
# boards/arm/nrf52/nrf52-feather/src/Makefile
#
# Copyright (C) 2018 Gregory Nutt. All rights reserved.
# Author: Janne Rosberg <janne@offcode.fi>
#
# 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

View File

@ -0,0 +1,94 @@
/****************************************************************************
* boards/arm/nrf52/nrf52-feather/src/nrf52-feather.h
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <nuttx/compiler.h>
#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 */

View File

@ -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 <janne@offcode.fi>
@ -46,7 +46,7 @@
#include <nuttx/board.h>
#include "chip.h"
#include "nrf52-generic.h"
#include "nrf52-feather.h"
/****************************************************************************
* Public Functions

View File

@ -0,0 +1,147 @@
/****************************************************************************
* boards/arm/nrf52/nrf52-feather/src/lpc43_autoleds.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#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 */

View File

@ -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 <gnutt@nuttx.org>
@ -47,7 +47,7 @@
#include "up_arch.h"
#include "up_internal.h"
#include "nrf52-generic.h"
#include "nrf52-feather.h"
/****************************************************************************
* Public Functions

View File

@ -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 <gnutt@nuttx.org>

View File

@ -0,0 +1,158 @@
/****************************************************************************
* boards/arm/nrf52/nrf52-feather/src/nrf52_userleds.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Janne Rosberg <janne@offcode.fi>
*
* 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 <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <arch/board/board.h>
#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 */

View File

@ -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

View File

@ -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

View File

@ -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:<subdir>
Where <subdir> 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);

View File

@ -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

View File

@ -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

View File

@ -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 <janne@offcode.fi>
@ -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 */

View File

@ -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 <gnutt@nuttx.org>
#
# 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 =

View File

@ -0,0 +1,121 @@
/****************************************************************************
* boards/arm/nrf52/nrf52832-dk/scripts/flash_config.ld
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Janne Rosberg <janne@offcode.fi>
*
* 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) }
}

View File

@ -0,0 +1,2 @@
/.depend
/Make.dep

View File

@ -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 <janne@offcode.fi>

View File

@ -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 <gnutt@nuttx.org>
@ -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 */

View File

@ -0,0 +1,89 @@
/****************************************************************************
* boards/arm/nrf52/nrf52832-dk/src/nrf52_appinit.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Janne Rosberg <janne@offcode.fi>
*
* 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 <nuttx/config.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/board.h>
#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
}

View File

@ -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 <gnutt@nuttx.org>
@ -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 */

View File

@ -0,0 +1,96 @@
/****************************************************************************
* boards/arm/nrf52/nrf52832-dk/src/lpc43_boot.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#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

View File

@ -0,0 +1,97 @@
/****************************************************************************
* boards/arm/nrf52/nrf52832-dk/src/nrf53_bringup.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <sys/types.h>
#include <syslog.h>
#ifdef CONFIG_NRF52_WDT
# include "nrf52_wdt.h"
#endif
#ifdef CONFIG_USERLED
# include <nuttx/leds/userled.h>
#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;
}

View File

@ -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 <janne@offcode.fi>
@ -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
*/

View File

@ -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 <janne@offcode.fi>
@ -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 */

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -0,0 +1,125 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dk/include/board.h
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* 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 <nuttx/config.h>
#include <stdbool.h>
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_NRF52_GPIO_IRQ)
# include <nuttx/irq.h>
#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 */

View File

@ -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 <gnutt@nuttx.org>
#
# 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 =

View File

@ -0,0 +1,121 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dk/scripts/flash_config.ld
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* 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) }
}

View File

@ -0,0 +1,2 @@
/.depend
/Make.dep

View File

@ -0,0 +1,55 @@
############################################################################
# boards/arm/nrf52/nrf52840-dk/src/Makefile
#
# Copyright (C) 2019 Gregory Nutt. All rights reserved.
# Author: Mateusz Szafoni <raiden00@railab.me>
#
# 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

View File

@ -0,0 +1,101 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* 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 <nuttx/config.h>
#include <nuttx/compiler.h>
#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 */

View File

@ -0,0 +1,89 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dk/src/nrf52_appinit.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* 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 <nuttx/config.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/board.h>
#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
}

View File

@ -0,0 +1,144 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dk/src/nrf52_autoleds.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#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 */

View File

@ -0,0 +1,96 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dk/src/nrf52_boot.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#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

View File

@ -0,0 +1,83 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <sys/types.h>
#include <syslog.h>
#ifdef CONFIG_USERLED
# include <nuttx/leds/userled.h>
#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;
}

View File

@ -0,0 +1,164 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dk/src/nrf52_buttons.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Janne Rosberg <janne@offcode.fi>
*
* 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 <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#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 */

View File

@ -0,0 +1,164 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dk/src/nrf52_userleds.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Janne Rosberg <janne@offcode.fi>
*
* 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 <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <arch/board/board.h>
#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 */

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -0,0 +1,112 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dongle/include/board.h
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* 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 <nuttx/config.h>
#include <stdbool.h>
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_NRF52_GPIO_IRQ)
# include <nuttx/irq.h>
#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 */

View File

@ -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 <gnutt@nuttx.org>
#
# 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 =

View File

@ -0,0 +1,121 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dongle/scripts/flash_config.ld
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* 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) }
}

View File

@ -0,0 +1,2 @@
/.depend
/Make.dep

View File

@ -0,0 +1,51 @@
############################################################################
# boards/arm/nrf52/nrf52840-dongle/src/Makefile
#
# Copyright (C) 2019 Gregory Nutt. All rights reserved.
# Author: Mateusz Szafoni <raiden00@railab.me>
#
# 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

View File

@ -0,0 +1,101 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dongle/src/nrf52840-dongle.h
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* 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 <nuttx/config.h>
#include <nuttx/compiler.h>
#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 */

View File

@ -0,0 +1,89 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dongle/src/nrf52_appinit.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
*
* 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 <nuttx/config.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/board.h>
#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
}

View File

@ -0,0 +1,144 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dongle/src/nrf52_autoleds.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#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 */

View File

@ -0,0 +1,96 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dongle/src/nrf52_boot.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#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

View File

@ -0,0 +1,83 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dongle/src/nrf52_bringup.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <sys/types.h>
#include <syslog.h>
#ifdef CONFIG_USERLED
# include <nuttx/leds/userled.h>
#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;
}

View File

@ -0,0 +1,164 @@
/****************************************************************************
* boards/arm/nrf52/nrf52840-dongle/src/nrf52_userleds.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Janne Rosberg <janne@offcode.fi>
*
* 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 <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <arch/board/board.h>
#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 */