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.
§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 | 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. | true | - |
ESP_HAL_EMBASSY_CONFIG_TIMER_QUEUE | The flavour of the timer queue provided by this crate. Accepts either If you use embassy-executor, the The | single-integrated | - |
ESP_HAL_EMBASSY_CONFIG_GENERIC_QUEUE_SIZE | The capacity of the queue when the generic timer queue flavour is selected. | 64 | Positive integer |
§Feature Flags
defmt
— Implementdefmt::Format
on certain types.log
— Enable logging via the log crateexecutors
(enabled by default) — ProvideExecutor
andInterruptExecutor
Structs§
- Executor
- Thread mode executor.
- Interrupt
Executor - Interrupt mode executor.
Traits§
- Timer
Collection - A trait to allow better UX for initializing the timers.
Functions§
- init
- Initialize embassy.
Attribute Macros§
- main
- Creates a new
executor
instance and declares an application entry point spawning the corresponding function body as an async task.