1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
//! STM32L4 HAL implementation
//!
//! NOTE: This HAL implementation is under active development (as is the underlying
//! `embedded_hal` itself, together with its traits, some of which are unproven).
//! We follow the HAL implementation in <https://github.com/therealprof/stm32f4xx-hal>
//! and pull in individual devices behind features - the goal is for this implementation
//! to become ubiquitous for the STM32L4 family of devices (well-tested, feature-complete,
//! well-documented). However! At this time, actual testing has only been performed for
//! the STM32L432KC microcontroller. Participation is of course very welcome!

#![no_std]

#[cfg(not(any(
    feature = "stm32l431",
    feature = "stm32l451",
    feature = "stm32l471",
    feature = "stm32l412",
    feature = "stm32l422",
    feature = "stm32l432",
    feature = "stm32l442",
    feature = "stm32l452",
    feature = "stm32l462",
    feature = "stm32l433",
    feature = "stm32l443",
    feature = "stm32l475",
    feature = "stm32l476",
    feature = "stm32l486",
    feature = "stm32l496",
    feature = "stm32l4a6",
    // note L4+ PAC support is mostly missing so other than r9/s9 these features don't actually exist yet
    // feature = "stm32l4p5",
    // feature = "stm32l4q5",
    // feature = "stm32l4r5",
    // feature = "stm32l4s5",
    // feature = "stm32l4r7",
    // feature = "stm32l4s7",
    // these have PAC support. Hal integration is very slim though
    feature = "stm32l4r9",
    feature = "stm32l4s9"
)))]
compile_error!(
    "\
This crate requires one of the following features enabled:
    stm32l431, stm32l451, stm32l471
    stm32l412, stm32l422, stm32l432, stm32l442, stm32l452, stm32l462
    stm32l433, stm32l443
    stm32l475, 
    stm32l476, stm32l486, stm32l496, stm32l4a6
    stm32l4r9, stm32l4s9
"
);

// the common lists of features to spec what a MCU is capable of
// lists are split by 3rd digit and 2nd digit groups

// L4x1
// any(feature = "stm32l431", feature = "stm32l451", feature = "stm32l471")
// L4x2
// any(feature = "stm32l412", feature = "stm32l422", feature = "stm32l432", feature = "stm32l442", feature = "stm32l452", feature = "stm32l462")
// L4x3
// any(feature = "stm32l433", feature = "stm32l443")
// L4x5
// any(feature = "stm32l475")
// L4x6
// any(feature = "stm32l476", feature = "stm32l486", feature = "stm32l496", , feature = "stm32l4a6")
// L4+x9
// any(feature = "stm32l4r9", feature = "stm32l4s9")

// NOTE: The even member of the pair has additional hashing peripheral(s)
// L41 / L42
// any(feature = "stm32l412", feature = "stm32l422")
// L43 / L44
// any(feature = "stm32l431", feature = "stm32l432", feature = "stm32l433", feature = "stm32l442", feature = "stm32l443")
// L45 / L46
// any(feature = "stm32l451", feature = "stm32l452", feature = "stm32l462")
// L47 / L48
// any(feature = "stm32l471", feature = "stm32l475", feature = "stm32l476", feature = "stm32l486")
// L49 / L4a
// any(feature = "stm32l496", feature = "stm32l4a6")
// L4r / L4s
// any(feature = "stm32l4r9", feature = "stm32l4s9")

pub use embedded_hal as hal;

pub use stm32l4;
#[cfg(any(feature = "stm32l431", feature = "stm32l451", feature = "stm32l471"))]
pub use stm32l4::stm32l4x1 as pac;

#[cfg(any(feature = "stm32l412", feature = "stm32l422"))]
pub use stm32l4::stm32l412 as pac;
#[cfg(any(
    feature = "stm32l432",
    feature = "stm32l442",
    feature = "stm32l452",
    feature = "stm32l462"
))]
pub use stm32l4::stm32l4x2 as pac;

#[cfg(any(feature = "stm32l433", feature = "stm32l443"))]
pub use stm32l4::stm32l4x3 as pac;

#[cfg(any(feature = "stm32l475"))]
pub use stm32l4::stm32l4x5 as pac;

#[cfg(any(
    feature = "stm32l476",
    feature = "stm32l486",
    feature = "stm32l496",
    feature = "stm32l4a6"
))]
pub use stm32l4::stm32l4x6 as pac;

#[cfg(any(feature = "stm32l4r9", feature = "stm32l4s9",))]
pub use stm32l4::stm32l4r9 as pac;

#[cfg(feature = "rt")]
pub use self::pac::interrupt;
// aliases for crate::pac
pub use crate::pac as device;
pub use crate::pac as stm32;

pub mod traits;

#[cfg(not(any(feature = "stm32l4r9", feature = "stm32l4s9",)))]
pub mod adc;
#[cfg(not(any(feature = "stm32l4r9", feature = "stm32l4s9",)))]
#[cfg(not(any(feature = "stm32l412",)))]
pub mod can;
pub mod crc;
pub mod datetime;
pub mod delay;
pub mod dma;
pub mod dmamux;
pub mod flash;
pub mod gpio;
pub mod i2c;
pub mod lptimer;
#[cfg(all(
    feature = "otg_fs",
    any(
        feature = "stm32l475",
        feature = "stm32l476",
        feature = "stm32l486",
        feature = "stm32l496",
        feature = "stm32l4a6",
    )
))]
pub mod otg_fs;
pub mod prelude;
pub mod pwm;
pub mod pwr;
#[cfg(not(any(
    feature = "stm32l433",
    feature = "stm32l443",
    feature = "stm32l4r9",
    feature = "stm32l4s9",
)))]
pub mod qspi;
pub mod rcc;
pub mod rng;
pub mod rtc;
pub mod serial;
pub mod signature;
pub mod spi;
pub mod time;
pub mod timer;
pub mod tsc;
#[cfg(all(
    feature = "stm32-usbd",
    any(
        feature = "stm32l412",
        feature = "stm32l422",
        feature = "stm32l432",
        feature = "stm32l442",
        feature = "stm32l452",
        feature = "stm32l462",
        feature = "stm32l433",
        feature = "stm32l443"
    )
))]
pub mod usb;
pub mod watchdog;

mod sealed {
    pub trait Sealed {}
}
pub(crate) use sealed::Sealed;