Skip to main content

gd32e2_hal/
prelude.rs

1//! One import for the traits whose methods this HAL is used through.
2//!
3//! Traits are re-exported anonymously (`as _`): their methods arrive, their names
4//! do not. Types are not re-exported — import those from their own modules.
5//!
6//! ```ignore
7//! use gd32e2_hal::prelude::*;          // everything
8//! use gd32e2_hal::prelude::gpio::*;    // or one peripheral at a time
9//! ```
10//!
11//! The glob at this level covers every peripheral and takes [`usart::io`] for the
12//! serial traits. [`usart::nb`] is the other choice, never both: their `read` and
13//! `write` land on the same type, and two traits of one name in scope make every
14//! such call ambiguous (`E0034`).
15
16/// ADC entry point.
17pub mod adc {
18    pub use crate::adc::AdcExt as _;
19}
20
21/// DMA entry point.
22pub mod dma {
23    pub use crate::dma::DmaExt as _;
24}
25
26/// EXTI entry point.
27pub mod exti {
28    pub use crate::exti::ExtiExt as _;
29}
30
31/// Flash controller entry point.
32pub mod fmc {
33    pub use crate::fmc::FmcExt as _;
34}
35
36/// Port entry point and pin state.
37pub mod gpio {
38    pub use crate::gpio::GpioExt as _;
39    pub use embedded_hal::digital::{InputPin as _, OutputPin as _, StatefulOutputPin as _};
40}
41
42/// I²C transactions.
43pub mod i2c {
44    pub use embedded_hal::i2c::I2c as _;
45}
46
47/// Clock tree entry point.
48pub mod rcu {
49    pub use crate::rcu::RcuExt as _;
50}
51
52/// SPI transfers.
53pub mod spi {
54    pub use embedded_hal::spi::SpiBus as _;
55}
56
57/// System configuration entry point.
58pub mod syscfg {
59    pub use crate::syscfg::SyscfgExt as _;
60}
61
62/// Suffixes for durations and frequencies: `500.millis()`, `100.kHz()`.
63pub mod time {
64    pub use crate::time::{BpsExtU32 as _, ExtU32 as _, RateExtU32 as _};
65}
66
67/// Timer entry point, delays, PWM duty, and `block!` for capture reads.
68pub mod timer {
69    pub use crate::timer::TimerExt as _;
70    pub use embedded_hal::delay::DelayNs as _;
71    pub use embedded_hal::pwm::SetDutyCycle as _;
72    pub use nb::block;
73}
74
75/// Watchdog entry points.
76pub mod watchdog {
77    pub use crate::watchdog::{FwdgtExt as _, WwdgtExt as _};
78}
79
80/// Serial traits, in two flavours — take one.
81pub mod usart {
82    /// Blocking byte streams, with `read_exact` / `write_all` / `write_fmt`.
83    pub mod io {
84        pub use embedded_io::{Read as _, ReadReady as _, Write as _, WriteReady as _};
85    }
86
87    /// Non-blocking single bytes, driven through `block!`.
88    pub mod nb {
89        pub use ::nb::block;
90        pub use embedded_hal_nb::serial::{Read as _, Write as _};
91    }
92}
93
94pub use self::adc::*;
95pub use self::dma::*;
96pub use self::exti::*;
97pub use self::fmc::*;
98pub use self::gpio::*;
99pub use self::i2c::*;
100pub use self::rcu::*;
101pub use self::spi::*;
102pub use self::syscfg::*;
103pub use self::time::*;
104pub use self::timer::*;
105pub use self::usart::io::*;
106pub use self::watchdog::*;