stm32f7xx_hal/
lib.rs

1//! HAL for the STM32F7xx family of microcontrollers
2
3#![cfg_attr(not(test), no_std)]
4#![allow(non_camel_case_types)]
5
6#[cfg(not(feature = "device-selected"))]
7compile_error!(
8    "This crate requires one of the following device features enabled:
9        stm32f722
10        stm32f723
11        stm32f730
12        stm32f730-lpc
13        stm32f732
14        stm32f733
15        stm32f745
16        stm32f746
17        stm32f756
18        stm32f765
19        stm32f767
20        stm32f769
21        stm32f777
22        stm32f778
23        stm32f779
24                "
25);
26
27pub(crate) use embedded_hal as hal;
28
29#[cfg(feature = "stm32f722")]
30pub use stm32f7::stm32f7x2 as pac;
31
32#[cfg(feature = "stm32f723")]
33pub use stm32f7::stm32f7x3 as pac;
34
35#[cfg(any(feature = "stm32f730", feature = "stm32f730-lpc"))]
36pub use stm32f7::stm32f730 as pac;
37
38#[cfg(feature = "stm32f732")]
39pub use stm32f7::stm32f7x2 as pac;
40
41#[cfg(feature = "stm32f733")]
42pub use stm32f7::stm32f7x3 as pac;
43
44#[cfg(feature = "stm32f745")]
45pub use stm32f7::stm32f745 as pac;
46
47#[cfg(feature = "stm32f746")]
48pub use stm32f7::stm32f7x6 as pac;
49
50#[cfg(feature = "stm32f756")]
51pub use stm32f7::stm32f7x6 as pac;
52
53#[cfg(feature = "stm32f765")]
54pub use stm32f7::stm32f765 as pac;
55
56#[cfg(feature = "stm32f767")]
57pub use stm32f7::stm32f7x7 as pac;
58
59#[cfg(feature = "stm32f769")]
60pub use stm32f7::stm32f7x9 as pac;
61
62#[cfg(feature = "stm32f777")]
63pub use stm32f7::stm32f7x7 as pac;
64
65#[cfg(feature = "stm32f778")]
66pub use stm32f7::stm32f7x9 as pac;
67
68#[cfg(feature = "stm32f779")]
69pub use stm32f7::stm32f7x9 as pac;
70
71// Enable use of interrupt macro
72#[cfg(feature = "rt")]
73pub use crate::pac::interrupt;
74
75#[cfg(all(feature = "device-selected", feature = "has-can"))]
76pub mod can;
77
78#[cfg(feature = "device-selected")]
79pub mod dma;
80
81#[cfg(all(feature = "device-selected", feature = "fmc"))]
82pub mod fmc;
83
84#[cfg(all(feature = "fmc_lcd", feature = "device-selected", feature = "fmc"))]
85pub mod fmc_lcd;
86
87#[cfg(feature = "device-selected")]
88pub mod gpio;
89
90#[cfg(feature = "device-selected")]
91pub mod dac;
92
93#[cfg(all(
94    feature = "usb_fs",
95    any(
96        feature = "stm32f722",
97        feature = "stm32f723",
98        feature = "stm32f730",
99        feature = "stm32f730-lpc",
100        feature = "stm32f732",
101        feature = "stm32f733",
102        feature = "stm32f746",
103        feature = "stm32f767",
104    )
105))]
106pub mod otg_fs;
107
108#[cfg(all(
109    feature = "usb_hs",
110    any(
111        feature = "stm32f722",
112        feature = "stm32f723",
113        feature = "stm32f730",
114        feature = "stm32f730-lpc",
115        feature = "stm32f732",
116        feature = "stm32f733",
117        feature = "stm32f746",
118        feature = "stm32f767",
119    )
120))]
121pub mod otg_hs;
122
123#[cfg(feature = "device-selected")]
124pub mod prelude;
125
126#[cfg(feature = "device-selected")]
127pub mod rcc;
128
129#[cfg(feature = "device-selected")]
130pub mod rtc;
131
132#[cfg(feature = "device-selected")]
133pub mod serial;
134
135#[cfg(feature = "device-selected")]
136pub mod spi;
137
138#[cfg(feature = "device-selected")]
139pub mod timer;
140
141#[cfg(feature = "device-selected")]
142pub mod signature;
143
144#[cfg(feature = "device-selected")]
145pub mod i2c;
146
147#[cfg(feature = "device-selected")]
148pub mod rng;
149
150#[cfg(feature = "device-selected")]
151pub mod qspi;
152
153#[cfg(any(feature = "stm32f765", feature = "stm32f767", feature = "stm32f769"))]
154pub mod adc;
155
156#[cfg(any(feature = "stm32f767", feature = "stm32f769"))]
157pub mod qei;
158
159#[cfg(feature = "ltdc")]
160pub mod ltdc;
161
162#[cfg(feature = "device-selected")]
163pub mod flash;
164
165#[cfg(feature = "device-selected")]
166pub mod watchdog;
167
168pub mod state {
169    /// Indicates that a peripheral is enabled
170    pub struct Enabled;
171
172    /// Indicates that a peripheral is disabled
173    pub struct Disabled;
174}
175
176#[cfg(feature = "device-selected")]
177mod sealed {
178    pub trait Sealed {}
179}
180#[cfg(feature = "device-selected")]
181pub(crate) use sealed::Sealed;
182
183fn stripped_type_name<T>() -> &'static str {
184    let s = core::any::type_name::<T>();
185    let p = s.split("::");
186    p.last().unwrap()
187}
188
189/// Bits per second
190pub type BitsPerSecond = fugit::HertzU32;
191
192/// Extension trait that adds convenience methods to the `u32` type
193pub trait U32Ext {
194    /// Wrap in `Bps`
195    fn bps(self) -> BitsPerSecond;
196}
197
198impl U32Ext for u32 {
199    fn bps(self) -> BitsPerSecond {
200        BitsPerSecond::from_raw(self)
201    }
202}