xref: /btstack/port/msp432p401lp-cc256x/startup_msp432p401r_gcc.c (revision 14ce5a690e126902ae23edb22d5800d11495e12e)
1f7529f1dSMatthias Ringwald /*
2f7529f1dSMatthias Ringwald  * -------------------------------------------
3f7529f1dSMatthias Ringwald  *    MSP432 DriverLib - v3_10_00_09
4f7529f1dSMatthias Ringwald  * -------------------------------------------
5f7529f1dSMatthias Ringwald  *
6f7529f1dSMatthias Ringwald  * --COPYRIGHT--,BSD,BSD
7f7529f1dSMatthias Ringwald  * Copyright (c) 2014, Texas Instruments Incorporated
8f7529f1dSMatthias Ringwald  * All rights reserved.
9f7529f1dSMatthias Ringwald  *
10f7529f1dSMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
11f7529f1dSMatthias Ringwald  * modification, are permitted provided that the following conditions
12f7529f1dSMatthias Ringwald  * are met:
13f7529f1dSMatthias Ringwald  *
14f7529f1dSMatthias Ringwald  * *  Redistributions of source code must retain the above copyright
15f7529f1dSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
16f7529f1dSMatthias Ringwald  *
17f7529f1dSMatthias Ringwald  * *  Redistributions in binary form must reproduce the above copyright
18f7529f1dSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
19f7529f1dSMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
20f7529f1dSMatthias Ringwald  *
21f7529f1dSMatthias Ringwald  * *  Neither the name of Texas Instruments Incorporated nor the names of
22f7529f1dSMatthias Ringwald  *    its contributors may be used to endorse or promote products derived
23f7529f1dSMatthias Ringwald  *    from this software without specific prior written permission.
24f7529f1dSMatthias Ringwald  *
25f7529f1dSMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26f7529f1dSMatthias Ringwald  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27f7529f1dSMatthias Ringwald  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28f7529f1dSMatthias Ringwald  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29f7529f1dSMatthias Ringwald  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30f7529f1dSMatthias Ringwald  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31f7529f1dSMatthias Ringwald  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32f7529f1dSMatthias Ringwald  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33f7529f1dSMatthias Ringwald  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34f7529f1dSMatthias Ringwald  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35f7529f1dSMatthias Ringwald  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36f7529f1dSMatthias Ringwald  * --/COPYRIGHT--*/
37f7529f1dSMatthias Ringwald //*****************************************************************************
38f7529f1dSMatthias Ringwald //
39f7529f1dSMatthias Ringwald // Copyright (C) 2012 - 2015 Texas Instruments Incorporated - http://www.ti.com/
40f7529f1dSMatthias Ringwald //
41f7529f1dSMatthias Ringwald // Redistribution and use in source and binary forms, with or without
42f7529f1dSMatthias Ringwald // modification, are permitted provided that the following conditions
43f7529f1dSMatthias Ringwald // are met:
44f7529f1dSMatthias Ringwald //
45f7529f1dSMatthias Ringwald //  Redistributions of source code must retain the above copyright
46f7529f1dSMatthias Ringwald //  notice, this list of conditions and the following disclaimer.
47f7529f1dSMatthias Ringwald //
48f7529f1dSMatthias Ringwald //  Redistributions in binary form must reproduce the above copyright
49f7529f1dSMatthias Ringwald //  notice, this list of conditions and the following disclaimer in the
50f7529f1dSMatthias Ringwald //  documentation and/or other materials provided with the
51f7529f1dSMatthias Ringwald //  distribution.
52f7529f1dSMatthias Ringwald //
53f7529f1dSMatthias Ringwald //  Neither the name of Texas Instruments Incorporated nor the names of
54f7529f1dSMatthias Ringwald //  its contributors may be used to endorse or promote products derived
55f7529f1dSMatthias Ringwald //  from this software without specific prior written permission.
56f7529f1dSMatthias Ringwald //
57f7529f1dSMatthias Ringwald // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
58f7529f1dSMatthias Ringwald // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
59f7529f1dSMatthias Ringwald // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
60f7529f1dSMatthias Ringwald // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
61f7529f1dSMatthias Ringwald // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62f7529f1dSMatthias Ringwald // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
63f7529f1dSMatthias Ringwald // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
64f7529f1dSMatthias Ringwald // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
65f7529f1dSMatthias Ringwald // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
66f7529f1dSMatthias Ringwald // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
67f7529f1dSMatthias Ringwald // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68f7529f1dSMatthias Ringwald //
69f7529f1dSMatthias Ringwald // MSP432 Family Interrupt Vector Table for GCC
70f7529f1dSMatthias Ringwald //
71f7529f1dSMatthias Ringwald //****************************************************************************
72f7529f1dSMatthias Ringwald 
73f7529f1dSMatthias Ringwald #include <stdint.h>
74f7529f1dSMatthias Ringwald 
75f7529f1dSMatthias Ringwald /* Forward declaration of the default fault handlers. */
769a7ee89cSMatthias Ringwald void resetISR(void);
77f7529f1dSMatthias Ringwald static void nmiISR(void);
78f7529f1dSMatthias Ringwald static void faultISR(void);
79f7529f1dSMatthias Ringwald static void defaultISR(void);
80f7529f1dSMatthias Ringwald 
81f7529f1dSMatthias Ringwald #ifndef HWREG
82f7529f1dSMatthias Ringwald #define HWREG(x) (*((volatile uint32_t *)(x)))
83f7529f1dSMatthias Ringwald #endif
84f7529f1dSMatthias Ringwald 
85f7529f1dSMatthias Ringwald /* system initialization funtion */
86f7529f1dSMatthias Ringwald extern void SystemInit(void);
87f7529f1dSMatthias Ringwald 
88f7529f1dSMatthias Ringwald /* Entry point for the application. */
89f7529f1dSMatthias Ringwald extern int main(void);
90f7529f1dSMatthias Ringwald 
91f7529f1dSMatthias Ringwald /* External declarations for the interrupt handlers used by the application. */
92f7529f1dSMatthias Ringwald /* To be added by the user */
93f7529f1dSMatthias Ringwald extern void EUSCIA2_IRQHandler(void);
948ba100b5SMatthias Ringwald extern void DMA_INT1_IRQHandler(void);
958ba100b5SMatthias Ringwald extern void DMA_INT2_IRQHandler(void);
96f7529f1dSMatthias Ringwald 
97f7529f1dSMatthias Ringwald /* To be added by the user */
98f7529f1dSMatthias Ringwald extern void SysTick_Handler(void);
99f7529f1dSMatthias Ringwald 
100f7529f1dSMatthias Ringwald /* Interrupt vector table.  Note that the proper constructs must be placed on this to */
101f7529f1dSMatthias Ringwald /* ensure that it ends up at physical address 0x0000.0000 or at the start of          */
102f7529f1dSMatthias Ringwald /* the program if located at a start address other than 0.                            */
103f7529f1dSMatthias Ringwald void (* const interruptVectors[])(void) __attribute__ ((section (".intvecs"))) =
104f7529f1dSMatthias Ringwald {
105*14ce5a69SMatthias Ringwald     (void (*)(void))((uint32_t)0x20010000),
106f7529f1dSMatthias Ringwald                                             /* The initial stack pointer */
107f7529f1dSMatthias Ringwald     resetISR,                               /* The reset handler         */
108f7529f1dSMatthias Ringwald     nmiISR,                                 /* The NMI handler           */
109f7529f1dSMatthias Ringwald     faultISR,                               /* The hard fault handler    */
110f7529f1dSMatthias Ringwald     defaultISR,                             /* The MPU fault handler     */
111f7529f1dSMatthias Ringwald     defaultISR,                             /* The bus fault handler     */
112f7529f1dSMatthias Ringwald     defaultISR,                             /* The usage fault handler   */
113f7529f1dSMatthias Ringwald     0,                                      /* Reserved                  */
114f7529f1dSMatthias Ringwald     0,                                      /* Reserved                  */
115f7529f1dSMatthias Ringwald     0,                                      /* Reserved                  */
116f7529f1dSMatthias Ringwald     0,                                      /* Reserved                  */
117f7529f1dSMatthias Ringwald     defaultISR,                             /* SVCall handler            */
118f7529f1dSMatthias Ringwald     defaultISR,                             /* Debug monitor handler     */
119f7529f1dSMatthias Ringwald     0,                                      /* Reserved                  */
120f7529f1dSMatthias Ringwald     defaultISR,                             /* The PendSV handler        */
121f7529f1dSMatthias Ringwald     SysTick_Handler,                        /* The SysTick handler       */
122f7529f1dSMatthias Ringwald     defaultISR,                             /* PSS ISR                   */
123f7529f1dSMatthias Ringwald     defaultISR,                             /* CS ISR                    */
124f7529f1dSMatthias Ringwald     defaultISR,                             /* PCM ISR                   */
125f7529f1dSMatthias Ringwald     defaultISR,                             /* WDT ISR                   */
126f7529f1dSMatthias Ringwald     defaultISR,                             /* FPU ISR                   */
127f7529f1dSMatthias Ringwald     defaultISR,                             /* FLCTL ISR                 */
128f7529f1dSMatthias Ringwald     defaultISR,                             /* COMP0 ISR                 */
129f7529f1dSMatthias Ringwald     defaultISR,                             /* COMP1 ISR                 */
130f7529f1dSMatthias Ringwald     defaultISR,                             /* TA0_0 ISR                 */
131f7529f1dSMatthias Ringwald     defaultISR,                             /* TA0_N ISR                 */
132f7529f1dSMatthias Ringwald     defaultISR,                             /* TA1_0 ISR                 */
133f7529f1dSMatthias Ringwald     defaultISR,                             /* TA1_N ISR                 */
134f7529f1dSMatthias Ringwald     defaultISR,                             /* TA2_0 ISR                 */
135f7529f1dSMatthias Ringwald     defaultISR,                             /* TA2_N ISR                 */
136f7529f1dSMatthias Ringwald     defaultISR,                             /* TA3_0 ISR                 */
137f7529f1dSMatthias Ringwald     defaultISR,                             /* TA3_N ISR                 */
138f7529f1dSMatthias Ringwald     defaultISR,                             /* EUSCIA0 ISR               */
139f7529f1dSMatthias Ringwald     defaultISR,                             /* EUSCIA1 ISR               */
1408ba100b5SMatthias Ringwald     defaultISR,                             /* EUSCIA2 ISR               */
141f7529f1dSMatthias Ringwald     defaultISR,                             /* EUSCIA3 ISR               */
142f7529f1dSMatthias Ringwald     defaultISR,                             /* EUSCIB0 ISR               */
143f7529f1dSMatthias Ringwald     defaultISR,                             /* EUSCIB1 ISR               */
144f7529f1dSMatthias Ringwald     defaultISR,                             /* EUSCIB2 ISR               */
145f7529f1dSMatthias Ringwald     defaultISR,                             /* EUSCIB3 ISR               */
146f7529f1dSMatthias Ringwald     defaultISR,                             /* ADC14 ISR                 */
147f7529f1dSMatthias Ringwald     defaultISR,                             /* T32_INT1 ISR              */
148f7529f1dSMatthias Ringwald     defaultISR,                             /* T32_INT2 ISR              */
149f7529f1dSMatthias Ringwald     defaultISR,                             /* T32_INTC ISR              */
150f7529f1dSMatthias Ringwald     defaultISR,                             /* AES ISR                   */
151f7529f1dSMatthias Ringwald     defaultISR,                             /* RTC ISR                   */
152f7529f1dSMatthias Ringwald     defaultISR,                             /* DMA_ERR ISR               */
153f7529f1dSMatthias Ringwald     defaultISR,                             /* DMA_INT3 ISR              */
1548ba100b5SMatthias Ringwald     DMA_INT2_IRQHandler,                    /* DMA_INT2 ISR              */
1558ba100b5SMatthias Ringwald     DMA_INT1_IRQHandler,                    /* DMA_INT1 ISR              */
156f7529f1dSMatthias Ringwald     defaultISR,                             /* DMA_INT0 ISR              */
157f7529f1dSMatthias Ringwald     defaultISR,                             /* PORT1 ISR                 */
158f7529f1dSMatthias Ringwald     defaultISR,                             /* PORT2 ISR                 */
159f7529f1dSMatthias Ringwald     defaultISR,                             /* PORT3 ISR                 */
160f7529f1dSMatthias Ringwald     defaultISR,                             /* PORT4 ISR                 */
161f7529f1dSMatthias Ringwald     defaultISR,                             /* PORT5 ISR                 */
162f7529f1dSMatthias Ringwald     defaultISR,                             /* PORT6 ISR                 */
163f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 41               */
164f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 42               */
165f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 43               */
166f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 44               */
167f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 45               */
168f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 46               */
169f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 47               */
170f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 48               */
171f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 49               */
172f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 50               */
173f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 51               */
174f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 52               */
175f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 53               */
176f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 54               */
177f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 55               */
178f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 56               */
179f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 57               */
180f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 58               */
181f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 59               */
182f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 60               */
183f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 61               */
184f7529f1dSMatthias Ringwald     defaultISR,                             /* Reserved 62               */
185f7529f1dSMatthias Ringwald     defaultISR                              /* Reserved 63               */
186f7529f1dSMatthias Ringwald };
187f7529f1dSMatthias Ringwald 
188f7529f1dSMatthias Ringwald /* This is the code that gets called when the processor first starts execution */
189f7529f1dSMatthias Ringwald /* following a reset event.  Only the absolutely necessary set is performed,   */
190f7529f1dSMatthias Ringwald /* after which the application supplied entry() routine is called.  Any fancy  */
191f7529f1dSMatthias Ringwald /* actions (such as making decisions based on the reset cause register, and    */
192f7529f1dSMatthias Ringwald /* resetting the bits in that register) are left solely in the hands of the    */
193f7529f1dSMatthias Ringwald /* application.                                                                */
194f7529f1dSMatthias Ringwald extern uint32_t __data_load__;
195f7529f1dSMatthias Ringwald extern uint32_t __data_start__;
196f7529f1dSMatthias Ringwald extern uint32_t __data_end__;
197f7529f1dSMatthias Ringwald 
resetISR(void)198f7529f1dSMatthias Ringwald void resetISR(void)
199f7529f1dSMatthias Ringwald {
200f7529f1dSMatthias Ringwald     /* Copy the data segment initializers from flash to SRAM. */
201f7529f1dSMatthias Ringwald     uint32_t *pui32Src, *pui32Dest;
202f7529f1dSMatthias Ringwald 
203f7529f1dSMatthias Ringwald     pui32Src = &__data_load__;
204f7529f1dSMatthias Ringwald     for(pui32Dest = &__data_start__; pui32Dest < &__data_end__; )
205f7529f1dSMatthias Ringwald     {
206f7529f1dSMatthias Ringwald         *pui32Dest++ = *pui32Src++;
207f7529f1dSMatthias Ringwald     }
208f7529f1dSMatthias Ringwald 
209f7529f1dSMatthias Ringwald     /* Zero fill the bss segment. */
210f7529f1dSMatthias Ringwald     __asm("    ldr     r0, =__bss_start__\n"
211f7529f1dSMatthias Ringwald           "    ldr     r1, =__bss_end__\n"
212f7529f1dSMatthias Ringwald           "    mov     r2, #0\n"
213f7529f1dSMatthias Ringwald           "    .thumb_func\n"
214f7529f1dSMatthias Ringwald           "zero_loop:\n"
215f7529f1dSMatthias Ringwald           "        cmp     r0, r1\n"
216f7529f1dSMatthias Ringwald           "        it      lt\n"
217f7529f1dSMatthias Ringwald           "        strlt   r2, [r0], #4\n"
218f7529f1dSMatthias Ringwald           "        blt     zero_loop");
219f7529f1dSMatthias Ringwald 
220f7529f1dSMatthias Ringwald     /* Call system initialization routine */
221f7529f1dSMatthias Ringwald   SystemInit();
222f7529f1dSMatthias Ringwald 
223f7529f1dSMatthias Ringwald     /* Call the application's entry point. */
224f7529f1dSMatthias Ringwald     main();
225f7529f1dSMatthias Ringwald }
226f7529f1dSMatthias Ringwald 
227f7529f1dSMatthias Ringwald 
228f7529f1dSMatthias Ringwald /* This is the code that gets called when the processor receives a NMI.  This  */
229f7529f1dSMatthias Ringwald /* simply enters an infinite loop, preserving the system state for examination */
230f7529f1dSMatthias Ringwald /* by a debugger.                                                              */
nmiISR(void)231f7529f1dSMatthias Ringwald static void nmiISR(void)
232f7529f1dSMatthias Ringwald {
233f7529f1dSMatthias Ringwald     /* Enter an infinite loop. */
234f7529f1dSMatthias Ringwald     while(1)
235f7529f1dSMatthias Ringwald     {
236f7529f1dSMatthias Ringwald     }
237f7529f1dSMatthias Ringwald }
238f7529f1dSMatthias Ringwald 
239f7529f1dSMatthias Ringwald 
240f7529f1dSMatthias Ringwald /* This is the code that gets called when the processor receives a fault        */
241f7529f1dSMatthias Ringwald /* interrupt.  This simply enters an infinite loop, preserving the system state */
242f7529f1dSMatthias Ringwald /* for examination by a debugger.                                               */
faultISR(void)243f7529f1dSMatthias Ringwald static void faultISR(void)
244f7529f1dSMatthias Ringwald {
245f7529f1dSMatthias Ringwald     /* Enter an infinite loop. */
246f7529f1dSMatthias Ringwald     while(1)
247f7529f1dSMatthias Ringwald     {
248f7529f1dSMatthias Ringwald     }
249f7529f1dSMatthias Ringwald }
250f7529f1dSMatthias Ringwald 
251f7529f1dSMatthias Ringwald 
252f7529f1dSMatthias Ringwald /* This is the code that gets called when the processor receives an unexpected  */
253f7529f1dSMatthias Ringwald /* interrupt.  This simply enters an infinite loop, preserving the system state */
254f7529f1dSMatthias Ringwald /* for examination by a debugger.                                               */
defaultISR(void)255f7529f1dSMatthias Ringwald static void defaultISR(void)
256f7529f1dSMatthias Ringwald {
257f7529f1dSMatthias Ringwald     /* Enter an infinite loop. */
258f7529f1dSMatthias Ringwald     while(1)
259f7529f1dSMatthias Ringwald     {
260f7529f1dSMatthias Ringwald     }
261f7529f1dSMatthias Ringwald }
262