xref: /aosp_15_r20/external/pigweed/targets/stm32f429i_disc1_stm32cube/vector_table.c (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1 // Copyright 2021 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 
15 #include <stdbool.h>
16 
17 #include "pw_boot/boot.h"
18 #include "pw_boot_cortex_m/boot.h"
19 #include "pw_preprocessor/compiler.h"
20 #include "stm32f4xx.h"
21 
22 // Default handler to insert into the ARMv7-M vector table (below).
23 // This function exists for convenience. If a device isn't doing what you
24 // expect, it might have hit a fault and ended up here.
DefaultFaultHandler(void)25 static void DefaultFaultHandler(void) {
26   while (true) {
27     // Wait for debugger to attach.
28   }
29 }
30 
31 // This is the device's interrupt vector table. It's not referenced in any
32 // code because the platform (STM32F4xx) expects this table to be present at the
33 // beginning of flash. The exact address is specified in the pw_boot_armv7m
34 // configuration as part of the target config.
35 //
36 // For more information, see ARMv7-M Architecture Reference Manual DDI 0403E.b
37 // section B1.5.3.
38 
39 // This typedef is for convenience when building the vector table. With the
40 // exception of SP_main (0th entry in the vector table), all the entries of the
41 // vector table are function pointers.
42 typedef void (*InterruptHandler)(void);
43 
44 // This is the timer interrupt handler implemented by the stm32cubef4 timer
45 // template.
46 void TIM6_DAC_IRQHandler(void);
47 
48 // Interrupt handlers critical for OS operation.
49 void SVC_Handler(void);
50 void PendSV_Handler(void);
51 void SysTick_Handler(void);
52 
53 PW_KEEP_IN_SECTION(".vector_table")
54 const InterruptHandler vector_table[] = {
55     // The starting location of the stack pointer.
56     // This address is NOT an interrupt handler/function pointer, it is simply
57     // the address that the main stack pointer should be initialized to. The
58     // value is reinterpret casted because it needs to be in the vector table.
59     [0] = (InterruptHandler)(&pw_boot_stack_high_addr),
60 
61     // Reset handler, dictates how to handle reset interrupt. This is the
62     // address that the Program Counter (PC) is initialized to at boot.
63     [1] = pw_boot_Entry,
64 
65     // NMI handler.
66     [2] = DefaultFaultHandler,
67     // HardFault handler.
68     [3] = DefaultFaultHandler,
69     // 4-6: Specialized fault handlers.
70     // 7-10: Reserved.
71     // SVCall handler.
72     [11] = SVC_Handler,
73     // DebugMon handler.
74     [12] = DefaultFaultHandler,
75     // 13: Reserved.
76     // PendSV handler.
77     [14] = PendSV_Handler,
78     // SysTick handler.
79     [15] = SysTick_Handler,
80     // stm32f4xx_hal sys-tick handler.
81     [TIM6_DAC_IRQn + 16] = TIM6_DAC_IRQHandler,
82 };
83