Expand description
Convenience re-export of multiple traits.
This allows a HAL user to conveniently import this module and have all the helper traits already imported. Otherwise the use of peripherals would require the import of the corresponding module and the import of the trait, which connects this HAL to the autogenerated svd2rust API in crate::pac.
§Example
Consider the following code.
#[entry]
fn main() -> ! {
let dp = pac::Peripherals::take().unwrap();
let gpiog = dp.GPIOG.split();
let mut led1 = gpiog.pg13.into_push_pull_output();
led1.set_high().unwrap();
}
Without the prelude we would have to import the following traits:
use stm32f4xx_hal::gpio::GpioExt; // for the split method.
use embedded_hal::digital::v2::OutputPin; // for the set_high() function.
// And more use-statements with more complex code.
These imports are a bit unintuitive, because we can create the objects without the import. But we need these traits to access most of their functions.
The prelude module keeps the import section cleaner:
use stm32f4xx_hal::prelude::*;
Re-exports§
pub use embedded_hal::delay::DelayNs as _;
pub use crate::can::CanExt as _stm32f4xx_hal_can_CanExt;
pub use crate::dac::DacExt as _stm32f4xx_hal_dac_DacExt;
pub use crate::dma::traits::DmaEventExt as _;
pub use crate::dma::traits::DmaFlagExt as _;
pub use crate::dma::traits::Stream as _;
pub use crate::dma::traits::StreamISR as _;
pub use crate::gpio::outport::OutPort as _;
pub use crate::gpio::ExtiPin as _stm32f4xx_hal_gpio_ExtiPin;
pub use crate::gpio::GpioExt as _stm32f4xx_hal_gpio_GpioExt;
pub use crate::i2c::dma::I2CMasterHandleIT as _stm32f4xx_hal_i2c_dma_I2CMasterHandleIT;
pub use crate::i2c::dma::I2CMasterReadDMA as _stm32f4xx_hal_i2c_dma_I2CMasterReadDMA;
pub use crate::i2c::dma::I2CMasterWriteDMA as _stm32f4xx_hal_i2c_dma_I2CMasterWriteDMA;
pub use crate::i2c::dma::I2CMasterWriteReadDMA as _stm32f4xx_hal_i2c_dma_I2CMasterWriteReadDMA;
pub use crate::i2c::I2cExt as _stm32f4xx_hal_i2c_I2cExt;
pub use crate::i2s::I2sExt as _stm32f4xx_hal_i2s_I2sExt;
pub use crate::qei::QeiExt as _stm32f4xx_hal_QeiExt;
pub use crate::rcc::RccExt as _stm32f4xx_hal_rcc_RccExt;
pub use crate::rng::RngExt as _stm32f4xx_hal_rng_RngExt;
pub use crate::sai::SAIExt as _;
pub use crate::serial::dma::SerialHandleIT as _stm32f4xx_hal_serial_dma_SerialHandleIT;
pub use crate::serial::dma::SerialReadDMA as _stm32f4xx_hal_serial_dma_SerialReadDMA;
pub use crate::serial::dma::SerialWriteDMA as _stm32f4xx_hal_serial_dma_SerialWriteDMA;
pub use crate::serial::RxISR as _stm32f4xx_hal_serial_RxISR;
pub use crate::serial::RxListen as _stm32f4xx_hal_serial_RxListen;
pub use crate::serial::SerialExt as _stm32f4xx_hal_serial_SerialExt;
pub use crate::serial::TxISR as _stm32f4xx_hal_serial_TxISR;
pub use crate::serial::TxListen as _stm32f4xx_hal_serial_TxListen;
pub use crate::spi::SpiExt as _stm32f4xx_hal_spi_SpiExt;
pub use crate::syscfg::SysCfgExt as _stm32f4xx_hal_syscfg_SysCfgExt;
pub use crate::time::U32Ext as _stm32f4xx_hal_time_U32Ext;
pub use crate::timer::MonoTimer64Ext as _;
pub use crate::timer::MonoTimerExt as _;
pub use crate::timer::PwmExt as _stm32f4xx_hal_timer_PwmExt;
pub use crate::timer::SysMonoTimerExt as _stm32f4xx_hal_timer_SysMonoTimerExt;
pub use crate::timer::SysTimerExt as _stm32f4xx_hal_timer_SysCounterExt;
pub use crate::timer::TimerExt as _stm32f4xx_hal_timer_TimerExt;
pub use crate::ClearFlags as _;
pub use crate::Listen as _;
pub use crate::ReadFlags as _;
Traits§
- _embedded_
hal_ Capture - Input capture
- _embedded_
hal_ Pwm - Pulse Width Modulation
- _embedded_
hal_ Qei - Quadrature encoder interface
- _embedded_
hal_ adc_ OneShot - ADCs that sample on single channels per request, and do so at the time of the request.
- _embedded_
hal_ blocking_ serial_ Write - Write half of a serial interface (blocking variant)
- _embedded_
hal_ serial_ nb_ Read - Read half of a serial interface.
- _embedded_
hal_ serial_ nb_ Write - Write half of a serial interface.
- _fugit_
ExtU32 - Extension trait for simple short-hands for u32 Durations
- _fugit_
Rate ExtU32 - Extension trait for simple short-hands for u32 Rate