pub fn init(time_driver: impl TimeBase)
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 single object of, or a 1-4 element array of the following:
esp_hal::timer::timg::Timer
esp_hal::timer::systimer::Alarm
esp_hal::timer::AnyTimer
esp_hal::timer::OneShotTimer
- A mutable static slice of
OneShotTimer
instances - A mutable static array of
OneShotTimer
instances
Note that if you use the multiple-integrated
timer-queue flavour, then
you need to pass as many timers as you start executors. In other cases,
you can pass a single timer.
ยง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.