ariel_os

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 use peripherals and/or hooks.
    • peripherals: (optional) provide the function with a peripheral struct as the first parameter. The peripherals parameter can only be used on autostart tasks. The peripheral struct must be defined with the ariel_os::hal::define_peripherals! macro.
    • hooks: (optional) available hooks are:
      • usb_builder_hook: when present, the macro will define a static USB_BUILDER_HOOK of type UsbBuilderHook, allowing to access and modify the system-provided embassy_usb::Builder through Delegate::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 to 1). Cannot be used on autostart tasks.

§Examples

use ariel_os::usb::UsbBuilderHook;

#[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.