Module stm32f4xx_hal::prelude [−][src]
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 crate::dac::DacExt as _stm32f4xx_hal_dac_DacExt;
pub use crate::gpio::ExtiPin as _stm32f4xx_hal_gpio_ExtiPin;
pub use crate::gpio::GpioExt as _stm32f4xx_hal_gpio_GpioExt;
pub use crate::i2c::Pins as _stm32f4xx_hal_i2c_Pins;
pub use crate::rcc::RccExt as _stm32f4xx_hal_rcc_RccExt;
pub use crate::rng::RngExt as _stm32f4xx_hal_rng_RngExt;
pub use crate::syscfg::SysCfgExt as _stm32f4xx_hal_syscfg_SysCfgExt;
pub use crate::time::U32Ext as _stm32f4xx_hal_time_U32Ext;
Traits
Input capture
Pulse Width Modulation
Quadrature encoder interface
ADCs that sample on single channels per request, and do so at the time of the request.
Millisecond delay
Microsecond delay
Blocking read
Blocking write
Blocking write + read
Write half of a serial interface (blocking variant)
Blocking transfer
Blocking write
Read half of a serial interface
Write half of a serial interface
Full duplex (master mode)
A count down timer
Feeds an existing watchdog to ensure the processor isn’t reset. Sometimes commonly referred to as “kicking” or “refreshing”.
Disables a running watchdog timer so the processor won’t be reset.
Enables A watchdog timer to reset the processor if software is frozen or stalled.