2 * Copyright (c) 2016, Texas Instruments Incorporated
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include <ti/devices/cc32xx/inc/hw_types.h>
37 #include <ti/devices/cc32xx/inc/hw_ints.h>
38 #include <ti/devices/cc32xx/inc/hw_memmap.h>
39 #include <ti/devices/cc32xx/inc/hw_common_reg.h>
41 #include <ti/devices/cc32xx/driverlib/interrupt.h>
42 #include <ti/devices/cc32xx/inc/hw_apps_rcm.h>
43 #include <ti/devices/cc32xx/driverlib/rom_map.h>
44 #include <ti/devices/cc32xx/driverlib/prcm.h>
46 //*****************************************************************************
48 // Forward declaration of the default fault handlers.
50 //*****************************************************************************
52 static void nmiISR(void);
53 static void faultISR(void);
54 static void defaultHandler(void);
55 static void busFaultHandler(void);
57 //*****************************************************************************
59 // External declaration for the reset handler that is to be called when the
60 // processor is started
62 //*****************************************************************************
63 extern void _c_int00(void);
64 extern void vPortSVCHandler(void);
65 extern void xPortPendSVHandler(void);
66 extern void xPortSysTickHandler(void);
68 //*****************************************************************************
70 // Linker variable that marks the top of the stack.
72 //*****************************************************************************
73 extern unsigned long __STACK_END;
75 //*****************************************************************************
76 // The vector table. Note that the proper constructs must be placed on this to
77 // ensure that it ends up at physical address 0x0000.0000 or at the start of
78 // the program if located at a start address other than 0.
80 //*****************************************************************************
81 #pragma RETAIN(resetVectors)
82 #pragma DATA_SECTION(resetVectors, ".resetVecs")
83 void (* const resetVectors[16])(void) =
85 (void (*)(void))((unsigned long)&__STACK_END),
86 // The initial stack pointer
87 resetISR, // The reset handler
88 nmiISR, // The NMI handler
89 faultISR, // The hard fault handler
90 defaultHandler, // The MPU fault handler
91 busFaultHandler, // The bus fault handler
92 defaultHandler, // The usage fault handler
97 vPortSVCHandler, // SVCall handler
98 defaultHandler, // Debug monitor handler
100 xPortPendSVHandler, // The PendSV handler
101 xPortSysTickHandler // The SysTick handler
105 #pragma DATA_SECTION(ramVectors, ".ramVecs")
106 static unsigned long ramVectors[256];
108 //*****************************************************************************
110 // Copy the first 16 vectors from the read-only/reset table to the runtime
111 // RAM table. Fill the remaining vectors with a stub. This vector table will
112 // be updated at runtime.
114 //*****************************************************************************
115 void initVectors(void)
119 /* Copy from reset vector table into RAM vector table */
120 memcpy(ramVectors, resetVectors, 16*4);
122 /* fill remaining vectors with default handler */
123 for (i=16; i < 256; i++) {
124 ramVectors[i] = (unsigned long)defaultHandler;
127 /* Set vector table base */
128 MAP_IntVTableBaseSet((unsigned long)&ramVectors[0]);
130 /* Enable Processor */
131 MAP_IntMasterEnable();
132 MAP_IntEnable(FAULT_SYSTICK);
135 //*****************************************************************************
137 // This is the code that gets called when the processor first starts execution
138 // following a reset event. Only the absolutely necessary set is performed,
139 // after which the application supplied entry() routine is called. Any fancy
140 // actions (such as making decisions based on the reset cause register, and
141 // resetting the bits in that register) are left solely in the hands of the
144 //*****************************************************************************
148 * Set stack pointer based on the stack value stored in the vector table.
149 * This is necessary to ensure that the application is using the correct
150 * stack when using a debugger since a reset within the debugger will
151 * load the stack pointer from the bootloader's vector table at address '0'.
153 __asm(" .global resetVectorAddr\n"
154 " ldr r0, resetVectorAddr\n"
159 /* Jump to the CCS C Initialization Routine. */
160 __asm(" .global _c_int00\n"
163 _Pragma("diag_suppress 1119");
164 __asm("resetVectorAddr: .word resetVectors");
165 _Pragma("diag_default 1119");
168 //*****************************************************************************
170 // This is the code that gets called when the processor receives a NMI. This
171 // simply enters an infinite loop, preserving the system state for examination
174 //*****************************************************************************
178 /* Enter an infinite loop. */
184 //*****************************************************************************
186 // This is the code that gets called when the processor receives a fault
187 // interrupt. This simply enters an infinite loop, preserving the system state
188 // for examination by a debugger.
190 //*****************************************************************************
194 /* Enter an infinite loop. */
200 //*****************************************************************************
202 // This is the code that gets called when the processor receives an unexpected
203 // interrupt. This simply enters an infinite loop, preserving the system state
204 // for examination by a debugger.
206 //*****************************************************************************
209 busFaultHandler(void)
211 /* Enter an infinite loop. */
217 //*****************************************************************************
219 // This is the code that gets called when the processor receives an unexpected
220 // interrupt. This simply enters an infinite loop, preserving the system state
221 // for examination by a debugger.
223 //*****************************************************************************
227 /* Enter an infinite loop. */