pub fn init<'d>() -> Result<Controller<'d>, InitializationError>Expand description
Initialize for using Wi-Fi and or BLE.
Wi-Fi and BLE require a preemptive scheduler to be present. Without one, the underlying firmware
can’t operate. The scheduler must implement the interfaces in the esp-radio-rtos-driver
crate. If you are using an embedded RTOS like Ariel OS, it needs to provide an appropriate
implementation.
If you are not using an embedded RTOS, use the esp-rtos crate which provides the
necessary functionality.
Make sure to not call this function while interrupts are disabled.
§Errors
- The function may return an error if the scheduler is not initialized.
- The function may return an error if interrupts are disabled.
- The function may return an error if initializing the underlying driver fails.
§Example
For examples of the necessary setup, see your RTOS’s documentation. If you are
using the esp-rtos crate, you will need to initialize the scheduler before calling this
function:
use esp_hal::timer::timg::TimerGroup;
let timg0 = TimerGroup::new(peripherals.TIMG0);
let software_interrupt = SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
esp_rtos::start(timg0.timer0, software_interrupt);
// You can now start esp-radio:
let esp_radio_controller = esp_radio::init().unwrap();