1#![no_std]
6#![allow(non_camel_case_types)]
7#![feature(associated_type_defaults)]
8#![feature(impl_trait_in_assoc_type)]
9#![feature(negative_impls)]
10#![feature(min_specialization)]
11#![feature(macro_metavar_expr)]
12#![feature(more_qualified_paths)]
13#![feature(adt_const_params)]
14#![feature(trivial_bounds)]
15
16use enumflags2::{BitFlag, BitFlags};
17
18pub use embedded_hal as hal;
19pub use embedded_hal_02 as hal_02;
20
21pub use nb;
22pub use nb::block;
23
24#[cfg(feature = "n32g401")]
25pub use n32g4::n32g401 as pac;
27
28#[cfg(feature = "n32g432")]
29pub use n32g4::n32g432 as pac;
31
32#[cfg(feature = "n32g435")]
33pub use n32g4::n32g435 as pac;
35
36#[cfg(feature = "n32g451")]
37pub use n32g4::n32g451 as pac;
39
40#[cfg(feature = "n32g452")]
41pub use n32g4::n32g452 as pac;
43
44#[cfg(feature = "n32g455")]
45pub use n32g4::n32g455 as pac;
47
48#[cfg(feature = "n32g457")]
49pub use n32g4::n32g457 as pac;
51
52#[cfg(feature = "n32g4fr")]
53pub use n32g4::n32g4fr as pac;
55
56pub mod adc;
57pub mod afio;
58pub mod bb;
59#[cfg(any(feature = "n32g451",feature = "n32g452",feature = "n32g455",feature = "n32g457",feature = "n32g4fr"))]
60pub mod bkp;
61pub mod can;
62pub mod crc;
63pub mod delay;
64pub mod dma;
65pub mod fmc;
66pub mod gpio;
67pub mod i2c;
68pub mod pwm;
69pub mod sac;
70pub mod serial;
71pub mod spi;
72pub mod rcc;
73pub mod time;
74pub mod timer;
75pub mod prelude;
76pub mod pwr;
77pub mod usb;
78mod sealed {
79pub trait Sealed {}
80}
81pub(crate) use sealed::Sealed;
82
83fn stripped_type_name<T>() -> &'static str {
84 let s = core::any::type_name::<T>();
85 let p = s.split("::");
86 p.last().unwrap()
87}
88
89pub trait ReadFlags {
90 type Flag: BitFlag;
92
93 fn flags(&self) -> BitFlags<Self::Flag>;
95}
96
97pub trait ClearFlags {
98 type Flag: BitFlag;
100
101 fn clear_flags(&mut self, flags: impl Into<BitFlags<Self::Flag>>);
106
107 #[inline(always)]
109 fn clear_all_flags(&mut self) {
110 self.clear_flags(BitFlags::ALL)
111 }
112}
113
114pub trait Listen {
115 type Event: BitFlag;
117
118 fn listen(&mut self, event: impl Into<BitFlags<Self::Event>>);
123
124 fn listen_only(&mut self, event: impl Into<BitFlags<Self::Event>>);
129
130 fn unlisten(&mut self, event: impl Into<BitFlags<Self::Event>>);
132
133 #[inline(always)]
135 fn listen_all(&mut self) {
136 self.listen(BitFlags::ALL)
137 }
138
139 #[inline(always)]
141 fn unlisten_all(&mut self) {
142 self.unlisten(BitFlags::ALL)
143 }
144}
145