Skip to content

Commit 2f6615e

Browse files
committed
Hide most of the unstable peripherals
1 parent a6a83d3 commit 2f6615e

File tree

3 files changed

+85
-60
lines changed

3 files changed

+85
-60
lines changed

esp-hal/src/dma/gdma.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ cfg_if::cfg_if! {
720720
}
721721
}
722722

723-
crate::impl_dma_eligible! {
723+
crate::dma::impl_dma_eligible! {
724724
AnyGdmaChannel {
725725
#[cfg(spi2)]
726726
SPI2 => Spi2,

esp-hal/src/dma/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,8 +1558,7 @@ impl RxCircularState {
15581558
}
15591559

15601560
#[doc(hidden)]
1561-
#[macro_export]
1562-
macro_rules! impl_dma_eligible {
1561+
macro_rules! _impl_dma_eligible {
15631562
([$dma_ch:ident] $name:ident => $dma:ident) => {
15641563
impl $crate::dma::DmaEligible for $crate::peripherals::$name {
15651564
type Dma = $dma_ch;
@@ -1577,11 +1576,13 @@ macro_rules! impl_dma_eligible {
15771576
) => {
15781577
$(
15791578
$(#[$cfg])?
1580-
$crate::impl_dma_eligible!([$dma_ch] $name => $dma);
1579+
$crate::dma::impl_dma_eligible!([$dma_ch] $name => $dma);
15811580
)*
15821581
};
15831582
}
15841583

1584+
pub(crate) use _impl_dma_eligible as impl_dma_eligible;
1585+
15851586
/// Helper type to get the DMA (Rx and Tx) channel for a peripheral.
15861587
pub type PeripheralDmaChannel<T> = <T as DmaEligible>::Dma;
15871588
/// Helper type to get the DMA Rx channel for a peripheral.

esp-hal/src/lib.rs

Lines changed: 80 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ pub use xtensa_lx;
151151
#[cfg(xtensa)]
152152
pub use xtensa_lx_rt::{self, entry};
153153

154+
// TODO what should we reexport stably?
154155
#[cfg(any(esp32, esp32s3))]
155156
pub use self::soc::cpu_control;
156157
#[cfg(efuse)]
@@ -163,88 +164,110 @@ pub use self::soc::psram;
163164
#[cfg(ulp_riscv_core)]
164165
pub use self::soc::ulp_core;
165166

166-
#[cfg(aes)]
167-
pub mod aes;
168-
#[cfg(any(adc, dac))]
169-
pub mod analog;
170-
#[cfg(assist_debug)]
171-
pub mod assist_debug;
172167
#[cfg(any(dport, hp_sys, pcr, system))]
173168
pub mod clock;
174169

175170
pub mod config;
176171

177172
#[cfg(any(xtensa, all(riscv, systimer)))]
178173
pub mod delay;
179-
#[cfg(any(gdma, pdma))]
180-
pub mod dma;
181-
#[cfg(ecc)]
182-
pub mod ecc;
183-
#[cfg(soc_etm)]
184-
pub mod etm;
185174
#[cfg(gpio)]
186175
pub mod gpio;
187-
#[cfg(hmac)]
188-
pub mod hmac;
189176
#[cfg(any(i2c0, i2c1))]
190177
pub mod i2c;
191-
#[cfg(any(i2s0, i2s1))]
192-
pub mod i2s;
193178
#[cfg(any(dport, interrupt_core0, interrupt_core1))]
194179
pub mod interrupt;
195-
#[cfg(lcd_cam)]
196-
pub mod lcd_cam;
197-
#[cfg(ledc)]
198-
pub mod ledc;
199-
#[cfg(any(mcpwm0, mcpwm1))]
200-
pub mod mcpwm;
201-
#[cfg(usb0)]
202-
pub mod otg_fs;
203-
#[cfg(parl_io)]
204-
pub mod parl_io;
205-
#[cfg(pcnt)]
206-
pub mod pcnt;
207180
pub mod peripheral;
208181
pub mod prelude;
209182
#[cfg(any(hmac, sha))]
210183
mod reg_access;
211-
#[cfg(any(lp_clkrst, rtc_cntl))]
212-
pub mod reset;
213-
#[cfg(rmt)]
214-
pub mod rmt;
215-
#[cfg(rng)]
216-
pub mod rng;
217-
pub mod rom;
218-
#[cfg(rsa)]
219-
pub mod rsa;
220-
#[cfg(any(lp_clkrst, rtc_cntl))]
221-
pub mod rtc_cntl;
222-
#[cfg(sha)]
223-
pub mod sha;
224184
#[cfg(any(spi0, spi1, spi2, spi3))]
225185
pub mod spi;
226-
#[cfg(any(dport, hp_sys, pcr, system))]
227-
pub mod system;
228-
pub mod time;
229-
#[cfg(any(systimer, timg0, timg1))]
230-
pub mod timer;
231-
#[cfg(touch)]
232-
pub mod touch;
233-
#[cfg(trace0)]
234-
pub mod trace;
235-
#[cfg(any(twai0, twai1))]
236-
pub mod twai;
237186
#[cfg(any(uart0, uart1, uart2))]
238187
pub mod uart;
239-
#[cfg(usb_device)]
240-
pub mod usb_serial_jtag;
241188

242-
pub mod debugger;
189+
pub mod macros;
190+
pub mod rom;
243191

192+
pub mod debugger;
244193
#[doc(hidden)]
245194
pub mod sync;
195+
pub mod time;
246196

247-
pub mod macros;
197+
// can't use instability on inline module definitions, see https://github.com/rust-lang/rust/issues/54727
198+
#[doc(hidden)]
199+
macro_rules! unstable {
200+
($(
201+
$(#[$meta:meta])*
202+
pub mod $module:ident;
203+
)*) => {
204+
$(
205+
$(#[$meta])*
206+
#[cfg(feature = "unstable")]
207+
pub mod $module;
208+
209+
$(#[$meta])*
210+
#[cfg(not(feature = "unstable"))]
211+
#[allow(unused)]
212+
pub(crate) mod $module;
213+
)*
214+
};
215+
}
216+
217+
unstable! {
218+
#[cfg(aes)]
219+
pub mod aes;
220+
#[cfg(any(adc, dac))]
221+
pub mod analog;
222+
#[cfg(assist_debug)]
223+
pub mod assist_debug;
224+
#[cfg(any(gdma, pdma))]
225+
pub mod dma;
226+
#[cfg(ecc)]
227+
pub mod ecc;
228+
#[cfg(soc_etm)]
229+
pub mod etm;
230+
#[cfg(hmac)]
231+
pub mod hmac;
232+
#[cfg(any(i2s0, i2s1))]
233+
pub mod i2s;
234+
#[cfg(lcd_cam)]
235+
pub mod lcd_cam;
236+
#[cfg(ledc)]
237+
pub mod ledc;
238+
#[cfg(any(mcpwm0, mcpwm1))]
239+
pub mod mcpwm;
240+
#[cfg(usb0)]
241+
pub mod otg_fs;
242+
#[cfg(parl_io)]
243+
pub mod parl_io;
244+
#[cfg(pcnt)]
245+
pub mod pcnt;
246+
#[cfg(any(lp_clkrst, rtc_cntl))]
247+
pub mod reset;
248+
#[cfg(rmt)]
249+
pub mod rmt;
250+
#[cfg(rng)]
251+
pub mod rng;
252+
#[cfg(rsa)]
253+
pub mod rsa;
254+
#[cfg(any(lp_clkrst, rtc_cntl))]
255+
pub mod rtc_cntl;
256+
#[cfg(sha)]
257+
pub mod sha;
258+
#[cfg(any(dport, hp_sys, pcr, system))]
259+
pub mod system;
260+
#[cfg(any(systimer, timg0, timg1))]
261+
pub mod timer;
262+
#[cfg(touch)]
263+
pub mod touch;
264+
#[cfg(trace0)]
265+
pub mod trace;
266+
#[cfg(any(twai0, twai1))]
267+
pub mod twai;
268+
#[cfg(usb_device)]
269+
pub mod usb_serial_jtag;
270+
}
248271

249272
/// State of the CPU saved when entering exception or interrupt
250273
pub mod trapframe {
@@ -309,6 +332,7 @@ pub(crate) mod private {
309332
}
310333
}
311334

335+
#[cfg(feature = "unstable")]
312336
#[doc(hidden)]
313337
pub use private::Internal;
314338

0 commit comments

Comments
 (0)