1 // Copyright 2020 The Pigweed Authors
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
7 // https://www.apache.org/licenses/LICENSE-2.0
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
15 #include "pw_boot_armv7m/boot.h"
19 // Default handler to insert into the ARMv7-M vector table (below).
20 // This function exists for convenience. If a device isn't doing what you
21 // expect, it might have hit a fault and ended up here.
22 void DefaultFaultHandler(void) {
24 // Wait for debugger to attach.
28 // This is the device's interrupt vector table. It's not referenced in any
29 // code because the platform (STM32F4xx) expects this table to be present at the
30 // beginning of flash. The exact address is specified in the pw_boot_armv7m
31 // configuration as part of the target config.
33 // For more information, see ARMv7-M Architecture Reference Manual DDI 0403E.b
36 // This typedef is for convenience when building the vector table. With the
37 // exception of SP_main (0th entry in the vector table), all the entries of the
38 // vector table are function pointers.
39 typedef void (*InterruptHandler)();
41 PW_KEEP_IN_SECTION(".vector_table")
42 const InterruptHandler vector_table[] = {
43 // The starting location of the stack pointer.
44 // This address is NOT an interrupt handler/function pointer, it is simply
45 // the address that the main stack pointer should be initialized to. The
46 // value is reinterpret casted because it needs to be in the vector table.
47 [0] = reinterpret_cast<InterruptHandler>(&pw_boot_stack_high_addr),
49 // Reset handler, dictates how to handle reset interrupt. This is the
50 // address that the Program Counter (PC) is initialized to at boot.
54 [2] = DefaultFaultHandler,
56 [3] = DefaultFaultHandler,