diff --git a/boards/Kconfig b/boards/Kconfig index 3df736aef4..ee2b176451 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -1115,6 +1115,13 @@ config ARCH_BOARD_NRF5340_AUDIO_DK ---help--- This option selects the nRF5340 Audio Development Kit (PCA10121) +config ARCH_BOARD_THINGY53 + bool "Nordic Thingy:53 IoT prototyping platform" + depends on ARCH_CHIP_NRF53 + select ARCH_HAVE_BUTTONS + ---help--- + This option selects the Thingy:53 multi-protocol IoT prototyping platform + config ARCH_BOARD_NUTINY_NUC120 bool "Nuvoton NuTiny NUC120" depends on ARCH_CHIP_NUC120LE3AN @@ -2921,6 +2928,7 @@ config ARCH_BOARD default "thingy52" if ARCH_BOARD_THINGY52 default "nrf5340-dk" if ARCH_BOARD_NRF5340_DK default "nrf5340-audio-dk" if ARCH_BOARD_NRF5340_AUDIO_DK + default "thingy53" if ARCH_BOARD_THINGY53 default "ntosd-dm320" if ARCH_BOARD_NTOSD_DM320 default "nucleo-144" if ARCH_BOARD_NUCLEO_144 default "nucleo-f072rb" if ARCH_BOARD_NUCLEO_F072RB diff --git a/boards/arm/nrf53/thingy53/Kconfig b/boards/arm/nrf53/thingy53/Kconfig new file mode 100644 index 0000000000..de41e1ab5c --- /dev/null +++ b/boards/arm/nrf53/thingy53/Kconfig @@ -0,0 +1,8 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_THINGY53 + +endif diff --git a/boards/arm/nrf53/thingy53/configs/nsh_cpuapp/defconfig b/boards/arm/nrf53/thingy53/configs/nsh_cpuapp/defconfig new file mode 100644 index 0000000000..2670a7e3b0 --- /dev/null +++ b/boards/arm/nrf53/thingy53/configs/nsh_cpuapp/defconfig @@ -0,0 +1,41 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="thingy53" +CONFIG_ARCH_BOARD_THINGY53=y +CONFIG_ARCH_CHIP="nrf53" +CONFIG_ARCH_CHIP_NRF5340=y +CONFIG_ARCH_CHIP_NRF5340_CPUAPP=y +CONFIG_ARCH_CHIP_NRF53=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_EXPERIMENTAL=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MM_REGIONS=2 +CONFIG_NRF53_UART0=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=524288 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=26 +CONFIG_START_MONTH=3 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/nrf53/thingy53/configs/nsh_cpunet/defconfig b/boards/arm/nrf53/thingy53/configs/nsh_cpunet/defconfig new file mode 100644 index 0000000000..8e7d4510e1 --- /dev/null +++ b/boards/arm/nrf53/thingy53/configs/nsh_cpunet/defconfig @@ -0,0 +1,41 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="thingy53" +CONFIG_ARCH_BOARD_THINGY53=y +CONFIG_ARCH_CHIP="nrf53" +CONFIG_ARCH_CHIP_NRF5340=y +CONFIG_ARCH_CHIP_NRF5340_CPUNET=y +CONFIG_ARCH_CHIP_NRF53=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_EXPERIMENTAL=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MM_REGIONS=2 +CONFIG_NRF53_UART0=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=65535 +CONFIG_RAM_START=0x21000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=26 +CONFIG_START_MONTH=3 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/nrf53/thingy53/include/board.h b/boards/arm/nrf53/thingy53/include/board.h new file mode 100644 index 0000000000..3e86a7b0ed --- /dev/null +++ b/boards/arm/nrf53/thingy53/include/board.h @@ -0,0 +1,132 @@ +/**************************************************************************** + * boards/arm/nrf53/thingy53/include/board.h + * + * 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_NRF53_THINGY53_INCLUDE_BOARD_H +#define __BOARDS_ARM_NRF53_THINGY53_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_NRF53_GPIOTE) +# include +#endif + +#include "hardware/nrf53_osc.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +#define BOARD_SYSTICK_CLOCK (64000000) +#define BOARD_OSC_XOSC32KI_INTCAP (OSC_XOSC32KI_INTCAP_C7PF) + +/* Button definitions *******************************************************/ + +/* Board supports four buttons. */ + +#define BUTTON_BTN1 0 +#define BUTTON_BTN2 1 + +#define BUTTON_BTN1_BIT (1 << BUTTON_BTN1) +#define BUTTON_BTN2_BIT (1 << BUTTON_BTN2) + +/* UART Pins ****************************************************************/ + +/* UART0 APP: + * UART0_RX - P0-12 + * UART0_TX - P0-11 + * + * UART0 NET: + * UART0_RX - P0-10 + * UART0_TX - P0-09 + */ + +#ifdef CONFIG_ARCH_CHIP_NRF5340_CPUAPP +# define BOARD_UART0_RX_PIN (GPIO_MCUSEL_APP | GPIO_INPUT | \ + GPIO_PORT0 | GPIO_PIN(12)) +# define BOARD_UART0_TX_PIN (GPIO_MCUSEL_APP | GPIO_OUTPUT | \ + GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(11)) + +/* Declarations for the Net core */ + +# define BOARD_NET_UART0_RX_PIN (GPIO_MCUSEL_NET | GPIO_INPUT | \ + GPIO_PORT0 | GPIO_PIN(10)) +# define BOARD_NET_UART0_TX_PIN (GPIO_MCUSEL_NET | GPIO_OUTPUT | \ + GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(9)) +#endif + +#ifdef CONFIG_ARCH_CHIP_NRF5340_CPUNET +# define BOARD_UART0_RX_PIN (GPIO_MCUSEL_NET | GPIO_INPUT | \ + GPIO_PORT0 | GPIO_PIN(10)) +# define BOARD_UART0_TX_PIN (GPIO_MCUSEL_NET | GPIO_OUTPUT | \ + GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(9)) +#endif + +/* SPI Pins *****************************************************************/ + +/* SPI0 + * SPI0_SCK - P0.29 + * SPI0_MOSI - P0.28 + * SPI0_MISO - P0.26 + */ + +#define BOARD_SPI0_SCK_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(29)) +#define BOARD_SPI0_MOSI_PIN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(28)) +#define BOARD_SPI0_MISO_PIN (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(26)) + +/* I2C Pins *****************************************************************/ + +/* I2C0 (TWI0) + * I2C0_SCL - P1.02 + * I2C0_SDA - P1.03 + */ + +#define BOARD_I2C0_SCL_PIN (GPIO_OUTPUT | GPIO_PORT1 | GPIO_PIN(2)) +#define BOARD_I2C0_SDA_PIN (GPIO_INPUT | GPIO_PORT1 | GPIO_PIN(3)) + +/* ADC Pins *****************************************************************/ + +/* ADC + * ADC CH0 - P0.06 - AIN2 - BAT_MEAS + */ + +#define NRF52_ADC_CH0_PIN (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(6)) + +/* QSPI Pins ****************************************************************/ + +/* QSPI0 + * QSPI CS - P0.18 + * QSPI SCK - P0.17 + * QSPI IO0 - P0.13 + * QSPI IO1 - P0.14 + */ + +#define NRF52_QSPI0_CSN_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(18)) +#define NRF52_QSPI0_SCK_PIN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(17)) +#define NRF52_QSPI0_IO0_PIN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(13)) +#define NRF52_QSPI0_IO1_PIN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(14)) + +#endif /* __BOARDS_ARM_NRF53_THINGY53_INCLUDE_BOARD_H */ diff --git a/boards/arm/nrf53/thingy53/scripts/Make.defs b/boards/arm/nrf53/thingy53/scripts/Make.defs new file mode 100644 index 0000000000..9418115034 --- /dev/null +++ b/boards/arm/nrf53/thingy53/scripts/Make.defs @@ -0,0 +1,54 @@ +############################################################################ +# boards/arm/nrf53/thingy53/scripts/Make.defs +# +# 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/armv8-m/Toolchain.defs + +ifeq ($(CONFIG_ARCH_CHIP_NRF5340_CPUAPP),y) +ifeq ($(CONFIG_RPTUN),y) +LDSCRIPT = flash_rptun_app.ld +else +LDSCRIPT = flash_app.ld +endif +endif + +ifeq ($(CONFIG_ARCH_CHIP_NRF5340_CPUNET),y) +ifeq ($(CONFIG_RPTUN),y) +LDSCRIPT = flash_rptun_net.ld +else +LDSCRIPT = flash_net.ld +endif +endif + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +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 diff --git a/boards/arm/nrf53/thingy53/scripts/flash_app.ld b/boards/arm/nrf53/thingy53/scripts/flash_app.ld new file mode 100644 index 0000000000..8d722826a9 --- /dev/null +++ b/boards/arm/nrf53/thingy53/scripts/flash_app.ld @@ -0,0 +1,106 @@ +/**************************************************************************** + * boards/arm/nrf53/thingy53/scripts/flash_app.ld + * + * 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 = 0x00000000, LENGTH = 1024K + datamem (rwx) : ORIGIN = 0x20000000, LENGTH = 512K +} + +OUTPUT_ARCH(arm) +ENTRY(__start) /* Treat __start as the anchor for dead code stripping */ +EXTERN(_vectors) /* Force the vectors to be included in the output */ +SECTIONS +{ + .text : + { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > progmem + + .init_section : + { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > progmem + + .ARM.extab : + { + *(.ARM.extab*) + } > progmem + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : + { + *(.ARM.exidx*) + } > progmem + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > datamem AT > progmem + + /* BSS */ + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > datamem + + /* Stabs debugging sections. */ + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/nrf53/thingy53/scripts/flash_net.ld b/boards/arm/nrf53/thingy53/scripts/flash_net.ld new file mode 100644 index 0000000000..b8f5d95409 --- /dev/null +++ b/boards/arm/nrf53/thingy53/scripts/flash_net.ld @@ -0,0 +1,108 @@ +/**************************************************************************** + * boards/arm/nrf53/thingy53/scripts/flash_net.ld + * + * 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 +{ + app_progmem (rx) : ORIGIN = 0x00000000, LENGTH = 1024K + app_datamem (rwx) : ORIGIN = 0x20000000, LENGTH = 512K + progmem (rx) : ORIGIN = 0x01000000, LENGTH = 256K + datamem (rwx) : ORIGIN = 0x21000000, LENGTH = 64K +} + +OUTPUT_ARCH(arm) +ENTRY(__start) /* Treat __start as the anchor for dead code stripping */ +EXTERN(_vectors) /* Force the vectors to be included in the output */ +SECTIONS +{ + .text : + { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > progmem + + .init_section : + { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > progmem + + .ARM.extab : + { + *(.ARM.extab*) + } > progmem + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : + { + *(.ARM.exidx*) + } > progmem + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > datamem AT > progmem + + /* BSS */ + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > datamem + + /* Stabs debugging sections. */ + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/nrf53/thingy53/scripts/flash_rptun_app.ld b/boards/arm/nrf53/thingy53/scripts/flash_rptun_app.ld new file mode 100644 index 0000000000..c4d7449799 --- /dev/null +++ b/boards/arm/nrf53/thingy53/scripts/flash_rptun_app.ld @@ -0,0 +1,114 @@ +/**************************************************************************** + * boards/arm/nrf53/thingy53/scripts/flash_rptun_app.ld + * + * 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 = 0x00000000, LENGTH = 1024K + datamem (rwx) : ORIGIN = 0x20000000, LENGTH = 512K-32K + shared (rwx) : ORIGIN = 0x20078000, LENGTH = 32K +} + +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 + + /* Shared memory */ + + .shmem : + { + *(.shmem) + } > shared + + /* Stabs debugging sections. */ + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/nrf53/thingy53/scripts/flash_rptun_net.ld b/boards/arm/nrf53/thingy53/scripts/flash_rptun_net.ld new file mode 100644 index 0000000000..7feca55986 --- /dev/null +++ b/boards/arm/nrf53/thingy53/scripts/flash_rptun_net.ld @@ -0,0 +1,109 @@ +/**************************************************************************** + * boards/arm/nrf53/thingy53/scripts/flash_rptun_net.ld + * + * 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 +{ + app_progmem (rx) : ORIGIN = 0x00000000, LENGTH = 1024K + app_datamem (rwx) : ORIGIN = 0x20000000, LENGTH = 512K-32K + shared (rwx) : ORIGIN = 0x20078000, LENGTH = 32K + progmem (rx) : ORIGIN = 0x01000000, LENGTH = 256K + datamem (rwx) : ORIGIN = 0x21000000, LENGTH = 64K +} + +OUTPUT_ARCH(arm) +ENTRY(__start) /* Treat __start as the anchor for dead code stripping */ +EXTERN(_vectors) /* Force the vectors to be included in the output */ +SECTIONS +{ + .text : + { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > progmem + + .init_section : + { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > progmem + + .ARM.extab : + { + *(.ARM.extab*) + } > progmem + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : + { + *(.ARM.exidx*) + } > progmem + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > datamem AT > progmem + + /* BSS */ + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > datamem + + /* Stabs debugging sections. */ + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/nrf53/thingy53/src/Makefile b/boards/arm/nrf53/thingy53/src/Makefile new file mode 100644 index 0000000000..28d2b1211a --- /dev/null +++ b/boards/arm/nrf53/thingy53/src/Makefile @@ -0,0 +1,37 @@ +############################################################################ +# boards/arm/nrf53/thingy53/src/Makefile +# +# 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 = nrf53_boot.c nrf53_bringup.c + +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += nrf53_appinit.c +endif + +ifeq ($(CONFIG_NRF53_APPCORE),y) +CSRCS += nrf53_cpunet_boot.c +endif + +ifeq ($(CONFIG_ARCH_BUTTONS),y) +CSRCS += nrf53_buttons.c +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/nrf53/thingy53/src/nrf53_appinit.c b/boards/arm/nrf53/thingy53/src/nrf53_appinit.c new file mode 100644 index 0000000000..b2f6d7037d --- /dev/null +++ b/boards/arm/nrf53/thingy53/src/nrf53_appinit.c @@ -0,0 +1,74 @@ +/**************************************************************************** + * boards/arm/nrf53/thingy53/src/nrf53_appinit.c + * + * 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 + +#include +#include +#include + +#include + +#include "chip.h" +#include "thingy53.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 nrf53_bringup(); +#endif +} diff --git a/boards/arm/nrf53/thingy53/src/nrf53_boot.c b/boards/arm/nrf53/thingy53/src/nrf53_boot.c new file mode 100644 index 0000000000..a0728f7440 --- /dev/null +++ b/boards/arm/nrf53/thingy53/src/nrf53_boot.c @@ -0,0 +1,79 @@ +/**************************************************************************** + * boards/arm/nrf53/thingy53/src/nrf53_boot.c + * + * 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 + +#include + +#include +#include + +#include "arm_internal.h" +#include "thingy53.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf53_board_initialize + * + * Description: + * All NRF53xxx 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 nrf53_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 */ + + nrf53_bringup(); +} +#endif diff --git a/boards/arm/nrf53/thingy53/src/nrf53_bringup.c b/boards/arm/nrf53/thingy53/src/nrf53_bringup.c new file mode 100644 index 0000000000..d2b03390bc --- /dev/null +++ b/boards/arm/nrf53/thingy53/src/nrf53_bringup.c @@ -0,0 +1,224 @@ +/**************************************************************************** + * boards/arm/nrf53/thingy53/src/nrf53_bringup.c + * + * 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 + +#include +#include +#include + +#include + +#ifdef CONFIG_RPMSG_UART +# include +#endif + +#ifdef CONFIG_INPUT_BUTTONS +# include +#endif + +#ifdef CONFIG_NRF53_SOFTDEVICE_CONTROLLER +# include "nrf53_sdc.h" +#endif + +#ifdef CONFIG_RPTUN +# include +# ifdef CONFIG_UART_BTH4 +# include +# endif +# ifdef CONFIG_NET_BLUETOOTH +# include +# endif +# include "nrf53_rptun.h" +#endif + +#include "thingy53.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define NRF53_TIMER (0) + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#ifdef CONFIG_NRF53_APPCORE + +/**************************************************************************** + * Name: nrf53_appcore_bleinit + ****************************************************************************/ + +static int nrf53_appcore_bleinit(void) +{ + int ret = OK; + +#ifdef CONFIG_BLUETOOTH_RPMSG + struct bt_driver_s *bt_dev = NULL; + + bt_dev = rpmsghci_register("appcore", "bthci"); + if (bt_dev == NULL) + { + syslog(LOG_ERR, "ERROR: rpmsghci_register() failed: %d\n", -errno); + return -ENOMEM; + } + +# ifdef CONFIG_UART_BTH4 + /* Register UART BT H4 device */ + + ret = uart_bth4_register("/dev/ttyHCI", bt_dev); + if (ret < 0) + { + syslog(LOG_ERR, "bt_bth4_register error: %d\n", ret); + } +# elif defined(CONFIG_NET_BLUETOOTH) + /* Register network device */ + + ret = bt_netdev_register(bt_dev); + if (ret < 0) + { + syslog(LOG_ERR, "bt_netdev_register error: %d\n", ret); + } +# else +# error +# endif +#endif + + return ret; +} + +#else + +/**************************************************************************** + * Name: nrf53_netcore_bleinit + ****************************************************************************/ + +static int nrf53_netcore_bleinit(void) +{ + int ret = OK; + +#ifdef CONFIG_NRF53_SOFTDEVICE_CONTROLLER +# ifdef CONFIG_BLUETOOTH_RPMSG_SERVER + ret = nrf53_rpmsghci_server_initialize("bthci"); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: nrf53_rpmsghci_server_initialize() failed: %d\n", + ret); + } +# else + ret = nrf53_sdc_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: nrf53_sdc_initialize() failed: %d\n", ret); + } +# endif +#endif + + return ret; +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_RPMSG_UART +void rpmsg_serialinit(void) +{ +#ifdef CONFIG_NRF53_APPCORE + uart_rpmsg_init("appcore", "proxy", 4096, false); +#else + uart_rpmsg_init("netcore", "proxy", 4096, true); +#endif +} +#endif + +/**************************************************************************** + * Name: nrf53_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 nrf53_bringup(void) +{ + int ret; + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = nx_mount(NULL, NRF53_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_INPUT_BUTTONS + /* Register the BUTTON driver */ + + ret = btn_lower_initialize("/dev/buttons"); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_RPTUN +#ifdef CONFIG_NRF53_APPCORE + nrf53_rptun_init("nrf53-shmem", "appcore"); +#else + nrf53_rptun_init("nrf53-shmem", "netcore"); +#endif +#endif + + /* Initialize BLE */ + +#ifdef CONFIG_NRF53_APPCORE + ret = nrf53_appcore_bleinit(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: nrf53_appcore_bleinit failed: %d\n", ret); + } +#else + ret = nrf53_netcore_bleinit(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: nrf53_netcore_bleinit failed: %d\n", ret); + } +#endif + + UNUSED(ret); + return OK; +} diff --git a/boards/arm/nrf53/thingy53/src/nrf53_buttons.c b/boards/arm/nrf53/thingy53/src/nrf53_buttons.c new file mode 100644 index 0000000000..2f1ea1a794 --- /dev/null +++ b/boards/arm/nrf53/thingy53/src/nrf53_buttons.c @@ -0,0 +1,151 @@ +/**************************************************************************** + * boards/arm/nrf53/thingy53/src/nrf53_buttons.c + * + * 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 + +#include +#include +#include + +#include +#include +#include + +#include "nrf53_gpio.h" +#include "nrf53_gpiote.h" + +#include "thingy53.h" + +#ifdef CONFIG_ARCH_BUTTONS + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* Pin configuration for each nrf5340 button. This array is indexed by + * the BUTTON_* definitions in board.h + */ + +static const uint32_t g_buttons[NUM_BUTTONS] = +{ + GPIO_BUTTON1, + GPIO_BUTTON2, +}; + +/**************************************************************************** + * 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. + * + ****************************************************************************/ + +uint32_t board_button_initialize(void) +{ + int i; + + /* Configure the GPIO pins as inputs. */ + + for (i = 0; i < NUM_BUTTONS; i++) + { + nrf53_gpio_config(g_buttons[i]); + } + + return NUM_BUTTONS; +} + +/**************************************************************************** + * Name: board_buttons + ****************************************************************************/ + +uint32_t board_buttons(void) +{ + uint32_t ret = 0; + int i; + + /* Check that state of each key */ + + for (i = 0; i < NUM_BUTTONS; i++) + { + /* A LOW value means that the key is pressed. */ + + bool released = nrf53_gpio_read(g_buttons[BUTTON_BTN1]); + + /* Accumulate the set of depressed (not released) keys */ + + if (!released) + { + ret |= (1 << i); + } + } + + 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, void *arg) +{ + int ret = OK; + + ret = nrf53_gpiote_set_event(g_buttons[id], true, true, irqhandler, arg); + if (ret < 0) + { + ierr("ERROR: nrf53_gpiote_set_event\n"); + return ret; + } + + return OK; +} +#endif + +#endif /* CONFIG_ARCH_BUTTONS */ diff --git a/boards/arm/nrf53/thingy53/src/nrf53_cpunet_boot.c b/boards/arm/nrf53/thingy53/src/nrf53_cpunet_boot.c new file mode 100644 index 0000000000..ab7bf8be0a --- /dev/null +++ b/boards/arm/nrf53/thingy53/src/nrf53_cpunet_boot.c @@ -0,0 +1,44 @@ +/**************************************************************************** + * boards/arm/nrf53/thingy53/src/nrf53_cpunet_boot.c + * + * 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 + +#include "nrf53_gpio.h" +#include "nrf53_cpunet.h" + +#include + +#ifndef CONFIG_NRF53_NET_GPIO_ALLOW_ALL +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void nrf53_board_gpio_cpunet_allow(void) +{ + /* UART0 pins */ + + nrf53_gpio_cpunet_allow(BOARD_NET_UART0_RX_PIN); + nrf53_gpio_cpunet_allow(BOARD_NET_UART0_TX_PIN); +} +#endif diff --git a/boards/arm/nrf53/thingy53/src/thingy53.h b/boards/arm/nrf53/thingy53/src/thingy53.h new file mode 100644 index 0000000000..98d96f9a20 --- /dev/null +++ b/boards/arm/nrf53/thingy53/src/thingy53.h @@ -0,0 +1,157 @@ +/**************************************************************************** + * boards/arm/nrf53/thingy53/src/thingy53.h + * + * 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_NRF53_THINGY53_SRC_THINGY53_H +#define __BOARDS_ARM_NRF53_THINGY53_SRC_THINGY53_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "nrf53_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +/* procfs File System */ + +#ifdef CONFIG_FS_PROCFS +# ifdef CONFIG_NSH_PROC_MOUNTPOINT +# define NRF53_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT +# else +# define NRF53_PROCFS_MOUNTPOINT "/proc" +# endif +#endif + +/* LED definitions **********************************************************/ + +#define GPIO_LED_R (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN(8)) +#define GPIO_LED_G (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN(6)) +#define GPIO_LED_B (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN(7)) + +/* Button definitions *******************************************************/ + +#define GPIO_BUTTON1 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT1 | GPIO_PIN(14)) +#define GPIO_BUTTON2 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT1 | GPIO_PIN(13)) + +/* nRF21540 front end module + * RX_EN - P1.11 + * MODE - P1.12 + * SEL - P1.10 + * TX_EN - P0.30 + * CSN - P0.24 + */ + +#define GPIO_NRF21540_RXEN (GPIO_OUTPUT | GPIO_PORT1 | GPIO_PIN(11)) +#define GPIO_NRF21540_MODE (GPIO_OUTPUT | GPIO_PORT1 | GPIO_PIN(12)) +#define GPIO_NRF21540_SEL (GPIO_OUTPUT | GPIO_PORT1 | GPIO_PIN(10)) +#define GPIO_NRF21540_TXEN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(30)) +#define GPIO_NRF21540_CSN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(24)) + +/* Sensor power control + * SENS_PWR_CTRL - P0.31 + */ + +#define GPIO_SENS_PWRCTRL (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(31)) + +/* ADXL362 + * INT1 - P0.19 + * CS - P0.22 + */ + +#define GPIO_ADXL362_INT1 (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(19)) +#define GPIO_ADXL362_CS (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(22)) + +/* BMI270 + * INT1 - P0.23 + * CS - P1.04 + */ + +#define GPIO_BMI270_INT1 (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(23)) +#define GPIO_BMI270_CS (GPIO_OUTPUT | GPIO_PORT1 | GPIO_PIN(4)) + +/* BMM150 + * INT - P0.20 + * DRDY - P0.21 + */ + +#define GPIO_BMM150_INT (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(20)) +#define GPIO_BMM150_DRDY (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(21)) + +/* BH1749 + * INT - P1.05 + */ + +#define GPIO_BH1749_INT (GPIO_INPUT | GPIO_PORT1 | GPIO_PIN(5)) + +/* nPM1100 PMIC status and control + * ERR - P1.01 + * CHG - P1.00 + * ISET - P0.07 + */ + +#define GPIO_NPM1100_ERR (GPIO_INPUT | GPIO_PORT1 | GPIO_PIN(1)) +#define GPIO_NPM1100_CHG (GPIO_INPUT | GPIO_PORT1 | GPIO_PIN(0)) +#define GPIO_NPM1100_ISET (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(7)) + +/* Battery monitoring + * EN - P0.16 + */ + +#define GPIO_BATT_EN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(16)) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Functions Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf53_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 nrf53_bringup(void); + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_NRF53_THINGY53_SRC_THINGY53_H */