stm32f4xx/
lib.rs

1// Licensed under the Apache License, Version 2.0 or the MIT License.
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3// Copyright Tock Contributors 2022.
4
5//! Peripheral implementations for the STM32F4xx MCU.
6//!
7//! STM32F446RE: <https://www.st.com/en/microcontrollers/stm32f4.html>
8
9#![no_std]
10
11pub mod chip;
12pub mod chip_specific;
13pub mod nvic;
14
15// Peripherals
16pub mod adc;
17pub mod can;
18pub mod dac;
19pub mod dbg;
20pub mod dma;
21pub mod exti;
22pub mod flash;
23pub mod fsmc;
24pub mod gpio;
25pub mod i2c;
26pub mod rcc;
27pub mod spi;
28pub mod syscfg;
29pub mod tim2;
30pub mod trng;
31pub mod usart;
32
33// Clocks
34pub mod clocks;
35
36use cortexm4f::{initialize_ram_jump_to_main, unhandled_interrupt, CortexM4F, CortexMVariant};
37
38extern "C" {
39    // _estack is not really a function, but it makes the types work
40    // You should never actually invoke it!!
41    fn _estack();
42}
43
44#[cfg_attr(
45    all(target_arch = "arm", target_os = "none"),
46    link_section = ".vectors"
47)]
48// used Ensures that the symbol is kept until the final binary
49#[cfg_attr(all(target_arch = "arm", target_os = "none"), used)]
50pub static BASE_VECTORS: [unsafe extern "C" fn(); 16] = [
51    _estack,
52    initialize_ram_jump_to_main,
53    unhandled_interrupt,           // NMI
54    CortexM4F::HARD_FAULT_HANDLER, // Hard Fault
55    unhandled_interrupt,           // MemManage
56    unhandled_interrupt,           // BusFault
57    unhandled_interrupt,           // UsageFault
58    unhandled_interrupt,
59    unhandled_interrupt,
60    unhandled_interrupt,
61    unhandled_interrupt,
62    CortexM4F::SVC_HANDLER, // SVC
63    unhandled_interrupt,    // DebugMon
64    unhandled_interrupt,
65    unhandled_interrupt,        // PendSV
66    CortexM4F::SYSTICK_HANDLER, // SysTick
67];
68
69pub unsafe fn init() {
70    cortexm4f::nvic::disable_all();
71    cortexm4f::nvic::clear_all_pending();
72    cortexm4f::nvic::enable_all();
73}