stm32h7xx_hal/
lib.rs

1//! *See the [examples](https://github.com/stm32-rs/stm32h7xx-hal/tree/master/examples) folder for more usage examples*
2//!
3//! This Hardware Abstraction Layer (HAL) provides the following functionality:
4//!
5//! Setup and Configuration
6//!
7//! * [Power Configuration](crate::pwr)
8//! * [Reset and Clock Control](crate::rcc)
9//!
10//! Digital IO
11//!
12//! * [General Purpose Input / Output](crate::gpio)
13//! * [External interrupt controller](crate::exti)
14//!
15//! Analog IO
16//!
17//! * [Analog to Digital Converter (ADC)](crate::adc)
18//! * [Digital to Analog Converter (DAC)](crate::dac)
19//!
20//! Digital Busses
21//!
22//! * [Inter Integrated Circuit (I2C)](crate::i2c)
23//! * [Serial Peripheral Interface (SPI)](crate::spi)
24//! * [Serial Data (USART/UART)](crate::serial)
25//! * [Serial Audio Interface](crate::sai)
26//! * [Quad or Octo SPI](crate::xspi) Feature gate `xspi`
27//! * [Ethernet](crate::ethernet) Feature gate `ethernet`
28//! * [USB HS](crate::usb_hs) Feature gate `usb_hs`
29//! * [LCD-TFT Display Controller](crate::ltdc) Feature gate `ltdc`
30//! * MIPI DSI (STM32H747/757 only) Feature gate `dsi`
31//! * [CAN and CAN-FD](crate::can) Feature gate `can`
32//!
33//! External Memory
34//!
35//! * [Flexible Memory Controller (FMC)](crate::fmc) Feature gate `fmc`
36//! * [SD Card (SDMMC)](crate::sdmmc) Feature gate `sdmmc` (FAT16/32 driver is available under the `sdmmc-fatfs` feature gate)
37//!
38//! Timing functions
39//!
40//! * [Pulse Width Modulation (PWM)](crate::pwm)
41//! * [Quadrature Encoder Interface](crate::qei)
42//! * [Real-Time Clock](crate::rtc) Feature gate `rtc`
43//! * [Timers](crate::timer)
44//! * [Delays](crate::delay)
45//!
46//! Others
47//!
48//! * [Direct Memory Access (DMA)](crate::dma)
49//! * [Cyclic Redundancy Check (CRC)](crate::crc) Feature gate `crc`
50//! * [Random Number Generator](crate::rng) ([rand_core::RngCore] is implemented under the `rand` feature gate)
51//! * [Embedded Flash Memory](crate::flash)
52//! * [System Window Watchdog](crate::system_watchdog)
53//! * [Independent Watchdog](crate::independent_watchdog)
54//!
55//! Cargo Features
56//!
57//! * [`defmt`](https://defmt.ferrous-systems.com/) formatting for some types can be enabled with the feature `defmt`.
58
59#![cfg_attr(not(test), no_std)]
60#![cfg_attr(docsrs, feature(doc_cfg))]
61#![allow(non_camel_case_types)]
62
63extern crate paste;
64
65#[cfg(not(feature = "device-selected"))]
66compile_error!(
67    "This crate requires one of the following device features enabled:
68        stm32h742
69        stm32h743
70        stm32h753
71        stm32h750
72        stm32h742v
73        stm32h743v
74        stm32h753v
75        stm32h750v
76        stm32h747cm7
77        stm32h757cm7
78        stm32h7b3
79        stm32h7b0
80        stm32h7a3
81        stm32h735
82"
83);
84
85pub use embedded_hal as hal;
86pub mod traits;
87
88pub use nb;
89pub use nb::block;
90
91// Single core
92#[cfg(any(
93    feature = "stm32h742",
94    feature = "stm32h743",
95    feature = "stm32h750",
96))]
97pub use stm32h7::stm32h743 as stm32;
98#[cfg(any(
99    feature = "stm32h742v",
100    feature = "stm32h743v",
101    feature = "stm32h750v",
102))]
103pub use stm32h7::stm32h743v as stm32;
104
105// Single core with crypto
106#[cfg(feature = "stm32h753")]
107pub use stm32h7::stm32h753 as stm32;
108#[cfg(feature = "stm32h753v")]
109pub use stm32h7::stm32h753v as stm32;
110
111// Dual core
112#[cfg(feature = "stm32h747cm7")]
113pub use stm32h7::stm32h747cm7 as stm32;
114#[cfg(feature = "stm32h757cm7")]
115pub use stm32h7::stm32h757cm7 as stm32;
116// TODO(rm0399): soundness of PeripheralREC macro in rcc/rec.rs
117
118// High Memory Integration
119#[cfg(any(
120    feature = "stm32h7b3",
121    feature = "stm32h7a3",
122    feature = "stm32h7b0",
123))]
124pub use stm32h7::stm32h7b3 as stm32;
125
126// High Speed
127#[cfg(feature = "stm32h735")]
128pub use stm32h7::stm32h735 as stm32;
129
130#[cfg(all(feature = "rm0433", feature = "rm0399"))]
131compile_error!("Cannot not select both rm0433 and rm0399");
132
133#[cfg(all(feature = "cm7", feature = "cm4"))]
134compile_error!("Cannot not select both CM7 and CM4");
135
136#[cfg(feature = "device-selected")]
137pub use crate::stm32 as pac;
138#[cfg(feature = "device-selected")]
139pub use crate::stm32 as device;
140
141// Enable use of interrupt macro
142#[cfg(feature = "rt")]
143#[cfg_attr(docsrs, doc(cfg(feature = "rt")))]
144pub use crate::stm32::interrupt;
145
146#[cfg(feature = "device-selected")]
147pub mod adc;
148#[cfg(all(feature = "device-selected", feature = "can"))]
149#[cfg_attr(docsrs, doc(cfg(feature = "can")))]
150pub mod can;
151#[cfg(all(feature = "device-selected", feature = "crc"))]
152#[cfg_attr(docsrs, doc(cfg(feature = "crc")))]
153pub mod crc;
154#[cfg(feature = "device-selected")]
155pub mod dac;
156#[cfg(feature = "device-selected")]
157pub mod delay;
158#[cfg(feature = "device-selected")]
159pub mod dma;
160#[cfg(all(feature = "device-selected", feature = "dsi", feature = "rm0399"))]
161pub mod dsi;
162#[cfg(all(
163    feature = "device-selected",
164    feature = "ethernet",
165    not(feature = "rm0455")
166))]
167#[cfg_attr(docsrs, doc(cfg(feature = "ethernet")))]
168pub mod ethernet;
169#[cfg(feature = "device-selected")]
170pub mod exti;
171#[cfg(feature = "device-selected")]
172pub mod flash;
173#[cfg(all(feature = "device-selected", feature = "fmc"))]
174#[cfg_attr(docsrs, doc(cfg(feature = "fmc")))]
175pub mod fmc;
176#[cfg(feature = "device-selected")]
177pub mod gpio;
178#[cfg(feature = "device-selected")]
179pub mod i2c;
180#[cfg(feature = "device-selected")]
181pub mod independent_watchdog;
182#[cfg(all(feature = "device-selected", feature = "ltdc"))]
183#[cfg_attr(docsrs, doc(cfg(feature = "ltdc")))]
184pub mod ltdc;
185#[cfg(feature = "device-selected")]
186pub mod prelude;
187#[cfg(feature = "device-selected")]
188pub mod pwm;
189#[cfg(feature = "device-selected")]
190pub mod pwr;
191#[cfg(feature = "device-selected")]
192pub mod qei;
193#[cfg(feature = "device-selected")]
194pub mod rcc;
195#[cfg(feature = "device-selected")]
196pub mod rng;
197#[cfg(all(feature = "device-selected", feature = "rtc"))]
198#[cfg_attr(docsrs, doc(cfg(feature = "rtc")))]
199pub mod rtc;
200#[cfg(feature = "device-selected")]
201pub mod sai;
202#[cfg(all(feature = "device-selected", feature = "sdmmc"))]
203#[cfg_attr(docsrs, doc(cfg(feature = "sdmmc")))]
204pub mod sdmmc;
205#[cfg(feature = "device-selected")]
206pub mod serial;
207#[cfg(feature = "device-selected")]
208pub mod signature;
209#[cfg(feature = "device-selected")]
210pub mod spi;
211#[cfg(feature = "device-selected")]
212pub mod system_watchdog;
213#[cfg(feature = "device-selected")]
214pub mod time;
215#[cfg(feature = "device-selected")]
216pub mod timer;
217#[cfg(all(feature = "device-selected", feature = "usb_hs"))]
218#[cfg_attr(docsrs, doc(cfg(feature = "usb_hs")))]
219pub mod usb_hs;
220#[cfg(all(feature = "device-selected", feature = "xspi"))]
221#[cfg_attr(docsrs, doc(cfg(feature = "xspi")))]
222pub mod xspi;
223
224#[cfg(feature = "device-selected")]
225mod sealed {
226    pub trait Sealed {}
227}
228#[cfg(feature = "device-selected")]
229pub(crate) use sealed::Sealed;
230
231fn stripped_type_name<T>() -> &'static str {
232    let s = core::any::type_name::<T>();
233    let p = s.split("::");
234    p.last().unwrap()
235}