boards/arm Add support to Seeed Xiao nRF52840 Board
Build Documentation / build-html (push) Waiting to run

Signed-off-by: Rodrigo Sim <rcsim10@gmail.com>
This commit is contained in:
Rodrigo Sim
2025-01-18 19:02:08 -03:00
committed by Alan C. Assis
parent 71a221708c
commit 405287081d
20 changed files with 1753 additions and 0 deletions
+11
View File
@@ -1221,6 +1221,13 @@ config ARCH_BOARD_NRF52840_DONGLE
---help---
This option selects the Nordic nRF52840 Dongle (PCA10059)
config ARCH_BOARD_XIAO_NRF52840
bool "Seeed Xiao nRF52840"
depends on ARCH_CHIP_NRF52
select ARCH_HAVE_LEDS
---help---
This option selects the Seeed Xiao nRF52840 Board
config ARCH_BOARD_ARDUINO_NANO_33BLE
bool "Arduino Nano 33 BLE Sense based on Nordic nRF52840"
depends on ARCH_CHIP_NRF52
@@ -3414,6 +3421,7 @@ config ARCH_BOARD
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 "xiao-nrf52840" if ARCH_BOARD_XIAO_NRF52840
default "thingy52" if ARCH_BOARD_THINGY52
default "nrf5340-dk" if ARCH_BOARD_NRF5340_DK
default "nrf5340-audio-dk" if ARCH_BOARD_NRF5340_AUDIO_DK
@@ -3932,6 +3940,9 @@ endif
if ARCH_BOARD_NRF52840_DK
source "boards/arm/nrf52/nrf52840-dk/Kconfig"
endif
if ARCH_BOARD_XIAO_NRF52840
source "boards/arm/nrf52/xiao-nrf52840/Kconfig"
endif
if ARCH_BOARD_THINGY52
source "boards/arm/nrf52/thingy52/Kconfig"
endif
@@ -0,0 +1,23 @@
# ##############################################################################
# boards/arm/nrf52/xiao-nrf52840/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
add_subdirectory(src)
+8
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_XIAO_NRF52840
endif
@@ -0,0 +1,53 @@
#
# 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_ARCH_LEDS is not set
# CONFIG_DEV_CONSOLE is not set
# CONFIG_SYSLOG_DEFAULT is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="xiao-nrf52840"
CONFIG_ARCH_BOARD_XIAO_NRF52840=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_BOARDCTL_USBDEVCTRL=y
CONFIG_BOARD_LOOPSPERMSEC=5500
CONFIG_BUILTIN=y
CONFIG_CDCACM=y
CONFIG_CDCACM_CONSOLE=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_GPIO=y
CONFIG_EXAMPLES_GPIO=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_EXAMPLES_LEDS=y
CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INTELHEX_BINARY=y
CONFIG_LINE_MAX=64
CONFIG_MM_REGIONS=2
CONFIG_NRF52_GPIOTE=y
CONFIG_NRF52_HFCLK_XTAL=y
CONFIG_NRF52_USBDEV=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=65535
CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_START_DAY=26
CONFIG_START_MONTH=3
CONFIG_SYSTEM_NSH=y
CONFIG_USERLED=y
CONFIG_USERLED_LOWER=y
@@ -0,0 +1,42 @@
#
# 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="xiao-nrf52840"
CONFIG_ARCH_BOARD_XIAO_NRF52840=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_INIT_ENTRYPOINT="nsh_main"
CONFIG_INTELHEX_BINARY=y
CONFIG_LINE_MAX=64
CONFIG_MM_REGIONS=2
CONFIG_NRF52_UART0=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=65535
CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_START_DAY=26
CONFIG_START_MONTH=3
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_SERIAL_CONSOLE=y
@@ -0,0 +1,46 @@
#
# 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_DEV_CONSOLE is not set
# CONFIG_SYSLOG_DEFAULT is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="xiao-nrf52840"
CONFIG_ARCH_BOARD_XIAO_NRF52840=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_BOARDCTL_USBDEVCTRL=y
CONFIG_BOARD_LOOPSPERMSEC=5500
CONFIG_BUILTIN=y
CONFIG_CDCACM=y
CONFIG_CDCACM_CONSOLE=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INTELHEX_BINARY=y
CONFIG_LINE_MAX=64
CONFIG_MM_REGIONS=2
CONFIG_NRF52_HFCLK_XTAL=y
CONFIG_NRF52_USBDEV=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=65535
CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_START_DAY=26
CONFIG_START_MONTH=3
CONFIG_SYSTEM_NSH=y
@@ -0,0 +1,98 @@
/****************************************************************************
* boards/arm/nrf52/xiao-nrf52840/include/board.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_NRF52_XIAO_NRF52840_INCLUDE_BOARD_H
#define __BOARDS_ARM_NRF52_XIAO_NRF52840_INCLUDE_BOARD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_NRF52_GPIOTE)
# 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_NLEDS 3
/* 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)
/* 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:
*
* uint32_t board_userled_initialize(void);
* void board_userled(int led, bool ledon);
* void board_userled_all(uint32_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_PORT1 | GPIO_PIN(12))
#define BOARD_UART0_TX_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN(11))
#endif /* __BOARDS_ARM_NRF52_XIAO_NRF52840_INCLUDE_BOARD_H */
@@ -0,0 +1,41 @@
############################################################################
# boards/arm/nrf52/xiao-nrf52840/scripts/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/.config
include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
LDSCRIPT = flash_config.ld
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
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
@@ -0,0 +1,109 @@
/****************************************************************************
* boards/arm/nrf52/xiao-nrf52840/scripts/flash_config.ld
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
MEMORY
{
progmem (rx) : ORIGIN = 0x001000, LENGTH = 960K
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(.);
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o) .ctors))
_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) }
}
@@ -0,0 +1,55 @@
# ##############################################################################
# boards/arm/nrf52/xiao-nrf52840/src/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS nrf52_boot.c nrf52_bringup.c)
if(CONFIG_BOARDCTL)
list(APPEND SRCS nrf52_appinit.c)
endif()
if(CONFIG_ARCH_LEDS)
list(APPEND SRCS nrf52_autoleds.c)
else()
list(APPEND SRCS nrf52_userleds.c)
endif()
if(CONFIG_USBDEV)
list(APPEND SRCS nrf52_usb.c)
endif()
if(CONFIG_USBDEV_COMPOSITE)
list(APPEND SRCS nrf52_composite.c)
endif()
if(CONFIG_DEV_GPIO)
list(APPEND SRCS nrf52_gpio.c)
endif()
target_sources(board PRIVATE ${SRCS})
if(CONFIG_ARCH_BOARD_COMMON)
set_property(GLOBAL PROPERTY LD_SCRIPT
"${NUTTX_COMMON_DIR}/scripts/flash_config.ld")
else()
set_property(GLOBAL PROPERTY LD_SCRIPT
"${NUTTX_BOARD_DIR}/scripts/flash_config.ld")
endif()
@@ -0,0 +1,51 @@
############################################################################
# boards/arm/nrf52/xiao-nrf52840/src/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/Make.defs
CSRCS = nrf52_boot.c nrf52_bringup.c
ifeq ($(CONFIG_BOARDCTL),y)
CSRCS += nrf52_appinit.c
endif
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += nrf52_autoleds.c
else
CSRCS += nrf52_userleds.c
endif
ifeq ($(CONFIG_USBDEV),y)
CSRCS += nrf52_usb.c
endif
ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
CSRCS += nrf52_composite.c
endif
ifeq ($(CONFIG_DEV_GPIO),y)
CSRCS += nrf52_gpio.c
endif
DEPPATH += --dep-path board
VPATH += :board
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board
@@ -0,0 +1,76 @@
/****************************************************************************
* boards/arm/nrf52/xiao-nrf52840/src/nrf52_appinit.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/board.h>
#include "chip.h"
#include "xiao-nrf52840.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 could 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
}
@@ -0,0 +1,118 @@
/****************************************************************************
* boards/arm/nrf52/xiao-nrf52840/src/nrf52_autoleds.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <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 "arm_internal.h"
#include "xiao-nrf52840.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] =
{
GPIO_LED1, GPIO_LED2, GPIO_LED3
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: led_dumppins
****************************************************************************/
#ifdef LED_VERBOSE
static void led_dumppins(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 */
@@ -0,0 +1,81 @@
/****************************************************************************
* boards/arm/nrf52/xiao-nrf52840/src/nrf52_boot.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "arm_internal.h"
#include "xiao-nrf52840.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 */
nrf52_bringup();
}
#endif
@@ -0,0 +1,105 @@
/****************************************************************************
* boards/arm/nrf52/xiao-nrf52840/src/nrf52_bringup.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <syslog.h>
#include "xiao-nrf52840.h"
#ifdef CONFIG_USERLED
# include <nuttx/leds/userled.h>
#endif
#ifdef CONFIG_NRF52_RADIO_IEEE802154
# include "nrf52_ieee802154.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_BOARDCTL=y :
* Called from the NSH library
*
****************************************************************************/
int nrf52_bringup(void)
{
int ret;
#ifdef CONFIG_FS_PROCFS
/* Mount the procfs file system */
ret = nx_mount(NULL, NRF52_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: Failed to mount the PROC filesystem: %d\n", ret);
}
#endif /* CONFIG_FS_PROCFS */
#ifdef CONFIG_USERLED
/* Register the LED driver */
ret = userled_lower_initialize(CONFIG_EXAMPLES_LEDS_DEVPATH);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
}
#endif
#ifdef CONFIG_NRF52_RADIO_IEEE802154
ret = nrf52_ieee802154_initialize();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: Failed to initialize IEE802154 radio: %d\n",
ret);
}
#endif
#ifdef CONFIG_DEV_GPIO
ret = nrf52_gpio_initialize();
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret);
return ret;
}
#endif
UNUSED(ret);
return OK;
}
@@ -0,0 +1,179 @@
/****************************************************************************
* boards/arm/nrf52/xiao-nrf52840/src/nrf52_composite.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <assert.h>
#include <nuttx/usb/usbdev.h>
#include <nuttx/usb/cdcacm.h>
#include <nuttx/usb/rndis.h>
#include <nuttx/usb/composite.h>
#include "nrf52_usbd.h"
#include "xiao-nrf52840.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
void *board_composite0_connect(void)
{
struct composite_devdesc_s dev[2];
int ifnobase = 0;
int strbase = COMPOSITE_NSTRIDS;
int dev_idx = 0;
int epin = 1;
int epout = 1;
#ifdef CONFIG_RNDIS_COMPOSITE
/* Configure the RNDIS USB device */
/* Ask the RNDIS driver to fill in the constants we didn't
* know here.
*/
usbdev_rndis_get_composite_devdesc(&dev[dev_idx]);
/* Interfaces */
dev[dev_idx].devinfo.ifnobase = ifnobase;
dev[dev_idx].minor = 0;
/* Strings */
dev[dev_idx].devinfo.strbase = strbase;
/* Endpoints */
dev[dev_idx].devinfo.epno[RNDIS_EP_INTIN_IDX] = epin++;
dev[dev_idx].devinfo.epno[RNDIS_EP_BULKIN_IDX] = epin++;
dev[dev_idx].devinfo.epno[RNDIS_EP_BULKOUT_IDX] = epout++;
/* Count up the base numbers */
ifnobase += dev[dev_idx].devinfo.ninterfaces;
strbase += dev[dev_idx].devinfo.nstrings;
dev_idx += 1;
#endif
#ifdef CONFIG_CDCACM_COMPOSITE
/* Configure the CDC/ACM device */
/* Ask the cdcacm driver to fill in the constants we didn't
* know here.
*/
cdcacm_get_composite_devdesc(&dev[dev_idx]);
/* Overwrite and correct some values... */
/* The callback functions for the CDC/ACM class */
dev[dev_idx].classobject = cdcacm_classobject;
dev[dev_idx].uninitialize = cdcacm_uninitialize;
/* Interfaces */
dev[dev_idx].devinfo.ifnobase = ifnobase; /* Offset to Interface-IDs */
dev[dev_idx].minor = 0; /* The minor interface number */
/* Strings */
dev[dev_idx].devinfo.strbase = strbase; /* Offset to String Numbers */
/* Endpoints */
dev[dev_idx].devinfo.epno[CDCACM_EP_INTIN_IDX] = epin++;
dev[dev_idx].devinfo.epno[CDCACM_EP_BULKIN_IDX] = epin++;
dev[dev_idx].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = epout++;
/* Count up the base numbers */
ifnobase += dev[dev_idx].devinfo.ninterfaces;
strbase += dev[dev_idx].devinfo.nstrings;
dev_idx += 1;
#endif
DEBUGASSERT(epin <= NRF52_NENDPOINTS);
DEBUGASSERT(epout <= NRF52_NENDPOINTS);
return composite_initialize(composite_getdevdescs(), dev, dev_idx);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_composite_initialize
*
* Description:
* Perform architecture specific initialization of a composite USB device.
*
****************************************************************************/
int board_composite_initialize(int port)
{
return OK;
}
/****************************************************************************
* Name: board_composite_connect
*
* Description:
* Connect the USB composite device on the specified USB device port using
* the specified configuration. The interpretation of the configid is
* board specific.
*
* Input Parameters:
* port - The USB device port.
* configid - The USB composite configuration
*
* Returned Value:
* A non-NULL handle value is returned on success. NULL is returned on
* any failure.
*
****************************************************************************/
void *board_composite_connect(int port, int configid)
{
if (configid == 0)
{
return board_composite0_connect();
}
else
{
return NULL;
}
}
@@ -0,0 +1,324 @@
/****************************************************************************
* boards/arm/nrf52/xiao-nrf52840/src/nrf52_gpio.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/clock.h>
#include <nuttx/wdog.h>
#include <nuttx/ioexpander/gpio.h>
#include <arch/board/board.h>
#include "chip.h"
#include "nrf52_gpio.h"
#include "nrf52_gpiote.h"
#include "xiao-nrf52840.h"
#if defined(CONFIG_DEV_GPIO) && !defined(CONFIG_GPIO_LOWER_HALF)
/****************************************************************************
* Private Types
****************************************************************************/
struct nrf52gpio_dev_s
{
struct gpio_dev_s gpio;
uint8_t id;
};
struct nrf52gpint_dev_s
{
struct nrf52gpio_dev_s nrf52gpio;
pin_interrupt_t callback;
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int gpin_read(struct gpio_dev_s *dev, bool *value);
static int gpout_read(struct gpio_dev_s *dev, bool *value);
static int gpout_write(struct gpio_dev_s *dev, bool value);
static int gpint_read(struct gpio_dev_s *dev, bool *value);
static int gpint_attach(struct gpio_dev_s *dev,
pin_interrupt_t callback);
static int gpint_enable(struct gpio_dev_s *dev, bool enable);
/****************************************************************************
* Private Data
****************************************************************************/
static const struct gpio_operations_s gpin_ops =
{
.go_read = gpin_read,
.go_write = NULL,
.go_attach = NULL,
.go_enable = NULL,
};
static const struct gpio_operations_s gpout_ops =
{
.go_read = gpout_read,
.go_write = gpout_write,
.go_attach = NULL,
.go_enable = NULL,
};
static const struct gpio_operations_s gpint_ops =
{
.go_read = gpint_read,
.go_write = NULL,
.go_attach = gpint_attach,
.go_enable = gpint_enable,
};
#if BOARD_NGPIOIN > 0
/* This array maps the GPIO pins used as INPUT */
static const uint32_t g_gpioinputs[BOARD_NGPIOIN] =
{
GPIO_IN1,
};
static struct nrf52gpio_dev_s g_gpin[BOARD_NGPIOIN];
#endif
#if BOARD_NGPIOOUT
/* This array maps the GPIO pins used as OUTPUT */
static const uint32_t g_gpiooutputs[BOARD_NGPIOOUT] =
{
GPIO_OUT1,
};
static struct nrf52gpio_dev_s g_gpout[BOARD_NGPIOOUT];
#endif
#if BOARD_NGPIOINT > 0
/* This array maps the GPIO pins used as INTERRUPT INPUTS */
static const uint32_t g_gpiointinputs[BOARD_NGPIOINT] =
{
GPIO_INT1,
};
static struct nrf52gpint_dev_s g_gpint[BOARD_NGPIOINT];
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
static int nrf52gpio_interrupt(int irq, void *context, void *arg)
{
struct nrf52gpint_dev_s *nrf52gpint =
(struct nrf52gpint_dev_s *)arg;
DEBUGASSERT(nrf52gpint != NULL && nrf52gpint->callback != NULL);
gpioinfo("Interrupt! callback=%p\n", nrf52gpint->callback);
nrf52gpint->callback(&nrf52gpint->nrf52gpio.gpio,
nrf52gpint->nrf52gpio.id);
return OK;
}
static int gpin_read(struct gpio_dev_s *dev, bool *value)
{
struct nrf52gpio_dev_s *nrf52gpio =
(struct nrf52gpio_dev_s *)dev;
DEBUGASSERT(nrf52gpio != NULL && value != NULL);
DEBUGASSERT(nrf52gpio->id < BOARD_NGPIOIN);
gpioinfo("Reading...\n");
*value = nrf52_gpio_read(g_gpioinputs[nrf52gpio->id]);
return OK;
}
static int gpout_read(struct gpio_dev_s *dev, bool *value)
{
struct nrf52gpio_dev_s *nrf52gpio =
(struct nrf52gpio_dev_s *)dev;
DEBUGASSERT(nrf52gpio != NULL && value != NULL);
DEBUGASSERT(nrf52gpio->id < BOARD_NGPIOOUT);
gpioinfo("Reading...\n");
*value = nrf52_gpio_read(g_gpiooutputs[nrf52gpio->id]);
return OK;
}
static int gpout_write(struct gpio_dev_s *dev, bool value)
{
struct nrf52gpio_dev_s *nrf52gpio =
(struct nrf52gpio_dev_s *)dev;
DEBUGASSERT(nrf52gpio != NULL);
DEBUGASSERT(nrf52gpio->id < BOARD_NGPIOOUT);
gpioinfo("Writing %d\n", (int)value);
nrf52_gpio_write(g_gpiooutputs[nrf52gpio->id], value);
return OK;
}
static int gpint_read(struct gpio_dev_s *dev, bool *value)
{
struct nrf52gpint_dev_s *nrf52gpint =
(struct nrf52gpint_dev_s *)dev;
DEBUGASSERT(nrf52gpint != NULL && value != NULL);
DEBUGASSERT(nrf52gpint->nrf52gpio.id < BOARD_NGPIOINT);
gpioinfo("Reading int pin...\n");
*value = nrf52_gpio_read(g_gpiointinputs[nrf52gpint->nrf52gpio.id]);
return OK;
}
static int gpint_attach(struct gpio_dev_s *dev,
pin_interrupt_t callback)
{
struct nrf52gpint_dev_s *nrf52gpint =
(struct nrf52gpint_dev_s *)dev;
gpioinfo("Attaching the callback\n");
/* Make sure the interrupt is disabled */
nrf52_gpiote_set_event(g_gpiointinputs[nrf52gpint->nrf52gpio.id], false,
false, NULL, NULL);
gpioinfo("Attach %p\n", callback);
nrf52gpint->callback = callback;
return OK;
}
static int gpint_enable(struct gpio_dev_s *dev, bool enable)
{
struct nrf52gpint_dev_s *nrf52gpint =
(struct nrf52gpint_dev_s *)dev;
if (enable)
{
if (nrf52gpint->callback != NULL)
{
gpioinfo("Enabling the interrupt\n");
/* Configure the interrupt for rising edge */
nrf52_gpiote_set_event(g_gpiointinputs[nrf52gpint->nrf52gpio.id],
true, false, nrf52gpio_interrupt,
&g_gpint[nrf52gpint->nrf52gpio.id]);
}
}
else
{
gpioinfo("Disable the interrupt\n");
nrf52_gpiote_set_event(g_gpiointinputs[nrf52gpint->nrf52gpio.id],
false, false, NULL, NULL);
}
return OK;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nrf52_gpio_initialize
*
* Description:
* Initialize GPIO drivers for use with /apps/examples/gpio
*
****************************************************************************/
int nrf52_gpio_initialize(void)
{
int i;
int pincount = 0;
#if BOARD_NGPIOIN > 0
for (i = 0; i < BOARD_NGPIOIN; i++)
{
/* Setup and register the GPIO pin */
g_gpin[i].gpio.gp_pintype = GPIO_INPUT_PIN;
g_gpin[i].gpio.gp_ops = &gpin_ops;
g_gpin[i].id = i;
gpio_pin_register(&g_gpin[i].gpio, pincount);
/* Configure the pin that will be used as input */
nrf52_gpio_config(g_gpioinputs[i]);
pincount++;
}
#endif
#if BOARD_NGPIOOUT > 0
for (i = 0; i < BOARD_NGPIOOUT; i++)
{
/* Setup and register the GPIO pin */
g_gpout[i].gpio.gp_pintype = GPIO_OUTPUT_PIN;
g_gpout[i].gpio.gp_ops = &gpout_ops;
g_gpout[i].id = i;
gpio_pin_register(&g_gpout[i].gpio, pincount);
/* Configure the pin that will be used as output */
nrf52_gpio_write(g_gpiooutputs[i], 0);
nrf52_gpio_config(g_gpiooutputs[i]);
pincount++;
}
#endif
#if BOARD_NGPIOINT > 0
for (i = 0; i < BOARD_NGPIOINT; i++)
{
/* Setup and register the GPIO pin */
g_gpint[i].nrf52gpio.gpio.gp_pintype = GPIO_INTERRUPT_PIN;
g_gpint[i].nrf52gpio.gpio.gp_ops = &gpint_ops;
g_gpint[i].nrf52gpio.id = i;
gpio_pin_register(&g_gpint[i].nrf52gpio.gpio, pincount);
/* Configure the pin that will be used as interrupt input */
nrf52_gpio_config(g_gpiointinputs[i]);
pincount++;
}
#endif
return 0;
}
#endif /* CONFIG_DEV_GPIO && !CONFIG_GPIO_LOWER_HALF */
@@ -0,0 +1,58 @@
/****************************************************************************
* boards/arm/nrf52/xiao-nrf52840/src/nrf52_usb.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
#include "nrf52_usbd.h"
#include "xiao-nrf52840.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nrf52_usbsuspend
*
* Description:
* Board logic must provide the nrf52_usbsuspend logic if the USBDEV
* driver is used. This function is called whenever the USB enters or
* leaves suspend mode.
* This is an opportunity for the board logic to shutdown clocks, power,
* etc. while the USB is suspended.
*
****************************************************************************/
void nrf52_usbsuspend(struct usbdev_s *dev, bool resume)
{
uinfo("resume: %d\n", resume);
}
@@ -0,0 +1,150 @@
/****************************************************************************
* boards/arm/nrf52/xiao-nrf52840/src/nrf52_userleds.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <arch/board/board.h>
#include "chip.h"
#include "arm_internal.h"
#include "xiao-nrf52840.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:
*
* uint32_t board_userled_initialize(void);
* void board_userled(int led, bool ledon);
* void board_userled_all(uint32_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(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
****************************************************************************/
uint32_t 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");
return BOARD_NLEDS;
}
/****************************************************************************
* 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(uint32_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 */
@@ -0,0 +1,125 @@
/****************************************************************************
* boards/arm/nrf52/xiao-nrf52840/src/xiao-nrf52840.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_NRF52_XIAO_NRF52840_SRC_XIAO_NRF52840_H
#define __BOARDS_ARM_NRF52_XIAO_NRF52840_SRC_XIAO_NRF52840_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include "nrf52_gpio.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* procfs File System */
#ifdef CONFIG_FS_PROCFS
# ifdef CONFIG_NSH_PROC_MOUNTPOINT
# define NRF52_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT
# else
# define NRF52_PROCFS_MOUNTPOINT "/proc"
# endif
#endif
/* LED definitions **********************************************************/
/* Definitions to configure LED GPIO as outputs */
/* RGB LED:
* RGB_RED - P0-26
* RGB_GREEN - P0-30
* RGB_BLUE - P0-6
*/
#define GPIO_LED1 (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT0 | GPIO_PIN(6))
#define GPIO_LED2 (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT0 | GPIO_PIN(26))
#define GPIO_LED3 (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT0 | GPIO_PIN(30))
/* Button definitions *******************************************************/
/* No buttons on board */
/* GPIO pins used by the GPIO Subsystem */
#define BOARD_NGPIOIN 1 /* Amount of GPIO Input pins */
#define BOARD_NGPIOOUT 1 /* Amount of GPIO Output pins */
#define BOARD_NGPIOINT 1 /* Amount of GPIO Input w/ Interruption pins */
#define GPIO_IN1 (GPIO_INPUT | GPIO_VALUE_ZERO | GPIO_PORT0 | GPIO_PIN(2))
#define GPIO_INT1 (GPIO_INPUT | GPIO_VALUE_ZERO | GPIO_PORT0 | GPIO_PIN(3))
#define GPIO_OUT1 (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT0 | GPIO_PIN(28))
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Functions Prototypes
****************************************************************************/
/****************************************************************************
* Name: nrf52_gpio_initialize
*
* Description:
* Initialize GPIO drivers for use with /apps/examples/gpio
*
* Return Value:
* OK on success; a negated errno value on failure.
*
****************************************************************************/
#ifdef CONFIG_DEV_GPIO
int nrf52_gpio_initialize(void);
#endif
/****************************************************************************
* Name: nrf52_bringup
*
* Description:
* Perform architecture-specific initialization
*
* CONFIG_BOARD_LATE_INITIALIZE=y :
* Called from board_late_initialize().
*
* CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y :
* Called from the NSH library
*
****************************************************************************/
int nrf52_bringup(void);
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_NRF52_XIAO_NRF52840_SRC_XIAO_NRF52840_H */