stm32l4xx_hal/
lib.rs

1//! STM32L4 HAL implementation
2//!
3//! NOTE: This HAL implementation is under active development (as is the underlying
4//! `embedded_hal` itself, together with its traits, some of which are unproven).
5//! We follow the HAL implementation in <https://github.com/therealprof/stm32f4xx-hal>
6//! and pull in individual devices behind features - the goal is for this implementation
7//! to become ubiquitous for the STM32L4 family of devices (well-tested, feature-complete,
8//! well-documented). However! At this time, actual testing has only been performed for
9//! the STM32L432KC microcontroller. Participation is of course very welcome!
10
11#![no_std]
12
13#[cfg(not(any(
14    feature = "stm32l431",
15    feature = "stm32l451",
16    feature = "stm32l471",
17    feature = "stm32l412",
18    feature = "stm32l422",
19    feature = "stm32l432",
20    feature = "stm32l442",
21    feature = "stm32l452",
22    feature = "stm32l462",
23    feature = "stm32l433",
24    feature = "stm32l443",
25    feature = "stm32l475",
26    feature = "stm32l476",
27    feature = "stm32l486",
28    feature = "stm32l496",
29    feature = "stm32l4a6",
30    // note L4+ PAC support is mostly missing so other than r9/s9 these features don't actually exist yet
31    // feature = "stm32l4p5",
32    // feature = "stm32l4q5",
33    // feature = "stm32l4r5",
34    // feature = "stm32l4s5",
35    // feature = "stm32l4r7",
36    // feature = "stm32l4s7",
37    // these have PAC support. Hal integration is very slim though
38    feature = "stm32l4r9",
39    feature = "stm32l4s9"
40)))]
41compile_error!(
42    "\
43This crate requires one of the following features enabled:
44    stm32l431, stm32l451, stm32l471
45    stm32l412, stm32l422, stm32l432, stm32l442, stm32l452, stm32l462
46    stm32l433, stm32l443
47    stm32l475, 
48    stm32l476, stm32l486, stm32l496, stm32l4a6
49    stm32l4r9, stm32l4s9
50"
51);
52
53// the common lists of features to spec what a MCU is capable of
54// lists are split by 3rd digit and 2nd digit groups
55
56// L4x1
57// any(feature = "stm32l431", feature = "stm32l451", feature = "stm32l471")
58// L4x2
59// any(feature = "stm32l412", feature = "stm32l422", feature = "stm32l432", feature = "stm32l442", feature = "stm32l452", feature = "stm32l462")
60// L4x3
61// any(feature = "stm32l433", feature = "stm32l443")
62// L4x5
63// any(feature = "stm32l475")
64// L4x6
65// any(feature = "stm32l476", feature = "stm32l486", feature = "stm32l496", , feature = "stm32l4a6")
66// L4+x9
67// any(feature = "stm32l4r9", feature = "stm32l4s9")
68
69// NOTE: The even member of the pair has additional hashing peripheral(s)
70// L41 / L42
71// any(feature = "stm32l412", feature = "stm32l422")
72// L43 / L44
73// any(feature = "stm32l431", feature = "stm32l432", feature = "stm32l433", feature = "stm32l442", feature = "stm32l443")
74// L45 / L46
75// any(feature = "stm32l451", feature = "stm32l452", feature = "stm32l462")
76// L47 / L48
77// any(feature = "stm32l471", feature = "stm32l475", feature = "stm32l476", feature = "stm32l486")
78// L49 / L4a
79// any(feature = "stm32l496", feature = "stm32l4a6")
80// L4r / L4s
81// any(feature = "stm32l4r9", feature = "stm32l4s9")
82
83pub use embedded_hal as hal;
84
85pub use stm32l4;
86#[cfg(any(feature = "stm32l431", feature = "stm32l451", feature = "stm32l471"))]
87pub use stm32l4::stm32l4x1 as pac;
88
89#[cfg(any(feature = "stm32l412", feature = "stm32l422"))]
90pub use stm32l4::stm32l412 as pac;
91#[cfg(any(
92    feature = "stm32l432",
93    feature = "stm32l442",
94    feature = "stm32l452",
95    feature = "stm32l462"
96))]
97pub use stm32l4::stm32l4x2 as pac;
98
99#[cfg(any(feature = "stm32l433", feature = "stm32l443"))]
100pub use stm32l4::stm32l4x3 as pac;
101
102#[cfg(any(feature = "stm32l475"))]
103pub use stm32l4::stm32l4x5 as pac;
104
105#[cfg(any(
106    feature = "stm32l476",
107    feature = "stm32l486",
108    feature = "stm32l496",
109    feature = "stm32l4a6"
110))]
111pub use stm32l4::stm32l4x6 as pac;
112
113#[cfg(any(feature = "stm32l4r9", feature = "stm32l4s9",))]
114pub use stm32l4::stm32l4r9 as pac;
115
116#[cfg(feature = "rt")]
117pub use self::pac::interrupt;
118// aliases for crate::pac
119pub use crate::pac as device;
120pub use crate::pac as stm32;
121
122pub mod traits;
123
124#[cfg(not(any(feature = "stm32l4r9", feature = "stm32l4s9",)))]
125pub mod adc;
126#[cfg(not(any(feature = "stm32l4r9", feature = "stm32l4s9",)))]
127#[cfg(not(any(feature = "stm32l412",)))]
128pub mod can;
129pub mod crc;
130pub mod datetime;
131pub mod delay;
132pub mod dma;
133pub mod dmamux;
134pub mod flash;
135pub mod gpio;
136pub mod i2c;
137pub mod lptimer;
138#[cfg(all(
139    feature = "otg_fs",
140    any(
141        feature = "stm32l475",
142        feature = "stm32l476",
143        feature = "stm32l486",
144        feature = "stm32l496",
145        feature = "stm32l4a6",
146    )
147))]
148pub mod otg_fs;
149pub mod prelude;
150pub mod pwm;
151pub mod pwr;
152#[cfg(not(any(
153    feature = "stm32l433",
154    feature = "stm32l443",
155    feature = "stm32l4r9",
156    feature = "stm32l4s9",
157)))]
158pub mod qspi;
159pub mod rcc;
160pub mod rng;
161pub mod rtc;
162pub mod serial;
163pub mod signature;
164pub mod spi;
165pub mod time;
166pub mod timer;
167pub mod tsc;
168#[cfg(all(
169    feature = "stm32-usbd",
170    any(
171        feature = "stm32l412",
172        feature = "stm32l422",
173        feature = "stm32l432",
174        feature = "stm32l442",
175        feature = "stm32l452",
176        feature = "stm32l462",
177        feature = "stm32l433",
178        feature = "stm32l443"
179    )
180))]
181pub mod usb;
182pub mod watchdog;
183
184mod sealed {
185    pub trait Sealed {}
186}
187pub(crate) use sealed::Sealed;