You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/01/27 03:14:39 UTC
(nuttx) branch master updated: add xmc4800-relax to nuttx
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 26ffb1f568 add xmc4800-relax to nuttx
26ffb1f568 is described below
commit 26ffb1f568cd2f9d8815c385746931642e773abb
Author: ThomasNS <th...@wandercraft.eu>
AuthorDate: Thu Jan 25 18:40:11 2024 +0100
add xmc4800-relax to nuttx
---
boards/Kconfig | 13 +
boards/arm/xmc4/xmc4800-relax/Kconfig | 4 +
.../arm/xmc4/xmc4800-relax/configs/nsh/defconfig | 43 +++
boards/arm/xmc4/xmc4800-relax/include/board.h | 351 +++++++++++++++++++++
boards/arm/xmc4/xmc4800-relax/scripts/Make.defs | 46 +++
boards/arm/xmc4/xmc4800-relax/scripts/flash.ld | 127 ++++++++
boards/arm/xmc4/xmc4800-relax/src/Makefile | 43 +++
boards/arm/xmc4/xmc4800-relax/src/xmc4800-relax.h | 95 ++++++
boards/arm/xmc4/xmc4800-relax/src/xmc4_appinit.c | 71 +++++
boards/arm/xmc4/xmc4800-relax/src/xmc4_autoleds.c | 177 +++++++++++
boards/arm/xmc4/xmc4800-relax/src/xmc4_boot.c | 80 +++++
boards/arm/xmc4/xmc4800-relax/src/xmc4_bringup.c | 81 +++++
boards/arm/xmc4/xmc4800-relax/src/xmc4_buttons.c | 64 ++++
boards/arm/xmc4/xmc4800-relax/src/xmc4_spi.c | 280 ++++++++++++++++
boards/arm/xmc4/xmc4800-relax/src/xmc4_userleds.c | 87 +++++
15 files changed, 1562 insertions(+)
diff --git a/boards/Kconfig b/boards/Kconfig
index 720b612067..624f0ba9ab 100644
--- a/boards/Kconfig
+++ b/boards/Kconfig
@@ -2868,6 +2868,15 @@ config ARCH_BOARD_XMC4700RELAX
---help---
Infineon XMC4700 Relax
+config ARCH_BOARD_XMC4800RELAX
+ bool "Infineon XMC4800 Relax"
+ depends on ARCH_CHIP_XMC4800
+ select ARCH_HAVE_LEDS
+ select ARCH_HAVE_BUTTONS
+ select ARCH_HAVE_IRQBUTTONS
+ ---help---
+ Infineon XMC4800 Relax
+
config ARCH_BOARD_VERDIN_MX8MP
bool "Toradex Verdin i.MX8MP"
depends on ARCH_CHIP_MX8MP
@@ -3364,6 +3373,7 @@ config ARCH_BOARD
default "viewtool-stm32f107" if ARCH_BOARD_VIEWTOOL_STM32F107
default "xmc4500-relax" if ARCH_BOARD_XMC4500RELAX
default "xmc4700-relax" if ARCH_BOARD_XMC4700RELAX
+ default "xmc4800-relax" if ARCH_BOARD_XMC4800RELAX
default "verdin-mx8mp" if ARCH_BOARD_VERDIN_MX8MP
default "z16f2800100zcog" if ARCH_BOARD_Z16F2800100ZCOG
default "z20x" if ARCH_BOARD_Z20X
@@ -4070,6 +4080,9 @@ endif
if ARCH_BOARD_XMC4700RELAX
source "boards/arm/xmc4/xmc4700-relax/Kconfig"
endif
+if ARCH_BOARD_XMC4800RELAX
+source "boards/arm/xmc4/xmc4800-relax/Kconfig"
+endif
if ARCH_BOARD_VERDIN_MX8MP
source "boards/arm/mx8mp/verdin-mx8mp/Kconfig"
endif
diff --git a/boards/arm/xmc4/xmc4800-relax/Kconfig b/boards/arm/xmc4/xmc4800-relax/Kconfig
new file mode 100644
index 0000000000..f72f3c094c
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/Kconfig
@@ -0,0 +1,4 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
diff --git a/boards/arm/xmc4/xmc4800-relax/configs/nsh/defconfig b/boards/arm/xmc4/xmc4800-relax/configs/nsh/defconfig
new file mode 100644
index 0000000000..b96ceae5a2
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/configs/nsh/defconfig
@@ -0,0 +1,43 @@
+#
+# 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_RAMFUNCS is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="xmc4800-relax"
+CONFIG_ARCH_BOARD_XMC4800RELAX=y
+CONFIG_ARCH_BUTTONS=y
+CONFIG_ARCH_CHIP="xmc4"
+CONFIG_ARCH_CHIP_XMC4800=y
+CONFIG_ARCH_CHIP_XMC4=y
+CONFIG_ARCH_INTERRUPTSTACK=2048
+CONFIG_ARCH_IRQBUTTONS=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARD_LOOPSPERMSEC=8000
+CONFIG_BUILTIN=y
+CONFIG_DEBUG_NOOPT=y
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INTELHEX_BINARY=y
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_LINELEN=64
+CONFIG_NSH_READLINE=y
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_RAM_SIZE=65536
+CONFIG_RAM_START=0x20000000
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_HPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_START_DAY=10
+CONFIG_START_MONTH=3
+CONFIG_START_YEAR=2014
+CONFIG_SYSTEM_NSH=y
+CONFIG_TESTING_RAMTEST=y
+CONFIG_UART0_SERIAL_CONSOLE=y
+CONFIG_XMC4_USIC0=y
+CONFIG_XMC4_USIC0_CHAN1_NONE=y
diff --git a/boards/arm/xmc4/xmc4800-relax/include/board.h b/boards/arm/xmc4/xmc4800-relax/include/board.h
new file mode 100644
index 0000000000..f999325df9
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/include/board.h
@@ -0,0 +1,351 @@
+/****************************************************************************
+ * boards/arm/xmc4/xmc4800-relax/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_XMC4_XMC4800_RELAX_INCLUDE_BOARD_H
+#define __BOARDS_ARM_XMC4_XMC4800_RELAX_INCLUDE_BOARD_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#ifndef __ASSEMBLY__
+# include <stdint.h>
+# include <stdbool.h>
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Clocking *****************************************************************/
+
+/* The maximum frequency for the XMC4800 is 144MHz. */
+
+#undef BOARD_FCPU_120MHZ
+#define BOARD_FCPU_144MHZ 1
+
+/* Watchdog clock source selection */
+
+#define WDT_CLKSRC_FOFI 0 /* fOFI clock */
+#define WDT_CLKSRC_FSTDY 1 /* fSTDY clock */
+#define WDT_CLKSRC_FPLL 2 /* fPLL clock */
+
+/* External Clock source selection */
+
+#define EXT_CLKSRC_FSYS 0 /* fSYS clock */
+#define EXT_CLKSRC_FUSB 2 /* fUSB clock divided by ECKDIV */
+#define EXT_CLKSRC_FPLL 3 /* fPLL clock divided by ECKDIV */
+
+/* Factory Calibration */
+
+#undef BOARD_FOFI_CALIBRATION /* Enable factory calibration */
+
+/* On-board crystals */
+
+#define BOARD_XTAL_FREQUENCY 12000000 /* 12MHz XTAL */
+#define BOARD_RTC_XTAL_FREQUENCY 32769 /* 32.768KHz RTC XTAL */
+
+/* TODO: enable the RTC osc, use RTC for time/date
+ */
+
+/* Select the external crystal as the PLL clock source */
+
+#define BOARD_PLL_CLOCKSRC_XTAL 1 /* PLL Clock source == extnernal crystal */
+#undef BOARD_PLL_CLOCKSRC_OFI /* PLL Clock source != internal fast oscillator */
+
+/* PLL Configuration:
+ *
+ * fXTAL = 12Mhz
+ * 260 MHz <= fVCO <= 520 MHz
+ *
+ * fVCO = fXTAL * ndiv / pdiv
+ * fPLL = fVCO / k2div
+ * fSYS = fPLL / sysdiv
+ * fETH = fSYS / 2 (fixed div by 2)
+ * fCCU = fSYS / ccudiv (div by 1 or 2)
+ * fCPU = fSYS / cpudiv (div by 1 or 2)
+ * fPERIPH = fCPU / pbdiv (div by 1 or 2)
+ */
+
+#define BOARD_ENABLE_PLL 1 /* enable the PLL */
+#define CPU_FREQ 120 /* MHz */
+
+/* TODO: Automate PLL calculations */
+
+#if CPU_FREQ == 120
+
+/* 120 MHz
+ *
+ * fVCO = 12MHz * 40 / 2 = 480MHz
+ * fPLL = 480MHz / 2 = 240MHz
+ * fSYS = fPLL / 2 = 120MHz
+ * fCCU = fSYS / 2 = 60MHz
+ * fCPU = fSYS / 1 = 120MHz
+ * fPB = fCPU / 2 = 60MHz
+ * fETH = fSYS / 2 = 60MHz
+ */
+
+# define BOARD_PLL_NDIV 40
+# define BOARD_PLL_PDIV 1
+# define BOARD_PLL_K2DIV 4
+# define BOARD_PLL_SYSDIV 1
+# define BOARD_PLL_CPUDIV 1
+# define BOARD_PLL_PBDIV 2
+# define BOARD_PLL_CCUDIV 2
+# define BOARD_PLL_EBUDIV 4
+
+#elif CPU_FREQ == 144
+
+/* 144 MHz
+ *
+ * fVCO = 12MHz * 36 / 1 = 432MHz
+ * fPLL = 432MHz / 3 = 144MHz
+ * fSYS = fPLL / 1 = 144MHz
+ * fCCU = fSYS / 2 = 72MHz
+ * fCPU = fSYS / 1 = 144MHz
+ * fPB = fCPU / 2 = 72MHz
+ * fETH = fSYS / 2 = 72MHz
+ */
+
+# define BOARD_PLL_NDIV 36
+# define BOARD_PLL_PDIV 1
+# define BOARD_PLL_K2DIV 3
+# define BOARD_PLL_SYSDIV 1
+# define BOARD_PLL_CPUDIV 1
+# define BOARD_PLL_PBDIV 2
+# define BOARD_PLL_CCUDIV 2
+# define BOARD_PLL_EBUDIV 2
+
+#else
+# error "Illegal or Unsupported CPU Frequency"
+#endif
+
+# define BOARD_CCUDIV_ENABLE (BOARD_PLL_CCUDIV - 1)
+# define BOARD_CPUDIV_ENABLE (BOARD_PLL_CPUDIV - 1)
+
+# define BOARD_VCO_FREQUENCY (BOARD_XTAL_FREQUENCY * BOARD_PLL_NDIV / BOARD_PLL_PDIV)
+# define BOARD_PLL_FREQUENCY (BOARD_VCO_FREQUENCY / BOARD_PLL_K2DIV)
+# define BOARD_SYS_FREQUENCY (BOARD_PLL_FREQUENCY / BOARD_PLL_SYSDIV)
+# define BOARD_CCU_FREQUENCY (BOARD_SYS_FREQUENCY / BOARD_PLL_CCUDIV)
+# define BOARD_CPU_FREQUENCY (BOARD_SYS_FREQUENCY / BOARD_PLL_CPUDIV)
+# define BOARD_PERIPH_FREQUENCY (BOARD_CPU_FREQUENCY / BOARD_PLL_PBDIV)
+# define BOARD_ETH_FREQUENCY (BOARD_SYS_FREQUENCY / 2)
+
+# define BOARD_WDT_SOURCE WDT_CLKSRC_FOFI
+# define BOARD_WDTDIV 1
+# define BOARD_WDT_FREQUENCY 24000000
+
+# define BOARD_EXT_SOURCE EXT_CLKSRC_FPLL
+# define BOARD_PLL_ECKDIV 480 /* [1,512] */
+
+# define kHz_1 1000
+# define MHz_1 (kHz_1 * kHz_1)
+# define MHz_50 ( 50 * MHz_1)
+# define MHz_260 (260 * MHz_1)
+# define MHz_520 (520 * MHz_1)
+
+/* range check VCO frequency */
+
+# if (BOARD_VCO_FREQUENCY < MHz_260)
+# error "VCO freq must be >= 260 MHz"
+# endif
+
+# if (BOARD_VCO_FREQUENCY > MHz_520)
+# error "VCO freq must be <= 520 MHz"
+# endif
+
+/* range check Ethernet MAC frequency */
+
+# if (BOARD_ETH_FREQUENCY <= MHz_50)
+# error "ETH freq must be > 50 MHz"
+# endif
+
+/* check ccudiv cpudiv pbdiv against Table 11-5
+ * of XMC4800 User Manual
+ */
+
+#define CLKDIV_INDEX (4 * (BOARD_PLL_CCUDIV-1) + \
+ 2 * (BOARD_PLL_CPUDIV-1) + \
+ (BOARD_PLL_PBDIV-1) )
+
+#if (CLKDIV_INDEX == 3) || (CLKDIV_INDEX == 4) || (CLKDIV_INDEX > 6)
+# error "Illegal combination of dividers! Ref: Table 11-5 of UM"
+#endif
+
+/* EXT clock settings */
+
+#define BOARD_EXTCKL_ENABLE 1 /* 0 disables output */
+
+#if BOARD_EXTCKL_ENABLE
+# define EXTCLK_PIN_P0_8 8
+# define EXTCLK_PIN_P1_15 15
+# define BOARD_EXTCLK_PIN EXTCLK_PIN_P0_8
+# define BOARD_EXT_SOURCE EXT_CLKSRC_FPLL
+# define BOARD_EXT_FREQUENCY (250 * kHz_1) /* Desired output freq */
+# define BOARD_EXTDIV (BOARD_PLL_FREQUENCY / BOARD_EXT_FREQUENCY)
+
+/* range check EXTDIV */
+
+# if BOARD_EXTDIV > 512
+# error "EXTCLK Divisor out of range!"
+# endif
+#endif
+
+/* Standby clock source selection
+ *
+ * BOARD_STDBY_CLOCKSRC_OSI - Internal 32.768KHz slow oscillator
+ * BOARD_STDBY_CLOCKSRC_OSCULP - External 32.768KHz crystal
+ */
+
+#define BOARD_STDBY_CLOCKSRC_OSI 1
+#undef BOARD_STDBY_CLOCKSRC_OSCULP
+#define BOARD_STDBY_FREQUENCY 32768
+
+/* USB PLL settings.
+ *
+ * fUSBPLL = 48MHz and fUSBPLLVCO = 384 MHz
+ *
+ * Note: Implicit divider of 2 and fUSBPLLVCO >= 260 MHz and
+ * fUSBPLLVCO <= 520 MHz
+ */
+
+#undef BOARD_ENABLE_USBPLL
+#define BOARD_USB_PDIV 2
+#define BOARD_USB_NDIV 64
+
+/* FLASH wait states */
+
+#define BOARD_FLASH_WS 5
+
+/* LED definitions **********************************************************/
+
+/* The XMC4800 Relax board has two LEDs:
+ *
+ * LED1 P5.9 High output illuminates
+ * LED2 P5.8 High output illuminates
+ *
+ * If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in
+ * any way.
+ * The following definitions are used to access individual LEDs.
+ */
+
+/* LED index values for use with board_userled() */
+
+#define BOARD_LED0 0
+#define BOARD_LED1 1
+#define BOARD_NLEDS 2
+
+/* LED bits for use with board_userled_all() */
+
+#define BOARD_LED0_BIT (1 << BOARD_LED0)
+#define BOARD_LED1_BIT (1 << BOARD_LED1)
+
+/* 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/sam_autoleds.c. The LEDs are used to encode
+ * OS-related events as follows:
+ *
+ * SYMBOL Meaning LED state
+ * LED2 LED1
+ * --------------------- -------------------------- ------ ------
+ */
+
+#define LED_STARTED 0 /* NuttX has been started OFF OFF */
+#define LED_HEAPALLOCATE 0 /* Heap has been allocated OFF OFF */
+#define LED_IRQSENABLED 0 /* Interrupts enabled OFF OFF */
+#define LED_STACKCREATED 1 /* Idle stack created ON OFF */
+#define LED_INIRQ 2 /* In an interrupt No change */
+#define LED_SIGNAL 2 /* In a signal handler No change */
+#define LED_ASSERTION 2 /* An assertion failed No change */
+#define LED_PANIC 3 /* The system has crashed N/C Blinking */
+#undef LED_IDLE /* MCU is is sleep mode Not used */
+
+/* Thus if LED1 is statically on, NuttX has successfully booted and is,
+ * apparently, running normally. If LED2 is flashing at approximately
+ * 2Hz, then a fatal error has been detected and the system has halted.
+ */
+
+/* Button definitions *******************************************************/
+
+/* The XMC4800 Relax board has two buttons:
+ *
+ * BUTTON1 P15.13 Low input sensed when button pressed
+ * BUTTON2 P15.12 Low input sensed when button pressed
+ */
+
+#define BUTTON_0 0
+#define BUTTON_1 1
+#define NUM_BUTTONS 2
+
+#define BUTTON_0_BIT (1 << BUTTON_0)
+#define BUTTON_1_BIT (1 << BUTTON_1)
+
+/* USIC0 ********************************************************************/
+
+/* USIC0 CH0 is used as UART0
+ *
+ * RX - P1.4
+ * TX - P1.5
+ */
+
+#define BOARD_UART0_DX USIC_DXB
+#define GPIO_UART0_RXD GPIO_U0C0_DX0B
+#define GPIO_UART0_TXD (GPIO_U0C0_DOUT0_3 | GPIO_PADA1P_STRONGSOFT | GPIO_OUTPUT_SET)
+
+/* USIC2 CH0 is used as SPI4
+ *
+ * MOSI - P3.8 (UC2C0.DOUT0)
+ * MISO - P3.7 (UC2C0.DX0C)
+ * SCLK - P3.9 (UC2C0.SCLKOUT)
+ */
+
+#define BOARD_SPI_DX USIC_DXC
+#define GPIO_SPI4_MOSI (GPIO_U2C0_DOUT0_2 | GPIO_PADA2_STRONGMEDIUM)
+#define GPIO_SPI4_MISO (GPIO_U2C0_DX0C)
+#define GPIO_SPI4_SCLK (GPIO_U2C0_SCLKOUT_1 | GPIO_PADA2_STRONGMEDIUM)
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __BOARDS_ARM_XMC4_XMC4800_RELAX_INCLUDE_BOARD_H */
diff --git a/boards/arm/xmc4/xmc4800-relax/scripts/Make.defs b/boards/arm/xmc4/xmc4800-relax/scripts/Make.defs
new file mode 100644
index 0000000000..2de14ea75b
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/scripts/Make.defs
@@ -0,0 +1,46 @@
+############################################################################
+# boards/arm/xmc4/xmc4800-relax/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
+
+LDSCRIPT = flash.ld
+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
+
+# Loadable module definitions
+
+CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
+
+LDMODULEFLAGS = -r -e module_initialize
+LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
diff --git a/boards/arm/xmc4/xmc4800-relax/scripts/flash.ld b/boards/arm/xmc4/xmc4800-relax/scripts/flash.ld
new file mode 100644
index 0000000000..ea554ecd7e
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/scripts/flash.ld
@@ -0,0 +1,127 @@
+/****************************************************************************
+ * boards/arm/xmc4/xmc4800-relax/scripts/flash.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 XMC4800 has 2048Kb of FLASH accessible via:
+* 1) the cacheable address space at 0x0800:0000
+* 2) the non-cacheable address space at 0x0c00:0000
+*
+* The on-chip SRAM is split up into three blocks:
+* 1) 96Kb of program memory beginning at the address 0x1ffe:8000
+* 2) 128Kb of data memory beginning at the address 0x2000:0000
+* 3) 128Kb of communication memory beginning at the address 0x2002:0000
+*/
+
+MEMORY
+{
+ flash (rx) : ORIGIN = 0x0c000000, LENGTH = 2048K
+ psram (rwx) : ORIGIN = 0x1ffe8000, LENGTH = 96K
+ sram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K
+ dsram1 (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
+ dsram2 (rwx) : ORIGIN = 0x20020000, LENGTH = 128K
+}
+
+OUTPUT_ARCH(arm)
+ENTRY(_stext)
+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(.);
+ } > 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
+
+ __exidx_start = ABSOLUTE(.);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx*)
+ } > flash
+ __exidx_end = ABSOLUTE(.);
+
+ _eronly = ABSOLUTE(.);
+
+ .data :
+ {
+ _sdata = ABSOLUTE(.);
+ *(.data .data.*)
+ *(.gnu.linkonce.d.*)
+ CONSTRUCTORS
+ . = ALIGN(4);
+ _edata = ABSOLUTE(.);
+ } > sram AT > flash
+
+ .bss :
+ {
+ _sbss = ABSOLUTE(.);
+ *(.bss .bss.*)
+ *(.gnu.linkonce.b.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = ABSOLUTE(.);
+ } > sram
+
+ /* Global data not cleared after reset. */
+
+ .noinit :
+ {
+ _snoinit = ABSOLUTE(.);
+ *(.noinit*)
+ _enoinit = 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/xmc4/xmc4800-relax/src/Makefile b/boards/arm/xmc4/xmc4800-relax/src/Makefile
new file mode 100644
index 0000000000..2138d5de4a
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/src/Makefile
@@ -0,0 +1,43 @@
+############################################################################
+# boards/arm/xmc4/xmc4800-relax/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 = xmc4_boot.c xmc4_bringup.c
+
+ifeq ($(CONFIG_INPUT_BUTTONS),y)
+CSRCS += xmc4_buttons.c
+endif
+
+ifeq ($(CONFIG_ARCH_LEDS),y)
+CSRCS += xmc4_autoleds.c
+else
+CSRCS += xmc4_userleds.c
+endif
+
+ifeq ($(CONFIG_XMC4_USCI_SPI),y)
+CSRCS += xmc4_spi.c
+endif
+
+ifeq ($(CONFIG_BOARDCTL),y)
+CSRCS += xmc4_appinit.c
+endif
+
+include $(TOPDIR)/boards/Board.mk
diff --git a/boards/arm/xmc4/xmc4800-relax/src/xmc4800-relax.h b/boards/arm/xmc4/xmc4800-relax/src/xmc4800-relax.h
new file mode 100644
index 0000000000..e47b8cab83
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/src/xmc4800-relax.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+ * boards/arm/xmc4/xmc4800-relax/src/xmc4800-relax.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_XMC4_XMC4800_RELAX_SRC_XMC4800_RELAX_H
+#define __BOARDS_ARM_XMC4_XMC4800_RELAX_SRC_XMC4800_RELAX_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include "xmc4_gpio.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* LEDs
+ *
+ * The XMC4800 Relax board has two LEDs:
+ *
+ * LED1 P5.9, Pad type A1+, High output illuminates
+ * LED2 P5.8, Pad type A1+ High output illuminates
+ */
+
+#define GPIO_LED1 (GPIO_OUTPUT | GPIO_OUTPUT_PUSHPULL | \
+ GPIO_PADA1P_STRONGSOFT | GPIO_PINCTRL_SOFTWARE | \
+ GPIO_OUTPUT_CLEAR | GPIO_PORT5 | GPIO_PIN9)
+#define GPIO_LED2 (GPIO_OUTPUT | GPIO_OUTPUT_PUSHPULL | \
+ GPIO_PADA1P_STRONGSOFT | GPIO_PINCTRL_SOFTWARE | \
+ GPIO_OUTPUT_CLEAR | GPIO_PORT5 | GPIO_PIN8)
+
+/* BUTTONS
+ *
+ * The XMC4800 Relax board has two buttons:
+ *
+ * BUTTON1 P15.13, Pad type A2, Low input sensed when button pressed
+ * BUTTON2 P15.12, Pad type A2, Low input sensed when button pressed
+ */
+
+#define GPIO_BUTTON1 (GPIO_INPUT | GPIO_PINCTRL_SOFTWARE | \
+ GPIO_PORT15 | GPIO_PIN13)
+#define GPIO_BUTTON2 (GPIO_INPUT | GPIO_PINCTRL_SOFTWARE | \
+ GPIO_PORT15 | GPIO_PIN12)
+
+/* SPIs Chip select */
+
+#define GPIO_CS (GPIO_OUTPUT | GPIO_OUTPUT_PUSHPULL | \
+ GPIO_PADA1P_STRONGSOFT | GPIO_PINCTRL_SOFTWARE | \
+ GPIO_OUTPUT_SET | GPIO_PORT3 | GPIO_PIN10)
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: xmc4_bringup
+ *
+ * Description:
+ * Bring up board features
+ *
+ ****************************************************************************/
+
+int xmc4_bringup(void);
+
+#endif /* __ASSEMBLY__ */
+#endif /* __BOARDS_ARM_XMC4_XMC4800_RELAX_SRC_XMC4800_RELAX_H */
diff --git a/boards/arm/xmc4/xmc4800-relax/src/xmc4_appinit.c b/boards/arm/xmc4/xmc4800-relax/src/xmc4_appinit.c
new file mode 100644
index 0000000000..0e18b041b2
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/src/xmc4_appinit.c
@@ -0,0 +1,71 @@
+/****************************************************************************
+ * boards/arm/xmc4/xmc4800-relax/src/xmc4_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 <stdint.h>
+
+#include <arch/board/board.h>
+
+#include "xmc4800-relax.h"
+
+/****************************************************************************
+ * 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)
+{
+#ifndef CONFIG_BOARD_LATE_INITIALIZE
+ /* Perform board initialization */
+
+ return xmc4_bringup();
+#else
+ return OK;
+#endif /* CONFIG_BOARD_LATE_INITIALIZE */
+}
diff --git a/boards/arm/xmc4/xmc4800-relax/src/xmc4_autoleds.c b/boards/arm/xmc4/xmc4800-relax/src/xmc4_autoleds.c
new file mode 100644
index 0000000000..683bc786a5
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/src/xmc4_autoleds.c
@@ -0,0 +1,177 @@
+/****************************************************************************
+ * boards/arm/xmc4/xmc4800-relax/src/xmc4_autoleds.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.
+ *
+ ****************************************************************************/
+
+/* The XMC4800 Relax Lite v1 board has two LEDs:
+ *
+ * LED1 P5.9 High output illuminates
+ * LED2 P5.8 High output illuminates
+ *
+ * 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/sam_autoleds.c. The LEDs are used to encode
+ * OS-related events as follows:
+ *
+ * SYMBOL Meaning LED state
+ * LED1 LED2
+ * ------------------ ------------------------ ------ ------
+ * LED_STARTED NuttX has been started OFF OFF
+ * LED_HEAPALLOCATE Heap has been allocated OFF OFF
+ * LED_IRQSENABLED Interrupts enabled OFF OFF
+ * LED_STACKCREATED Idle stack created ON OFF
+ * LED_INIRQ In an interrupt No change
+ * LED_SIGNAL In a signal handler No change
+ * LED_ASSERTION An assertion failed No change
+ * LED_PANIC The system has crashed N/C Blinking
+ * LED_IDLE MCU is is sleep mode Not used
+ */
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/board.h>
+#include <arch/board/board.h>
+
+#include "xmc4_gpio.h"
+#include "xmc4800-relax.h"
+
+#ifdef CONFIG_ARCH_LEDS
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static void board_led1_on(int led)
+{
+ bool ledon = false;
+
+ switch (led)
+ {
+ case 0: /* LED1=OFF */
+ break;
+
+ case 1: /* LED1=ON */
+ ledon = true;
+ break;
+
+ case 2: /* LED1=N/C */
+ case 3: /* LED1=N/C */
+ default:
+ return;
+ }
+
+ xmc4_gpio_write(GPIO_LED1, ledon);
+}
+
+static void board_led2_on(int led)
+{
+ bool ledon = false;
+
+ switch (led)
+ {
+ case 0: /* LED2=OFF */
+ case 1: /* LED2=OFF */
+ break;
+
+ case 3: /* LED2=ON */
+ ledon = true;
+ break;
+
+ case 2: /* LED2=N/C */
+ default:
+ return;
+ }
+
+ xmc4_gpio_write(GPIO_LED2, ledon);
+}
+
+static void board_led1_off(int led)
+{
+ switch (led)
+ {
+ case 0: /* LED1=OFF */
+ case 1: /* LED1=OFF */
+ break;
+
+ case 2: /* LED1=N/C */
+ case 3: /* LED1=N/C */
+ default:
+ return;
+ }
+
+ xmc4_gpio_write(GPIO_LED1, false);
+}
+
+static void board_led2_off(int led)
+{
+ switch (led)
+ {
+ case 0: /* LED2=OFF */
+ case 1: /* LED2=OFF */
+ case 3: /* LED2=OFF */
+ break;
+
+ case 2: /* LED2=N/C */
+ default:
+ return;
+ }
+
+ xmc4_gpio_write(GPIO_LED2, false);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_autoled_initialize
+ ****************************************************************************/
+
+void board_autoled_initialize(void)
+{
+ /* Configure LED1-2 GPIOs for output */
+
+ xmc4_gpio_config(GPIO_LED1);
+ xmc4_gpio_config(GPIO_LED2);
+}
+
+/****************************************************************************
+ * Name: board_autoled_on
+ ****************************************************************************/
+
+void board_autoled_on(int led)
+{
+ board_led1_on(led);
+ board_led2_on(led);
+}
+
+/****************************************************************************
+ * Name: board_autoled_off
+ ****************************************************************************/
+
+void board_autoled_off(int led)
+{
+ board_led1_off(led);
+ board_led2_off(led);
+}
+
+#endif /* CONFIG_ARCH_LEDS */
diff --git a/boards/arm/xmc4/xmc4800-relax/src/xmc4_boot.c b/boards/arm/xmc4/xmc4800-relax/src/xmc4_boot.c
new file mode 100644
index 0000000000..2a41dde74c
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/src/xmc4_boot.c
@@ -0,0 +1,80 @@
+/****************************************************************************
+ * boards/arm/xmc4/xmc4800-relax/src/xmc4_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 <nuttx/board.h>
+#include <arch/board/board.h>
+
+#include "xmc4800-relax.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: xmc4_board_initialize
+ *
+ * Description:
+ * All XMC4 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 xmc4_board_initialize(void)
+{
+#ifdef CONFIG_ARCH_LEDS
+ /* Configure on-board LEDs if LED support has been selected. */
+
+ board_autoled_initialize();
+#endif
+
+#ifdef CONFIG_XMC4_USCI_SPI
+ xmc4_spidev_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 initialization */
+
+ xmc4_bringup();
+}
+#endif /* CONFIG_BOARD_LATE_INITIALIZE */
diff --git a/boards/arm/xmc4/xmc4800-relax/src/xmc4_bringup.c b/boards/arm/xmc4/xmc4800-relax/src/xmc4_bringup.c
new file mode 100644
index 0000000000..97ea35c150
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/src/xmc4_bringup.c
@@ -0,0 +1,81 @@
+/****************************************************************************
+ * boards/arm/xmc4/xmc4800-relax/src/xmc4_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 <debug.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#ifdef CONFIG_XMC4_USCI_SPI
+# include <nuttx/spi/spi_transfer.h>
+#endif
+#ifdef CONFIG_USERLED
+# include <nuttx/leds/userled.h>
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: xmc4_bringup
+ *
+ * Description:
+ * Bring up board features
+ *
+ ****************************************************************************/
+
+int xmc4_bringup(void)
+{
+ int ret = OK;
+
+#ifdef CONFIG_XMC4_USCI_SPI
+ struct spi_dev_s *spi;
+ spi = xmc4_spibus_initialize(4);
+
+ if (!spi)
+ {
+ return -ENODEV;
+ }
+
+ ret = spi_register(spi, 0);
+ if (ret < 0)
+ {
+ snerr("ERROR: Failed to register driver: %d\n", ret);
+ }
+#endif
+
+#ifdef CONFIG_USERLED
+ /* Register the LED driver */
+
+ ret = userled_lower_initialize("/dev/userleds");
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
+ }
+#endif
+
+ return ret;
+}
diff --git a/boards/arm/xmc4/xmc4800-relax/src/xmc4_buttons.c b/boards/arm/xmc4/xmc4800-relax/src/xmc4_buttons.c
new file mode 100644
index 0000000000..dc997bbd1a
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/src/xmc4_buttons.c
@@ -0,0 +1,64 @@
+/****************************************************************************
+ * boards/arm/xmc4/xmc4800-relax/src/xmc4_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 <nuttx/config.h>
+
+#include <arch/board/board.h>
+#include "xmc4800-relax.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_button_initialize
+ ****************************************************************************/
+
+uint32_t board_button_initialize(void)
+{
+#warning Missing logic
+ return 0;
+}
+
+/****************************************************************************
+ * Name: board_buttons
+ ****************************************************************************/
+
+uint32_t board_buttons(void)
+{
+#warning Missing logic
+ return 0;
+}
+
+/****************************************************************************
+ * Name: board_button_irq
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_IRQBUTTONS
+int board_button_irq(int id, xcpt_t irqhandler, void *arg)
+{
+#warning Missing logic
+ return -ENOSYS;
+}
+#endif /* CONFIG_ARCH_IRQBUTTONS */
diff --git a/boards/arm/xmc4/xmc4800-relax/src/xmc4_spi.c b/boards/arm/xmc4/xmc4800-relax/src/xmc4_spi.c
new file mode 100644
index 0000000000..9923f119dc
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/src/xmc4_spi.c
@@ -0,0 +1,280 @@
+/****************************************************************************
+ * boards/arm/xmc4/xmc4800-relax/src/xmc4_spi.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 <errno.h>
+#include <stdbool.h>
+
+#include <nuttx/spi/spi.h>
+
+#include "xmc4800-relax.h"
+#include "xmc4_gpio.h"
+#include "xmc4_spi.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: xmc4_spidev_initialize
+ *
+ * Description:
+ * Called to configure SPI chip select GPIO pins.
+ *
+ ****************************************************************************/
+
+void weak_function xmc4_spidev_initialize(void)
+{
+ /* Configure SPI0 chip selects */
+
+#ifdef CONFIG_XMC4_SPI0
+#endif
+
+ /* Configure SPI1 chip selects */
+
+#ifdef CONFIG_XMC4_SPI1
+#endif
+
+ /* Configure SPI2 chip selects */
+
+#if defined(CONFIG_XMC4_SPI2)
+#endif
+
+ /* Configure SPI3 chip selects */
+
+#ifdef CONFIG_XMC4_SPI3
+#endif
+
+ /* Configure SPI4 chip selects */
+
+#ifdef CONFIG_XMC4_SPI4
+ xmc4_gpio_config(GPIO_CS);
+#endif
+}
+
+/****************************************************************************
+ * Name: xmc4_spi[n]select, xmc4_spi[n]status, and xmc4_spi[n]cmddata
+ *
+ * Description:
+ * These external functions must be provided by board-specific logic. They
+ * are implementations of the select, status, and cmddata methods of the
+ * SPI interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
+ * All other methods including xmc4_spibus_initialize()) are provided by
+ * common xmc4 logic. To use this common SPI logic on your board:
+ *
+ * 1. Provide logic in xmc4_boardinitialize() to configure SPI chip select
+ * pins.
+ * 2. Provide xmc4_spi[n]select() and xmc4_spi[n]status() functions
+ * in your board-specific logic. These functions will perform chip
+ * selection and status operations using GPIOs in the way your board
+ * is configured.
+ * 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
+ * xmc4_spi[n]cmddata() functions in your board-specific logic. These
+ * functions will perform cmd/data selection operations using GPIOs in
+ * the way your board is configured.
+ * 3. Add a call to xmc4_spibus_initialize() in your low level application
+ * initialization logic
+ * 4. The handle returned by xmc4_spibus_initialize() may then be used to
+ * bind the SPI driver to higher level logic (e.g., calling
+ * mmcsd_spislotinitialize(), for example, will bind the SPI driver to
+ * the SPI MMC/SD driver).
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: xmc4_spi[n]select
+ *
+ * Description:
+ * PIO chip select pins may be programmed by the board specific logic in
+ * one of two different ways. First, the pins may be programmed as SPI
+ * peripherals. In that case, the pins are completely controlled by the
+ * SPI driver. This method still needs to be provided, but it may be only
+ * a stub.
+ *
+ * An alternative way to program the PIO chip select pins is as a normal
+ * GPIO output. In that case, the automatic control of the CS pins is
+ * bypassed and this function must provide control of the chip select.
+ * NOTE: In this case, the GPIO output pin does *not* have to be the
+ * same as the NPCS pin normal associated with the chip select number.
+ *
+ * Input Parameters:
+ * devid - Identifies the (logical) device
+ * selected - TRUE:Select the device, FALSE:De-select the device
+ *
+ * Returned Values:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_XMC4_SPI0
+void xmc4_spi0select(struct spi_dev_s *dev, uint32_t devid,
+ bool selected)
+{
+ spiinfo("devid: %d CS: %s\n",
+ (int)devid, selected ? "assert" : "de-assert");
+}
+#endif
+
+#ifdef CONFIG_XMC4_SPI1
+void xmc4_spi1select(struct spi_dev_s *dev, uint32_t devid,
+ bool selected)
+{
+ spiinfo("devid: %d CS: %s\n",
+ (int)devid, selected ? "assert" : "de-assert");
+}
+#endif
+
+#ifdef CONFIG_XMC4_SPI2
+void xmc4_spi2select(struct spi_dev_s *dev, uint32_t devid,
+ bool selected)
+{
+ spiinfo("devid: %d CS: %s\n",
+ (int)devid, selected ? "assert" : "de-assert");
+}
+#endif
+
+#ifdef CONFIG_XMC4_SPI3
+void xmc4_spi3select(struct spi_dev_s *dev, uint32_t devid,
+ bool selected)
+{
+ spiinfo("devid: %d CS: %s\n",
+ (int)devid, selected ? "assert" : "de-assert");
+}
+#endif
+
+#ifdef CONFIG_XMC4_SPI4
+void xmc4_spi4select(struct spi_dev_s *dev, uint32_t devid,
+ bool selected)
+{
+ spiinfo("devid: %d CS: %s\n",
+ (int)devid, selected ? "assert" : "de-assert");
+
+ xmc4_gpio_write(GPIO_CS, !selected);
+}
+#endif
+
+/****************************************************************************
+ * Name: xmc4_spi[n]status
+ *
+ * Description:
+ * Return status information associated with the SPI device.
+ *
+ * Input Parameters:
+ * devid - Identifies the (logical) device
+ *
+ * Returned Values:
+ * Bit-encoded SPI status (see include/nuttx/spi/spi.h).
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_XMC4_SPI0
+uint8_t xmc4_spi0status(struct spi_dev_s *dev, uint32_t devid)
+{
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_XMC4_SPI1
+uint8_t xmc4_spi1status(struct spi_dev_s *dev, uint32_t devid)
+{
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_XMC4_SPI2
+uint8_t xmc4_spi2status(struct spi_dev_s *dev, uint32_t devid)
+{
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_XMC4_SPI3
+uint8_t xmc4_spi3status(struct spi_dev_s *dev, uint32_t devid)
+{
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_XMC4_SPI4
+uint8_t xmc4_spi4status(struct spi_dev_s *dev, uint32_t devid)
+{
+ return 0;
+}
+#endif
+
+/****************************************************************************
+ * Name: xmc4_spi[n]cmddata
+ *
+ * Description:
+ * Some SPI interfaces, particularly with LCDs, and an auxiliary 9th data
+ * input that determines where the other 8 data bits represent command or
+ * data. These interfaces control that CMD/DATA GPIO output
+ *
+ * Input Parameters:
+ * devid - Identifies the (logical) device
+ * cmd - Determines where command or data should be selected.
+ *
+ * Returned Values:
+ * Bit-encoded SPI status (see include/nuttx/spi/spi.h).
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SPI_CMDDATA
+#ifdef CONFIG_XMC4_SPI0
+int xmc4_spi0cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
+{
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_XMC4_SPI1
+int xmc4_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
+{
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_XMC4_SPI2
+int xmc4_spi2cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
+{
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_XMC4_SPI3
+int xmc4_spi3cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
+{
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_XMC4_SPI4
+int xmc4_spi4cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
+{
+ return 0;
+}
+#endif
+#endif /* CONFIG_SPI_CMDDATA */
diff --git a/boards/arm/xmc4/xmc4800-relax/src/xmc4_userleds.c b/boards/arm/xmc4/xmc4800-relax/src/xmc4_userleds.c
new file mode 100644
index 0000000000..a4cdac0d49
--- /dev/null
+++ b/boards/arm/xmc4/xmc4800-relax/src/xmc4_userleds.c
@@ -0,0 +1,87 @@
+/****************************************************************************
+ * boards/arm/xmc4/xmc4800-relax/src/xmc4_userleds.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 <arch/board/board.h>
+
+#include "xmc4_gpio.h"
+#include "xmc4800-relax.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_userled_initialize
+ ****************************************************************************/
+
+uint32_t board_userled_initialize(void)
+{
+ /* Configure LED1-2 GPIOs for output */
+
+ xmc4_gpio_config(GPIO_LED1);
+ xmc4_gpio_config(GPIO_LED2);
+ return BOARD_NLEDS;
+}
+
+/****************************************************************************
+ * Name: board_userled
+ ****************************************************************************/
+
+void board_userled(int led, bool ledon)
+{
+ gpioconfig_t ledcfg;
+
+ if (led == BOARD_LED0)
+ {
+ ledcfg = GPIO_LED1;
+ }
+ else if (led == BOARD_LED1)
+ {
+ ledcfg = GPIO_LED2;
+ }
+ else
+ {
+ return;
+ }
+
+ xmc4_gpio_write(ledcfg, ledon);
+}
+
+/****************************************************************************
+ * Name: board_userled_all
+ ****************************************************************************/
+
+void board_userled_all(uint32_t ledset)
+{
+ bool ledon;
+
+ ledon = ((ledset & BOARD_LED0_BIT) != 0);
+ xmc4_gpio_write(GPIO_LED1, ledon);
+
+ ledon = ((ledset & BOARD_LED1_BIT) != 0);
+ xmc4_gpio_write(GPIO_LED2, ledon);
+}