// Public Time Functions ==========================================================================
/// Lets the microcontroller wait for the specified time in milliseconds. In this time no other instructions
/// other than interrupts can be run.
///
/// # Example
///
/// ```rust,no_run
/// use rustuino::*;
///
/// let pin = PA0::output();
///
/// loop {
///   pin.write(true);
///   delay(1000);
///   pin.write(false);
///   delay(1000);
/// }
/// ```
Public Time Functions
Lets the microcontroller wait for the specified time in milliseconds. In this time no other instructions
other than interrupts can be run.
Public Time Functions Lets the microcontroller wait for the specified time in milliseconds . In this time no other instructions other than interrupts can be run .
pub fn delay(ms: u16) {
  let peripheral_ptr;
  unsafe {peripheral_ptr = stm32f4::stm32f446::Peripherals::steal();}
  let rcc = &peripheral_ptr.RCC;
  let tim6 = &peripheral_ptr.TIM6;
  if rcc.apb1enr.read().tim6en().is_disabled() {
    rcc.apb1enr.modify(|_, w| w.tim6en().enabled());
    tim6.cr1.modify(|_, w| {
      w.arpe().enabled();
      w.opm().set_bit()
    });
    // 16MHz -> 1MHz : 1000 = 1kHz -> 1ms
    tim6.psc.write(|w| w.psc().bits(16000));
  }
  tim6.arr.write(|w| w.arr().bits(ms));
  tim6.egr.write(|w| w.ug().update());
  tim6.cr1.modify(|_, w| w.cen().enabled());
  while tim6.cr1.read().cen().bit_is_set() {}
}
pub fn delay ( ms : u16 ) { let peripheral_ptr ; unsafe { peripheral_ptr = stm32f4 :: stm32f446 :: Peripherals :: steal ( ) ; } let rcc = & peripheral_ptr . RCC ; let tim6 = & peripheral_ptr . TIM6 ; if rcc . apb1enr . read ( ) . tim6en ( ) . is_disabled ( ) { rcc . apb1enr . modify ( | _ , w | w . tim6en ( ) . enabled ( ) ) ; tim6 . cr1 . modify ( | _ , w | { w . arpe ( ) . enabled ( ) ; w . opm ( ) . set_bit ( ) } ) ; // 16MHz -> 1MHz : 1000 = 1kHz -> 1ms tim6 . psc . write ( | w | w . psc ( ) . bits ( 16000 ) ) ; } tim6 . arr . write ( | w | w . arr ( ) . bits ( ms ) ) ; tim6 . egr . write ( | w | w . ug ( ) . update ( ) ) ; tim6 . cr1 . modify ( | _ , w | w . cen ( ) . enabled ( ) ) ; while tim6 . cr1 . read ( ) . cen ( ) . bit_is_set ( ) { } }
Public Time Functions
Lets the microcontroller wait for the specified time in milliseconds.
Public Time Functions Lets the microcontroller wait for the specified time in milliseconds .
ms
u16
example
```rust,no_run
use rustuino::*.

let pin = PA0::output().


` ` ` rust no_run use rustuino :: * . let pin = PA0 :: output () .