Attribute Macro task
#[task]Expand description
Defines an async task and optionally registers it for autostart.
If this function is only used to spawn other tasks before returning, consider using
spawner instead, to avoid statically allocating this transient async function as an
embassy_executor::task.
§Parameters
autostart: (optional) run the task at startup; required to useperipheralsand/or hooks.peripherals: (optional) provide the function with a peripheral struct as the first parameter. Theperipheralsparameter can only be used onautostarttasks. The peripheral struct must be defined with theariel_os::hal::define_peripherals!macro.- hooks: (optional) available hooks are:
usb_builder_hook: when present, the macro will define a staticUSB_BUILDER_HOOKof typeUsbBuilderHook, allowing to access and modify the system-providedembassy_usb::BuilderthroughDelegate::with(), before it is built by the system.
pool_size: (optional) set the maximum number of concurrent tasks that can be spawned for the function (defaults to1). Cannot be used onautostarttasks.
§Examples
ⓘ
#[ariel_os::task(autostart, peripherals, usb_builder_hook)]
async fn task(peripherals: /* your peripheral type */) {}See Ariel OS examples for more.
§Panics
This macro panics when the ariel-os crate cannot be found as a dependency of the crate where
this macro is used.