diff --git a/boards/Kconfig b/boards/Kconfig index a1e4b603ba5e9..48b22f084b77a 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -35,6 +35,14 @@ config ARCH_BOARD_ARDUINO_DUE This options selects the Arduino DUE board featuring the Atmel ATSAM3X8E MCU running at 84 MHz. +config ARCH_BOARD_ARDUINO_R4_MINIMA + bool "Arduino R4 Minima" + depends on ARCH_CHIP_RA4 + select ARCH_HAVE_LEDS + ---help--- + This options selects the Arduino R4 Minima board featuring the Renesas + R7FA4M1 MCU running at 48 MHz. + config ARCH_BOARD_ARDUINO_M0 bool "Arduino M0" depends on ARCH_CHIP_SAMD21G18A @@ -3313,6 +3321,7 @@ config ARCH_BOARD default "amber" if ARCH_BOARD_AMBER default "arduino-mega2560" if ARCH_BOARD_ARDUINO_MEGA2560 default "arduino-due" if ARCH_BOARD_ARDUINO_DUE + default "arduino-r4-minima" if ARCH_BOARD_ARDUINO_R4_MINIMA default "arduino-m0" if ARCH_BOARD_ARDUINO_M0 default "arduino-nano-33ble" if ARCH_BOARD_ARDUINO_NANO_33BLE default "arduino-nano-33ble-rev2" if ARCH_BOARD_ARDUINO_NANO_33BLE_REV2 @@ -4000,6 +4009,9 @@ endif if ARCH_BOARD_ARDUINO_DUE source "boards/arm/sam34/arduino-due/Kconfig" endif +if ARCH_BOARD_ARDUINO_R4_MINIMA +source "boards/arm/ra4/arduino-r4-minima/Kconfig" +endif if ARCH_BOARD_ARDUINO_M0 source "boards/arm/samd2l2/arduino-m0/Kconfig" endif diff --git a/boards/arm/ra4/arduino-r4-minima/CMakeLists.txt b/boards/arm/ra4/arduino-r4-minima/CMakeLists.txt new file mode 100644 index 0000000000000..e37293135ec0e --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/CMakeLists.txt @@ -0,0 +1,21 @@ +# ############################################################################## +# boards/arm/nrf52/nrf52-feather/CMakeLists.txt +# +# 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) diff --git a/boards/arm/ra4/arduino-r4-minima/Kconfig b/boards/arm/ra4/arduino-r4-minima/Kconfig new file mode 100644 index 0000000000000..5d94625c18c8e --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/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_ARDUINO_R4_MINIMA + +endif diff --git a/boards/arm/ra4/arduino-r4-minima/configs/nsh-leds/defconfig b/boards/arm/ra4/arduino-r4-minima/configs/nsh-leds/defconfig new file mode 100644 index 0000000000000..329eeae53abe9 --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/configs/nsh-leds/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_ARCH_LEDS is not set +# CONFIG_READLINE_ECHO is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="arduino-r4-minima" +CONFIG_ARCH_BOARD_ARDUINO_R4_MINIMA=y +CONFIG_ARCH_CHIP="ra4" +CONFIG_ARCH_CHIP_R7FA4M1ABxxFM=y +CONFIG_ARCH_CHIP_RA4=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARD_LOOPSPERMSEC=6965 +CONFIG_BUILTIN=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_IFUPDOWN=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=32768 +CONFIG_RAM_START=0x20000000 +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SCI2_SERIAL_CONSOLE=y +CONFIG_START_DAY=28 +CONFIG_START_MONTH=6 +CONFIG_START_YEAR=2013 +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=32 +CONFIG_USERLED=y +CONFIG_USERLED_LOWER=y diff --git a/boards/arm/ra4/arduino-r4-minima/configs/nsh/defconfig b/boards/arm/ra4/arduino-r4-minima/configs/nsh/defconfig new file mode 100644 index 0000000000000..7ec30433017cd --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/configs/nsh/defconfig @@ -0,0 +1,40 @@ +# +# 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="arm" +CONFIG_ARCH_BOARD="arduino-r4-minima" +CONFIG_ARCH_BOARD_ARDUINO_R4_MINIMA=y +CONFIG_ARCH_CHIP="ra4" +CONFIG_ARCH_CHIP_R7FA4M1ABxxFM=y +CONFIG_ARCH_CHIP_RA4=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARD_LOOPSPERMSEC=6965 +CONFIG_BUILTIN=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_IFUPDOWN=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=32768 +CONFIG_RAM_START=0x20000000 +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SCI2_SERIAL_CONSOLE=y +CONFIG_START_DAY=28 +CONFIG_START_MONTH=6 +CONFIG_START_YEAR=2013 +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=32 +CONFIG_TESTING_OSTEST=y +CONFIG_TESTING_OSTEST_NBARRIER_THREADS=3 +CONFIG_TESTING_OSTEST_STACKSIZE=2048 diff --git a/boards/arm/ra4/arduino-r4-minima/include/board.h b/boards/arm/ra4/arduino-r4-minima/include/board.h new file mode 100644 index 0000000000000..ca4ecdb06d286 --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/include/board.h @@ -0,0 +1,128 @@ +/**************************************************************************** + * boards/arm/ra4/arduino-r4-minima/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_RA_ARDUINO_UNO_R4_INCLUDE_BOARD_H +#define __BOARDS_ARM_RA_ARDUINO_UNO_R4_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +/* This is the canonical configuration: + * System Clock source : HOCO + * ICLK(Hz) : 64000000 + * PCLKA(Hz) : 64000000 + * PCLKB(Hz) : 64000000 + * PCLKC(Hz) : 64000000 + * PCLKD(Hz) : 64000000 + * FCLK(Hz) : 64000000 + * USBCLK(Hz) : 0 + */ + +/* Clock selection HOCO, MOCO, LOCO, PLL */ + +#define RA_CKSEL R_SYSTEM_SCKSCR_CKSEL_HOCO + +#define RA_HOCOEN !R_OFS1_HOCOEN /* Inverted logic to enable */ +#define RA_HOCO_FREQUENCY R_OFS1_HOCOFRQ1_64MHZ + +#define RA_ICK_DIV R_SYSTEM_SCKDIVCR_ICK_DIV_1 +#define RA_ICLK_FREQUENCY 64000000 +#define RA_FCK_DIV R_SYSTEM_SCKDIVCR_FCK_DIV_1 +#define RA_FCK_FREQUENCY 64000000 +#define RA_PCKA_DIV R_SYSTEM_SCKDIVCR_PCKA_DIV_1 +#define RA_PCKA_FREQUENCY 64000000 +#define RA_PCKB_DIV R_SYSTEM_SCKDIVCR_PCKB_DIV_1 +#define RA_PCKB_FREQUENCY 64000000 +#define RA_PCKC_DIV R_SYSTEM_SCKDIVCR_PCKC_DIV_1 +#define RA_PCKC_FREQUENCY 64000000 +#define RA_PCKD_DIV R_SYSTEM_SCKDIVCR_PCKD_DIV_1 +#define RA_PCKD_FREQUENCY 64000000 + +/* Alternate function pin selections */ + +#define GPIO_SCI2_RX GPIO_RXD2_MISO2_SCL2_1 /* P301 */ +#define GPIO_SCI2_TX GPIO_TXD2_MOSI2_SDA2_1 /* P302 */ + +#define GPIO_SCI1_RX GPIO_RXD1_MISO1_SCL1_3 /* P502 */ +#define GPIO_SCI1_TX GPIO_TXD1_MOSI1_SDA1_3 /* P501 */ + +#define GPIO_SCI9_RX GPIO_RXD9_MISO9_SCL9_1 /* P110 */ +#define GPIO_SCI9_TX GPIO_TXD9_MOSI9_SDA9_1 /* P109 */ + +/* LED pin selections */ + +#define GPIO_L_LED (gpio_pinset_t){ PORT1,PIN11, (GPIO_OUPUT | GPIO_LOW_DRIVE | GPIO_OUTPUT_LOW)} /* P111 */ +#define GPIO_TX_LED (gpio_pinset_t){ PORT0,PIN12, (GPIO_OUPUT | GPIO_LOW_DRIVE | GPIO_OUTPUT_HIGH)} /* P012 */ +#define GPIO_RX_LED (gpio_pinset_t){ PORT0,PIN13, (GPIO_OUPUT | GPIO_LOW_DRIVE | GPIO_OUTPUT_HIGH)} /* P013 */ + +#define LED_DRIVER_PATH "/dev/userleds" + +/* LED index values for use with board_userled() */ + +#define BOARD_LED_L 0 +#define BOARD_LED_RX 1 +#define BOARD_LED_TX 2 +#define BOARD_NLEDS 3 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED_L_BIT (1 << BOARD_LED_L) +#define BOARD_LED_RX_BIT (1 << BOARD_LED_RX) +#define BOARD_LED_TX_BIT (1 << BOARD_LED_TX) + +/* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is + * defined. In that case, the usage by the board port is defined in + * include/board.h and src/ra4m1_leds.c. The LEDs are used to encode + * OS-related events as follows: + * + * SYMBOL MEANING LED STATE + * L TX RX + * ----------------------- -------------------------- ---- ---- ---- + */ + + #define LED_STARTED 0 /* NuttX has been started OFF OFF OFF */ + #define LED_HEAPALLOCATE 0 /* Heap has been allocated OFF OFF OFF */ + #define LED_IRQSENABLED 0 /* Interrupts enabled OFF OFF OFF */ + #define LED_STACKCREATED 1 /* Idle stack created ON OFF OFF */ + #define LED_INIRQ 2 /* In an interrupt N/C GLOW OFF */ + #define LED_SIGNAL 2 /* In a signal handler N/C GLOW OFF */ + #define LED_ASSERTION 2 /* An assertion failed N/C GLOW OFF */ + #define LED_PANIC 3 /* The system has crashed N/C N/C Blinking */ + #define LED_PANIC 3 /* MCU is is sleep mode ---- Not used ---- */ + +/* ID_CODE */ + +#define IDCODE1 0xFFFFFFFF +#define IDCODE2 0xFFFFFFFF +#define IDCODE3 0xFFFFFFFF +#define IDCODE4 0xFFFFFFFF + +#endif /* __BOARDS_ARM_RA_ARDUINO_UNO_R4_INCLUDE_BOARD_H */ diff --git a/boards/arm/ra4/arduino-r4-minima/scripts/Make.defs b/boards/arm/ra4/arduino-r4-minima/scripts/Make.defs new file mode 100644 index 0000000000000..f41aecb839c44 --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/scripts/Make.defs @@ -0,0 +1,38 @@ +############################################################################ +# boards/arm/ra4/arduino-r4-minima/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/armv7-m/Toolchain.defs + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)arduino-r4-minima.ld + +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/ra4/arduino-r4-minima/scripts/arduino-r4-minima.ld b/boards/arm/ra4/arduino-r4-minima/scripts/arduino-r4-minima.ld new file mode 100644 index 0000000000000..f28ef0b7c3e2b --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/scripts/arduino-r4-minima.ld @@ -0,0 +1,128 @@ +/**************************************************************************** + * boards/arm/ra4m1/arduino-r4-minima/scripts/arduino-r4-minima.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. + * + ****************************************************************************/ + +/* The RA4M1 has 256Kb of FLASH beginning at address 0x0000:0000 and + * 32KB SRAM. + */ + +MEMORY +{ + flash (rx) : ORIGIN = 0x00000000, LENGTH = 256K + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 32K + idcode (rx) : ORIGIN = 0x01010018, LENGTH = 0x20 +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +ENTRY(_stext) +SECTIONS +{ + .text : + { + _stext = ABSOLUTE(.); + *(.vectors) + . = _stext + 0x400; + KEEP(*(.rom_registers*)) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + .init_section : + { + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array .ctors)) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : + { + *(.ARM.extab*) + } >flash + + .ARM.exidx : + { + __exidx_start = ABSOLUTE(.); + *(.ARM.exidx*) + __exidx_end = ABSOLUTE(.); + } >flash + + .id_code : + { + __ID_Code_Start = .; + KEEP(*(.id_code*)) + __ID_Code_End = .; + } > idcode + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram AT > flash + + _eronly = LOADADDR(.data); + + .ramfunc ALIGN(4): + { + _sramfuncs = ABSOLUTE(.); + *(.ramfunc .ramfunc.*) + _eramfuncs = ABSOLUTE(.); + } > sram AT > flash + + _framfuncs = LOADADDR(.ramfunc); + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(8); + _ebss = ABSOLUTE(.); + } > sram + + /* 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/ra4/arduino-r4-minima/src/CMakeLists.txt b/boards/arm/ra4/arduino-r4-minima/src/CMakeLists.txt new file mode 100644 index 0000000000000..e1ca1ca5145eb --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/src/CMakeLists.txt @@ -0,0 +1,32 @@ +# ############################################################################## +# boards/arm/nrf52/thingy91-nrf52/src/CMakeLists.txt +# +# 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 ra4m1_boot.c ra4m1_bringup.c ra4m1_appinit.c) + +if(CONFIG_ARCH_LEDS) + list(APPEND SRCS ra4m1_autoleds.c) +else() + list(APPEND SRCS ra4m1_userleds.c) +endif() + +target_sources(board PRIVATE ${SRCS}) + +set_property(GLOBAL PROPERTY LD_SCRIPT + "${NUTTX_BOARD_DIR}/scripts/arduino-r4-minima.ld") diff --git a/boards/arm/ra4/arduino-r4-minima/src/Makefile b/boards/arm/ra4/arduino-r4-minima/src/Makefile new file mode 100644 index 0000000000000..e7585e8d2b50b --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/src/Makefile @@ -0,0 +1,35 @@ +############################################################################ +# boards/arm/ra4/arduino-r4-minima/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 = ra4m1_boot.c ra4m1_bringup.c + +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += ra4m1_autoleds.c +else +CSRCS += ra4m1_userleds.c +endif + +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += ra4m1_appinit.c +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/ra4/arduino-r4-minima/src/arduino-r4-minima.h b/boards/arm/ra4/arduino-r4-minima/src/arduino-r4-minima.h new file mode 100644 index 0000000000000..8662aa4b30542 --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/src/arduino-r4-minima.h @@ -0,0 +1,71 @@ +/**************************************************************************** + * boards/arm/ra4/arduino-r4-minima/src/arduino-r4-minima.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_RA4M1_ARDUINO_R4_MINIMA_SRC_H +#define __BOARDS_ARM_RA4M1_ARDUINO_R4_MINIMA_SRC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Functions Definitions + ****************************************************************************/ + +/**************************************************************************** + * Name: ra_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=y && CONFIG_BOARDCTL=y : + * Called from the NSH library + * + ****************************************************************************/ + +int ra4m1_bringup(void); + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RA4M1_ARDUINO_R4_MINIMA_SRC_H */ diff --git a/boards/arm/ra4/arduino-r4-minima/src/ra4m1_appinit.c b/boards/arm/ra4/arduino-r4-minima/src/ra4m1_appinit.c new file mode 100644 index 0000000000000..13e39f6aec6fa --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/src/ra4m1_appinit.c @@ -0,0 +1,76 @@ +/**************************************************************************** + * boards/arm/ra4/arduino-r4-minima/src/ra4m1_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 "arduino-r4-minima.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * 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 ra4m1_bringup(); +#endif +} diff --git a/boards/arm/ra4/arduino-r4-minima/src/ra4m1_autoleds.c b/boards/arm/ra4/arduino-r4-minima/src/ra4m1_autoleds.c new file mode 100644 index 0000000000000..035e29e01c101 --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/src/ra4m1_autoleds.c @@ -0,0 +1,193 @@ +/**************************************************************************** + * boards/arm/ra4/arduino-r4-minima/src/ra4m1_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 + +#include +#include +#include +#include + +#include + +#include "chip.h" +#include "ra_gpio.h" +#include "arduino-r4-minima.h" + +/* The board.h file may override pin configurations defined in ra_pinmap.h */ + +#include + +#ifdef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* There are three user-controllable LEDs on board the Arduino Due board: + * + * LED GPIO + * ---------------- ----- + * L Amber LED P111 + * TX Yellow LED P012 + * RX Yellow LED P013 + * + * LED L is connected to ground and can be illuminated by driving the PB27 + * output high. The TX and RX LEDs are pulled high and can be illuminated by + * driving the corresponding + * GPIO output to low. + * + * These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is + * defined. In that case, the usage by the board port is defined in + * include/board.h and src/ra_leds.c. The LEDs are used to encode OS-related + * events as follows: + * + * SYMBOL MEANING LED STATE + * L TX RX + * ------------------- ----------------------- -------- -------- -------- + * LED_STARTED NuttX has been started OFF OFF OFF + * LED_HEAPALLOCATE Heap has been allocated OFF OFF OFF + * LED_IRQSENABLED Interrupts enabled OFF OFF OFF + * LED_STACKCREATED Idle stack created ON OFF OFF + * LED_INIRQ In an interrupt N/C GLOW OFF + * LED_SIGNAL In a signal handler N/C GLOW OFF + * LED_ASSERTION An assertion failed N/C GLOW OFF + * LED_PANIC The system has crashed N/C N/C Blinking + * LED_IDLE MCU is is sleep mode ------ Not used -------- + * + * Thus if LED L is statically on, NuttX has successfully booted and is, + * apparently, running normmally. If LED RX is glowing, then NuttX is + * handling interrupts (and also signals and assertions). If TX is flashing + * at approximately 2Hz, then a fatal error has been detected and the system + */ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_autoled_initialize + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + /* Configure RX and TX LED GPIOs for output */ + + ra_configgpio(GPIO_L_LED); + ra_configgpio(GPIO_RX_LED); + ra_configgpio(GPIO_TX_LED); +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ + switch (led) + { + /* 0: LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED: L=OFF TX=OFF + * RX=OFF + * + * Since the LEDs were initially all OFF and since this state only + * occurs one time, nothing need be done. + */ + + default: + case 0: + break; + + /* 1: LED_STACKCREATED: L=ON TX=OFF RX=OFF + * + * This case will also occur only once. Note that unlike the other + * LEDs, LED L is active high. + */ + + case 1: + ra_gpiowrite(GPIO_L_LED, true); + break; + + /* 2: LED_INIRQ, LED_SIGNAL, LED_ASSERTION: L=N/C TX=ON RX=N/C + * + * This case will occur many times. LED TX is active low. + */ + + case 2: + ra_gpiowrite(GPIO_TX_LED, false); + break; + + /* 3: LED_PANIC: L=N/X TX=N/C RX=ON + * + * This case will also occur many times. LED RX is active low. + */ + + case 3: + ra_gpiowrite(GPIO_RX_LED, false); + break; + } +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ + switch (led) + { + /* 0: LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED: L=OFF TX=OFF + * RX=OFF + * 1: LED_STACKCREATED: L=ON TX=OFF RX=OFF + * + * These cases should never happen. + */ + + default: + case 1: + case 0: + break; + + /* 2: LED_INIRQ, LED_SIGNAL, LED_ASSERTION: L=N/C TX=OFF RX=N/C + * + * This case will occur many times. LED TX is active low. + */ + + case 2: + ra_gpiowrite(GPIO_TX_LED, true); + break; + + /* 3: LED_PANIC: L=N/X TX=N/C RX=OFF + * + * This case will also occur many times. LED RX is active low. + */ + + case 3: + ra_gpiowrite(GPIO_RX_LED, true); + break; + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/boards/arm/ra4/arduino-r4-minima/src/ra4m1_boot.c b/boards/arm/ra4/arduino-r4-minima/src/ra4m1_boot.c new file mode 100644 index 0000000000000..550f0b1643e3b --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/src/ra4m1_boot.c @@ -0,0 +1,78 @@ +/**************************************************************************** + * boards/arm/ra4/arduino-r4-minima/src/ra4m1_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 "arduino-r4-minima.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ra4m1_boardinitialize + * + * Description: + * All RA4M1 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 ra_boardinitialize(void) +{ +#ifdef CONFIG_ARCH_LEDS + /* Configure on-board LEDs if LED support has been selected. */ + + 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 */ + + ra4m1_bringup(); +} + +#endif diff --git a/boards/arm/ra4/arduino-r4-minima/src/ra4m1_bringup.c b/boards/arm/ra4/arduino-r4-minima/src/ra4m1_bringup.c new file mode 100644 index 0000000000000..84f80e705719f --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/src/ra4m1_bringup.c @@ -0,0 +1,80 @@ +/**************************************************************************** + * boards/arm/ra4/arduino-r4-minima/src/ra4m1_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 +#include +#include + +#include "arduino-r4-minima.h" + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +#undef HAVE_LEDS + +#if !defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER) +# define HAVE_LEDS 1 +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ra4m1_bringup + * + * Description: + * Perform architecture-specific initialization + * + * + ****************************************************************************/ + +int ra4m1_bringup(void) +{ + int ret; + +#ifdef HAVE_LEDS + board_userled_initialize(); + + /* Register the LED driver */ + + ret = userled_lower_initialize(LED_DRIVER_PATH); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret); + return ret; + } +#endif + + UNUSED(ret); + return OK; +} diff --git a/boards/arm/ra4/arduino-r4-minima/src/ra4m1_userleds.c b/boards/arm/ra4/arduino-r4-minima/src/ra4m1_userleds.c new file mode 100644 index 0000000000000..60f4dbafe5adc --- /dev/null +++ b/boards/arm/ra4/arduino-r4-minima/src/ra4m1_userleds.c @@ -0,0 +1,108 @@ +/**************************************************************************** + * boards/arm/ra4/arduino-r4-minima/src/ra4m1_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 + +#include +#include +#include + +#include "chip.h" +#include "ra_gpio.h" +#include "arduino-r4-minima.h" + +#include + +#ifndef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +uint32_t board_userled_initialize(void) +{ + /* Configure LED GPIOs for output */ + + ra_configgpio(GPIO_L_LED); + ra_configgpio(GPIO_RX_LED); + ra_configgpio(GPIO_TX_LED); + return BOARD_NLEDS; +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + gpio_pinset_t ledcfg; + + if (led == BOARD_LED_L) + { + ledcfg = GPIO_L_LED; + ledon = ledon; + } + else if (led == BOARD_LED_RX) + { + ledcfg = GPIO_RX_LED; + ledon = !ledon; + } + else if (led == BOARD_LED_TX) + { + ledcfg = GPIO_TX_LED; + ledon = !ledon; + } + else + { + return; + } + + ra_gpiowrite(ledcfg, ledon); +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint32_t ledset) +{ + bool ledon; + + ledon = ((ledset & BOARD_LED_L_BIT) != 0); + ra_gpiowrite(GPIO_L_LED, ledon); + + ledon = ((ledset & BOARD_LED_RX_BIT) != 0); + ra_gpiowrite(GPIO_RX_LED, ledon); + + ledon = ((ledset & BOARD_LED_TX_BIT) != 0); + ra_gpiowrite(GPIO_TX_LED, ledon); +} + +#endif /* !CONFIG_ARCH_LEDS */