1 /******************************************************************************
3 * Copyright (C) 2012-2018 Texas Instruments Incorporated - http://www.ti.com/
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
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ******************************************************************************/
37 /* Entry point for the application. */
40 /* Reserve space for the system stack. */
41 extern uint32_t __stack_top;
43 typedef void(*pFunc)(void);
45 /* Interrupt handler prototypes */
46 void default_handler(void);
47 void reset_handler(void);
50 * The vector table. Note that the proper constructs must be placed on this to
51 * ensure that it ends up at physical address 0x0000.0000 or at the start of
52 * the program if located at a start address other than 0.
54 void (* const intr_vectors[])(void) __attribute__((section(".intvecs"))) = {
55 (pFunc)&__stack_top, /* The initial stack pointer */
56 reset_handler, /* The reset handler */
57 default_handler, /* The NMI handler */
58 default_handler, /* The hard fault handler */
59 default_handler, /* The MPU fault handler */
60 default_handler, /* The bus fault handler */
61 default_handler, /* The usage fault handler */
66 default_handler, /* SVCall handler */
67 default_handler, /* Debug monitor handler */
69 default_handler, /* The PendSV handler */
70 default_handler /* The SysTick handler */
74 * The following are constructs created by the linker, indicating where
75 * the "data" and "bss" segments reside in memory. The initializers for
76 * the "data" segment resides immediately following the "text" segment.
78 extern uint32_t __bss_start__;
79 extern uint32_t __bss_end__;
82 * This is the code that gets called when the processor first starts execution
83 * following a reset event. Only the absolutely necessary set is performed,
84 * after which the application supplied entry() routine is called. Any fancy
85 * actions (such as making decisions based on the reset cause register, and
86 * resetting the bits in that register) are left solely in the hands of the
89 __attribute__((section(".reset"))) __attribute__((naked))
90 void reset_handler(void)
92 /* Set stack pointer */
93 __asm(" MOVW.W r0, #0x1700\n"
94 " MOVT.W r0, #0x0100\n"
97 /* Zero fill the bss segment. */
98 __asm(" ldr r0, =__bss_start__\n"
99 " ldr r1, =__bss_end__\n"
105 " strlt r2, [r0], #4\n"
108 /* Call the application's entry point. */
113 * This is the code that gets called when the processor receives an unexpected
114 * interrupt. This simply enters an infinite loop, preserving the system state
115 * for examination by a debugger.
117 void default_handler(void)
119 /* Enter an infinite loop. */