Expand description
Embassy support for esp-hal.
Embassy is a modern asynchronous framework intended for use with embedded systems. This package provides support for building applications using Embassy with esp-hal.
Note that this crate currently requires you to enable the unstable feature
on esp-hal.
§Executors
Two types of executors are provided:
- Executor: A thread-mode executor
- InterruptExecutor: An interrupt-mode executor
InterruptExecutor can be used to achieve preemptive multitasking in asynchronous applications, which is typically something reserved for more traditional RTOS. More information can be found in the Embassy documentation.
§Initialization
Embassy must be initialized by calling the init function. This initialization must be performed prior to spawning any tasks.
Initialization requires a number of timers to be passed in. The number of
timers required depends on the timer queue flavour used, as well as the
number of executors started. 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.
§Configuration
You can configure the behaviour of the embassy runtime by using the following environment variables:
| Name | Description | Default value | Allowed value |
|---|---|---|---|
ESP_HAL_EMBASSY_CONFIG_LOW_POWER_WAIT ⚠️ Unstable | Enables the lower-power wait if no tasks are ready to run on the thread-mode executor. This allows the MCU to use less power if the workload allows. Recommended for battery-powered systems. May impact analog performance. | ||
ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE ⚠️ Unstable | The flavour of the timer queue provided by this crate. Integrated queues require the If you use embassy-executor, the The |
| |
ESP_HAL_EMBASSY_CONFIG_GENERIC_QUEUE_SIZE ⚠️ Unstable | The capacity of the queue when the |
§Feature Flags
executors(enabled by default) — Enable theExecutorandInterruptExecutorembassy executor implementations.
§Logging Feature Flags
log-04— Enable logging output using version 0.4 of thelogcrate.defmt— Enable logging output usingdefmtand implementdefmt::Formaton certain types.
Structs§
- Executor
- Thread mode executor.
- Interrupt
Executor - Interrupt mode executor.
Traits§
Functions§
- init
- Initialize embassy.
Attribute Macros§
- main
- Creates a new
executorinstance and declares an application entry point spawning the corresponding function body as an async task.