diff options
author | Harald Welte <laforge@gnumonks.org> | 2011-12-27 22:25:56 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2011-12-27 22:25:56 +0100 |
commit | a34cdbc1a9f87f9f3d87416c95aa92d8395a783f (patch) | |
tree | 5e856c02464e712f65bb58cde3abeb0e4ac9d224 /boards | |
parent | da884b450104a85d867bcf4222a511ca84ad3523 (diff) |
complete 'board' support for osmo-sdr hardware
Diffstat (limited to 'boards')
-rw-r--r-- | boards/osmo-sdr/board.mak | 31 | ||||
-rw-r--r-- | boards/osmo-sdr/board_cstartup_gnu.c | 167 | ||||
-rw-r--r-- | boards/osmo-sdr/board_cstartup_iar.c | 136 | ||||
-rw-r--r-- | boards/osmo-sdr/board_cstartup_keil.c | 128 | ||||
-rw-r--r-- | boards/osmo-sdr/board_lowlevel.h | 50 | ||||
-rw-r--r-- | boards/osmo-sdr/board_memories.c | 44 | ||||
-rw-r--r-- | boards/osmo-sdr/board_memories.h | 43 | ||||
-rw-r--r-- | boards/osmo-sdr/board_powermode.c | 174 | ||||
-rw-r--r-- | boards/osmo-sdr/board_powermode.h | 50 | ||||
-rw-r--r-- | boards/osmo-sdr/exceptions.c | 588 | ||||
-rw-r--r-- | boards/osmo-sdr/exceptions.h | 134 |
11 files changed, 1545 insertions, 0 deletions
diff --git a/boards/osmo-sdr/board.mak b/boards/osmo-sdr/board.mak new file mode 100644 index 0000000..8c527cd --- /dev/null +++ b/boards/osmo-sdr/board.mak @@ -0,0 +1,31 @@ +# ----------------------------------------------------------------------------
+# ATMEL Microcontroller Software Support
+# ----------------------------------------------------------------------------
+# Copyright (c) 2008, Atmel Corporation
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# - Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the disclaimer below.
+#
+# Atmel's name may not be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+# DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+# ----------------------------------------------------------------------------
+
+# Defines which are the available memory targets for the AT91SAM3UE-EK board.
+
+MEMORIES = sram flash sram_rumba
diff --git a/boards/osmo-sdr/board_cstartup_gnu.c b/boards/osmo-sdr/board_cstartup_gnu.c new file mode 100644 index 0000000..66a433b --- /dev/null +++ b/boards/osmo-sdr/board_cstartup_gnu.c @@ -0,0 +1,167 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+#include "board.h"
+#include "exceptions.h"
+#include "board_lowlevel.h"
+
+//------------------------------------------------------------------------------
+// External Variables
+//------------------------------------------------------------------------------
+
+// Stack top
+extern unsigned int _estack;
+
+// Vector start address
+extern unsigned int _vect_start;
+
+// Initialize segments
+extern unsigned int _sfixed;
+extern unsigned int _sfixed;
+extern unsigned int _efixed;
+extern unsigned int _srelocate;
+extern unsigned int _erelocate;
+extern unsigned int _szero;
+extern unsigned int _ezero;
+#if defined(psram)
+extern unsigned int _svectorrelocate;
+extern unsigned int _evectorrelocate;
+#endif
+
+//------------------------------------------------------------------------------
+// ProtoTypes
+//------------------------------------------------------------------------------
+
+extern int main(void);
+void ResetException(void);
+
+//------------------------------------------------------------------------------
+// Exception Table
+//------------------------------------------------------------------------------
+
+__attribute__((section(".vectors")))
+IntFunc exception_table[] = {
+
+ // Configure Initial Stack Pointer, using linker-generated symbols
+ (IntFunc)&_estack,
+ ResetException,
+
+ NMI_Handler,
+ HardFault_Handler,
+ MemManage_Handler,
+ BusFault_Handler,
+ UsageFault_Handler,
+ 0, 0, 0, 0, // Reserved
+ SVC_Handler,
+ DebugMon_Handler,
+ 0, // Reserved
+ PendSV_Handler,
+ SysTick_Handler,
+
+ // Configurable interrupts
+ SUPC_IrqHandler, // 0 SUPPLY CONTROLLER
+ RSTC_IrqHandler, // 1 RESET CONTROLLER
+ RTC_IrqHandler, // 2 REAL TIME CLOCK
+ RTT_IrqHandler, // 3 REAL TIME TIMER
+ WDT_IrqHandler, // 4 WATCHDOG TIMER
+ PMC_IrqHandler, // 5 PMC
+ EFC0_IrqHandler, // 6 EFC0
+ EFC1_IrqHandler, // 7 EFC1
+ DBGU_IrqHandler, // 8 DBGU
+ HSMC4_IrqHandler, // 9 HSMC4
+ PIOA_IrqHandler, // 10 Parallel IO Controller A
+ PIOB_IrqHandler, // 11 Parallel IO Controller B
+ PIOC_IrqHandler, // 12 Parallel IO Controller C
+ USART0_IrqHandler, // 13 USART 0
+ USART1_IrqHandler, // 14 USART 1
+ USART2_IrqHandler, // 15 USART 2
+ USART3_IrqHandler, // 16 USART 3
+ MCI0_IrqHandler, // 17 Multimedia Card Interface
+ TWI0_IrqHandler, // 18 TWI 0
+ TWI1_IrqHandler, // 19 TWI 1
+ SPI0_IrqHandler, // 20 Serial Peripheral Interface
+ SSC0_IrqHandler, // 21 Serial Synchronous Controller 0
+ TC0_IrqHandler, // 22 Timer Counter 0
+ TC1_IrqHandler, // 23 Timer Counter 1
+ TC2_IrqHandler, // 24 Timer Counter 2
+ PWM_IrqHandler, // 25 Pulse Width Modulation Controller
+ ADCC0_IrqHandler, // 26 ADC controller0
+ ADCC1_IrqHandler, // 27 ADC controller1
+ HDMA_IrqHandler, // 28 HDMA
+ USBD_IrqHandler, // 29 USB Device High Speed UDP_HS
+ IrqHandlerNotUsed // 30 not used
+};
+
+
+//------------------------------------------------------------------------------
+/// This is the code that gets called on processor reset. To initialize the
+/// device. And call the main() routine.
+//------------------------------------------------------------------------------
+void ResetException(void)
+{
+ unsigned int *pSrc, *pDest;
+
+ LowLevelInit();
+#if defined(psram)
+ pDest = &_vect_start;
+ pSrc = &_svectorrelocate;
+ for(; pSrc < &_evectorrelocate;) {
+ *pDest++ = *pSrc++;
+ }
+#endif
+
+ // Initialize data
+ pSrc = &_efixed;
+ pDest = &_srelocate;
+ if (pSrc != pDest) {
+ for(; pDest < &_erelocate;) {
+
+ *pDest++ = *pSrc++;
+ }
+ }
+
+ // Zero fill bss
+ for(pDest = &_szero; pDest < &_ezero;) {
+
+ *pDest++ = 0;
+ }
+
+#if defined(psram)
+ pSrc = (unsigned int *)&_vect_start;
+#else
+ pSrc = (unsigned int *)&_sfixed;
+#endif
+
+ AT91C_BASE_NVIC->NVIC_VTOFFR = ((unsigned int)(pSrc)) | (0x0 << 7);
+
+ main();
+}
diff --git a/boards/osmo-sdr/board_cstartup_iar.c b/boards/osmo-sdr/board_cstartup_iar.c new file mode 100644 index 0000000..d2a06de --- /dev/null +++ b/boards/osmo-sdr/board_cstartup_iar.c @@ -0,0 +1,136 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+#include "board.h"
+#include "exceptions.h"
+#include "board_lowlevel.h"
+
+//------------------------------------------------------------------------------
+// Types
+//------------------------------------------------------------------------------
+typedef union { IntFunc __fun; void * __ptr; } IntVector;
+
+//------------------------------------------------------------------------------
+// ProtoTypes
+//------------------------------------------------------------------------------
+
+extern void __iar_program_start( void );
+
+int __low_level_init( void );
+
+//------------------------------------------------------------------------------
+// Variables
+//------------------------------------------------------------------------------
+extern unsigned int __ICFEDIT_vector_start__;
+
+//------------------------------------------------------------------------------
+// Exception Table
+//------------------------------------------------------------------------------
+
+#pragma language=extended
+#pragma segment="CSTACK"
+
+// The name "__vector_table" has special meaning for C-SPY:
+// it is where the SP start value is found, and the NVIC vector
+// table register (VTOR) is initialized to this address if != 0.
+
+#pragma section = ".vectors"
+#pragma location = ".vectors"
+const IntVector __vector_table[] =
+{
+ { .__ptr = __sfe( "CSTACK" ) },
+ __iar_program_start,
+
+ NMI_Handler,
+ HardFault_Handler,
+ MemManage_Handler,
+ BusFault_Handler,
+ UsageFault_Handler,
+ 0, 0, 0, 0, // Reserved
+ SVC_Handler,
+ DebugMon_Handler,
+ 0, // Reserved
+ PendSV_Handler,
+ SysTick_Handler,
+
+ // Configurable interrupts
+ SUPC_IrqHandler, // 0 SUPPLY CONTROLLER
+ RSTC_IrqHandler, // 1 RESET CONTROLLER
+ RTC_IrqHandler, // 2 REAL TIME CLOCK
+ RTT_IrqHandler, // 3 REAL TIME TIMER
+ WDT_IrqHandler, // 4 WATCHDOG TIMER
+ PMC_IrqHandler, // 5 PMC
+ EFC0_IrqHandler, // 6 EFC0
+ EFC1_IrqHandler, // 7 EFC1
+ DBGU_IrqHandler, // 8 DBGU
+ HSMC4_IrqHandler, // 9 HSMC4
+ PIOA_IrqHandler, // 10 Parallel IO Controller A
+ PIOB_IrqHandler, // 11 Parallel IO Controller B
+ PIOC_IrqHandler, // 12 Parallel IO Controller C
+ USART0_IrqHandler, // 13 USART 0
+ USART1_IrqHandler, // 14 USART 1
+ USART2_IrqHandler, // 15 USART 2
+ USART3_IrqHandler, // 16 USART 3
+ MCI0_IrqHandler, // 17 Multimedia Card Interface
+ TWI0_IrqHandler, // 18 TWI 0
+ TWI1_IrqHandler, // 19 TWI 1
+ SPI0_IrqHandler, // 20 Serial Peripheral Interface
+ SSC0_IrqHandler, // 21 Serial Synchronous Controller 0
+ TC0_IrqHandler, // 22 Timer Counter 0
+ TC1_IrqHandler, // 23 Timer Counter 1
+ TC2_IrqHandler, // 24 Timer Counter 2
+ PWM_IrqHandler, // 25 Pulse Width Modulation Controller
+ ADCC0_IrqHandler, // 26 ADC controller0
+ ADCC1_IrqHandler, // 27 ADC controller1
+ HDMA_IrqHandler, // 28 HDMA
+ USBD_IrqHandler, // 29 USB Device High Speed UDP_HS
+ IrqHandlerNotUsed // 30 not used
+};
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// This is the code that gets called on processor reset. To initialize the
+/// device.
+//------------------------------------------------------------------------------
+int __low_level_init( void )
+{
+ unsigned int * src = __section_begin(".vectors");
+
+ LowLevelInit();
+
+ AT91C_BASE_NVIC->NVIC_VTOFFR = ((unsigned int)(src)) | (0x0 << 7);
+
+ return 1; // if return 0, the data sections will not be initialized.
+}
diff --git a/boards/osmo-sdr/board_cstartup_keil.c b/boards/osmo-sdr/board_cstartup_keil.c new file mode 100644 index 0000000..63c6820 --- /dev/null +++ b/boards/osmo-sdr/board_cstartup_keil.c @@ -0,0 +1,128 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+#include "board.h"
+#include "exceptions.h"
+#include "board_lowlevel.h"
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// Types
+//------------------------------------------------------------------------------
+typedef union { IntFunc __fun; void * __ptr; } IrqVector;
+
+//------------------------------------------------------------------------------
+// ProtoTypes
+//------------------------------------------------------------------------------
+extern int Image$$ARM_LIB_STACK$$ZI$$Limit;
+extern int Image$$Vector_region$$Base;
+extern int Image$$Vector_region$$Limit;
+
+extern void __main(void);
+void resetHandler( void );
+
+//------------------------------------------------------------------------------
+// Variables
+//------------------------------------------------------------------------------
+
+#pragma arm section rodata="vectors"
+const IrqVector __vector_table[] =
+{
+ (IntFunc)&Image$$ARM_LIB_STACK$$ZI$$Limit,
+ resetHandler,
+
+ NMI_Handler,
+ HardFault_Handler,
+ MemManage_Handler,
+ BusFault_Handler,
+ UsageFault_Handler,
+ 0, 0, 0, 0, // Reserved
+ SVC_Handler,
+ DebugMon_Handler,
+ 0, // Reserved
+ PendSV_Handler,
+ SysTick_Handler,
+
+ // Configurable interrupts
+ SUPC_IrqHandler, // 0 SUPPLY CONTROLLER
+ RSTC_IrqHandler, // 1 RESET CONTROLLER
+ RTC_IrqHandler, // 2 REAL TIME CLOCK
+ RTT_IrqHandler, // 3 REAL TIME TIMER
+ WDT_IrqHandler, // 4 WATCHDOG TIMER
+ PMC_IrqHandler, // 5 PMC
+ EFC0_IrqHandler, // 6 EFC0
+ EFC1_IrqHandler, // 7 EFC1
+ DBGU_IrqHandler, // 8 DBGU
+ HSMC4_IrqHandler, // 9 HSMC4
+ PIOA_IrqHandler, // 10 Parallel IO Controller A
+ PIOB_IrqHandler, // 11 Parallel IO Controller B
+ PIOC_IrqHandler, // 12 Parallel IO Controller C
+ USART0_IrqHandler, // 13 USART 0
+ USART1_IrqHandler, // 14 USART 1
+ USART2_IrqHandler, // 15 USART 2
+ USART3_IrqHandler, // 16 USART 3
+ MCI0_IrqHandler, // 17 Multimedia Card Interface
+ TWI0_IrqHandler, // 18 TWI 0
+ TWI1_IrqHandler, // 19 TWI 1
+ SPI0_IrqHandler, // 20 Serial Peripheral Interface
+ SSC0_IrqHandler, // 21 Serial Synchronous Controller 0
+ TC0_IrqHandler, // 22 Timer Counter 0
+ TC1_IrqHandler, // 23 Timer Counter 1
+ TC2_IrqHandler, // 24 Timer Counter 2
+ PWM_IrqHandler, // 25 Pulse Width Modulation Controller
+ ADCC0_IrqHandler, // 26 ADC controller0
+ ADCC1_IrqHandler, // 27 ADC controller1
+ HDMA_IrqHandler, // 28 HDMA
+ USBD_IrqHandler, // 29 USB Device High Speed UDP_HS
+ IrqHandlerNotUsed // 30 not used
+};
+#pragma arm section
+
+//------------------------------------------------------------------------------
+/// This is the code that gets called on processor reset. To initialize the
+/// device.
+//------------------------------------------------------------------------------
+void resetHandler( void )
+{
+ unsigned int *pSrc = (unsigned int *)&Image$$Vector_region$$Base;
+
+ // Low level Initialize
+ LowLevelInit();
+
+ AT91C_BASE_NVIC->NVIC_VTOFFR = ((unsigned int)(pSrc)) | (0x0 << 7);
+
+ // Enter C library entry point
+ __main();
+}
diff --git a/boards/osmo-sdr/board_lowlevel.h b/boards/osmo-sdr/board_lowlevel.h new file mode 100644 index 0000000..e3fdf46 --- /dev/null +++ b/boards/osmo-sdr/board_lowlevel.h @@ -0,0 +1,50 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+/// \unit
+///
+/// !!!Purpose
+///
+/// Collection of methods for lowlevel.
+///
+//------------------------------------------------------------------------------
+
+#ifndef BOARD_LOWLEVEL_H
+#define BOARD_LOWLEVEL_H
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+extern void LowLevelInit(void);
+extern void SetDefaultMaster(unsigned char enable);
+extern void SetFlashWaitState(unsigned char ws);
+
+#endif // BOARD_LOWLEVEL_H
+
diff --git a/boards/osmo-sdr/board_memories.c b/boards/osmo-sdr/board_memories.c new file mode 100644 index 0000000..628bc1c --- /dev/null +++ b/boards/osmo-sdr/board_memories.c @@ -0,0 +1,44 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2009, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+/*
+ Title: Memories implementation
+*/
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include <board.h>
+#include <pio/pio.h>
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
diff --git a/boards/osmo-sdr/board_memories.h b/boards/osmo-sdr/board_memories.h new file mode 100644 index 0000000..b8ecb44 --- /dev/null +++ b/boards/osmo-sdr/board_memories.h @@ -0,0 +1,43 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+/// \unit
+/// !Purpose
+///
+///
+/// !Usage
+///
+//------------------------------------------------------------------------------
+
+#ifndef BOARD_MEMORIES_H
+#define BOARD_MEMORIES_H
+
+#endif //#ifndef BOARD_MEMORIES_H
+
diff --git a/boards/osmo-sdr/board_powermode.c b/boards/osmo-sdr/board_powermode.c new file mode 100644 index 0000000..cc46e03 --- /dev/null +++ b/boards/osmo-sdr/board_powermode.c @@ -0,0 +1,174 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include "board.h"
+
+//------------------------------------------------------------------------------
+// Internal definitions
+//------------------------------------------------------------------------------
+
+#define NORMAL_POWER_MODE 0
+#define LOW_POWER_MODE 1
+
+//------------------------------------------------------------------------------
+// Internal variables
+//------------------------------------------------------------------------------
+
+static volatile unsigned char powerMode = NORMAL_POWER_MODE;
+static unsigned int oldFmr0;
+static unsigned int oldFmr1;
+static unsigned int oldPll;
+static unsigned int oldMck;
+
+//------------------------------------------------------------------------------
+// Internal functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Save and restore working clock.
+/// Here working clock must be running from PLL
+/// and external crystal oscillator is used.
+//------------------------------------------------------------------------------
+static void SaveWorkingClock(unsigned int *pOldPll, unsigned int *pOldMck)
+{
+ // Save previous values for PLL A and Master Clock configuration
+ *pOldPll = AT91C_BASE_CKGR->CKGR_PLLAR;
+ *pOldMck = AT91C_BASE_PMC->PMC_MCKR;
+}
+
+static void RestoreWorkingClock(unsigned int oldPll, unsigned int oldMck)
+{
+
+ // Switch to slow clock first
+ AT91C_BASE_PMC->PMC_MCKR = (AT91C_BASE_PMC->PMC_MCKR & ~AT91C_PMC_CSS)
+ | AT91C_PMC_CSS_SLOW_CLK;
+ while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY));
+
+ AT91C_BASE_PMC->PMC_MCKR = (AT91C_BASE_PMC->PMC_MCKR & ~AT91C_PMC_PRES)
+ | AT91C_PMC_PRES_CLK;
+ while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY));
+
+ // Restart Main Oscillator
+ AT91C_BASE_PMC->PMC_MOR = (0x37 << 16)
+ | (0x3F<<8)
+ | AT91C_CKGR_MOSCRCEN
+ | AT91C_CKGR_MOSCXTEN;
+ while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MOSCXTS));
+ // Switch to moscsel
+ AT91C_BASE_PMC->PMC_MOR = (0x37 << 16)
+ | (0x3F<<8)
+ | AT91C_CKGR_MOSCRCEN
+ | AT91C_CKGR_MOSCXTEN
+ | AT91C_CKGR_MOSCSEL;
+ while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MOSCSELS));
+
+ // Switch to main oscillator
+ AT91C_BASE_PMC->PMC_MCKR = (AT91C_BASE_PMC->PMC_MCKR & ~AT91C_PMC_CSS)
+ | AT91C_PMC_CSS_MAIN_CLK;
+ while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY));
+
+ AT91C_BASE_PMC->PMC_MCKR = (AT91C_BASE_PMC->PMC_MCKR & ~AT91C_PMC_PRES)
+ | AT91C_PMC_PRES_CLK;
+ while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY));
+
+ // Restart PLL A
+ AT91C_BASE_CKGR->CKGR_PLLAR = oldPll;
+ while(!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCKA));
+
+ // Switch to fast clock
+ AT91C_BASE_PMC->PMC_MCKR = (oldMck & ~AT91C_PMC_CSS)
+ | AT91C_PMC_CSS_MAIN_CLK;
+ while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY));
+
+ AT91C_BASE_PMC->PMC_MCKR = oldMck;
+ while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY));
+
+ // Setup Flash waitstates
+ AT91C_BASE_EFC0->EFC_FMR = oldFmr0;
+ AT91C_BASE_EFC1->EFC_FMR = oldFmr1;
+}
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Put the CPU in 32kHz, disable PLL, main oscillator
+/// Put voltage regulator in standby mode
+/// USB clock is automatically disabled.
+//------------------------------------------------------------------------------
+void LowPowerMode(void)
+{
+ if (powerMode == LOW_POWER_MODE)
+ return;
+
+ powerMode = LOW_POWER_MODE;
+
+ SaveWorkingClock(&oldPll, &oldMck);
+
+ oldFmr0 = AT91C_BASE_EFC0->EFC_FMR;
+ AT91C_BASE_EFC0->EFC_FMR = AT91C_EFC_FWS_3WS;
+ oldFmr1 = AT91C_BASE_EFC1->EFC_FMR;
+ AT91C_BASE_EFC1->EFC_FMR = AT91C_EFC_FWS_3WS;
+
+ AT91C_BASE_PMC->PMC_MCKR = (AT91C_BASE_PMC->PMC_MCKR & ~AT91C_PMC_CSS)
+ | AT91C_PMC_CSS_SLOW_CLK;
+ while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY));
+
+ AT91C_BASE_PMC->PMC_MCKR = (AT91C_BASE_PMC->PMC_MCKR & ~AT91C_PMC_PRES)
+ | AT91C_PMC_PRES_CLK;
+ while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY));
+
+ // Stop PLL A
+ // MULA: PLL A Multiplier 0 = The PLL A is deactivated.
+ // STMODE must be set at 2 when the PLLA is Off
+ AT91C_BASE_PMC->PMC_PLLAR = 0x2 << 14;
+
+ // Stop Main Oscillator
+ AT91C_BASE_PMC->PMC_MOR = (0x37 << 16) | (0x3F << 8);
+}
+
+//------------------------------------------------------------------------------
+/// Put voltage regulator in normal mode
+/// Return the CPU to normal speed enable PLLs, main oscillator
+/// USB clock is automatically enabled.
+//------------------------------------------------------------------------------
+void NormalPowerMode(void)
+{
+ if (powerMode == NORMAL_POWER_MODE)
+ return;
+
+ RestoreWorkingClock(oldPll, oldMck);
+
+ powerMode = NORMAL_POWER_MODE;
+}
diff --git a/boards/osmo-sdr/board_powermode.h b/boards/osmo-sdr/board_powermode.h new file mode 100644 index 0000000..fd6372f --- /dev/null +++ b/boards/osmo-sdr/board_powermode.h @@ -0,0 +1,50 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+/// \unit
+/// !Purpose
+///
+///
+/// !Usage
+///
+//------------------------------------------------------------------------------
+
+#ifndef BOARD_POWERMODE_H
+#define BOARD_POWERMODE_H
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+extern void LowPowerMode(void);
+
+extern void NormalPowerMode(void);
+
+#endif //#ifndef BOARD_MEMORIES_H
+
diff --git a/boards/osmo-sdr/exceptions.c b/boards/osmo-sdr/exceptions.c new file mode 100644 index 0000000..efbd6d4 --- /dev/null +++ b/boards/osmo-sdr/exceptions.c @@ -0,0 +1,588 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+/*
+** This file contains the default exception handlers
+** and exception table.
+*/
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include "exceptions.h"
+#include <board.h>
+#include <stdio.h>
+#include <core_cm3.h>
+
+//------------------------------------------------------------------------------
+// Local definitions
+//------------------------------------------------------------------------------
+/* define compiler specific symbols */
+#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
+ #define __ASM __asm /*!< asm keyword for ARM Compiler */
+ #define __INLINE __inline /*!< inline keyword for ARM Compiler */
+
+#elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
+ #define __ASM __asm /*!< asm keyword for IAR Compiler */
+ #define __INLINE inline /*!< inline keyword for IAR Compiler. Only avaiable in High optimization mode! */
+ #define __NOP __no_operation /*!< no operation intrinsic in IAR Compiler */
+
+#elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
+ #define __ASM asm /*!< asm keyword for GNU Compiler */
+ #define __INLINE inline /*!< inline keyword for GNU Compiler */
+
+#endif
+
+// Memory Manage Address Register (MMAR) address valid flag
+#define CFSR_MMARVALID (0x01 << 7)
+// Bus Fault Address Register (BFAR) address valid flag
+#define CFSR_BFARVALID (0x01 << 15)
+
+//------------------------------------------------------------------------------
+// Types
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// Functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Fault status report.
+/// Note: assume printf() function is avaliable here.
+/// \param pFaultName pointer to fault name string.
+/// \param pSP SP pointer when the fault happened
+//------------------------------------------------------------------------------
+void FaultReport(char *pFaultName, unsigned int *pSP)
+{
+ unsigned int cfsr;
+ unsigned int mmfar;
+ unsigned int bfar;
+
+ // Report fault
+ printf("\n\rEnter %s exception.\n\r", pFaultName);
+ cfsr = SCB->CFSR;
+ mmfar = SCB->MMFAR;
+ bfar = SCB->BFAR;
+ printf("MMSR: 0x%02x\n\r", (cfsr & 0xFF));
+ if ((cfsr & CFSR_MMARVALID) != 0) {
+ printf("MMAR: 0x%08x\n\r", mmfar);
+ }
+ printf("BFSR: 0x%02x\n\r", ((cfsr >> 8) & 0xFF));
+ if ((cfsr & CFSR_BFARVALID) != 0) {
+ printf("BFAR: 0x%08x\n\r", bfar);
+ }
+ printf("UFSR: 0x%04x\n\r", ((cfsr >> 16) & 0xFFFF));
+ printf("HFSR: 0x%08x\n\r", (unsigned int)SCB->HFSR);
+ printf("DFSR: 0x%08x\n\r", (unsigned int)SCB->DFSR);
+ printf("AFSR: 0x%08x\n\r", (unsigned int)SCB->AFSR);
+ printf("Stacked LR: 0x%08x\n\r", (unsigned int)(pSP[5]));
+ printf("Stacked PC: 0x%08x\n\r", (unsigned int)(pSP[6]));
+
+ // Clear fault status bits (write-clear)
+ SCB->CFSR = SCB->CFSR;
+ SCB->HFSR = SCB->HFSR;
+ SCB->DFSR = SCB->DFSR;
+ SCB->AFSR = SCB->AFSR;
+}
+
+//------------------------------------------------------------------------------
+// Exception Handlers
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// Default irq handler
+//------------------------------------------------------------------------------
+void IrqHandlerNotUsed(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// Provide weak aliases for each Exception handler to the IrqHandlerNotUsed.
+// As they are weak aliases, any function with the same name will override
+// this definition.
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// System interrupt
+//------------------------------------------------------------------------------
+WEAK void NMI_Handler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+WEAK void HardFault_HandlerBody(unsigned int *pSP)
+{
+ FaultReport("HardFault", pSP);
+ while(1);
+}
+
+#if defined ( __CC_ARM )
+WEAK __ASM void HardFault_Handler(void)
+{
+ import HardFault_HandlerBody
+ tst lr, #0x4
+ ite eq
+ mrseq r0, msp
+ mrsne r0, psp
+ b HardFault_HandlerBody
+}
+
+#elif defined ( __ICCARM__ )
+WEAK void HardFault_Handler(void)
+{
+ __ASM("tst lr, #0x4");
+ __ASM("ite eq");
+ __ASM("mrseq r0, msp");
+ __ASM("mrsne r0, psp");
+ __ASM("b HardFault_HandlerBody");
+}
+
+#elif defined ( __GNUC__ )
+WEAK void HardFault_Handler(void)
+{
+ __ASM volatile ("tst lr, #0x4");
+ __ASM volatile ("ite eq");
+ __ASM volatile ("mrseq r0, msp");
+ __ASM volatile ("mrsne r0, psp");
+ __ASM volatile ("add r0, r0, #4"); // because one word has been pushed to sp in this function
+ __ASM volatile ("b HardFault_HandlerBody");
+}
+
+#endif
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+WEAK void MemManage_HandlerBody(unsigned int *pSP)
+{
+ FaultReport("MenManage", pSP);
+ while(1);
+}
+
+#if defined ( __CC_ARM )
+WEAK __ASM void MemManage_Handler(void)
+{
+ import MemManage_HandlerBody
+ tst lr, #0x4
+ ite eq
+ mrseq r0, msp
+ mrsne r0, psp
+ b MemManage_HandlerBody
+}
+
+#elif defined ( __ICCARM__ )
+WEAK void MemManage_Handler(void)
+{
+ __ASM("tst lr, #0x4");
+ __ASM("ite eq");
+ __ASM("mrseq r0, msp");
+ __ASM("mrsne r0, psp");
+ __ASM("b MemManage_HandlerBody");
+}
+
+#elif defined ( __GNUC__ )
+WEAK void MemManage_Handler(void)
+{
+ __ASM volatile ("tst lr, #0x4");
+ __ASM volatile ("ite eq");
+ __ASM volatile ("mrseq r0, msp");
+ __ASM volatile ("mrsne r0, psp");
+ __ASM volatile ("add r0, r0, #4"); // because one word has been pushed to sp in this function
+ __ASM volatile ("b MemManage_HandlerBody");
+}
+
+#endif
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+WEAK void BusFault_HandlerBody(unsigned int *pSP)
+{
+ FaultReport("BusFault", pSP);
+ while(1);
+}
+
+#if defined ( __CC_ARM )
+WEAK __ASM void BusFault_Handler(void)
+{
+ import BusFault_HandlerBody
+ tst lr, #0x4
+ ite eq
+ mrseq r0, msp
+ mrsne r0, psp
+ b BusFault_HandlerBody
+}
+
+#elif defined ( __ICCARM__ )
+WEAK void BusFault_Handler(void)
+{
+ __ASM("tst lr, #0x4");
+ __ASM("ite eq");
+ __ASM("mrseq r0, msp");
+ __ASM("mrsne r0, psp");
+ __ASM("b BusFault_HandlerBody");
+}
+
+#elif defined ( __GNUC__ )
+WEAK void BusFault_Handler(void)
+{
+ __ASM volatile ("tst lr, #0x4");
+ __ASM volatile ("ite eq");
+ __ASM volatile ("mrseq r0, msp");
+ __ASM volatile ("mrsne r0, psp");
+ __ASM volatile ("add r0, r0, #4"); // because one word has been pushed to sp in this function
+ __ASM volatile ("b BusFault_HandlerBody");
+}
+
+#endif
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+WEAK void UsageFault_HandlerBody(unsigned int *pSP)
+{
+ FaultReport("UsageFault", pSP);
+ while(1);
+}
+
+#if defined ( __CC_ARM )
+WEAK __ASM void UsageFault_Handler(void)
+{
+ import UsageFault_HandlerBody
+ tst lr, #0x4
+ ite eq
+ mrseq r0, msp
+ mrsne r0, psp
+ b UsageFault_HandlerBody
+}
+
+#elif defined ( __ICCARM__ )
+WEAK void UsageFault_Handler(void)
+{
+ __ASM("tst lr, #0x4");
+ __ASM("ite eq");
+ __ASM("mrseq r0, msp");
+ __ASM("mrsne r0, psp");
+ __ASM("b UsageFault_HandlerBody");
+}
+
+#elif defined ( __GNUC__ )
+WEAK void UsageFault_Handler(void)
+{
+ __ASM volatile ("tst lr, #0x4");
+ __ASM volatile ("ite eq");
+ __ASM volatile ("mrseq r0, msp");
+ __ASM volatile ("mrsne r0, psp");
+ __ASM volatile ("add r0, r0, #4"); // because one word has been pushed to sp in this function
+ __ASM volatile ("b UsageFault_HandlerBody");
+}
+
+#endif
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+WEAK void SVC_Handler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+WEAK void DebugMon_Handler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+WEAK void PendSV_Handler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// for Cortex M3
+//------------------------------------------------------------------------------
+WEAK void SysTick_Handler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// External interrupt
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// for SAM7/9
+//------------------------------------------------------------------------------
+void SYS_IrqHandler( void )
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// SUPPLY CONTROLLER
+//------------------------------------------------------------------------------
+WEAK void SUPC_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// RESET CONTROLLER
+//------------------------------------------------------------------------------
+WEAK void RSTC_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// REAL TIME CLOCK
+//------------------------------------------------------------------------------
+WEAK void RTC_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// REAL TIME TIMER
+//------------------------------------------------------------------------------
+WEAK void RTT_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// WATCHDOG TIMER
+//------------------------------------------------------------------------------
+WEAK void WDT_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// PMC
+//------------------------------------------------------------------------------
+WEAK void PMC_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// EFC0
+//------------------------------------------------------------------------------
+WEAK void EFC0_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// EFC1
+//------------------------------------------------------------------------------
+WEAK void EFC1_IrqHandler(void)
+{
+ while(1);
+}
+//------------------------------------------------------------------------------
+// DBGU
+//------------------------------------------------------------------------------
+WEAK void DBGU_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// HSMC4
+//------------------------------------------------------------------------------
+WEAK void HSMC4_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// Parallel IO Controller A
+//------------------------------------------------------------------------------
+WEAK void PIOA_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// Parallel IO Controller B
+//------------------------------------------------------------------------------
+WEAK void PIOB_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// Parallel IO Controller C
+//------------------------------------------------------------------------------
+WEAK void PIOC_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// USART 0
+//------------------------------------------------------------------------------
+WEAK void USART0_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// USART 1
+//------------------------------------------------------------------------------
+WEAK void USART1_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// USART 2
+//------------------------------------------------------------------------------
+WEAK void USART2_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// USART 3
+//------------------------------------------------------------------------------
+WEAK void USART3_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// Multimedia Card Interface
+//------------------------------------------------------------------------------
+WEAK void MCI0_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// TWI 0
+//------------------------------------------------------------------------------
+WEAK void TWI0_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// TWI 1
+//------------------------------------------------------------------------------
+WEAK void TWI1_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// Serial Peripheral Interface 0
+//------------------------------------------------------------------------------
+WEAK void SPI0_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// Serial Synchronous Controller 0
+//------------------------------------------------------------------------------
+WEAK void SSC0_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// Timer Counter 0
+//------------------------------------------------------------------------------
+WEAK void TC0_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// Timer Counter 1
+//------------------------------------------------------------------------------
+WEAK void TC1_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// Timer Counter 2
+//------------------------------------------------------------------------------
+WEAK void TC2_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// PWM Controller
+//------------------------------------------------------------------------------
+WEAK void PWM_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// ADC controller0
+//------------------------------------------------------------------------------
+WEAK void ADCC0_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// ADC controller1
+//------------------------------------------------------------------------------
+WEAK void ADCC1_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// HDMA
+//------------------------------------------------------------------------------
+WEAK void HDMA_IrqHandler(void)
+{
+ while(1);
+}
+
+//------------------------------------------------------------------------------
+// USB Device
+//------------------------------------------------------------------------------
+WEAK void USBD_IrqHandler(void)
+{
+ while(1);
+}
+
diff --git a/boards/osmo-sdr/exceptions.h b/boards/osmo-sdr/exceptions.h new file mode 100644 index 0000000..fb397c3 --- /dev/null +++ b/boards/osmo-sdr/exceptions.h @@ -0,0 +1,134 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+/*
+** This file contains the default exception handlers
+** and exception table.
+*/
+
+//------------------------------------------------------------------------------
+// Types
+//------------------------------------------------------------------------------
+
+/// Function prototype for exception table items - interrupt handler.
+//typedef void( *IrqHandler )( void );
+typedef void( *IntFunc )( void );
+
+/// Weak attribute
+
+#if defined ( __CC_ARM )
+ #define WEAK __attribute__ ((weak))
+#elif defined ( __ICCARM__ )
+ #define WEAK __weak
+#elif defined ( __GNUC__ )
+ #define WEAK __attribute__ ((weak))
+#endif
+
+//------------------------------------------------------------------------------
+// Global functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// Exception Handlers
+//------------------------------------------------------------------------------
+
+extern void NMI_Handler( void );
+extern void HardFault_Handler( void );
+extern void MemManage_Handler( void );
+extern void BusFault_Handler( void );
+extern void UsageFault_Handler( void );
+extern void SVC_Handler( void );
+extern void DebugMon_Handler( void );
+extern void PendSV_Handler( void );
+extern void SysTick_Handler( void );
+void IrqHandlerNotUsed(void);
+
+
+// System Controller
+extern void SYS_IrqHandler(void);
+// SUPPLY CONTROLLER
+extern void SUPC_IrqHandler(void);
+// RESET CONTROLLER
+extern void RSTC_IrqHandler(void);
+// REAL TIME CLOCK
+extern void RTC_IrqHandler(void);
+// REAL TIME TIMER
+extern void RTT_IrqHandler(void);
+// WATCHDOG TIMER
+extern void WDT_IrqHandler(void);
+// PMC
+extern void PMC_IrqHandler(void);
+// EFC0
+extern void EFC0_IrqHandler(void);
+// EFC1
+extern void EFC1_IrqHandler(void);
+// DBGU
+extern void DBGU_IrqHandler(void);
+// HSMC4
+extern void HSMC4_IrqHandler(void);
+// Parallel IO Controller A
+extern void PIOA_IrqHandler(void);
+// Parallel IO Controller B
+extern void PIOB_IrqHandler(void);
+// Parallel IO Controller C
+extern void PIOC_IrqHandler(void);
+// USART 0
+extern void USART0_IrqHandler(void);
+// USART 1
+extern void USART1_IrqHandler(void);
+// USART 2
+extern void USART2_IrqHandler(void);
+// USART 3
+extern void USART3_IrqHandler(void);
+// Multimedia Card Interface
+extern void MCI0_IrqHandler(void);
+// TWI 0
+extern void TWI0_IrqHandler(void);
+// TWI 1
+extern void TWI1_IrqHandler(void);
+// Serial Peripheral Interface 0
+extern void SPI0_IrqHandler(void);
+// Serial Synchronous Controller 0
+extern void SSC0_IrqHandler(void);
+// Timer Counter 0
+extern void TC0_IrqHandler(void);
+// Timer Counter 1
+extern void TC1_IrqHandler(void);
+// Timer Counter 2
+extern void TC2_IrqHandler(void);
+// PWM Controller
+extern void PWM_IrqHandler(void);
+// ADC controller0
+extern void ADCC0_IrqHandler(void);
+// ADC controller1
+extern void ADCC1_IrqHandler(void);
+// HDMA
+extern void HDMA_IrqHandler(void);
+// USB Device
+extern void USBD_IrqHandler(void);
|