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
#![no_std]
pub use imxrt_ral as ral;
pub mod iomuxc {
pub use imxrt_iomuxc::*;
#[cfg(feature = "imxrt1062")]
pub use imxrt_iomuxc::imxrt106x::*;
pub(super) fn pads(_: crate::ral::iomuxc::Instance) -> Pads {
unsafe { Pads::new() }
}
}
pub mod ccm;
pub mod dma;
pub mod gpio;
pub mod gpt;
pub mod i2c;
pub mod pit;
pub mod pwm;
pub mod spi;
pub mod uart;
pub mod dcdc {
use imxrt_ral as ral;
pub struct DCDC(pub(crate) ral::dcdc::Instance);
impl DCDC {
pub fn raw(&mut self) -> &ral::dcdc::Instance {
&self.0
}
}
}
pub struct Peripherals {
pub iomuxc: iomuxc::Pads,
pub ccm: ccm::CCM,
pub pit: pit::UnclockedPIT,
pub dcdc: dcdc::DCDC,
pub pwm1: pwm::Unclocked<iomuxc::consts::U1>,
pub pwm2: pwm::Unclocked<iomuxc::consts::U2>,
pub pwm3: pwm::Unclocked<iomuxc::consts::U3>,
pub pwm4: pwm::Unclocked<iomuxc::consts::U4>,
pub i2c: i2c::Unclocked,
pub uart: uart::Unclocked,
pub spi: spi::Unclocked,
pub gpt1: gpt::Unclocked,
pub gpt2: gpt::Unclocked,
pub dma: dma::Unclocked,
}
impl Peripherals {
pub unsafe fn steal() -> Self {
Peripherals {
iomuxc: iomuxc::pads(ral::iomuxc::IOMUXC::steal()),
ccm: ccm::CCM::new(ral::ccm::CCM::steal(), ral::ccm_analog::CCM_ANALOG::steal()),
pit: pit::UnclockedPIT::new(ral::pit::PIT::steal()),
dcdc: dcdc::DCDC(ral::dcdc::DCDC::steal()),
pwm1: pwm::Unclocked::new(ral::pwm::PWM1::steal()),
pwm2: pwm::Unclocked::new(ral::pwm::PWM2::steal()),
pwm3: pwm::Unclocked::new(ral::pwm::PWM3::steal()),
pwm4: pwm::Unclocked::new(ral::pwm::PWM4::steal()),
i2c: i2c::Unclocked {
i2c1: ral::lpi2c::LPI2C1::steal(),
i2c2: ral::lpi2c::LPI2C2::steal(),
i2c3: ral::lpi2c::LPI2C3::steal(),
i2c4: ral::lpi2c::LPI2C4::steal(),
},
uart: uart::Unclocked {
uart1: ral::lpuart::LPUART1::steal(),
uart2: ral::lpuart::LPUART2::steal(),
uart3: ral::lpuart::LPUART3::steal(),
uart4: ral::lpuart::LPUART4::steal(),
uart5: ral::lpuart::LPUART5::steal(),
uart6: ral::lpuart::LPUART6::steal(),
uart7: ral::lpuart::LPUART7::steal(),
uart8: ral::lpuart::LPUART8::steal(),
},
spi: spi::Unclocked {
spi1: ral::lpspi::LPSPI1::steal(),
spi2: ral::lpspi::LPSPI2::steal(),
spi3: ral::lpspi::LPSPI3::steal(),
spi4: ral::lpspi::LPSPI4::steal(),
},
gpt1: gpt::Unclocked::one(ral::gpt::GPT1::steal()),
gpt2: gpt::Unclocked::two(ral::gpt::GPT2::steal()),
dma: dma::Unclocked::new(ral::dma0::DMA0::steal(), ral::dmamux::DMAMUX::steal()),
}
}
pub fn take() -> Option<Self> {
let p = Peripherals {
iomuxc: iomuxc::pads(ral::iomuxc::IOMUXC::take()?),
ccm: ccm::CCM::new(ral::ccm::CCM::take()?, ral::ccm_analog::CCM_ANALOG::take()?),
pit: pit::UnclockedPIT::new(ral::pit::PIT::take()?),
dcdc: dcdc::DCDC(ral::dcdc::DCDC::take()?),
pwm1: pwm::Unclocked::new(ral::pwm::PWM1::take()?),
pwm2: pwm::Unclocked::new(ral::pwm::PWM2::take()?),
pwm3: pwm::Unclocked::new(ral::pwm::PWM3::take()?),
pwm4: pwm::Unclocked::new(ral::pwm::PWM4::take()?),
i2c: i2c::Unclocked {
i2c1: ral::lpi2c::LPI2C1::take()?,
i2c2: ral::lpi2c::LPI2C2::take()?,
i2c3: ral::lpi2c::LPI2C3::take()?,
i2c4: ral::lpi2c::LPI2C4::take()?,
},
uart: uart::Unclocked {
uart1: ral::lpuart::LPUART1::take()?,
uart2: ral::lpuart::LPUART2::take()?,
uart3: ral::lpuart::LPUART3::take()?,
uart4: ral::lpuart::LPUART4::take()?,
uart5: ral::lpuart::LPUART5::take()?,
uart6: ral::lpuart::LPUART6::take()?,
uart7: ral::lpuart::LPUART7::take()?,
uart8: ral::lpuart::LPUART8::take()?,
},
spi: spi::Unclocked {
spi1: ral::lpspi::LPSPI1::take()?,
spi2: ral::lpspi::LPSPI2::take()?,
spi3: ral::lpspi::LPSPI3::take()?,
spi4: ral::lpspi::LPSPI4::take()?,
},
gpt1: gpt::Unclocked::one(ral::gpt::GPT1::take()?),
gpt2: gpt::Unclocked::two(ral::gpt::GPT2::take()?),
dma: dma::Unclocked::new(ral::dma0::DMA0::take()?, ral::dmamux::DMAMUX::take()?),
};
Some(p)
}
}