boards/arm/ra4 Add support to Seeed Xiao RA4M1 Board

Added initial support for Seeed Studio XIAO RA4M1 Board. Initial
support to NuttShell via Serial, gpio and userleds. Also two
configurations is available: nsh for basic NuttShell access and
combo for gpio and userleds.

Signed-off-by: Rodrigo Sim <rcsim10@gmail.com>
This commit is contained in:
Rodrigo Sim
2025-03-24 20:21:11 +08:00
committed by Xiang Xiao
parent 02937bd939
commit a4777f153b
17 changed files with 1271 additions and 0 deletions
+12
View File
@@ -43,6 +43,14 @@ config ARCH_BOARD_ARDUINO_R4_MINIMA
This options selects the Arduino R4 Minima board featuring the Renesas
R7FA4M1 MCU running at 48 MHz.
config ARCH_BOARD_XIAO_RA4M1
bool "Seeed Studio XIAO RA4M1"
depends on ARCH_CHIP_RA4
select ARCH_HAVE_LEDS
---help---
This options selects the Seeed Studio XIAO RA4M1 board featuring the Renesas
R7FA4M1 MCU running at 48 MHz.
config ARCH_BOARD_ARDUINO_M0
bool "Arduino M0"
depends on ARCH_CHIP_SAMD21G18A
@@ -3542,6 +3550,7 @@ config ARCH_BOARD
default "pic32mz-starterkit" if ARCH_BOARD_PIC32MZ_STARTERKIT
default "qemu-i486" if ARCH_BOARD_QEMU_I486
default "qemu-intel64" if ARCH_BOARD_INTEL64_QEMU
default "xiao-ra4m1" if ARCH_BOARD_XIAO_RA4M1
default "raspberrypi-pico" if ARCH_BOARD_RASPBERRYPI_PICO
default "raspberrypi-4b" if ARCH_BOARD_RASPBERRYPI_4B
default "raspberrypi-pico-w" if ARCH_BOARD_RASPBERRYPI_PICO_W
@@ -4051,6 +4060,9 @@ endif
if ARCH_BOARD_ARDUINO_R4_MINIMA
source "boards/arm/ra4/arduino-r4-minima/Kconfig"
endif
if ARCH_BOARD_XIAO_RA4M1
source "boards/arm/ra4/xiao-ra4m1/Kconfig"
endif
if ARCH_BOARD_ARDUINO_M0
source "boards/arm/samd2l2/arduino-m0/Kconfig"
endif
+21
View File
@@ -0,0 +1,21 @@
# ##############################################################################
# boards/arm/ra4/xiao-ra4m1/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)
+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_RA4M1
endif
@@ -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_LEDS is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="xiao-ra4m1"
CONFIG_ARCH_BOARD_XIAO_RA4M1=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_DEV_GPIO=y
CONFIG_EXAMPLES_GPIO=y
CONFIG_EXAMPLES_LEDS=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
CONFIG_USERLED=y
CONFIG_USERLED_LOWER=y
@@ -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="xiao-ra4m1"
CONFIG_ARCH_BOARD_XIAO_RA4M1=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
+130
View File
@@ -0,0 +1,130 @@
/****************************************************************************
* boards/arm/ra4/xiao-ra4m1/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_RA4_XIAO_RA4M1_INCLUDE_BOARD_H
#define __BOARDS_ARM_RA4_XIAO_RA4M1_INCLUDE_BOARD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* 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_LED (gpio_pinset_t){ PORT0,PIN11, (GPIO_OUPUT | GPIO_LOW_DRIVE | GPIO_OUTPUT_LOW)} /* P011 */
#define LED_DRIVER_PATH "/dev/userleds"
/* LED index values for use with board_userled() */
#define BOARD_LED_L 0
#define BOARD_NLEDS 1
/* LED bits for use with board_userled_all() */
#define BOARD_LED_L_BIT (1 << BOARD_LED_L)
/* 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 ---- */
/* GPIO definitions *********************************************************/
#define BOARD_NGPIOOUT 1
#define BOARD_NGPIOIN 1
#define GPIO_IN1 (gpio_pinset_t){ PORT0,PIN14, (GPIO_INPUT | GPIO_LOW_DRIVE)} /* P014 */
#define GPIO_OUT1 (gpio_pinset_t){ PORT0,PIN0, (GPIO_OUPUT | GPIO_LOW_DRIVE | GPIO_OUTPUT_LOW)} /* P000 */
/* ID_CODE */
#define IDCODE1 0xFFFFFFFF
#define IDCODE2 0xFFFFFFFF
#define IDCODE3 0xFFFFFFFF
#define IDCODE4 0xFFFFFFFF
#endif /* __BOARDS_ARM_RA4_XIAO_RA4M1_INCLUDE_BOARD_H */
@@ -0,0 +1,38 @@
############################################################################
# boards/arm/ra4/xiao-ra4m1/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)xiao-ra4m1.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
@@ -0,0 +1,128 @@
/****************************************************************************
* boards/arm/ra4/xiao-ra4m1/scripts/xiao-ra4m1.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) }
}
@@ -0,0 +1,36 @@
# ##############################################################################
# boards/arm/ra4/xiao-ra4m1/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()
if(CONFIG_DEV_GPIO)
list(APPEND SRCS ra4m1_gpio.c)
endif()
target_sources(board PRIVATE ${SRCS})
set_property(GLOBAL PROPERTY LD_SCRIPT
"${NUTTX_BOARD_DIR}/scripts/xiao-ra4m1.ld")
+39
View File
@@ -0,0 +1,39 @@
############################################################################
# boards/arm/ra4/xiao-ra4m1/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
ifeq ($(CONFIG_DEV_GPIO),y)
CSRCS += ra4m1_gpio.c
endif
include $(TOPDIR)/boards/Board.mk
@@ -0,0 +1,76 @@
/****************************************************************************
* boards/arm/ra4/xiao-ra4m1/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 <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/board.h>
#include "xiao-ra4m1.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
}
@@ -0,0 +1,139 @@
/****************************************************************************
* boards/arm/ra4/xiao-ra4m1/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 <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/board.h>
#include "chip.h"
#include "ra_gpio.h"
#include "xiao-ra4m1.h"
/* The board.h file may override pin configurations defined in ra_pinmap.h */
#include <arch/board/board.h>
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* There is one user-controllable LED on the Seeed Studio XIAO RA4M1 board:
*
* LED GPIO
* ---------------- -----
* L Yellow LED P011
*
* The LED is 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_autoleds.c. The LED is used to encode
* OS-related events as follows:
*
* SYMBOL MEANING LED STATE
* L
* ------------------- ----------------------- --------
* LED_STARTED NuttX has been started OFF
* LED_HEAPALLOCATE Heap has been allocated OFF
* LED_IRQSENABLED Interrupts enabled OFF
* LED_STACKCREATED Idle stack created ON
* LED_INIRQ In an interrupt N/C
* LED_SIGNAL In a signal handler N/C
* LED_ASSERTION An assertion failed N/C
* LED_PANIC The system has crashed N/C
* LED_IDLE MCU is is sleep mode ------
*/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_autoled_initialize
****************************************************************************/
void board_autoled_initialize(void)
{
/* Configure RX and TX LED GPIOs for output */
ra_configgpio(GPIO_LED);
}
/****************************************************************************
* Name: board_autoled_on
****************************************************************************/
void board_autoled_on(int led)
{
bool ledon = true;
switch (led)
{
case 0: /* LED Off */
ledon = false;
break;
case 2: /* LED No change */
return;
case 1: /* LED On */
case 3: /* LED On */
break;
}
/* High illuminates */
ra_gpiowrite(GPIO_LED, ledon);
}
/****************************************************************************
* Name: board_autoled_off
****************************************************************************/
void board_autoled_off(int led)
{
switch (led)
{
case 0: /* LED Off */
case 1: /* LED Off */
case 3: /* LED Off */
break;
case 2: /* LED No change */
return;
}
/* High illuminates */
ra_gpiowrite(GPIO_LED, false);
}
#endif /* CONFIG_ARCH_LEDS */
@@ -0,0 +1,78 @@
/****************************************************************************
* boards/arm/ra4/xiao-ra4m1/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 <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include "xiao-ra4m1.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
@@ -0,0 +1,84 @@
/****************************************************************************
* boards/arm/ra4/xiao-ra4m1/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 <nuttx/config.h>
#include <stdio.h>
#include <syslog.h>
#include <nuttx/board.h>
#include <nuttx/fs/fs.h>
#include <nuttx/leds/userled.h>
#include <nuttx/spi/spi_transfer.h>
#include "xiao-ra4m1.h"
#include <arch/board/board.h>
/****************************************************************************
* 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
#ifdef CONFIG_DEV_GPIO
ret = ra_gpio_initialize();
#endif
UNUSED(ret);
return OK;
}
+220
View File
@@ -0,0 +1,220 @@
/****************************************************************************
* boards/arm/ra4/xiao-ra4m1/src/ra4m1_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 <errno.h>
#include <arch/board/board.h>
#include <nuttx/ioexpander/gpio.h>
#include "ra_gpio.h"
#include "xiao-ra4m1.h"
#ifdef CONFIG_DEV_GPIO
/****************************************************************************
* Private Types
****************************************************************************/
struct ragpio_dev_s
{
struct gpio_dev_s gpio;
uint8_t id;
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
#if BOARD_NGPIOIN > 0
static int gpin_read(struct gpio_dev_s *dev, bool *value);
#endif
#if BOARD_NGPIOOUT > 0
static int gpout_read(struct gpio_dev_s *dev, bool *value);
static int gpout_write(struct gpio_dev_s *dev, bool value);
#endif
/****************************************************************************
* Private Data
****************************************************************************/
#if BOARD_NGPIOIN > 0
static const struct gpio_operations_s gpin_ops =
{
.go_read = gpin_read,
.go_write = NULL,
.go_attach = NULL,
.go_enable = NULL,
};
#endif
#if BOARD_NGPIOOUT > 0
static const struct gpio_operations_s gpout_ops =
{
.go_read = gpout_read,
.go_write = gpout_write,
.go_attach = NULL,
.go_enable = NULL,
};
#endif
#if BOARD_NGPIOIN > 0
/* This array maps the GPIO pins used as INPUT */
static const gpio_pinset_t g_gpioinputs[BOARD_NGPIOIN] =
{
GPIO_IN1,
};
static struct ragpio_dev_s g_gpin[BOARD_NGPIOIN];
#endif
#if BOARD_NGPIOOUT > 0
/* This array maps the GPIO pins used as OUTPUT */
static const gpio_pinset_t g_gpiooutputs[BOARD_NGPIOOUT] =
{
GPIO_OUT1
};
static struct ragpio_dev_s g_gpout[BOARD_NGPIOOUT];
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
#if BOARD_NGPIOIN > 0
static int gpin_read(struct gpio_dev_s *dev, bool *value)
{
struct ragpio_dev_s *ragpio = (struct ragpio_dev_s *)dev;
DEBUGASSERT(ragpio != NULL && value != NULL);
DEBUGASSERT(ragpio->id < BOARD_NGPIOIN);
gpioinfo("Reading...");
*value = ra_gpioread(g_gpioinputs[ragpio->id]);
return OK;
}
#endif
#if BOARD_NGPIOOUT > 0
static int gpout_read(struct gpio_dev_s *dev, bool *value)
{
struct ragpio_dev_s *ragpio = (struct ragpio_dev_s *)dev;
DEBUGASSERT(ragpio != NULL && value != NULL);
DEBUGASSERT(ragpio->id < BOARD_NGPIOOUT);
gpioinfo("Reading...");
*value = ra_gpioread(g_gpiooutputs[ragpio->id]);
return OK;
}
static int gpout_write(struct gpio_dev_s *dev, bool value)
{
struct ragpio_dev_s *ragpio = (struct ragpio_dev_s *)dev;
DEBUGASSERT(ragpio != NULL);
DEBUGASSERT(ragpio->id < BOARD_NGPIOOUT);
gpioinfo("Writing %d", (int)value);
ra_gpiowrite(g_gpiooutputs[ragpio->id], value);
return OK;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: ra_gpio_initialize
*
* Description:
* Initialize GPIO drivers for use with /apps/examples/gpio
*
****************************************************************************/
int ra_gpio_initialize(void)
{
int pincount = 0;
int i;
int ret = 0;
#if BOARD_NGPIOIN > 0
for (i = 0; i < BOARD_NGPIOIN; i++, pincount++)
{
/* 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;
ret = gpio_pin_register(&g_gpin[i].gpio, pincount);
if (ret < 0)
{
gpioerr("GPIOIN(%d): gpio_pin_register failed: %d", i, ret);
return ret;
}
/* Configure the pin that will be used as input */
ra_configgpio(g_gpioinputs[i]);
}
#endif
#if BOARD_NGPIOOUT > 0
for (i = 0; i < BOARD_NGPIOOUT; i++, pincount++)
{
/* 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;
ret = gpio_pin_register(&g_gpout[i].gpio, pincount);
if (ret < 0)
{
gpioerr("GPIOOUT(%d): gpio_pin_register failed: %d", i, ret);
return ret;
}
/* Configure the pin that will be used as output */
ra_configgpio(g_gpiooutputs[i]);
}
#endif
return ret;
}
#endif
@@ -0,0 +1,90 @@
/****************************************************************************
* boards/arm/ra4/xiao-ra4m1/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 <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include "chip.h"
#include "ra_gpio.h"
#include "xiao-ra4m1.h"
#include <arch/board/board.h>
#ifndef CONFIG_ARCH_LEDS
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_userled_initialize
****************************************************************************/
uint32_t board_userled_initialize(void)
{
/* Configure LED GPIOs for output */
ra_configgpio(GPIO_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_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_LED, ledon);
}
#endif /* !CONFIG_ARCH_LEDS */
@@ -0,0 +1,86 @@
/****************************************************************************
* boards/arm/ra4/xiao-ra4m1/src/xiao-ra4m1.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_RA4_XIAO_RA4M1_SRC_H
#define __BOARDS_ARM_RA4_XIAO_RA4M1_SRC_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <stdint.h>
#include <arch/irq.h>
#include <nuttx/irq.h>
/****************************************************************************
* 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);
/****************************************************************************
* Name: ra_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 ra_gpio_initialize(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_RA4_XIAO_RA4M1_SRC_H */