blob: ad2ea7d963b09783cfcf4ed2624187ee17865000 [file] [log] [blame]
Varun Sharma4d75b022021-04-01 21:43:48 -07001// Copyright 2020 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
Varun Sharma3fd15612021-08-12 10:39:01 -070017#include "pw_boot/boot.h"
18#include "pw_boot_cortex_m/boot.h"
Varun Sharma4d75b022021-04-01 21:43:48 -070019#include "stm32f4xx.h"
20
21// Default handler to insert into the ARMv7-M vector table (below).
22// This function exists for convenience. If a device isn't doing what you
23// expect, it might have hit a fault and ended up here.
24static void DefaultFaultHandler(void) {
25 while (true) {
26 // Wait for debugger to attach.
27 }
28}
29
30// This is the device's interrupt vector table. It's not referenced in any
31// code because the platform (STM32F4xx) expects this table to be present at the
32// beginning of flash. The exact address is specified in the pw_boot_armv7m
33// configuration as part of the target config.
34//
35// For more information, see ARMv7-M Architecture Reference Manual DDI 0403E.b
36// section B1.5.3.
37
38// This typedef is for convenience when building the vector table. With the
39// exception of SP_main (0th entry in the vector table), all the entries of the
40// vector table are function pointers.
41typedef void (*InterruptHandler)(void);
42
43// This is the timer interrupt handler implemented by the stm32cubef4 timer
44// template.
45void TIM6_DAC_IRQHandler(void);
46
47PW_KEEP_IN_SECTION(".vector_table")
48const InterruptHandler vector_table[] = {
49 // The starting location of the stack pointer.
50 // This address is NOT an interrupt handler/function pointer, it is simply
51 // the address that the main stack pointer should be initialized to. The
52 // value is reinterpret casted because it needs to be in the vector table.
53 [0] = (InterruptHandler)(&pw_boot_stack_high_addr),
54
55 // Reset handler, dictates how to handle reset interrupt. This is the
56 // address that the Program Counter (PC) is initialized to at boot.
57 [1] = pw_boot_Entry,
58
59 // NMI handler.
60 [2] = DefaultFaultHandler,
61 // HardFault handler.
62 [3] = DefaultFaultHandler,
63
64 // stm32f4xx_hal sys-tick handler.
65 [TIM6_DAC_IRQn + 16] = TIM6_DAC_IRQHandler,
66};