From 598ebd29a240497e148a89800897f4044c8d54ff Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 17 Oct 2014 12:02:32 -0600 Subject: [PATCH] More EFM32 files and logic --- arch/arm/src/efm32/Kconfig | 0 arch/arm/src/efm32/Make.defs | 103 +++++++++++ arch/arm/src/efm32/chip.h | 73 ++++++++ arch/arm/src/efm32/chip/efm32g_vectors.h | 97 ++++++++++ arch/arm/src/efm32/chip/efm32gg_vectors.h | 104 +++++++++++ arch/arm/src/efm32/chip/efm32tg_vectors.h | 88 ++++++++++ arch/arm/src/efm32/efm32_clockconfig.h | 61 +++++++ arch/arm/src/efm32/efm32_idle.c | 96 ++++++++++ arch/arm/src/efm32/efm32_lowputc.h | 66 +++++++ arch/arm/src/efm32/efm32_start.c | 205 ++++++++++++++++++++++ arch/arm/src/efm32/efm32_start.h | 61 +++++++ configs/efm32-g8xx-stk/README.txt | 70 ++++++++ configs/efm32-g8xx-stk/include/board.h | 64 +++++++ configs/efm32-g8xx-stk/src/efm32_boot.c | 18 +- 14 files changed, 1098 insertions(+), 8 deletions(-) mode change 100755 => 100644 arch/arm/src/efm32/Kconfig create mode 100644 arch/arm/src/efm32/Make.defs create mode 100644 arch/arm/src/efm32/chip.h create mode 100644 arch/arm/src/efm32/chip/efm32g_vectors.h create mode 100644 arch/arm/src/efm32/chip/efm32gg_vectors.h create mode 100644 arch/arm/src/efm32/chip/efm32tg_vectors.h create mode 100644 arch/arm/src/efm32/efm32_clockconfig.h create mode 100644 arch/arm/src/efm32/efm32_idle.c create mode 100644 arch/arm/src/efm32/efm32_lowputc.h create mode 100644 arch/arm/src/efm32/efm32_start.c create mode 100644 arch/arm/src/efm32/efm32_start.h diff --git a/arch/arm/src/efm32/Kconfig b/arch/arm/src/efm32/Kconfig old mode 100755 new mode 100644 diff --git a/arch/arm/src/efm32/Make.defs b/arch/arm/src/efm32/Make.defs new file mode 100644 index 0000000000..b1526d3438 --- /dev/null +++ b/arch/arm/src/efm32/Make.defs @@ -0,0 +1,103 @@ +############################################################################ +# arch/arm/src/efm32/Make.defs +# +# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_ARMV7M_CMNVECTOR),y) +HEAD_ASRC = +else +HEAD_ASRC = efm32_vectors.S +endif + +CMN_UASRCS = +CMN_UCSRCS = + +CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S +CMN_ASRCS += vfork.S + +CMN_CSRCS = up_assert.c up_blocktask.c up_copyfullstate.c +CMN_CSRCS += up_createstack.c up_mdelay.c up_udelay.c up_exit.c +CMN_CSRCS += up_initialize.c up_initialstate.c up_interruptcontext.c +CMN_CSRCS += up_memfault.c up_modifyreg8.c up_modifyreg16.c up_modifyreg32.c +CMN_CSRCS += up_releasepending.c up_releasestack.c up_reprioritizertr.c +CMN_CSRCS += up_schedulesigaction.c up_sigdeliver.c up_systemreset.c +CMN_CSRCS += up_unblocktask.c up_usestack.c up_doirq.c up_hardfault.c +CMN_CSRCS += up_svcall.c up_vfork.c +CMN_CSRCS += up_allocateheap.c +CMN_CSRCS += up_stackframe.c + +ifeq ($(CONFIG_ARMV7M_CMNVECTOR),y) +CMN_ASRCS += up_exception.S +CMN_CSRCS += up_vectors.c +endif + +ifeq ($(CONFIG_ARCH_RAMVECTORS),y) +CMN_CSRCS += up_ramvec_initialize.c up_ramvec_attach.c +endif + +ifeq ($(CONFIG_ARCH_MEMCPY),y) +CMN_ASRCS += up_memcpy.S +endif + +ifeq ($(CONFIG_BUILD_PROTECTED),y) +CMN_CSRCS += up_mpu.c up_task_start.c up_pthread_start.c +ifneq ($(CONFIG_DISABLE_SIGNALS),y) +CMN_CSRCS += up_signal_dispatch.c +CMN_UASRCS += up_signal_handler.S +endif +endif + +ifeq ($(CONFIG_DEBUG_STACK),y) +CMN_CSRCS += up_checkstack.c +endif + +ifeq ($(CONFIG_ELF),y) +CMN_CSRCS += up_elf.c +endif + +ifeq ($(CONFIG_ARCH_FPU),y) +CMN_ASRCS += up_fpu.S +ifneq ($(CONFIG_ARMV7M_CMNVECTOR),y) +CMN_CSRCS += up_copyarmstate.c +endif +endif + +CHIP_ASRCS = +CHIP_CSRCS = + +CHIP_CSRCS += efm32_start.c + +ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) +CHIP_CSRCS += efm32_idle.c +endif + diff --git a/arch/arm/src/efm32/chip.h b/arch/arm/src/efm32/chip.h new file mode 100644 index 0000000000..f7effac650 --- /dev/null +++ b/arch/arm/src/efm32/chip.h @@ -0,0 +1,73 @@ +/************************************************************************************ + * arch/arm/src/efm32/chip.h + * + * Copyright (C) 2009, 2011-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014 Pierre-noel Bouteville . All rights reserved. + * Author: Gregory Nutt + * Pierre-noel Bouteville + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +#ifndef __ARCH_ARM_SRC_EFM32_CHIP_H +#define __ARCH_ARM_SRC_EFM32_CHIP_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +/* Include the chip capabilities file */ + +#include + +/* Include the chip pin configuration file */ + +#ifdef CONFIG_ARMV7M_CMNVECTOR +# if defined(CONFIG_EFM32_EFM32TG) +# include "chip/efm32tg_vectors.h" +# elif defined(CONFIG_EFM32_EFM32G) +# include "chip/efm32g_vectors.h" +# elif defined(CONFIG_EFM32_EFM32GG) +# include "chip/efm32gg_vectors.h" +# else +# error "No vector file for this EFM32 family" +# endif +#endif + +/* Include the chip memory map. */ + +//#include "chip/efm32_memorymap.h" + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +#endif /* __ARCH_ARM_SRC_EFM32_CHIP_H */ diff --git a/arch/arm/src/efm32/chip/efm32g_vectors.h b/arch/arm/src/efm32/chip/efm32g_vectors.h new file mode 100644 index 0000000000..40abe8d6d9 --- /dev/null +++ b/arch/arm/src/efm32/chip/efm32g_vectors.h @@ -0,0 +1,97 @@ +/***************************************************************************** + * arch/arm/src/efm32/chip/efm32ggxxx_vectors.h + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ + +/***************************************************************************** + * Pre-processor Definitions + *****************************************************************************/ +/* This file is included by efm32_vectors.S. It provides the macro VECTOR + * that supplies each EFM32G vector in terms of a (lower-case) ISR label and + * an (upper-case) IRQ number as defined in arch/arm/include/efm32/efm32g_irq.h. + * efm32_vectors.S will defined the VECTOR in different ways in order to + * generate the interrupt vectors and handlers in their final form. + * + * Vectors for low and medium density devices + */ + +#if defined(CONFIG_EFM32_EFM32G) + +/* If the common ARMv7-M vector handling is used, then all it needs is the + * following definition that provides the number of supported vectors. + */ + +#ifdef CONFIG_ARMV7M_CMNVECTOR + +/* Reserve 30 interrupt table entries for I/O interrupts. */ + +# define ARMV7M_PERIPHERAL_INTERRUPTS 30 + +#else + /* IRQ# Source */ + VECTOR(EFM32_IRQ_DMA, EFM32_IRQ_DMA ) /* 0 DMA */ + VECTOR(EFM32_IRQ_GPIO_EVEN, EFM32_IRQ_GPIO_EVEN ) /* 1 GPIO_EVEN */ + VECTOR(EFM32_IRQ_TIMER0, EFM32_IRQ_TIMER0 ) /* 2 TIMER0 */ + VECTOR(EFM32_IRQ_USART0_RX, EFM32_IRQ_USART0_RX ) /* 3 USART0_RX */ + VECTOR(EFM32_IRQ_USART0_TX, EFM32_IRQ_USART0_TX ) /* 4 USART0_TX */ + VECTOR(EFM32_IRQ_ACMP, EFM32_IRQ_ACMP ) /* 5 ACMP0/ACMP1 */ + VECTOR(EFM32_IRQ_ADC0, EFM32_IRQ_ADC0 ) /* 6 ADC0 */ + VECTOR(EFM32_IRQ_DAC0, EFM32_IRQ_DAC0 ) /* 7 DAC0 */ + VECTOR(EFM32_IRQ_I2C0, EFM32_IRQ_I2C0 ) /* 8 I2C0 */ + VECTOR(EFM32_IRQ_GPIO_ODD, EFM32_IRQ_GPIO_ODD ) /* 9 GPIO_ODD */ + VECTOR(EFM32_IRQ_TIMER1, EFM32_IRQ_TIMER1 ) /* 10 TIMER1 */ + VECTOR(EFM32_IRQ_TIMER2, EFM32_IRQ_TIMER2 ) /* 11 TIMER2 */ + VECTOR(EFM32_IRQ_USART1_RX, EFM32_IRQ_USART1_RX ) /* 12 USART1_RX */ + VECTOR(EFM32_IRQ_USART1_TX, EFM32_IRQ_USART1_TX ) /* 13 USART1_TX */ + VECTOR(EFM32_IRQ_USART2_RX, EFM32_IRQ_USART2_RX ) /* 14 USART2_RX */ + VECTOR(EFM32_IRQ_USART2_TX, EFM32_IRQ_USART2_TX ) /* 15 USART2_TX */ + VECTOR(EFM32_IRQ_UART0_RX, EFM32_IRQ_UART0_RX ) /* 16 UART0_RX */ + VECTOR(EFM32_IRQ_UART0_TX, EFM32_IRQ_UART0_TX ) /* 17 UART0_TX */ + VECTOR(EFM32_IRQ_LEUART0, EFM32_IRQ_LEUART0 ) /* 18 LEUART0 */ + VECTOR(EFM32_IRQ_LEUART1, EFM32_IRQ_LEUART1 ) /* 19 LEUART1 */ + VECTOR(EFM32_IRQ_LETIMER0, EFM32_IRQ_LETIMER0 ) /* 20 LETIMER0 */ + VECTOR(EFM32_IRQ_PCNT0, EFM32_IRQ_PCNT0 ) /* 21 PCNT0 */ + VECTOR(EFM32_IRQ_PCNT1, EFM32_IRQ_PCNT1 ) /* 22 PCNT1 */ + VECTOR(EFM32_IRQ_PCNT2, EFM32_IRQ_PCNT2 ) /* 23 PCNT2 */ + VECTOR(EFM32_IRQ_RTC, EFM32_IRQ_RTC ) /* 24 RTC */ + VECTOR(EFM32_IRQ_CMU, EFM32_IRQ_CMU ) /* 25 CMU */ + VECTOR(EFM32_IRQ_VCMP, EFM32_IRQ_VCMP ) /* 26 VCMP */ + VECTOR(EFM32_IRQ_LCD, EFM32_IRQ_LCD ) /* 27 LCD */ + VECTOR(EFM32_IRQ_MSC, EFM32_IRQ_MSC ) /* 28 MSC */ + VECTOR(EFM32_IRQ_AES, EFM32_IRQ_AES ) /* 29 AES */ + +#endif + +#else +# error "Unknown EFM32 Type" +#endif diff --git a/arch/arm/src/efm32/chip/efm32gg_vectors.h b/arch/arm/src/efm32/chip/efm32gg_vectors.h new file mode 100644 index 0000000000..891fd31ddf --- /dev/null +++ b/arch/arm/src/efm32/chip/efm32gg_vectors.h @@ -0,0 +1,104 @@ +/***************************************************************************** + * arch/arm/src/efm32/chip/efm32ggxxx_vectors.h + * + * Copyright (C) 2014 Pierre-noel Bouteville . All rights reserved. + * Author: Pierre-noel Bouteville + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ + +/***************************************************************************** + * Pre-processor Definitions + *****************************************************************************/ +/* This file is included by efm32_vectors.S. It provides the macro VECTOR + * that supplies each EFM32GG vector in terms of a (lower-case) ISR label and + * an (upper-case) IRQ number as defined in arch/arm/include/efm32/efm32gg_irq.h. + * efm32_vectors.S will defined the VECTOR in different ways in order to + * generate the interrupt vectors and handlers in their final form. + * + * Vectors for low and medium density devices + */ + +#if defined(CONFIG_EFM32_EFM32GG) + +/* If the common ARMv7-M vector handling is used, then all it needs is the + * following definition that provides the number of supported vectors. + */ + +#ifdef CONFIG_ARMV7M_CMNVECTOR + +/* Reserve 39 interrupt table entries for I/O interrupts. */ + +# define ARMV7M_PERIPHERAL_INTERRUPTS 39 + +#else + VECTOR(EFM32_IRQ_DMA, EFM32_IRQ_DMA ) /* 0: EFM32_IRQ_DMA */ + VECTOR(EFM32_IRQ_GPIO_EVEN, EFM32_IRQ_GPIO_EVEN ) /* 1: EFM32_IRQ_GPIO_EVEN */ + VECTOR(EFM32_IRQ_TIMER0, EFM32_IRQ_TIMER0 ) /* 2: EFM32_IRQ_TIMER0 */ + VECTOR(EFM32_IRQ_USART0_RX, EFM32_IRQ_USART0_RX ) /* 3: EFM32_IRQ_USART0_RX */ + VECTOR(EFM32_IRQ_USART0_TX, EFM32_IRQ_USART0_TX ) /* 4: EFM32_IRQ_USART0_TX */ + VECTOR(EFM32_IRQ_USB, EFM32_IRQ_USB ) /* 5: EFM32_IRQ_USB */ + VECTOR(EFM32_IRQ_ACMP, EFM32_IRQ_ACMP ) /* 6: EFM32_IRQ_ACMP */ + VECTOR(EFM32_IRQ_ADC0, EFM32_IRQ_ADC0 ) /* 7: EFM32_IRQ_ADC0 */ + VECTOR(EFM32_IRQ_DAC0, EFM32_IRQ_DAC0 ) /* 8: EFM32_IRQ_DAC0 */ + VECTOR(EFM32_IRQ_I2C0, EFM32_IRQ_I2C0 ) /* 9: EFM32_IRQ_I2C0 */ + VECTOR(EFM32_IRQ_I2C1, EFM32_IRQ_I2C1 ) /* 10: EFM32_IRQ_I2C1 */ + VECTOR(EFM32_IRQ_GPIO_ODD, EFM32_IRQ_GPIO_ODD ) /* 11: EFM32_IRQ_GPIO_ODD */ + VECTOR(EFM32_IRQ_TIMER1, EFM32_IRQ_TIMER1 ) /* 12: EFM32_IRQ_TIMER1 */ + VECTOR(EFM32_IRQ_TIMER2, EFM32_IRQ_TIMER2 ) /* 13: EFM32_IRQ_TIMER2 */ + VECTOR(EFM32_IRQ_TIMER3, EFM32_IRQ_TIMER3 ) /* 14: EFM32_IRQ_TIMER3 */ + VECTOR(EFM32_IRQ_USART1_RX, EFM32_IRQ_USART1_RX ) /* 15: EFM32_IRQ_USART1_RX */ + VECTOR(EFM32_IRQ_USART1_TX, EFM32_IRQ_USART1_TX ) /* 16: EFM32_IRQ_USART1_TX */ + VECTOR(EFM32_IRQ_LESENSE, EFM32_IRQ_LESENSE ) /* 17: EFM32_IRQ_LESENSE */ + VECTOR(EFM32_IRQ_USART2_RX, EFM32_IRQ_USART2_RX ) /* 18: EFM32_IRQ_USART2_RX */ + VECTOR(EFM32_IRQ_USART2_TX, EFM32_IRQ_USART2_TX ) /* 19: EFM32_IRQ_USART2_TX */ + VECTOR(EFM32_IRQ_UART0_RX, EFM32_IRQ_UART0_RX ) /* 20: EFM32_IRQ_UART0_RX */ + VECTOR(EFM32_IRQ_UART0_TX, EFM32_IRQ_UART0_TX ) /* 21: EFM32_IRQ_UART0_TX */ + VECTOR(EFM32_IRQ_UART1_RX, EFM32_IRQ_UART1_RX ) /* 22: EFM32_IRQ_UART1_RX */ + VECTOR(EFM32_IRQ_UART1_TX, EFM32_IRQ_UART1_TX ) /* 23: EFM32_IRQ_UART1_TX */ + VECTOR(EFM32_IRQ_LEUART0, EFM32_IRQ_LEUART0 ) /* 24: EFM32_IRQ_LEUART0 */ + VECTOR(EFM32_IRQ_LEUART1, EFM32_IRQ_LEUART1 ) /* 25: EFM32_IRQ_LEUART1 */ + VECTOR(EFM32_IRQ_LETIMER0, EFM32_IRQ_LETIMER0 ) /* 26: EFM32_IRQ_LETIMER0 */ + VECTOR(EFM32_IRQ_PCNT0, EFM32_IRQ_PCNT0 ) /* 27: EFM32_IRQ_PCNT0 */ + VECTOR(EFM32_IRQ_PCNT1, EFM32_IRQ_PCNT1 ) /* 28: EFM32_IRQ_PCNT1 */ + VECTOR(EFM32_IRQ_PCNT2, EFM32_IRQ_PCNT2 ) /* 29: EFM32_IRQ_PCNT2 */ + VECTOR(EFM32_IRQ_RTC, EFM32_IRQ_RTC ) /* 30: EFM32_IRQ_RTC */ + VECTOR(EFM32_IRQ_BURTC, EFM32_IRQ_BURTC ) /* 31: EFM32_IRQ_BURTC */ + VECTOR(EFM32_IRQ_CMU, EFM32_IRQ_CMU ) /* 32: EFM32_IRQ_CMU */ + VECTOR(EFM32_IRQ_VCMP, EFM32_IRQ_VCMP ) /* 33: EFM32_IRQ_VCMP */ + VECTOR(EFM32_IRQ_LCD, EFM32_IRQ_LCD ) /* 34: EFM32_IRQ_LCD */ + VECTOR(EFM32_IRQ_MSC, EFM32_IRQ_MSC ) /* 35: EFM32_IRQ_MSC */ + VECTOR(EFM32_IRQ_AES, EFM32_IRQ_AES ) /* 36: EFM32_IRQ_AES */ + VECTOR(EFM32_IRQ_EBI, EFM32_IRQ_EBI ) /* 37: EFM32_IRQ_EBI */ + VECTOR(EFM32_IRQ_EMI, EFM32_IRQ_EMI ) /* 38: EFM32_IRQ_EMI */ +#endif + +#else +# error "Unknown EFM32 Type" +#endif diff --git a/arch/arm/src/efm32/chip/efm32tg_vectors.h b/arch/arm/src/efm32/chip/efm32tg_vectors.h new file mode 100644 index 0000000000..b5e34e7764 --- /dev/null +++ b/arch/arm/src/efm32/chip/efm32tg_vectors.h @@ -0,0 +1,88 @@ +/***************************************************************************** + * arch/arm/src/efm32/chip/efm32tg_vectors.h + * + * Copyright (C) 2014 Pierre-noel Bouteville . All rights reserved. + * Author: Pierre-noel Bouteville + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ + +/***************************************************************************** + * Pre-processor Definitions + *****************************************************************************/ +/* This file is included by efm32_vectors.S. It provides the macro VECTOR that + * supplies ach EFM32TG vector in terms of a (lower-case) ISR label and an + * (upper-case) IRQ number as defined in arch/arm/include/efm32/efm32tg_irq.h. + * efm32_vectors.S will defined the VECTOR in different ways in order to + * generate the interrupt vectors and handlers in their final form. + * + * Vectors for low and medium density devices + */ + +#if defined(CONFIG_EFM32_EFM32TG) + +/* If the common ARMv7-M vector handling is used, then all it needs is the + * following definition that provides the number of supported vectors. + */ + +#ifdef CONFIG_ARMV7M_CMNVECTOR + +/* Reserve 23 interrupt table entries for I/O interrupts. */ + +# define ARMV7M_PERIPHERAL_INTERRUPTS 23 + +#else + VECTOR(EFM32_IRQ_DMA, EFM32_IRQ_DMA ) /* 0: EFM32_IRQ_DMA */ + VECTOR(EFM32_IRQ_GPIO_EVEN, EFM32_IRQ_GPIO_EVEN ) /* 1: EFM32_IRQ_GPIO_EVEN */ + VECTOR(EFM32_IRQ_TIMER0, EFM32_IRQ_TIMER0 ) /* 2: EFM32_IRQ_TIMER0 */ + VECTOR(EFM32_IRQ_USART0_RX, EFM32_IRQ_USART0_RX ) /* 3: EFM32_IRQ_USART0_RX */ + VECTOR(EFM32_IRQ_USART0_TX, EFM32_IRQ_USART0_TX ) /* 4: EFM32_IRQ_USART0_TX */ + VECTOR(EFM32_IRQ_ACMP, EFM32_IRQ_ACMP ) /* 5: EFM32_IRQ_ACMP */ + VECTOR(EFM32_IRQ_ADC0, EFM32_IRQ_ADC0 ) /* 6: EFM32_IRQ_ADC0 */ + VECTOR(EFM32_IRQ_DAC0, EFM32_IRQ_DAC0 ) /* 7: EFM32_IRQ_DAC0 */ + VECTOR(EFM32_IRQ_I2C0, EFM32_IRQ_I2C0 ) /* 8: EFM32_IRQ_I2C0 */ + VECTOR(EFM32_IRQ_GPIO_ODD, EFM32_IRQ_GPIO_ODD ) /* 9: EFM32_IRQ_GPIO_ODD */ + VECTOR(EFM32_IRQ_TIMER1, EFM32_IRQ_TIMER1 ) /* 10: EFM32_IRQ_TIMER1 */ + VECTOR(EFM32_IRQ_USART1_RX, EFM32_IRQ_USART1_RX ) /* 11: EFM32_IRQ_USART1_RX */ + VECTOR(EFM32_IRQ_USART1_TX, EFM32_IRQ_USART1_TX ) /* 12: EFM32_IRQ_USART1_TX */ + VECTOR(EFM32_IRQ_LESENSE, EFM32_IRQ_LESENSE ) /* 13: EFM32_IRQ_LESENSE */ + VECTOR(EFM32_IRQ_LEUART0, EFM32_IRQ_LEUART0 ) /* 14: EFM32_IRQ_LEUART0 */ + VECTOR(EFM32_IRQ_LETIMER0, EFM32_IRQ_LETIMER0 ) /* 15: EFM32_IRQ_LETIMER0 */ + VECTOR(EFM32_IRQ_PCNT0, EFM32_IRQ_PCNT0 ) /* 16: EFM32_IRQ_PCNT0 */ + VECTOR(EFM32_IRQ_RTC, EFM32_IRQ_RTC ) /* 17: EFM32_IRQ_RTC */ + VECTOR(EFM32_IRQ_CMU, EFM32_IRQ_CMU ) /* 18: EFM32_IRQ_CMU */ + VECTOR(EFM32_IRQ_VCMP, EFM32_IRQ_VCMP ) /* 19: EFM32_IRQ_VCMP */ + VECTOR(EFM32_IRQ_LCD, EFM32_IRQ_LCD ) /* 20: EFM32_IRQ_LCD */ + VECTOR(EFM32_IRQ_MSC, EFM32_IRQ_MSC ) /* 21: EFM32_IRQ_MSC */ + VECTOR(EFM32_IRQ_AES, EFM32_IRQ_AES ) /* 22: EFM32_IRQ_AES */ +#endif + +#else +# error "Unknown EFM32 Type" +#endif diff --git a/arch/arm/src/efm32/efm32_clockconfig.h b/arch/arm/src/efm32/efm32_clockconfig.h new file mode 100644 index 0000000000..64e2bf56be --- /dev/null +++ b/arch/arm/src/efm32/efm32_clockconfig.h @@ -0,0 +1,61 @@ +/**************************************************************************** + * arch/arm/src/efm32/efm32_clockconfig.h + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_EFM32_EFM32_CLOCKCONFIG_H +#define __ARCH_ARM_SRC_EFM32_EFM32_CLOCKCONFIG_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: efm32_clockconfig + * + * Description: + * Called to initialize the EFM32. This does whatever setup is needed to + * put the SoC in a usable state. This includes the initialization of + * clocking using the settings in board.h. + * + ****************************************************************************/ + +void efm32_clockconfig(void); + +#endif /* __ARCH_ARM_SRC_EFM32_EFM32_CLOCKCONFIG_H */ diff --git a/arch/arm/src/efm32/efm32_idle.c b/arch/arm/src/efm32/efm32_idle.c new file mode 100644 index 0000000000..7b525bbe3e --- /dev/null +++ b/arch/arm/src/efm32/efm32_idle.c @@ -0,0 +1,96 @@ +/**************************************************************************** + * arch/arm/src/efm32/efm32_idle.c + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include +#include + +#include + +#include "chip.h" +#include "up_internal.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Does the board support an IDLE LED to indicate that the board is in the + * IDLE state? + */ + +#if defined(CONFIG_ARCH_LEDS) && defined(LED_IDLE) +# define BEGIN_IDLE() board_led_on(LED_IDLE) +# define END_IDLE() board_led_off(LED_IDLE) +#else +# define BEGIN_IDLE() +# define END_IDLE() +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_idle + * + * Description: + * up_idle() is the logic that will be executed when their is no other + * ready-to-run task. This is processor idle time and will continue until + * some interrupt occurs to cause a context switch from the idle task. + * + * Processing in this state may be processor-specific. e.g., this is where + * power management operations might be performed. + * + ****************************************************************************/ + +void up_idle(void) +{ + /* Perform IDLE mode power management */ + /* Sleep until an interrupt occurs to save power. */ +} diff --git a/arch/arm/src/efm32/efm32_lowputc.h b/arch/arm/src/efm32/efm32_lowputc.h new file mode 100644 index 0000000000..670ed9da74 --- /dev/null +++ b/arch/arm/src/efm32/efm32_lowputc.h @@ -0,0 +1,66 @@ +/**************************************************************************** + * arch/arm/src/efm32/efm32_lowputc.h + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_EFM32_EFM32_LOWPUTC_H +#define __ARCH_ARM_SRC_EFM32_EFM32_LOWPUTC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: efm32_lowsetup + * + * Description: + * Called at the very beginning of _start. Performs low level + * initialization including setup of the console UART. This UART done + * early so that the serial console is available for debugging very early + * in the boot sequence. + * + ****************************************************************************/ + +#if defined(CONFIG_DEV_LOWCONSOLE) || defined(CONFIG_DEBUG) +void efm32_lowsetup(void); +#else +# define efm32_lowsetup() +#endif + +#endif /* __ARCH_ARM_SRC_EFM32_EFM32_LOWPUTC_H */ diff --git a/arch/arm/src/efm32/efm32_start.c b/arch/arm/src/efm32/efm32_start.c new file mode 100644 index 0000000000..1cc28e5360 --- /dev/null +++ b/arch/arm/src/efm32/efm32_start.c @@ -0,0 +1,205 @@ +/**************************************************************************** + * arch/arm/src/efm32/efm32_start.c + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include + +#include "up_arch.h" +#include "up_internal.h" +#include "efm32_lowputc.h" +#include "efm32_clockconfig.h" +#include "efm32_start.h" + +/**************************************************************************** + * Private Function prototypes + ****************************************************************************/ + +#ifdef CONFIG_DEBUG_STACK +static void go_os_start(void *pv, unsigned int nbytes) + __attribute__ ((naked,no_instrument_function,noreturn)); +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: showprogress + * + * Description: + * Print a character on the UART to show boot status. + * + ****************************************************************************/ + +#ifdef CONFIG_DEBUG +# define showprogress(c) up_lowputc(c) +#else +# define showprogress(c) +#endif + +/**************************************************************************** + * Name: go_os_start + * + * Description: + * Set the IDLE stack to the + * + ****************************************************************************/ + +#ifdef CONFIG_DEBUG_STACK +static void go_os_start(void *pv, unsigned int nbytes) +{ + /* Set the IDLE stack to the stack coloration value then jump to + * os_start(). We take extreme care here because were currently + * executing on this stack. + * + * We want to avoid sneak stack access generated by the compiler. + */ + + __asm__ __volatile__ + ( + "\tmov r1, r1, lsr #2\n" /* R1 = nwords = nbytes >> 2 */ + "\tbeq 2f\n" /* (should not happen) */ + + "\tbic r0, r0, #3\n" /* R0 = Aligned stackptr */ + "\tmovw r2, #0xbeef\n" /* R2 = STACK_COLOR = 0xdeadbeef */ + "\tmovt r2, #0xdead\n" + + "1:\n" /* Top of the loop */ + "\tsub r1, r1, #1\n" /* R1 nwords-- */ + "\tcmp r1, #0\n" /* Check (nwords == 0) */ + "\tstr r2, [r0], #4\n" /* Save stack color word, increment stackptr */ + "\tbne 1b\n" /* Bottom of the loop */ + + "2:\n" + "\tmov r14, #0\n" /* LR = return address (none) */ + "\tb os_start\n" /* Branch to os_start */ + ); +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: _start + * + * Description: + * This is the reset entry point. + * + ****************************************************************************/ + +void __start(void) +{ + const uint32_t *src; + uint32_t *dest; + + /* Configure the uart so that we can get debug output as soon as possible */ + + efm32_clockconfig(); + efm32_lowsetup(); + showprogress('A'); + + /* Clear .bss. We'll do this inline (vs. calling memset) just to be + * certain that there are no issues with the state of global variables. + */ + + for (dest = &_sbss; dest < &_ebss; ) + { + *dest++ = 0; + } + + showprogress('B'); + + /* Move the initialized data section from his temporary holding spot in + * FLASH into the correct place in SRAM. The correct place in SRAM is + * give by _sdata and _edata. The temporary location is in FLASH at the + * end of all of the other read-only data (.text, .rodata) at _eronly. + */ + + for (src = &_eronly, dest = &_sdata; dest < &_edata; ) + { + *dest++ = *src++; + } + + showprogress('C'); + + /* Perform early serial initialization */ + + up_earlyserialinit(); + + showprogress('D'); + + /* For the case of the separate user-/kernel-space build, perform whatever + * platform specific initialization of the user memory is required. + * Normally this just means initializing the user space .data and .bss + * segments. + */ + +#ifdef CONFIG_NUTTX_KERNEL + efm32_userspace(); + showprogress('E'); +#endif + + /* Then start NuttX */ + + showprogress('\r'); + showprogress('\n'); + +#ifdef CONFIG_DEBUG_STACK + /* Set the IDLE stack to the coloration value and jump into os_start() */ + + go_os_start((FAR void *)&_ebss, CONFIG_IDLETHREAD_STACKSIZE); +#else + /* Call os_start() */ + + os_start(); + + /* Shouldn't get here */ + + for(;;); +#endif +} diff --git a/arch/arm/src/efm32/efm32_start.h b/arch/arm/src/efm32/efm32_start.h new file mode 100644 index 0000000000..8b73d92f22 --- /dev/null +++ b/arch/arm/src/efm32/efm32_start.h @@ -0,0 +1,61 @@ +/**************************************************************************** + * arch/arm/src/efm32/efm32_start.h + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_EFM32_EFM32_START_H +#define __ARCH_ARM_SRC_EFM32_EFM32_START_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: efm32_boardinitialize + * + * Description: + * All EFM32 architectures must provide the following entry point. This + * entry point is called early in the initialization before any devices + * have been initialized. + * + ****************************************************************************/ + +void efm32_boardinitialize(void); + +#endif /* __ARCH_ARM_SRC_EFM32_EFM32_START_H */ diff --git a/configs/efm32-g8xx-stk/README.txt b/configs/efm32-g8xx-stk/README.txt index 46fa9400dd..ed375c1c5f 100644 --- a/configs/efm32-g8xx-stk/README.txt +++ b/configs/efm32-g8xx-stk/README.txt @@ -14,3 +14,73 @@ README • Reset button and a switch to disconnect the battery. • On-board SEGGER J-Link USB emulator • ARM 20 pin JTAG/SWD standard Debug in/out connector + +LEDs +==== + + The EFM32 Gecko Start Kithas four yellow LEDs. 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/efm32_autoleds.c. + The LEDs are used to encode OS-related events as follows: + + SYMBOL Meaning LED1* LED2 LED3 LED4 + ----------------- ----------------------- ------ ----- ----- ------ + LED_STARTED NuttX has been started ON OFF OFF OFF + LED_HEAPALLOCATE Heap has been allocated OFF ON OFF OFF + LED_IRQSENABLED Interrupts enabled ON ON OFF OFF + LED_STACKCREATED Idle stack created OFF OFF ON OFF + LED_INIRQ In an interrupt** ON N/C N/C OFF + LED_SIGNAL In a signal handler*** N/C ON N/C OFF + LED_ASSERTION An assertion failed ON ON N/C OFF + LED_PANIC The system has crashed N/C N/C N/C ON + LED_IDLE STM32 is is sleep mode (Optional, not used) + + * If LED1, LED2, LED3 are statically on, then NuttX probably failed to boot + and these LEDs will give you some indication of where the failure was + ** The normal state is LED3 ON and LED1 faintly glowing. This faint glow + is because of timer interrupt that result in the LED being illuminated + on a small proportion of the time. +*** LED2 may also flicker normally if signals are processed. + +Configurations +============== + Each EFM32 Gecko Starter Kit configuration is maintained in a sub-director + and can be selected as follow: + + cd tools + ./configure.sh efm32-g8xx-stk/ + cd - + . ./setenv.sh + + If this is a Windows native build, then configure.bat should be used + instead of configure.sh: + + configure.bat STM32F4Discovery\ + + Where is one of the following: + + nsh: + --- + Configures the NuttShell (nsh) located at apps/examples/nsh. The + Configuration enables the serial interfaces on USARTx. Support for + builtin applications is enabled, but in the base configuration no + builtin applications are selected (see NOTES below). + + NOTES: + + 1. This configuration uses the mconf-based configuration tool. To + change this configuration using that tool, you should: + + a. Build and install the kconfig-mconf tool. See nuttx/README.txt + and misc/tools/ + + b. Execute 'make menuconfig' in nuttx/ in order to start the + reconfiguration process. + + 2. By default, this configuration uses the CodeSourcery toolchain + for Windows and builds under Cygwin (or probably MSYS). That + can easily be reconfigured, of course. + + CONFIG_HOST_WINDOWS=y : Builds under Windows + CONFIG_WINDOWS_CYGWIN=y : Using Cygwin + CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery for Windows diff --git a/configs/efm32-g8xx-stk/include/board.h b/configs/efm32-g8xx-stk/include/board.h index ddc32d0707..eb2bb574f2 100644 --- a/configs/efm32-g8xx-stk/include/board.h +++ b/configs/efm32-g8xx-stk/include/board.h @@ -40,8 +40,72 @@ * Included Files ****************************************************************************/ +#include + +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ +/* The EFM32 Gecko Starter Kit supports 4 yellow LEDs. One side is grounded + * so these LEDs are illuminated by outputting a high value. + * + * 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 efm32_setled() */ + +#define BOARD_LED1 0 +#define BOARD_LED2 1 +#define BOARD_LED3 2 +#define BOARD_LED4 3 +#define BOARD_NLEDS 4 + +#define BOARD_LED_GREEN BOARD_LED1 +#define BOARD_LED_ORANGE BOARD_LED2 +#define BOARD_LED_RED BOARD_LED3 +#define BOARD_LED_BLUE BOARD_LED4 + +/* LED bits for use with efm32_setleds() */ + +#define BOARD_LED1_BIT (1 << BOARD_LED1) +#define BOARD_LED2_BIT (1 << BOARD_LED2) +#define BOARD_LED3_BIT (1 << BOARD_LED3) +#define BOARD_LED4_BIT (1 << BOARD_LED4) + +/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the 4 LEDs on + * board the EFM32 Gecko Starter Kit. The following definitions describe + * how NuttX controls the LEDs in this configuration: + */ + +#define LED_STARTED 0 /* LED1 */ +#define LED_HEAPALLOCATE 1 /* LED2 */ +#define LED_IRQSENABLED 2 /* LED1 + LED2 */ +#define LED_STACKCREATED 3 /* LED3 */ +#define LED_INIRQ 4 /* LED1 + LED3 */ +#define LED_SIGNAL 5 /* LED2 + LED3 */ +#define LED_ASSERTION 6 /* LED1 + LED2 + LED3 */ +#define LED_PANIC 7 /* N/C + N/C + N/C + LED4 */ + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: efm32_ledinit, efm32_setled, and efm32_setleds + * + * Description: + * If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board + * LEDs. If CONFIG_ARCH_LEDS is not defined, then the following interfaces + * are available to control the LEDs from user applications. + * + ****************************************************************************/ + +#ifndef CONFIG_ARCH_LEDS +void efm32_ledinit(void); +void efm32_setled(int led, bool ledon); +void efm32_setleds(uint8_t ledset); +#endif + #endif /* __CONFIGS_EFM32_DK3650_INCLUDE_BOARD_H */ diff --git a/configs/efm32-g8xx-stk/src/efm32_boot.c b/configs/efm32-g8xx-stk/src/efm32_boot.c index ebe9ad0df1..b288be27b8 100644 --- a/configs/efm32-g8xx-stk/src/efm32_boot.c +++ b/configs/efm32-g8xx-stk/src/efm32_boot.c @@ -1,8 +1,8 @@ /***************************************************************************** - * configs/efm32-dk3650/src/efm32_boot.c + * configs/efm32-g8xx-stk/src/efm32_boot.c * - * Copyright (C) 2014 Richard Cochran. All rights reserved. - * Author: Richard Cochran + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -39,21 +39,23 @@ #include +#include "efm32_start.h" + #include "efm32-g8xx-stk.h" /**************************************************************************** * Public Functions ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: efm32_boardinitialize * * Description: - * All STM32 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. + * All EFM32 architectures must provide the following entry point. This + * entry point is called early in the initialization before any devices + * have been initialized. * - ************************************************************************************/ + ****************************************************************************/ void efm32_boardinitialize(void) {