1pub mod filter;
18pub mod interrupt;
19pub mod peripheral;
20pub mod pin;
21pub mod pioa;
22pub mod piob;
23#[cfg(feature = "pioc")]
24pub mod pioc;
25#[cfg(feature = "piod")]
26pub mod piod;
27#[cfg(feature = "pioe")]
28pub mod pioe;
29#[cfg(feature = "piof")]
30pub mod piof;
31pub mod structure;
32
33use crate::write_protect::{WpmrWpsrRegs, WriteProtect, WriteProtectKey};
34#[allow(clippy::wildcard_imports)]
35use structure::*;
36
37impl<Pio: PioRegisters> WriteProtectKey for Pio {
38 const WPKEY: u32 = 0x50494F;
39}
40
41impl<Pio: PioRegisters> WpmrWpsrRegs for Pio {
42 type Wpmr = <Self as PioRegisters>::Wpmr;
43
44 fn _wpmr(&self) -> &Self::Wpmr {
45 self._wpmr()
46 }
47
48 type Wpsr = <Self as PioRegisters>::Wpsr;
49
50 fn _wpsr(&self) -> &Self::Wpsr {
51 self._wpsr()
52 }
53}
54
55#[cfg_attr(
68 feature = "2fn",
69 doc = " - Peripheral AB Select Register (`PIO_ABSR`)"
70)]
71#[cfg_attr(
72 any(feature = "3fn", feature = "4fn"),
73 doc = " - Peripheral ABCD Select Register 0 (`PIO_ABCDSR0`)"
74)]
75#[cfg_attr(
76 any(feature = "3fn", feature = "4fn"),
77 doc = " - Peripheral ABCD Select Register 1 (`PIO_ABCDSR1`)"
78)]
79impl<Pio: PioRegisters> WriteProtect for Pio {}
82
83macro_rules! def_pioc {
84 ($(
85 $pio:ident($inner:ty) => {
86 $(
87 $(#[$meta:meta])*
88 $pio_abbv:ident: $num:literal
89 ),+$(,)?
90 }
91 ),+$(,)?) => {$(
92 paste::paste! {
93 $(
94 $(#[$meta])*
95 pub struct [<$pio_abbv:camel $num:camel>];
96 impl crate::pio::pin::PinId for [<$pio_abbv $num>] {
97 type Controller = crate::pac::$inner;
98 const MASK: u32 = 1 << $num;
99 }
100 )+
101
102 pub struct $pio {
103 $(
104 $(#[$meta])*
105 pub [<$pio_abbv:snake $num:snake>]: crate::pio::pin::Pin<
106 crate::pac::[<$pio:upper>],
107 [<$pio_abbv:camel $num:camel>],
108 crate::pio::pin::Unconfigured,
109 crate::pio::pin::Unconfigured,
110 crate::pio::pin::Unconfigured,
111 crate::pio::pin::Unconfigured,
112 crate::pio::pin::Unconfigured,
113 >,
114 )+
115 }
116
117 impl $pio {
118 pub fn [<from_ $pio:lower>](_pio: crate::pac::[<$pio:upper>]) -> Self {
119 $pio {
120 $(
121 [<$pio_abbv:snake $num:snake>]: unsafe { crate::pio::pin::Pin::new() },
122 )+
123 }
124 }
125
126 pub(crate) const fn inner(&self) -> &crate::pac::[<$pio:lower>]::RegisterBlock {
127 unsafe { &*crate::pac::[<$pio:upper>]::PTR }
128 }
129 }
130
131 const _: () = {
132 use crate::write_protect::{WriteProtect, WriteProtectKey, WpmrWpsrRegs};
133
134 impl WriteProtectKey for $pio {
135 const WPKEY: u32 = crate::pac::[<$pio:upper>]::WPKEY;
136 }
137
138 impl WpmrWpsrRegs for $pio {
139 type Wpmr = <crate::pac::[<$pio:upper>] as WpmrWpsrRegs>::Wpmr;
140 fn _wpmr(&self) -> &Self::Wpmr {
141 self.inner()._wpmr()
142 }
143 type Wpsr = <crate::pac::[<$pio:upper>] as WpmrWpsrRegs>::Wpsr;
144 fn _wpsr(&self) -> &Self::Wpsr {
145 self.inner()._wpsr()
146 }
147 }
148
149 impl WriteProtect for $pio {}
150 };
151 }
152 )+};
153}
154
155pub(crate) use def_pioc;
156
157#[allow(clippy::module_name_repetitions)]
158#[derive(Clone, Copy, Debug)]
159pub enum PioError {
161 LineLocked,
162 WriteProtected,
163}
164
165macro_rules! pin_peripherals {
166 (
167 pio: $pio:ty,
168 pinopts: [$($pinopts:tt),+$(,)?],
169 ) => {
170 $(
171 crate::pio::pin_peripherals! {
172 @pin
173 pio: $pio,
174 pinopts: $pinopts,
175 }
176 )+
177 };
178 (
179 @pin
180 pio: $pio:ty,
181 pinopts: [
182 pin: $pin:ty,
183 peripherals: [$($peripheral:ident),+]$(,)?
184 ],
185 ) => {
186 $(
187 crate::pio::pin_peripherals! {
188 @impl
189 pio: $pio,
190 pin: $pin,
191 peripheral: $peripheral,
192 }
193 )+
194 };
195 (
196 @impl
197 pio: $pio:ty,
198 pin: $pin:ty,
199 peripheral: $peripheral:ident,
200 ) => {
201 paste::paste! {
202 impl crate::pio::peripheral::PeripheralExistsFor<$pio, $pin>
203 for [<Peripheral $peripheral>] {}
204 }
205 };
206}
207
208pub(crate) use pin_peripherals;
209
210