forked from GeorgeSinodakis/cpp_stm32f103_snakeGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup.cpp
187 lines (176 loc) · 8.52 KB
/
startup.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include <stdint.h>
typedef uint32_t u32;
typedef uint8_t u8;
extern u32 _sidata, _sdata, _edata, _sbss, _ebss, _estack;
int main(void);
extern "C" void Reset_Handler(void);
extern "C" void Default_Handler(void);
extern "C" void __libc_init_array(void);
extern "C" void NMI_Handler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void HardFault_Handler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void MemManage_Handler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void BusFault_Handler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void UsageFault_Handler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void SVC_Handler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void DebugMon_Handler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void PendSV_Handler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void SysTick_Handler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void WWDG_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void PVD_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TAMPER_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void RTC_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void FLASH_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void RCC_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void EXTI0_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void EXTI1_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void EXTI2_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void EXTI3_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void EXTI4_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void DMA1_Channel1_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void DMA1_Channel2_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void DMA1_Channel3_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void DMA1_Channel4_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void DMA1_Channel5_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void DMA1_Channel6_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void DMA1_Channel7_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void ADC1_2_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void USB_HP_CAN_TX_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void USB_LP_CAN_RX0_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void CAN_RX1_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void CAN_SCE_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void EXTI9_5_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM1_BRK_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM1_UP_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM1_TRG_COM_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM1_CC_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM2_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM3_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM4_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void I2C1_EV_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void I2C1_ER_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void I2C2_EV_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void I2C2_ER_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void SPI1_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void SPI2_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void USART1_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void USART2_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void USART3_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void EXTI15_10_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void RTCAlarm_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM8_BRK_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM8_UP_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM8_TRG_COM_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM8_CC_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void ADC3_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void FSMC_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void SDIO_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM5_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void SPI3_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void UART4_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void UART5_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM6_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void TIM7_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void DMA2_Channel1_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void DMA2_Channel2_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void DMA2_Channel3_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void DMA2_Channel4_5_IRQHandler(void) __attribute__((weak, alias("Default_Handler")));
extern "C" void Reset_Handler(void)
{
//copy data section
u8 *source = (u8*)&_sidata, *destination = (u8*)&_sdata;
while (destination < (u8*)&_edata)
{
*destination++ = *source++;
}
//zero the bss section
destination = (u8*)&_sbss;
while (destination < (u8*)&_ebss)
{
*destination++ = 0;
}
asm ("bl __libc_init_array");
asm ("bl main");
while (1);
}
extern "C" void Default_Handler(void)
{
while (1);
}
u32 vectors[] __attribute__((section(".isr_vector"))) = {
(u32)&_estack,
(u32)Reset_Handler,
(u32)NMI_Handler,
(u32)HardFault_Handler,
(u32)MemManage_Handler,
(u32)BusFault_Handler,
(u32)UsageFault_Handler,
(u32)0,
(u32)0,
(u32)0,
(u32)0,
(u32)SVC_Handler,
(u32)DebugMon_Handler,
(u32)0,
(u32)PendSV_Handler,
(u32)SysTick_Handler,
(u32)WWDG_IRQHandler,
(u32)PVD_IRQHandler,
(u32)TAMPER_IRQHandler,
(u32)RTC_IRQHandler,
(u32)FLASH_IRQHandler,
(u32)RCC_IRQHandler,
(u32)EXTI0_IRQHandler,
(u32)EXTI1_IRQHandler,
(u32)EXTI2_IRQHandler,
(u32)EXTI3_IRQHandler,
(u32)EXTI4_IRQHandler,
(u32)DMA1_Channel1_IRQHandler,
(u32)DMA1_Channel2_IRQHandler,
(u32)DMA1_Channel3_IRQHandler,
(u32)DMA1_Channel4_IRQHandler,
(u32)DMA1_Channel5_IRQHandler,
(u32)DMA1_Channel6_IRQHandler,
(u32)DMA1_Channel7_IRQHandler,
(u32)ADC1_2_IRQHandler,
(u32)USB_HP_CAN_TX_IRQHandler,
(u32)USB_LP_CAN_RX0_IRQHandler,
(u32)CAN_RX1_IRQHandler,
(u32)CAN_SCE_IRQHandler,
(u32)EXTI9_5_IRQHandler,
(u32)TIM1_BRK_IRQHandler,
(u32)TIM1_UP_IRQHandler,
(u32)TIM1_TRG_COM_IRQHandler,
(u32)TIM1_CC_IRQHandler,
(u32)TIM2_IRQHandler,
(u32)TIM3_IRQHandler,
(u32)TIM4_IRQHandler,
(u32)I2C1_EV_IRQHandler,
(u32)I2C1_ER_IRQHandler,
(u32)I2C2_EV_IRQHandler,
(u32)I2C2_ER_IRQHandler,
(u32)SPI1_IRQHandler,
(u32)SPI2_IRQHandler,
(u32)USART1_IRQHandler,
(u32)USART2_IRQHandler,
(u32)USART3_IRQHandler,
(u32)EXTI15_10_IRQHandler,
(u32)RTCAlarm_IRQHandler,
(u32)0,
(u32)TIM8_BRK_IRQHandler,
(u32)TIM8_UP_IRQHandler,
(u32)TIM8_TRG_COM_IRQHandler,
(u32)TIM8_CC_IRQHandler,
(u32)ADC3_IRQHandler,
(u32)FSMC_IRQHandler,
(u32)SDIO_IRQHandler,
(u32)TIM5_IRQHandler,
(u32)SPI3_IRQHandler,
(u32)UART4_IRQHandler,
(u32)UART5_IRQHandler,
(u32)TIM6_IRQHandler,
(u32)TIM7_IRQHandler,
(u32)DMA2_Channel1_IRQHandler,
(u32)DMA2_Channel2_IRQHandler,
(u32)DMA2_Channel3_IRQHandler,
(u32)DMA2_Channel4_5_IRQHandler
};