Function init

Source
pub fn init(time_driver: impl TimerCollection)
Expand description

Initialize embassy.

Call this as soon as possible, before the first timer-related operation.

The time driver can be one of a number of different options:

  • A timg Timer instance
  • A systimer Alarm instance
  • An AnyTimer instance
  • A OneShotTimer instance
  • A mutable static slice of OneShotTimer instances
  • A mutable static array of OneShotTimer instances
  • A 2, 3, 4 element array of AnyTimer instances

ยงExamples

use esp_hal::timer::timg::TimerGroup;

let timg0 = TimerGroup::new(peripherals.TIMG0);
esp_hal_embassy::init(timg0.timer0);

// ... now you can spawn embassy tasks or use `Timer::after` etc.