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#![crate_name = "stm32f4xx"]
10#![crate_type = "rlib"]
11#![no_std]
12
13pub mod chip;
14pub mod chip_specific;
15pub mod nvic;
16
17// Peripherals
18pub mod adc;
19pub mod can;
20pub mod dac;
21pub mod dbg;
22pub mod dma;
23pub mod exti;
24pub mod flash;
25pub mod fsmc;
26pub mod gpio;
27pub mod i2c;
28pub mod rcc;
29pub mod spi;
30pub mod syscfg;
31pub mod tim2;
32pub mod trng;
33pub mod usart;
34
35// Clocks
36pub mod clocks;
37
38use cortexm4f::{initialize_ram_jump_to_main, unhandled_interrupt, CortexM4F, CortexMVariant};
39
40extern "C" {
41    // _estack is not really a function, but it makes the types work
42    // You should never actually invoke it!!
43    fn _estack();
44}
45
46#[cfg_attr(
47    all(target_arch = "arm", target_os = "none"),
48    link_section = ".vectors"
49)]
50// used Ensures that the symbol is kept until the final binary
51#[cfg_attr(all(target_arch = "arm", target_os = "none"), used)]
52pub static BASE_VECTORS: [unsafe extern "C" fn(); 16] = [
53    _estack,
54    initialize_ram_jump_to_main,
55    unhandled_interrupt,           // NMI
56    CortexM4F::HARD_FAULT_HANDLER, // Hard Fault
57    unhandled_interrupt,           // MemManage
58    unhandled_interrupt,           // BusFault
59    unhandled_interrupt,           // UsageFault
60    unhandled_interrupt,
61    unhandled_interrupt,
62    unhandled_interrupt,
63    unhandled_interrupt,
64    CortexM4F::SVC_HANDLER, // SVC
65    unhandled_interrupt,    // DebugMon
66    unhandled_interrupt,
67    unhandled_interrupt,        // PendSV
68    CortexM4F::SYSTICK_HANDLER, // SysTick
69];
70
71pub unsafe fn init() {
72    cortexm4f::nvic::disable_all();
73    cortexm4f::nvic::clear_all_pending();
74    cortexm4f::nvic::enable_all();
75}