From a0f1b0ee01d461607660d2d56b5b1bdc57e0d3fb Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 29 Jul 2022 21:58:35 +0200 Subject: [PATCH] Split embassy crate into embassy-executor, embassy-util. --- .github/workflows/rust.yml | 2 +- .vscode/settings.json | 5 + README.md | 12 +- ci.sh | 50 ++-- ci_stable.sh | 74 +++--- docs/modules/ROOT/examples/basic/Cargo.toml | 2 +- docs/modules/ROOT/examples/basic/src/main.rs | 8 +- .../ROOT/examples/layer-by-layer/Cargo.toml | 2 +- .../layer-by-layer/blinky-async/Cargo.toml | 2 +- .../layer-by-layer/blinky-async/src/main.rs | 4 +- embassy-boot/boot/Cargo.toml | 2 +- embassy-boot/nrf/Cargo.toml | 2 +- embassy-boot/stm32/Cargo.toml | 2 +- embassy-cortex-m/Cargo.toml | 3 +- embassy-cortex-m/src/executor.rs | 8 +- embassy-embedded-hal/Cargo.toml | 2 +- .../src/shared_bus/asynch/i2c.rs | 8 +- .../src/shared_bus/asynch/spi.rs | 8 +- .../src/shared_bus/blocking/i2c.rs | 6 +- .../src/shared_bus/blocking/spi.rs | 6 +- {embassy => embassy-executor}/Cargo.toml | 43 +--- {embassy => embassy-executor}/build.rs | 0 .../src/executor/arch/cortex_m.rs | 9 +- .../src/executor/arch/riscv32.rs | 0 .../src/executor/arch/std.rs | 0 .../src/executor/arch/wasm.rs | 0 .../src/executor/arch/xtensa.rs | 0 .../src/executor/mod.rs | 2 - .../src/executor/raw/mod.rs | 4 +- .../src/executor/raw/run_queue.rs | 0 .../src/executor/raw/timer_queue.rs | 0 .../src/executor/raw/util.rs | 0 .../src/executor/raw/waker.rs | 2 +- .../src/executor/spawner.rs | 12 +- {embassy => embassy-executor}/src/fmt.rs | 0 {embassy => embassy-executor}/src/lib.rs | 5 - .../src/time/delay.rs | 2 +- .../src/time/driver.rs | 10 +- .../src/time/driver_std.rs | 0 .../src/time/driver_wasm.rs | 0 .../src/time/duration.rs | 0 .../src/time/instant.rs | 0 {embassy => embassy-executor}/src/time/mod.rs | 4 +- .../src/time/timer.rs | 16 +- embassy-hal-common/Cargo.toml | 5 +- embassy-hal-common/src/lib.rs | 10 - embassy-lora/Cargo.toml | 7 +- embassy-lora/src/lib.rs | 2 +- embassy-lora/src/stm32wl/mod.rs | 2 +- embassy-lora/src/sx127x/sx127x_lora/mod.rs | 2 +- .../src/macros/cortex_m_interrupt_take.rs | 8 +- embassy-macros/src/macros/main.rs | 4 +- embassy-macros/src/macros/task.rs | 2 +- embassy-net/Cargo.toml | 5 +- embassy-net/src/stack.rs | 4 +- embassy-nrf/Cargo.toml | 11 +- embassy-nrf/src/buffered_uarte.rs | 14 +- embassy-nrf/src/gpiote.rs | 2 +- embassy-nrf/src/qdec.rs | 2 +- embassy-nrf/src/qspi.rs | 2 +- embassy-nrf/src/rng.rs | 2 +- embassy-nrf/src/saadc.rs | 2 +- embassy-nrf/src/spim.rs | 2 +- embassy-nrf/src/temp.rs | 2 +- embassy-nrf/src/time_driver.rs | 8 +- embassy-nrf/src/timer.rs | 6 +- embassy-nrf/src/twim.rs | 6 +- embassy-nrf/src/uarte.rs | 2 +- embassy-nrf/src/usb.rs | 2 +- embassy-rp/Cargo.toml | 5 +- embassy-rp/src/gpio.rs | 2 +- embassy-rp/src/timer.rs | 8 +- embassy-stm32/Cargo.toml | 11 +- embassy-stm32/src/dcmi.rs | 2 +- embassy-stm32/src/dma/bdma.rs | 2 +- embassy-stm32/src/dma/dma.rs | 2 +- embassy-stm32/src/dma/gpdma.rs | 2 +- embassy-stm32/src/eth/v1/mod.rs | 2 +- embassy-stm32/src/eth/v2/mod.rs | 2 +- embassy-stm32/src/exti.rs | 2 +- embassy-stm32/src/i2c/v2.rs | 2 +- embassy-stm32/src/rng.rs | 2 +- embassy-stm32/src/sdmmc/mod.rs | 6 +- embassy-stm32/src/subghz/mod.rs | 2 +- embassy-stm32/src/subghz/timeout.rs | 4 +- embassy-stm32/src/subghz/tx_params.rs | 18 +- embassy-stm32/src/time_driver.rs | 10 +- embassy-stm32/src/usart/buffered.rs | 2 +- embassy-stm32/src/usb/usb.rs | 4 +- embassy-usb-hid/Cargo.toml | 4 +- embassy-usb-hid/src/lib.rs | 23 +- embassy-usb-ncm/Cargo.toml | 2 +- embassy-usb-serial/Cargo.toml | 2 +- embassy-usb-serial/src/lib.rs | 2 +- embassy-usb/Cargo.toml | 2 +- embassy-usb/src/lib.rs | 2 +- embassy-util/Cargo.toml | 28 +++ embassy-util/build.rs | 29 +++ .../src/blocking_mutex/mod.rs | 11 - .../src/blocking_mutex/raw.rs | 3 +- {embassy => embassy-util}/src/channel/mod.rs | 0 {embassy => embassy-util}/src/channel/mpmc.rs | 27 +-- .../src/channel/pubsub/mod.rs | 6 +- .../src/channel/pubsub/publisher.rs | 3 +- .../src/channel/pubsub/subscriber.rs | 5 +- .../src/channel/signal.rs | 4 +- embassy-util/src/fmt.rs | 228 ++++++++++++++++++ .../src/util => embassy-util/src}/forever.rs | 2 +- embassy-util/src/lib.rs | 22 ++ {embassy => embassy-util}/src/mutex.rs | 15 +- .../src/util => embassy-util/src}/select.rs | 0 .../src/waitqueue/mod.rs | 1 - .../src/waitqueue/multi_waker.rs | 0 .../src/waitqueue/waker.rs | 0 .../util => embassy-util/src}/yield_now.rs | 0 embassy/src/util/mod.rs | 9 - embassy/src/waitqueue/waker.rs | 97 -------- examples/boot/application/nrf/Cargo.toml | 3 +- examples/boot/application/nrf/src/bin/a.rs | 4 +- examples/boot/application/nrf/src/bin/b.rs | 6 +- examples/boot/application/stm32f3/Cargo.toml | 3 +- .../boot/application/stm32f3/src/bin/a.rs | 4 +- .../boot/application/stm32f3/src/bin/b.rs | 6 +- examples/boot/application/stm32f7/Cargo.toml | 3 +- .../boot/application/stm32f7/src/bin/a.rs | 4 +- .../boot/application/stm32f7/src/bin/b.rs | 6 +- examples/boot/application/stm32h7/Cargo.toml | 3 +- .../boot/application/stm32h7/src/bin/a.rs | 4 +- .../boot/application/stm32h7/src/bin/b.rs | 6 +- examples/boot/application/stm32l0/Cargo.toml | 3 +- .../boot/application/stm32l0/src/bin/a.rs | 6 +- .../boot/application/stm32l0/src/bin/b.rs | 6 +- examples/boot/application/stm32l1/Cargo.toml | 3 +- .../boot/application/stm32l1/src/bin/a.rs | 6 +- .../boot/application/stm32l1/src/bin/b.rs | 6 +- examples/boot/application/stm32l4/Cargo.toml | 3 +- .../boot/application/stm32l4/src/bin/a.rs | 4 +- .../boot/application/stm32l4/src/bin/b.rs | 6 +- examples/boot/application/stm32wl/Cargo.toml | 3 +- .../boot/application/stm32wl/src/bin/a.rs | 4 +- .../boot/application/stm32wl/src/bin/b.rs | 6 +- examples/boot/bootloader/nrf/Cargo.toml | 1 - examples/boot/bootloader/stm32/Cargo.toml | 1 - examples/nrf/Cargo.toml | 5 +- examples/nrf/src/bin/awaitable_timer.rs | 4 +- examples/nrf/src/bin/blinky.rs | 6 +- examples/nrf/src/bin/buffered_uart.rs | 4 +- examples/nrf/src/bin/channel.rs | 12 +- .../nrf/src/bin/channel_sender_receiver.rs | 16 +- .../nrf/src/bin/executor_fairness_test.rs | 12 +- examples/nrf/src/bin/gpiote_channel.rs | 4 +- examples/nrf/src/bin/gpiote_port.rs | 6 +- examples/nrf/src/bin/multiprio.rs | 10 +- examples/nrf/src/bin/mutex.rs | 12 +- examples/nrf/src/bin/nvmc.rs | 6 +- examples/nrf/src/bin/ppi.rs | 4 +- examples/nrf/src/bin/pubsub.rs | 16 +- examples/nrf/src/bin/pwm.rs | 6 +- examples/nrf/src/bin/pwm_double_sequence.rs | 6 +- examples/nrf/src/bin/pwm_sequence.rs | 6 +- examples/nrf/src/bin/pwm_sequence_ppi.rs | 4 +- examples/nrf/src/bin/pwm_sequence_ws2812b.rs | 6 +- examples/nrf/src/bin/pwm_servo.rs | 6 +- examples/nrf/src/bin/qdec.rs | 4 +- examples/nrf/src/bin/qspi.rs | 4 +- examples/nrf/src/bin/qspi_lowpower.rs | 6 +- examples/nrf/src/bin/raw_spawn.rs | 8 +- examples/nrf/src/bin/rng.rs | 4 +- examples/nrf/src/bin/saadc.rs | 6 +- examples/nrf/src/bin/saadc_continuous.rs | 8 +- examples/nrf/src/bin/self_spawn.rs | 8 +- .../src/bin/self_spawn_current_executor.rs | 8 +- examples/nrf/src/bin/spim.rs | 4 +- examples/nrf/src/bin/temp.rs | 6 +- examples/nrf/src/bin/timer.rs | 10 +- examples/nrf/src/bin/twim.rs | 4 +- examples/nrf/src/bin/twim_lowpower.rs | 6 +- examples/nrf/src/bin/uart.rs | 4 +- examples/nrf/src/bin/uart_idle.rs | 4 +- examples/nrf/src/bin/uart_split.rs | 10 +- examples/nrf/src/bin/usb_ethernet.rs | 18 +- examples/nrf/src/bin/usb_hid_keyboard.rs | 13 +- examples/nrf/src/bin/usb_hid_mouse.rs | 10 +- examples/nrf/src/bin/usb_serial.rs | 4 +- examples/nrf/src/bin/usb_serial_multitask.rs | 10 +- examples/nrf/src/bin/wdt.rs | 4 +- examples/rp/Cargo.toml | 3 +- examples/rp/src/bin/blinky.rs | 6 +- examples/rp/src/bin/button.rs | 4 +- examples/rp/src/bin/gpio_async.rs | 6 +- examples/rp/src/bin/spi.rs | 4 +- examples/rp/src/bin/spi_display.rs | 6 +- examples/rp/src/bin/uart.rs | 4 +- examples/std/Cargo.toml | 3 +- examples/std/src/bin/net.rs | 8 +- examples/std/src/bin/serial.rs | 6 +- examples/std/src/bin/tick.rs | 8 +- examples/stm32f0/Cargo.toml | 3 +- examples/stm32f0/src/bin/hello.rs | 6 +- examples/stm32f1/Cargo.toml | 3 +- examples/stm32f1/src/bin/adc.rs | 6 +- examples/stm32f1/src/bin/blinky.rs | 6 +- examples/stm32f1/src/bin/hello.rs | 6 +- examples/stm32f1/src/bin/usb_serial.rs | 6 +- examples/stm32f2/Cargo.toml | 3 +- examples/stm32f2/src/bin/blinky.rs | 6 +- examples/stm32f2/src/bin/pll.rs | 6 +- examples/stm32f3/Cargo.toml | 3 +- examples/stm32f3/src/bin/blinky.rs | 6 +- examples/stm32f3/src/bin/button_events.rs | 14 +- examples/stm32f3/src/bin/button_exti.rs | 4 +- examples/stm32f3/src/bin/flash.rs | 4 +- examples/stm32f3/src/bin/hello.rs | 6 +- examples/stm32f3/src/bin/multiprio.rs | 10 +- examples/stm32f3/src/bin/spi_dma.rs | 4 +- examples/stm32f3/src/bin/usart_dma.rs | 4 +- examples/stm32f3/src/bin/usb_serial.rs | 6 +- examples/stm32f4/Cargo.toml | 3 +- examples/stm32f4/src/bin/adc.rs | 6 +- examples/stm32f4/src/bin/blinky.rs | 6 +- examples/stm32f4/src/bin/button_exti.rs | 4 +- examples/stm32f4/src/bin/flash.rs | 4 +- examples/stm32f4/src/bin/hello.rs | 6 +- examples/stm32f4/src/bin/multiprio.rs | 10 +- examples/stm32f4/src/bin/pwm.rs | 6 +- examples/stm32f4/src/bin/sdmmc.rs | 4 +- examples/stm32f4/src/bin/spi_dma.rs | 4 +- examples/stm32f4/src/bin/usart_buffered.rs | 4 +- examples/stm32f4/src/bin/usart_dma.rs | 4 +- examples/stm32f4/src/bin/wdt.rs | 6 +- examples/stm32f7/Cargo.toml | 3 +- examples/stm32f7/src/bin/adc.rs | 6 +- examples/stm32f7/src/bin/blinky.rs | 6 +- examples/stm32f7/src/bin/button_exti.rs | 4 +- examples/stm32f7/src/bin/eth.rs | 10 +- examples/stm32f7/src/bin/flash.rs | 6 +- examples/stm32f7/src/bin/hello.rs | 6 +- examples/stm32f7/src/bin/sdmmc.rs | 4 +- examples/stm32f7/src/bin/usart_dma.rs | 4 +- examples/stm32g0/Cargo.toml | 3 +- examples/stm32g0/src/bin/blinky.rs | 6 +- examples/stm32g0/src/bin/button_exti.rs | 4 +- examples/stm32g4/Cargo.toml | 3 +- examples/stm32g4/src/bin/blinky.rs | 6 +- examples/stm32g4/src/bin/button_exti.rs | 4 +- examples/stm32g4/src/bin/pwm.rs | 6 +- examples/stm32h7/Cargo.toml | 3 +- examples/stm32h7/src/bin/adc.rs | 6 +- examples/stm32h7/src/bin/blinky.rs | 6 +- examples/stm32h7/src/bin/button_exti.rs | 4 +- examples/stm32h7/src/bin/camera.rs | 8 +- examples/stm32h7/src/bin/eth.rs | 10 +- examples/stm32h7/src/bin/flash.rs | 6 +- examples/stm32h7/src/bin/fmc.rs | 6 +- .../stm32h7/src/bin/low_level_timer_api.rs | 6 +- examples/stm32h7/src/bin/mco.rs | 6 +- examples/stm32h7/src/bin/pwm.rs | 6 +- examples/stm32h7/src/bin/rng.rs | 4 +- examples/stm32h7/src/bin/sdmmc.rs | 4 +- examples/stm32h7/src/bin/signal.rs | 10 +- examples/stm32h7/src/bin/spi.rs | 6 +- examples/stm32h7/src/bin/spi_dma.rs | 6 +- examples/stm32h7/src/bin/usart.rs | 6 +- examples/stm32h7/src/bin/usart_dma.rs | 6 +- examples/stm32h7/src/bin/usart_split.rs | 12 +- examples/stm32l0/Cargo.toml | 3 +- examples/stm32l0/src/bin/blinky.rs | 6 +- examples/stm32l0/src/bin/button.rs | 4 +- examples/stm32l0/src/bin/button_exti.rs | 4 +- examples/stm32l0/src/bin/flash.rs | 4 +- examples/stm32l0/src/bin/lorawan.rs | 4 +- examples/stm32l0/src/bin/raw_spawn.rs | 8 +- examples/stm32l0/src/bin/spi.rs | 4 +- examples/stm32l0/src/bin/usart_dma.rs | 4 +- examples/stm32l0/src/bin/usart_irq.rs | 4 +- examples/stm32l1/Cargo.toml | 3 +- examples/stm32l1/src/bin/blinky.rs | 6 +- examples/stm32l1/src/bin/flash.rs | 4 +- examples/stm32l1/src/bin/spi.rs | 4 +- examples/stm32l4/Cargo.toml | 3 +- examples/stm32l4/src/bin/adc.rs | 2 +- examples/stm32l4/src/bin/blinky.rs | 6 +- examples/stm32l4/src/bin/button_exti.rs | 4 +- examples/stm32l4/src/bin/i2c.rs | 4 +- .../stm32l4/src/bin/i2c_blocking_async.rs | 4 +- examples/stm32l4/src/bin/i2c_dma.rs | 4 +- examples/stm32l4/src/bin/rng.rs | 4 +- .../stm32l4/src/bin/spi_blocking_async.rs | 4 +- examples/stm32l4/src/bin/spi_dma.rs | 4 +- examples/stm32l4/src/bin/usart_dma.rs | 4 +- examples/stm32l5/Cargo.toml | 3 +- examples/stm32l5/src/bin/button_exti.rs | 4 +- examples/stm32l5/src/bin/rng.rs | 4 +- examples/stm32l5/src/bin/usb_ethernet.rs | 18 +- examples/stm32l5/src/bin/usb_hid_mouse.rs | 6 +- examples/stm32l5/src/bin/usb_serial.rs | 4 +- examples/stm32u5/Cargo.toml | 3 +- examples/stm32u5/src/bin/blinky.rs | 6 +- examples/stm32wb/Cargo.toml | 3 +- examples/stm32wb/src/bin/blinky.rs | 6 +- examples/stm32wb/src/bin/button_exti.rs | 4 +- examples/stm32wl/Cargo.toml | 3 +- examples/stm32wl/src/bin/blinky.rs | 6 +- examples/stm32wl/src/bin/button_exti.rs | 4 +- examples/stm32wl/src/bin/flash.rs | 4 +- examples/stm32wl/src/bin/lorawan.rs | 4 +- examples/stm32wl/src/bin/subghz.rs | 6 +- examples/wasm/Cargo.toml | 3 +- examples/wasm/src/lib.rs | 8 +- tests/rp/Cargo.toml | 3 +- tests/rp/src/bin/gpio.rs | 4 +- tests/rp/src/bin/gpio_async.rs | 6 +- tests/stm32/Cargo.toml | 3 +- tests/stm32/src/bin/gpio.rs | 4 +- tests/stm32/src/bin/spi.rs | 4 +- tests/stm32/src/bin/spi_dma.rs | 4 +- tests/stm32/src/bin/timer.rs | 6 +- tests/stm32/src/bin/usart.rs | 4 +- tests/stm32/src/bin/usart_dma.rs | 4 +- 319 files changed, 1159 insertions(+), 998 deletions(-) rename {embassy => embassy-executor}/Cargo.toml (69%) rename {embassy => embassy-executor}/build.rs (100%) rename {embassy => embassy-executor}/src/executor/arch/cortex_m.rs (90%) rename {embassy => embassy-executor}/src/executor/arch/riscv32.rs (100%) rename {embassy => embassy-executor}/src/executor/arch/std.rs (100%) rename {embassy => embassy-executor}/src/executor/arch/wasm.rs (100%) rename {embassy => embassy-executor}/src/executor/arch/xtensa.rs (100%) rename {embassy => embassy-executor}/src/executor/mod.rs (98%) rename {embassy => embassy-executor}/src/executor/raw/mod.rs (98%) rename {embassy => embassy-executor}/src/executor/raw/run_queue.rs (100%) rename {embassy => embassy-executor}/src/executor/raw/timer_queue.rs (100%) rename {embassy => embassy-executor}/src/executor/raw/util.rs (100%) rename {embassy => embassy-executor}/src/executor/raw/waker.rs (91%) rename {embassy => embassy-executor}/src/executor/spawner.rs (93%) rename {embassy => embassy-executor}/src/fmt.rs (100%) rename {embassy => embassy-executor}/src/lib.rs (88%) rename {embassy => embassy-executor}/src/time/delay.rs (98%) rename {embassy => embassy-executor}/src/time/driver.rs (95%) rename {embassy => embassy-executor}/src/time/driver_std.rs (100%) rename {embassy => embassy-executor}/src/time/driver_wasm.rs (100%) rename {embassy => embassy-executor}/src/time/duration.rs (100%) rename {embassy => embassy-executor}/src/time/instant.rs (100%) rename {embassy => embassy-executor}/src/time/mod.rs (94%) rename {embassy => embassy-executor}/src/time/timer.rs (92%) create mode 100644 embassy-util/Cargo.toml create mode 100644 embassy-util/build.rs rename {embassy => embassy-util}/src/blocking_mutex/mod.rs (95%) rename {embassy => embassy-util}/src/blocking_mutex/raw.rs (97%) rename {embassy => embassy-util}/src/channel/mod.rs (100%) rename {embassy => embassy-util}/src/channel/mpmc.rs (95%) rename {embassy => embassy-util}/src/channel/pubsub/mod.rs (99%) rename {embassy => embassy-util}/src/channel/pubsub/publisher.rs (99%) rename {embassy => embassy-util}/src/channel/pubsub/subscriber.rs (97%) rename {embassy => embassy-util}/src/channel/signal.rs (96%) create mode 100644 embassy-util/src/fmt.rs rename {embassy/src/util => embassy-util/src}/forever.rs (99%) create mode 100644 embassy-util/src/lib.rs rename {embassy => embassy-util}/src/mutex.rs (91%) rename {embassy/src/util => embassy-util/src}/select.rs (100%) rename {embassy => embassy-util}/src/waitqueue/mod.rs (59%) rename {embassy => embassy-util}/src/waitqueue/multi_waker.rs (100%) rename embassy/src/waitqueue/waker_agnostic.rs => embassy-util/src/waitqueue/waker.rs (100%) rename {embassy/src/util => embassy-util/src}/yield_now.rs (100%) delete mode 100644 embassy/src/util/mod.rs delete mode 100644 embassy/src/waitqueue/waker.rs diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6115e618..d76e5ced 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -69,4 +69,4 @@ jobs: steps: - uses: actions/checkout@v2 - name: Test - run: cd embassy && cargo test + run: cd embassy-util && cargo test diff --git a/.vscode/settings.json b/.vscode/settings.json index 5ce8e4e7..1ac3fc51 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,10 +12,15 @@ //"embassy-net/medium-ethernet", //"embassy-net/tcp", //"embassy-net/pool-16", + //"time-tick-16mhz", + //"defmt-timestamp-uptime", "nightly", + //"unstable-traits", ], "rust-analyzer.linkedProjects": [ // Declare for the target you wish to develop + //"embassy-executor/Cargo.toml", + //"embassy-util/Cargo.toml", "examples/nrf/Cargo.toml", // "examples/rp/Cargo.toml", // "examples/std/Cargo.toml", diff --git a/README.md b/README.md index a7a7ccd5..42374067 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Rust's async/await allows - embassy-nrf, for the Nordic Semiconductor nRF52, nRF53, nRF91 series. - **Time that Just Works** - -No more messing with hardware timers. embassy::time provides Instant, Duration and Timer types that are globally available and never overflow. +No more messing with hardware timers. embassy_executor::time provides Instant, Duration and Timer types that are globally available and never overflow. - **Real-time ready** - Tasks on the same async executor run cooperatively, but you can create multiple executors with different priorities, so that higher priority tasks preempt lower priority ones. See the example. @@ -44,13 +44,13 @@ The nrf-softdevice cr ```rust,ignore use defmt::info; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull}; use embassy_nrf::Peripherals; // Declare async tasks -#[embassy::task] +#[embassy_executor::task] async fn blink(pin: AnyPin) { let mut led = Output::new(pin, Level::Low, OutputDrive::Standard); @@ -64,7 +64,7 @@ async fn blink(pin: AnyPin) { } // Main is itself an async task as well. -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { // Spawned tasks run in the background, concurrently. spawner.spawn(blink(p.P0_13.degrade())).unwrap(); @@ -132,7 +132,7 @@ Embassy is guaranteed to compile on the latest stable Rust version at the time o Several features require nightly: -- The `#[embassy::main]` and `#[embassy::task]` attribute macros. +- The `#[embassy_executor::main]` and `#[embassy_executor::task]` attribute macros. - Async traits These are enabled by activating the `nightly` Cargo feature. If you do so, Embassy is guaranteed to compile on the exact nightly version specified in `rust-toolchain.toml`. It might compile with older or newer nightly versions, but that may change in any new patch release. diff --git a/ci.sh b/ci.sh index e34f1dfe..6ec2410f 100755 --- a/ci.sh +++ b/ci.sh @@ -32,10 +32,10 @@ rm -rf stm32-metapac mv stm32-metapac-gen/out stm32-metapac cargo batch \ - --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features nightly \ - --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features nightly,log,executor-agnostic \ - --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features nightly,defmt \ - --- build --release --manifest-path embassy/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt \ + --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features nightly \ + --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features nightly,log \ + --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features nightly,defmt \ + --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt \ --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52805,gpiote,time-driver-rtc1 \ --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52810,gpiote,time-driver-rtc1 \ --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52811,gpiote,time-driver-rtc1 \ @@ -54,27 +54,27 @@ cargo batch \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits,log \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f410tb,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f411ce,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f429zi,log,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h755zi-cm7,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h7b3ai,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32l476vg,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wb15cc,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l072cz,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l041f6,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32l151cb-a,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f398ve,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32g0c1ve,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f217zg,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,stm32l552ze,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5ub,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f103re,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f100c4,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f410tb,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f411ce,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f429zi,log,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h7b3ai,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32l476vg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wb15cc,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l072cz,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l041f6,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32l151cb-a,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f398ve,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32g0c1ve,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f217zg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,stm32l552ze,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5ub,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f103re,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f100c4,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ --- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \ - --- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4,embassy/time-tick-32768hz \ + --- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \ --- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \ --- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-pac/Cargo.toml --target thumbv7em-none-eabi \ --- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-hal/Cargo.toml --target thumbv7em-none-eabi \ @@ -106,7 +106,7 @@ cargo batch \ --- build --release --manifest-path examples/boot/application/stm32l4/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/boot/stm32l4 --bin b \ --- build --release --manifest-path examples/boot/application/stm32wl/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/boot/stm32wl --bin b \ --- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \ - --- build --release --manifest-path examples/boot/bootloader/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4,embassy/time-tick-32768hz \ + --- build --release --manifest-path examples/boot/bootloader/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \ --- build --release --manifest-path examples/wasm/Cargo.toml --target wasm32-unknown-unknown --out-dir out/examples/wasm \ --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f103c8 --out-dir out/tests/bluepill-stm32f103c8 \ --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi --out-dir out/tests/nucleo-stm32f429zi \ diff --git a/ci_stable.sh b/ci_stable.sh index 2723936e..7521827d 100755 --- a/ci_stable.sh +++ b/ci_stable.sh @@ -9,10 +9,10 @@ export DEFMT_LOG=trace sed -i 's/channel.*/channel = "stable"/g' rust-toolchain.toml cargo batch \ - --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi \ - --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features log,executor-agnostic \ - --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features defmt \ - --- build --release --manifest-path embassy/Cargo.toml --target thumbv6m-none-eabi --features defmt \ + --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi \ + --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features log \ + --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features defmt \ + --- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv6m-none-eabi --features defmt \ --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52805,gpiote,time-driver-rtc1 \ --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52810,gpiote,time-driver-rtc1 \ --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52811,gpiote,time-driver-rtc1 \ @@ -30,38 +30,38 @@ cargo batch \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,defmt \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,log \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55vy,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55uc-cm4,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4r9zi,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f303vc,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,embassy/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,embassy/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55vy,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55uc-cm4,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4r9zi,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f303vc,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy-executor/time-tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy-executor/time-tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ --- build --release --manifest-path examples/nrf/Cargo.toml --target thumbv7em-none-eabi --no-default-features --out-dir out/examples/nrf --bin raw_spawn \ --- build --release --manifest-path examples/stm32l0/Cargo.toml --target thumbv6m-none-eabi --no-default-features --out-dir out/examples/stm32l0 --bin raw_spawn \ diff --git a/docs/modules/ROOT/examples/basic/Cargo.toml b/docs/modules/ROOT/examples/basic/Cargo.toml index ed1c3cb1..59e1a437 100644 --- a/docs/modules/ROOT/examples/basic/Cargo.toml +++ b/docs/modules/ROOT/examples/basic/Cargo.toml @@ -5,7 +5,7 @@ name = "embassy-basic-example" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../../../../embassy", features = ["defmt", "nightly"] } +embassy-executor = { version = "0.1.0", path = "../../../../../embassy-executor", features = ["defmt", "nightly"] } embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "nightly"] } defmt = "0.3" diff --git a/docs/modules/ROOT/examples/basic/src/main.rs b/docs/modules/ROOT/examples/basic/src/main.rs index 461741fd..cec39fd9 100644 --- a/docs/modules/ROOT/examples/basic/src/main.rs +++ b/docs/modules/ROOT/examples/basic/src/main.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::peripherals::P0_13; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; // global logger -#[embassy::task] +#[embassy_executor::task] async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) { loop { led.set_high(); @@ -20,7 +20,7 @@ async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300)))); diff --git a/docs/modules/ROOT/examples/layer-by-layer/Cargo.toml b/docs/modules/ROOT/examples/layer-by-layer/Cargo.toml index 2dca3cc8..9048d930 100644 --- a/docs/modules/ROOT/examples/layer-by-layer/Cargo.toml +++ b/docs/modules/ROOT/examples/layer-by-layer/Cargo.toml @@ -8,7 +8,7 @@ members = [ ] [patch.crates-io] -embassy = { path = "../../../../../embassy" } +embassy-executor = { path = "../../../../../embassy-executor" } embassy-stm32 = { path = "../../../../../embassy-stm32" } stm32-metapac = { path = "../../../../../stm32-metapac" } diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml index e0c63251..e2933076 100644 --- a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" cortex-m = "0.7" cortex-m-rt = "0.7" embassy-stm32 = { version = "0.1.0", features = ["stm32l475vg", "memory-x", "exti"], default-features = false } -embassy = { version = "0.1.0", default-features = false, features = ["nightly"] } +embassy-executor = { version = "0.1.0", default-features = false, features = ["nightly"] } defmt = "0.3.0" defmt-rtt = "0.3.0" diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs index 56bc698d..b944a799 100644 --- a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_s: Spawner, p: Peripherals) { let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh); let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13); diff --git a/embassy-boot/boot/Cargo.toml b/embassy-boot/boot/Cargo.toml index 5bb2c34b..abb7bb5c 100644 --- a/embassy-boot/boot/Cargo.toml +++ b/embassy-boot/boot/Cargo.toml @@ -9,7 +9,7 @@ description = "Bootloader using Embassy" [dependencies] defmt = { version = "0.3", optional = true } log = { version = "0.4", optional = true } -embassy = { path = "../../embassy", default-features = false } +embassy-util = { version = "0.1.0", path = "../../embassy-util" } embedded-storage = "0.3.0" embedded-storage-async = "0.3.0" diff --git a/embassy-boot/nrf/Cargo.toml b/embassy-boot/nrf/Cargo.toml index ea579483..5dc3ce52 100644 --- a/embassy-boot/nrf/Cargo.toml +++ b/embassy-boot/nrf/Cargo.toml @@ -9,7 +9,7 @@ description = "Bootloader lib for nRF chips" [dependencies] defmt = { version = "0.3", optional = true } -embassy = { path = "../../embassy", default-features = false } +embassy-util = { path = "../../embassy-util" } embassy-nrf = { path = "../../embassy-nrf", default-features = false, features = ["nightly"] } embassy-boot = { path = "../boot", default-features = false } cortex-m = { version = "0.7" } diff --git a/embassy-boot/stm32/Cargo.toml b/embassy-boot/stm32/Cargo.toml index 13ae54b3..eab8d160 100644 --- a/embassy-boot/stm32/Cargo.toml +++ b/embassy-boot/stm32/Cargo.toml @@ -11,7 +11,7 @@ defmt = { version = "0.3", optional = true } defmt-rtt = { version = "0.3", optional = true } log = { version = "0.4", optional = true } -embassy = { path = "../../embassy", default-features = false } +embassy-util = { path = "../../embassy-util" } embassy-stm32 = { path = "../../embassy-stm32", default-features = false, features = ["nightly"] } embassy-boot = { path = "../boot", default-features = false } cortex-m = { version = "0.7" } diff --git a/embassy-cortex-m/Cargo.toml b/embassy-cortex-m/Cargo.toml index 9dbec046..454f34e0 100644 --- a/embassy-cortex-m/Cargo.toml +++ b/embassy-cortex-m/Cargo.toml @@ -35,7 +35,8 @@ prio-bits-8 = [] defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } -embassy = { version = "0.1.0", path = "../embassy"} +embassy-util = { version = "0.1.0", path = "../embassy-util" } +embassy-executor = { version = "0.1.0", path = "../embassy-executor"} embassy-macros = { version = "0.1.0", path = "../embassy-macros"} embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common"} atomic-polyfill = "0.1.5" diff --git a/embassy-cortex-m/src/executor.rs b/embassy-cortex-m/src/executor.rs index 17ccf0e8..4a3fa990 100644 --- a/embassy-cortex-m/src/executor.rs +++ b/embassy-cortex-m/src/executor.rs @@ -1,7 +1,7 @@ //! Executor specific to cortex-m devices. use core::marker::PhantomData; -pub use embassy::executor::*; +pub use embassy_executor::executor::*; use crate::interrupt::{Interrupt, InterruptExt}; @@ -60,18 +60,18 @@ impl InterruptExecutor { /// The executor keeps running in the background through the interrupt. /// /// This returns a [`SendSpawner`] you can use to spawn tasks on it. A [`SendSpawner`] - /// is returned instead of a [`Spawner`](embassy::executor::Spawner) because the executor effectively runs in a + /// is returned instead of a [`Spawner`](embassy_executor::executor::Spawner) because the executor effectively runs in a /// different "thread" (the interrupt), so spawning tasks on it is effectively /// sending them. /// - /// To obtain a [`Spawner`](embassy::executor::Spawner) for this executor, use [`Spawner::for_current_executor()`](embassy::executor::Spawner::for_current_executor()) from + /// To obtain a [`Spawner`](embassy_executor::executor::Spawner) for this executor, use [`Spawner::for_current_executor()`](embassy_executor::executor::Spawner::for_current_executor()) from /// a task running in it. /// /// This function requires `&'static mut self`. This means you have to store the /// Executor instance in a place where it'll live forever and grants you mutable /// access. There's a few ways to do this: /// - /// - a [Forever](embassy::util::Forever) (safe) + /// - a [Forever](embassy_util::Forever) (safe) /// - a `static mut` (unsafe) /// - a local variable in a function you know never returns (like `fn main() -> !`), upgrading its lifetime with `transmute`. (unsafe) pub fn start(&'static mut self) -> SendSpawner { diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml index 455786be..f245783c 100644 --- a/embassy-embedded-hal/Cargo.toml +++ b/embassy-embedded-hal/Cargo.toml @@ -9,7 +9,7 @@ std = [] nightly = ["embedded-hal-async", "embedded-storage-async"] [dependencies] -embassy = { version = "0.1.0", path = "../embassy" } +embassy-util = { version = "0.1.0", path = "../embassy-util" } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } embedded-hal-async = { version = "0.1.0-alpha.1", optional = true } diff --git a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs index fa77a06d..bd023fb6 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs @@ -4,8 +4,8 @@ //! //! ```rust //! use embassy_embedded_hal::shared_bus::i2c::I2cDevice; -//! use embassy::mutex::Mutex; -//! use embassy::blocking_mutex::raw::ThreadModeRawMutex; +//! use embassy_util::mutex::Mutex; +//! use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; //! //! static I2C_BUS: Forever>> = Forever::new(); //! let config = twim::Config::default(); @@ -24,8 +24,8 @@ //! ``` use core::future::Future; -use embassy::blocking_mutex::raw::RawMutex; -use embassy::mutex::Mutex; +use embassy_util::blocking_mutex::raw::RawMutex; +use embassy_util::mutex::Mutex; use embedded_hal_async::i2c; use crate::shared_bus::I2cDeviceError; diff --git a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs index a08eaa82..caa37f6f 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs @@ -4,8 +4,8 @@ //! //! ```rust //! use embassy_embedded_hal::shared_bus::spi::SpiDevice; -//! use embassy::mutex::Mutex; -//! use embassy::blocking_mutex::raw::ThreadModeRawMutex; +//! use embassy_util::mutex::Mutex; +//! use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; //! //! static SPI_BUS: Forever>> = Forever::new(); //! let mut config = spim::Config::default(); @@ -27,8 +27,8 @@ //! ``` use core::future::Future; -use embassy::blocking_mutex::raw::RawMutex; -use embassy::mutex::Mutex; +use embassy_util::blocking_mutex::raw::RawMutex; +use embassy_util::mutex::Mutex; use embedded_hal_1::digital::blocking::OutputPin; use embedded_hal_1::spi::ErrorType; use embedded_hal_async::spi; diff --git a/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs b/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs index c8b5e30f..1fc343d1 100644 --- a/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs +++ b/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs @@ -4,7 +4,7 @@ //! //! ```rust //! use embassy_embedded_hal::shared_bus::blocking::i2c::I2cDevice; -//! use embassy::blocking_mutex::{NoopMutex, raw::NoopRawMutex}; +//! use embassy_util::blocking_mutex::{NoopMutex, raw::NoopRawMutex}; //! //! static I2C_BUS: Forever>>> = Forever::new(); //! let irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); @@ -18,8 +18,8 @@ use core::cell::RefCell; -use embassy::blocking_mutex::raw::RawMutex; -use embassy::blocking_mutex::Mutex; +use embassy_util::blocking_mutex::raw::RawMutex; +use embassy_util::blocking_mutex::Mutex; use embedded_hal_1::i2c::blocking::{I2c, Operation}; use embedded_hal_1::i2c::ErrorType; diff --git a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs index d0648f59..a6132659 100644 --- a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs @@ -4,7 +4,7 @@ //! //! ```rust //! use embassy_embedded_hal::shared_bus::blocking::spi::SpiDevice; -//! use embassy::blocking_mutex::{NoopMutex, raw::NoopRawMutex}; +//! use embassy_util::blocking_mutex::{NoopMutex, raw::NoopRawMutex}; //! //! static SPI_BUS: Forever>>> = Forever::new(); //! let irq = interrupt::take!(SPIM3); @@ -20,8 +20,8 @@ use core::cell::RefCell; -use embassy::blocking_mutex::raw::RawMutex; -use embassy::blocking_mutex::Mutex; +use embassy_util::blocking_mutex::raw::RawMutex; +use embassy_util::blocking_mutex::Mutex; use embedded_hal_1::digital::blocking::OutputPin; use embedded_hal_1::spi; use embedded_hal_1::spi::blocking::SpiBusFlush; diff --git a/embassy/Cargo.toml b/embassy-executor/Cargo.toml similarity index 69% rename from embassy/Cargo.toml rename to embassy-executor/Cargo.toml index a5d36c10..d8ac4ac0 100644 --- a/embassy/Cargo.toml +++ b/embassy-executor/Cargo.toml @@ -1,11 +1,12 @@ [package] -name = "embassy" +name = "embassy-executor" version = "0.1.0" edition = "2021" + [package.metadata.embassy_docs] -src_base = "https://github.com/embassy-rs/embassy/blob/embassy-v$VERSION/embassy/src/" -src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy/src/" +src_base = "https://github.com/embassy-rs/embassy/blob/embassy-executor-v$VERSION/embassy-executor/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-executor/src/" features = ["nightly", "defmt", "unstable-traits", "time", "time-tick-1mhz"] flavors = [ { name = "std", target = "x86_64-unknown-linux-gnu", features = ["std"] }, @@ -21,7 +22,7 @@ flavors = [ [features] default = [] -std = ["futures/std", "time", "time-tick-1mhz", "embassy-macros/std"] +std = ["time", "time-tick-1mhz", "embassy-macros/std"] wasm = ["wasm-bindgen", "js-sys", "embassy-macros/wasm", "wasm-timer", "time", "time-tick-1mhz"] # Enable nightly-only features @@ -35,12 +36,12 @@ unstable-traits = ["embedded-hal-1"] # To use this you must have a time driver provided. defmt-timestamp-uptime = ["defmt"] -# Enable `embassy::time` module. +# Enable `embassy_executor::time` module. # NOTE: This feature is only intended to be enabled by crates providing the time driver implementation. # Enabling it directly without supplying a time driver will fail to link. time = [] -# Set the `embassy::time` tick rate. +# Set the `embassy_executor::time` tick rate. # NOTE: This feature is only intended to be enabled by crates providing the time driver implementation. # If you're not writing your own driver, check the driver documentation to customize the tick rate. # If you're writing a driver and your tick rate is not listed here, please add it and send a PR! @@ -49,8 +50,6 @@ time-tick-1000hz = ["time"] time-tick-1mhz = ["time"] time-tick-16mhz = ["time"] -executor-agnostic = [] - [dependencies] defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } @@ -59,37 +58,13 @@ embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" } embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true} embedded-hal-async = { version = "0.1.0-alpha.1", optional = true} -futures = { version = "0.3.17", default-features = false, features = [ "cfg-target-has-atomic", "unstable" ] } -pin-project = { version = "1.0.8", default-features = false } +futures-util = { version = "0.3.17", default-features = false } embassy-macros = { version = "0.1.0", path = "../embassy-macros"} atomic-polyfill = "0.1.5" critical-section = "0.2.5" -heapless = "0.7.5" cfg-if = "1.0.0" # WASM dependencies wasm-bindgen = { version = "0.2.76", features = ["nightly"], optional = true } js-sys = { version = "0.3", optional = true } -wasm-timer = { version = "0.2.5", optional = true } - -[target."thumbv6m-none-eabi".dependencies] -cortex-m = "0.7.3" -[target."thumbv7m-none-eabi".dependencies] -cortex-m = "0.7.3" -[target."thumbv7em-none-eabi".dependencies] -cortex-m = "0.7.3" -[target."thumbv7em-none-eabihf".dependencies] -cortex-m = "0.7.3" -[target."thumbv8m.base-none-eabi".dependencies] -cortex-m = "0.7.3" -[target."thumbv8m.main-none-eabi".dependencies] -cortex-m = "0.7.3" -[target."thumbv8m.main-none-eabihf".dependencies] -cortex-m = "0.7.3" - -[dev-dependencies] -embassy = { path = ".", features = ["executor-agnostic"] } -futures-executor = { version = "0.3.17", features = [ "thread-pool" ] } -futures-test = "0.3.17" -futures-timer = "3.0.2" -futures-util = { version = "0.3.17", features = [ "channel" ] } +wasm-timer = { version = "0.2.5", optional = true } \ No newline at end of file diff --git a/embassy/build.rs b/embassy-executor/build.rs similarity index 100% rename from embassy/build.rs rename to embassy-executor/build.rs diff --git a/embassy/src/executor/arch/cortex_m.rs b/embassy-executor/src/executor/arch/cortex_m.rs similarity index 90% rename from embassy/src/executor/arch/cortex_m.rs rename to embassy-executor/src/executor/arch/cortex_m.rs index cf80389b..d6e758df 100644 --- a/embassy/src/executor/arch/cortex_m.rs +++ b/embassy-executor/src/executor/arch/cortex_m.rs @@ -1,3 +1,4 @@ +use core::arch::asm; use core::marker::PhantomData; use core::ptr; @@ -22,7 +23,7 @@ impl Executor { /// Create a new Executor. pub fn new() -> Self { Self { - inner: raw::Executor::new(|_| cortex_m::asm::sev(), ptr::null_mut()), + inner: raw::Executor::new(|_| unsafe { asm!("sev") }, ptr::null_mut()), not_send: PhantomData, } } @@ -49,8 +50,10 @@ impl Executor { init(self.inner.spawner()); loop { - unsafe { self.inner.poll() }; - cortex_m::asm::wfe(); + unsafe { + self.inner.poll(); + asm!("wfe"); + }; } } } diff --git a/embassy/src/executor/arch/riscv32.rs b/embassy-executor/src/executor/arch/riscv32.rs similarity index 100% rename from embassy/src/executor/arch/riscv32.rs rename to embassy-executor/src/executor/arch/riscv32.rs diff --git a/embassy/src/executor/arch/std.rs b/embassy-executor/src/executor/arch/std.rs similarity index 100% rename from embassy/src/executor/arch/std.rs rename to embassy-executor/src/executor/arch/std.rs diff --git a/embassy/src/executor/arch/wasm.rs b/embassy-executor/src/executor/arch/wasm.rs similarity index 100% rename from embassy/src/executor/arch/wasm.rs rename to embassy-executor/src/executor/arch/wasm.rs diff --git a/embassy/src/executor/arch/xtensa.rs b/embassy-executor/src/executor/arch/xtensa.rs similarity index 100% rename from embassy/src/executor/arch/xtensa.rs rename to embassy-executor/src/executor/arch/xtensa.rs diff --git a/embassy/src/executor/mod.rs b/embassy-executor/src/executor/mod.rs similarity index 98% rename from embassy/src/executor/mod.rs rename to embassy-executor/src/executor/mod.rs index 75826936..45d00c56 100644 --- a/embassy/src/executor/mod.rs +++ b/embassy-executor/src/executor/mod.rs @@ -10,8 +10,6 @@ //! - Fair: a task can't monopolize CPU time even if it's constantly being woken. All other tasks get a chance to run before a given task gets polled for the second time. //! - Creating multiple executor instances is supported, to run tasks with multiple priority levels. This allows higher-priority tasks to preempt lower-priority tasks. -#![deny(missing_docs)] - cfg_if::cfg_if! { if #[cfg(cortex_m)] { #[path="arch/cortex_m.rs"] diff --git a/embassy/src/executor/raw/mod.rs b/embassy-executor/src/executor/raw/mod.rs similarity index 98% rename from embassy/src/executor/raw/mod.rs rename to embassy-executor/src/executor/raw/mod.rs index 0cfe617e..87317bc0 100644 --- a/embassy/src/executor/raw/mod.rs +++ b/embassy-executor/src/executor/raw/mod.rs @@ -5,7 +5,7 @@ //! ## WARNING: here be dragons! //! //! Using this module requires respecting subtle safety contracts. If you can, prefer using the safe -//! executor wrappers in [`executor`](crate::executor) and the [`embassy::task`](embassy_macros::task) macro, which are fully safe. +//! executor wrappers in [`executor`](crate::executor) and the [`embassy_executor::task`](embassy_macros::task) macro, which are fully safe. mod run_queue; #[cfg(feature = "time")] @@ -99,7 +99,7 @@ impl TaskHeader { /// A `TaskStorage` must live forever, it may not be deallocated even after the task has finished /// running. Hence the relevant methods require `&'static self`. It may be reused, however. /// -/// Internally, the [embassy::task](embassy_macros::task) macro allocates an array of `TaskStorage`s +/// Internally, the [embassy_executor::task](embassy_macros::task) macro allocates an array of `TaskStorage`s /// in a `static`. The most common reason to use the raw `Task` is to have control of where /// the memory for the task is allocated: on the stack, or on the heap with e.g. `Box::leak`, etc. diff --git a/embassy/src/executor/raw/run_queue.rs b/embassy-executor/src/executor/raw/run_queue.rs similarity index 100% rename from embassy/src/executor/raw/run_queue.rs rename to embassy-executor/src/executor/raw/run_queue.rs diff --git a/embassy/src/executor/raw/timer_queue.rs b/embassy-executor/src/executor/raw/timer_queue.rs similarity index 100% rename from embassy/src/executor/raw/timer_queue.rs rename to embassy-executor/src/executor/raw/timer_queue.rs diff --git a/embassy/src/executor/raw/util.rs b/embassy-executor/src/executor/raw/util.rs similarity index 100% rename from embassy/src/executor/raw/util.rs rename to embassy-executor/src/executor/raw/util.rs diff --git a/embassy/src/executor/raw/waker.rs b/embassy-executor/src/executor/raw/waker.rs similarity index 91% rename from embassy/src/executor/raw/waker.rs rename to embassy-executor/src/executor/raw/waker.rs index 605cda4c..f6ae332f 100644 --- a/embassy/src/executor/raw/waker.rs +++ b/embassy-executor/src/executor/raw/waker.rs @@ -40,7 +40,7 @@ pub fn task_from_waker(waker: &Waker) -> NonNull { // TODO use waker_getters when stable. https://github.com/rust-lang/rust/issues/96992 let hack: &WakerHack = unsafe { mem::transmute(waker) }; if hack.vtable != &VTABLE { - panic!("Found waker not created by the embassy executor. Consider enabling the `executor-agnostic` feature on the `embassy` crate.") + panic!("Found waker not created by the Embassy executor. `embassy_executor::time::Timer` only works with the Embassy executor.") } // safety: we never create a waker with a null data pointer. diff --git a/embassy/src/executor/spawner.rs b/embassy-executor/src/executor/spawner.rs similarity index 93% rename from embassy/src/executor/spawner.rs rename to embassy-executor/src/executor/spawner.rs index c8d036eb..25a0d7db 100644 --- a/embassy/src/executor/spawner.rs +++ b/embassy-executor/src/executor/spawner.rs @@ -3,13 +3,13 @@ use core::mem; use core::ptr::NonNull; use core::task::Poll; -use futures::future::poll_fn; +use futures_util::future::poll_fn; use super::raw; /// Token to spawn a newly-created task in an executor. /// -/// When calling a task function (like `#[embassy::task] async fn my_task() { ... }`), the returned +/// When calling a task function (like `#[embassy_executor::task] async fn my_task() { ... }`), the returned /// value is a `SpawnToken` that represents an instance of the task, ready to spawn. You must /// then spawn it into an executor, typically with [`Spawner::spawn()`]. /// @@ -56,9 +56,9 @@ impl Drop for SpawnToken { pub enum SpawnError { /// Too many instances of this task are already running. /// - /// By default, a task marked with `#[embassy::task]` can only have one instance + /// By default, a task marked with `#[embassy_executor::task]` can only have one instance /// running at a time. You may allow multiple instances to run in parallel with - /// `#[embassy::task(pool_size = 4)]`, at the cost of higher RAM usage. + /// `#[embassy_executor::task(pool_size = 4)]`, at the cost of higher RAM usage. Busy, } @@ -101,7 +101,7 @@ impl Spawner { /// Spawn a task into an executor. /// - /// You obtain the `token` by calling a task function (i.e. one marked with `#[embassy::task]`). + /// You obtain the `token` by calling a task function (i.e. one marked with `#[embassy_executor::task]`). pub fn spawn(&self, token: SpawnToken) -> Result<(), SpawnError> { let task = token.raw_task; mem::forget(token); @@ -177,7 +177,7 @@ impl SendSpawner { /// Spawn a task into an executor. /// - /// You obtain the `token` by calling a task function (i.e. one marked with `#[embassy::task]`). + /// You obtain the `token` by calling a task function (i.e. one marked with `#[embassy_executor::task]`). pub fn spawn(&self, token: SpawnToken) -> Result<(), SpawnError> { let header = token.raw_task; mem::forget(token); diff --git a/embassy/src/fmt.rs b/embassy-executor/src/fmt.rs similarity index 100% rename from embassy/src/fmt.rs rename to embassy-executor/src/fmt.rs diff --git a/embassy/src/lib.rs b/embassy-executor/src/lib.rs similarity index 88% rename from embassy/src/lib.rs rename to embassy-executor/src/lib.rs index b7be8b34..69e4aeb4 100644 --- a/embassy/src/lib.rs +++ b/embassy-executor/src/lib.rs @@ -8,14 +8,9 @@ // This mod MUST go first, so that the others see its macros. pub(crate) mod fmt; -pub mod blocking_mutex; -pub mod channel; pub mod executor; -pub mod mutex; #[cfg(feature = "time")] pub mod time; -pub mod util; -pub mod waitqueue; #[cfg(feature = "nightly")] pub use embassy_macros::{main, task}; diff --git a/embassy/src/time/delay.rs b/embassy-executor/src/time/delay.rs similarity index 98% rename from embassy/src/time/delay.rs rename to embassy-executor/src/time/delay.rs index 83a895e9..d76ed32e 100644 --- a/embassy/src/time/delay.rs +++ b/embassy-executor/src/time/delay.rs @@ -35,7 +35,7 @@ cfg_if::cfg_if! { if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { use crate::time::Timer; use core::future::Future; - use futures::FutureExt; + use futures_util::FutureExt; impl embedded_hal_async::delay::DelayUs for Delay { type Error = core::convert::Infallible; diff --git a/embassy/src/time/driver.rs b/embassy-executor/src/time/driver.rs similarity index 95% rename from embassy/src/time/driver.rs rename to embassy-executor/src/time/driver.rs index 760a828b..48e2f1c7 100644 --- a/embassy/src/time/driver.rs +++ b/embassy-executor/src/time/driver.rs @@ -1,17 +1,17 @@ //! Time driver interface //! -//! This module defines the interface a driver needs to implement to power the `embassy::time` module. +//! This module defines the interface a driver needs to implement to power the `embassy_executor::time` module. //! //! # Implementing a driver //! //! - Define a struct `MyDriver` //! - Implement [`Driver`] for it //! - Register it as the global driver with [`time_driver_impl`]. -//! - Enable the Cargo features `embassy/time` and one of `embassy/time-tick-*` corresponding to the +//! - Enable the Cargo features `embassy-executor/time` and one of `embassy-executor/time-tick-*` corresponding to the //! tick rate of your driver. //! //! If you wish to make the tick rate configurable by the end user, you should do so by exposing your own -//! Cargo features and having each enable the corresponding `embassy/time-tick-*`. +//! Cargo features and having each enable the corresponding `embassy-executor/time-tick-*`. //! //! # Linkage details //! @@ -34,10 +34,10 @@ //! # Example //! //! ``` -//! use embassy::time::driver::{Driver, AlarmHandle}; +//! use embassy_executor::time::driver::{Driver, AlarmHandle}; //! //! struct MyDriver{}; // not public! -//! embassy::time_driver_impl!(static DRIVER: MyDriver = MyDriver{}); +//! embassy_executor::time_driver_impl!(static DRIVER: MyDriver = MyDriver{}); //! //! impl Driver for MyDriver { //! fn now(&self) -> u64 { diff --git a/embassy/src/time/driver_std.rs b/embassy-executor/src/time/driver_std.rs similarity index 100% rename from embassy/src/time/driver_std.rs rename to embassy-executor/src/time/driver_std.rs diff --git a/embassy/src/time/driver_wasm.rs b/embassy-executor/src/time/driver_wasm.rs similarity index 100% rename from embassy/src/time/driver_wasm.rs rename to embassy-executor/src/time/driver_wasm.rs diff --git a/embassy/src/time/duration.rs b/embassy-executor/src/time/duration.rs similarity index 100% rename from embassy/src/time/duration.rs rename to embassy-executor/src/time/duration.rs diff --git a/embassy/src/time/instant.rs b/embassy-executor/src/time/instant.rs similarity index 100% rename from embassy/src/time/instant.rs rename to embassy-executor/src/time/instant.rs diff --git a/embassy/src/time/mod.rs b/embassy-executor/src/time/mod.rs similarity index 94% rename from embassy/src/time/mod.rs rename to embassy-executor/src/time/mod.rs index 018e01c8..b787a5cf 100644 --- a/embassy/src/time/mod.rs +++ b/embassy-executor/src/time/mod.rs @@ -26,7 +26,7 @@ //! like `2021-08-24 13:33:21`). //! //! If persistence across reboots is not needed, support can be built on top of -//! `embassy::time` by storing the offset between "seconds elapsed since boot" +//! `embassy_executor::time` by storing the offset between "seconds elapsed since boot" //! and "seconds since unix epoch". //! //! # Time driver @@ -35,7 +35,7 @@ //! Only one driver can be active in a program. //! //! All methods and structs transparently call into the active driver. This makes it -//! possible for libraries to use `embassy::time` in a driver-agnostic way without +//! possible for libraries to use `embassy_executor::time` in a driver-agnostic way without //! requiring generic parameters. //! //! For more details, check the [`driver`] module. diff --git a/embassy/src/time/timer.rs b/embassy-executor/src/time/timer.rs similarity index 92% rename from embassy/src/time/timer.rs rename to embassy-executor/src/time/timer.rs index 2194a4b1..b9cdb1be 100644 --- a/embassy/src/time/timer.rs +++ b/embassy-executor/src/time/timer.rs @@ -2,8 +2,8 @@ use core::future::Future; use core::pin::Pin; use core::task::{Context, Poll}; -use futures::future::{select, Either}; -use futures::{pin_mut, Stream}; +use futures_util::future::{select, Either}; +use futures_util::{pin_mut, Stream}; use crate::executor::raw; use crate::time::{Duration, Instant}; @@ -49,9 +49,9 @@ impl Timer { /// # #![feature(type_alias_impl_trait)] /// # /// # fn foo() {} - /// use embassy::time::{Duration, Timer}; + /// use embassy_executor::time::{Duration, Timer}; /// - /// #[embassy::task] + /// #[embassy_executor::task] /// async fn demo_sleep_seconds() { /// // suspend this task for one second. /// Timer::after(Duration::from_secs(1)).await; @@ -88,10 +88,10 @@ impl Future for Timer { /// ``` no_run /// # #![feature(type_alias_impl_trait)] /// # -/// use embassy::time::{Duration, Timer}; +/// use embassy_executor::time::{Duration, Timer}; /// # fn foo() {} /// -/// #[embassy::task] +/// #[embassy_executor::task] /// async fn ticker_example_0() { /// loop { /// foo(); @@ -108,11 +108,11 @@ impl Future for Timer { /// ``` no_run /// # #![feature(type_alias_impl_trait)] /// # -/// use embassy::time::{Duration, Ticker}; +/// use embassy_executor::time::{Duration, Ticker}; /// use futures::StreamExt; /// # fn foo(){} /// -/// #[embassy::task] +/// #[embassy_executor::task] /// async fn ticker_example_1() { /// let mut ticker = Ticker::every(Duration::from_secs(1)); /// loop { diff --git a/embassy-hal-common/Cargo.toml b/embassy-hal-common/Cargo.toml index f7ebcc21..4a6a6100 100644 --- a/embassy-hal-common/Cargo.toml +++ b/embassy-hal-common/Cargo.toml @@ -6,9 +6,8 @@ edition = "2021" [features] [dependencies] -embassy = { version = "0.1.0", path = "../embassy" } - defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } -cortex-m = "0.7.3" + +embassy-util = { version = "0.1.0", path = "../embassy-util" } num-traits = { version = "0.2.14", default-features = false } diff --git a/embassy-hal-common/src/lib.rs b/embassy-hal-common/src/lib.rs index d3d9e0a8..5d2649d0 100644 --- a/embassy-hal-common/src/lib.rs +++ b/embassy-hal-common/src/lib.rs @@ -10,13 +10,3 @@ mod peripheral; pub mod ratio; pub mod ring_buffer; pub use peripheral::{Peripheral, PeripheralRef}; - -/// Low power blocking wait loop using WFE/SEV. -pub fn low_power_wait_until(mut condition: impl FnMut() -> bool) { - while !condition() { - // WFE might "eat" an event that would have otherwise woken the executor. - cortex_m::asm::wfe(); - } - // Retrigger an event to be transparent to the executor. - cortex_m::asm::sev(); -} diff --git a/embassy-lora/Cargo.toml b/embassy-lora/Cargo.toml index 9b6b2c65..6c1b01e6 100644 --- a/embassy-lora/Cargo.toml +++ b/embassy-lora/Cargo.toml @@ -8,8 +8,8 @@ src_base = "https://github.com/embassy-rs/embassy/blob/embassy-lora-v$VERSION/em src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-lora/src/" features = ["time", "defmt"] flavors = [ - { name = "sx127x", target = "thumbv7em-none-eabihf", features = ["sx127x", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy/time-tick-32768hz"] }, - { name = "stm32wl", target = "thumbv7em-none-eabihf", features = ["stm32wl", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy/time-tick-32768hz"] }, + { name = "sx127x", target = "thumbv7em-none-eabihf", features = ["sx127x", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-executor/time-tick-32768hz"] }, + { name = "stm32wl", target = "thumbv7em-none-eabihf", features = ["stm32wl", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-executor/time-tick-32768hz"] }, ] [lib] @@ -24,7 +24,8 @@ time = [] defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } -embassy = { version = "0.1.0", path = "../embassy", default-features = false } +embassy-executor = { version = "0.1.0", path = "../embassy-executor" } +embassy-util = { version = "0.1.0", path = "../embassy-util" } embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true } embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } embedded-hal-async = { version = "0.1.0-alpha.1" } diff --git a/embassy-lora/src/lib.rs b/embassy-lora/src/lib.rs index b2da2209..29ea4586 100644 --- a/embassy-lora/src/lib.rs +++ b/embassy-lora/src/lib.rs @@ -18,6 +18,6 @@ pub struct LoraTimer; impl lorawan_device::async_device::radio::Timer for LoraTimer { type DelayFuture<'m> = impl core::future::Future + 'm; fn delay_ms<'m>(&'m mut self, millis: u64) -> Self::DelayFuture<'m> { - embassy::time::Timer::after(embassy::time::Duration::from_millis(millis)) + embassy_executor::time::Timer::after(embassy_executor::time::Duration::from_millis(millis)) } } diff --git a/embassy-lora/src/stm32wl/mod.rs b/embassy-lora/src/stm32wl/mod.rs index b0d101b7..4a4c5cfb 100644 --- a/embassy-lora/src/stm32wl/mod.rs +++ b/embassy-lora/src/stm32wl/mod.rs @@ -2,7 +2,6 @@ use core::future::Future; use core::mem::MaybeUninit; -use embassy::channel::signal::Signal; use embassy_hal_common::{into_ref, PeripheralRef}; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{AnyPin, Output}; @@ -13,6 +12,7 @@ use embassy_stm32::subghz::{ Status, SubGhz, TcxoMode, TcxoTrim, Timeout, TxParams, }; use embassy_stm32::Peripheral; +use embassy_util::channel::signal::Signal; use lorawan_device::async_device::radio::{Bandwidth, PhyRxTx, RfConfig, RxQuality, SpreadingFactor, TxConfig}; use lorawan_device::async_device::Timings; diff --git a/embassy-lora/src/sx127x/sx127x_lora/mod.rs b/embassy-lora/src/sx127x/sx127x_lora/mod.rs index 8b937ec2..b3636d09 100644 --- a/embassy-lora/src/sx127x/sx127x_lora/mod.rs +++ b/embassy-lora/src/sx127x/sx127x_lora/mod.rs @@ -6,7 +6,7 @@ #![allow(dead_code)] use bit_field::BitField; -use embassy::time::{Duration, Timer}; +use embassy_executor::time::{Duration, Timer}; use embedded_hal::digital::v2::OutputPin; use embedded_hal_async::spi::SpiBus; diff --git a/embassy-macros/src/macros/cortex_m_interrupt_take.rs b/embassy-macros/src/macros/cortex_m_interrupt_take.rs index 29dca12f..133eb5c2 100644 --- a/embassy-macros/src/macros/cortex_m_interrupt_take.rs +++ b/embassy-macros/src/macros/cortex_m_interrupt_take.rs @@ -16,15 +16,15 @@ pub fn run(name: syn::Ident) -> Result { static HANDLER: interrupt::Handler; } - let func = HANDLER.func.load(::embassy::export::atomic::Ordering::Relaxed); - let ctx = HANDLER.ctx.load(::embassy::export::atomic::Ordering::Relaxed); + let func = HANDLER.func.load(::embassy_executor::export::atomic::Ordering::Relaxed); + let ctx = HANDLER.ctx.load(::embassy_executor::export::atomic::Ordering::Relaxed); let func: fn(*mut ()) = ::core::mem::transmute(func); func(ctx) } - static TAKEN: ::embassy::export::atomic::AtomicBool = ::embassy::export::atomic::AtomicBool::new(false); + static TAKEN: ::embassy_executor::export::atomic::AtomicBool = ::embassy_executor::export::atomic::AtomicBool::new(false); - if TAKEN.compare_exchange(false, true, ::embassy::export::atomic::Ordering::AcqRel, ::embassy::export::atomic::Ordering::Acquire).is_err() { + if TAKEN.compare_exchange(false, true, ::embassy_executor::export::atomic::Ordering::AcqRel, ::embassy_executor::export::atomic::Ordering::Acquire).is_err() { core::panic!("IRQ Already taken"); } diff --git a/embassy-macros/src/macros/main.rs b/embassy-macros/src/macros/main.rs index 5638276b..a8c8bb0d 100644 --- a/embassy-macros/src/macros/main.rs +++ b/embassy-macros/src/macros/main.rs @@ -49,14 +49,14 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result Result<(), wasm_bindgen::JsValue> { - static EXECUTOR: #embassy_path::util::Forever<#embassy_path::executor::Executor> = #embassy_path::util::Forever::new(); + static EXECUTOR: ::embassy_util::Forever<#embassy_path::executor::Executor> = ::embassy_util::Forever::new(); let executor = EXECUTOR.put(#embassy_path::executor::Executor::new()); executor.start(|spawner| { diff --git a/embassy-macros/src/macros/task.rs b/embassy-macros/src/macros/task.rs index 53c9af54..57087c81 100644 --- a/embassy-macros/src/macros/task.rs +++ b/embassy-macros/src/macros/task.rs @@ -16,7 +16,7 @@ struct Args { pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result { let args = Args::from_list(&args).map_err(|e| e.write_errors())?; - let embassy_prefix = args.embassy_prefix.append("embassy"); + let embassy_prefix = args.embassy_prefix.append("embassy_executor"); let embassy_path = embassy_prefix.path(); let pool_size: usize = args.pool_size.unwrap_or(1); diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index 70acc7e4..64cb5bd8 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-net-v$VERSION/embassy-net/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-net/src/" -features = [ "pool-4", "defmt", "tcp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "embassy/time", "embassy/time-tick-1mhz"] +features = [ "pool-4", "defmt", "tcp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "embassy-executor/time", "embassy-executor/time-tick-1mhz"] flavors = [ { name = "default", target = "thumbv7em-none-eabihf" }, ] @@ -37,7 +37,8 @@ pool-128 = [] defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } -embassy = { version = "0.1.0", path = "../embassy" } +embassy-executor = { version = "0.1.0", path = "../embassy-executor" } +embassy-util = { version = "0.1.0", path = "../embassy-util" } embedded-io = { version = "0.3.0", features = [ "async" ] } managed = { version = "0.8.0", default-features = false, features = [ "map" ] } diff --git a/embassy-net/src/stack.rs b/embassy-net/src/stack.rs index f3b1ff9d..06bb732f 100644 --- a/embassy-net/src/stack.rs +++ b/embassy-net/src/stack.rs @@ -2,8 +2,8 @@ use core::cell::UnsafeCell; use core::future::Future; use core::task::{Context, Poll}; -use embassy::time::{Instant, Timer}; -use embassy::waitqueue::WakerRegistration; +use embassy_executor::time::{Instant, Timer}; +use embassy_util::waitqueue::WakerRegistration; use futures::future::poll_fn; use futures::pin_mut; use heapless::Vec; diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index b2b6db1c..75780d41 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -16,12 +16,12 @@ flavors = [ [features] -time = ["embassy/time"] +time = ["embassy-executor/time"] -defmt = ["dep:defmt", "embassy/defmt", "embassy-usb?/defmt", "embedded-io?/defmt", "embassy-embedded-hal/defmt"] +defmt = ["dep:defmt", "embassy-executor/defmt", "embassy-util/defmt", "embassy-usb?/defmt", "embedded-io?/defmt", "embassy-embedded-hal/defmt"] # Enable nightly-only features -nightly = ["embassy/nightly", "embedded-hal-1", "embedded-hal-async", "embassy-usb", "embedded-storage-async", "dep:embedded-io", "embassy-embedded-hal/nightly"] +nightly = ["embedded-hal-1", "embedded-hal-async", "embassy-usb", "embedded-storage-async", "dep:embedded-io", "embassy-embedded-hal/nightly"] # Reexport the PAC for the currently enabled chip at `embassy_nrf::pac`. # This is unstable because semver-minor (non-breaking) releases of embassy-nrf may major-bump (breaking) the PAC version. @@ -57,14 +57,15 @@ _nrf5340-net = ["_nrf5340", "nrf5340-net-pac"] _nrf5340 = ["_gpio-p1", "_dppi"] _nrf9160 = ["nrf9160-pac", "_dppi"] -_time-driver = ["embassy/time-tick-32768hz", "time"] +_time-driver = ["embassy-executor/time-tick-32768hz", "time"] _ppi = [] _dppi = [] _gpio-p1 = [] [dependencies] -embassy = { version = "0.1.0", path = "../embassy" } +embassy-executor = { version = "0.1.0", path = "../embassy-executor", optional = true } +embassy-util = { version = "0.1.0", path = "../embassy-util" } embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]} embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["nrf"]} embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index 89c1ba90..21ff1d73 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs @@ -18,10 +18,10 @@ use core::future::Future; use core::sync::atomic::{compiler_fence, Ordering}; use core::task::Poll; -use embassy::waitqueue::WakerRegistration; use embassy_cortex_m::peripheral::{PeripheralMutex, PeripheralState, StateStorage}; use embassy_hal_common::ring_buffer::RingBuffer; -use embassy_hal_common::{into_ref, low_power_wait_until, PeripheralRef}; +use embassy_hal_common::{into_ref, PeripheralRef}; +use embassy_util::waitqueue::WakerRegistration; use futures::future::poll_fn; // Re-export SVD variants to allow user to directly set values pub use pac::uarte0::{baudrate::BAUDRATE_A as Baudrate, config::PARITY_A as Parity}; @@ -450,3 +450,13 @@ impl<'a, U: UarteInstance, T: TimerInstance> PeripheralState for StateInner<'a, trace!("irq: end"); } } + +/// Low power blocking wait loop using WFE/SEV. +fn low_power_wait_until(mut condition: impl FnMut() -> bool) { + while !condition() { + // WFE might "eat" an event that would have otherwise woken the executor. + cortex_m::asm::wfe(); + } + // Retrigger an event to be transparent to the executor. + cortex_m::asm::sev(); +} diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index cef80ae0..cf49b0db 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs @@ -2,8 +2,8 @@ use core::convert::Infallible; use core::future::Future; use core::task::{Context, Poll}; -use embassy::waitqueue::AtomicWaker; use embassy_hal_common::{impl_peripheral, Peripheral, PeripheralRef}; +use embassy_util::waitqueue::AtomicWaker; use futures::future::poll_fn; use crate::gpio::sealed::Pin as _; diff --git a/embassy-nrf/src/qdec.rs b/embassy-nrf/src/qdec.rs index f6daec25..83f2916b 100644 --- a/embassy-nrf/src/qdec.rs +++ b/embassy-nrf/src/qdec.rs @@ -2,8 +2,8 @@ use core::task::Poll; -use embassy::waitqueue::AtomicWaker; use embassy_hal_common::{into_ref, PeripheralRef}; +use embassy_util::waitqueue::AtomicWaker; use futures::future::poll_fn; use crate::gpio::sealed::Pin as _; diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs index 67634b5b..cedf88de 100644 --- a/embassy-nrf/src/qspi.rs +++ b/embassy-nrf/src/qspi.rs @@ -512,7 +512,7 @@ cfg_if::cfg_if! { } pub(crate) mod sealed { - use embassy::waitqueue::AtomicWaker; + use embassy_util::waitqueue::AtomicWaker; use super::*; diff --git a/embassy-nrf/src/rng.rs b/embassy-nrf/src/rng.rs index 9bebd6fa..7aad561b 100644 --- a/embassy-nrf/src/rng.rs +++ b/embassy-nrf/src/rng.rs @@ -2,9 +2,9 @@ use core::ptr; use core::sync::atomic::{AtomicPtr, Ordering}; use core::task::Poll; -use embassy::waitqueue::AtomicWaker; use embassy_hal_common::drop::OnDrop; use embassy_hal_common::{into_ref, PeripheralRef}; +use embassy_util::waitqueue::AtomicWaker; use futures::future::poll_fn; use crate::interrupt::InterruptExt; diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index 6ddc70e5..f2ef46d8 100644 --- a/embassy-nrf/src/saadc.rs +++ b/embassy-nrf/src/saadc.rs @@ -3,8 +3,8 @@ use core::sync::atomic::{compiler_fence, Ordering}; use core::task::Poll; -use embassy::waitqueue::AtomicWaker; use embassy_hal_common::{impl_peripheral, into_ref, PeripheralRef}; +use embassy_util::waitqueue::AtomicWaker; use futures::future::poll_fn; use pac::{saadc, SAADC}; use saadc::ch::config::{GAIN_A, REFSEL_A, RESP_A, TACQ_A}; diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index a512b481..57c0c14c 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs @@ -363,7 +363,7 @@ impl<'d, T: Instance> Drop for Spim<'d, T> { } pub(crate) mod sealed { - use embassy::waitqueue::AtomicWaker; + use embassy_util::waitqueue::AtomicWaker; use super::*; diff --git a/embassy-nrf/src/temp.rs b/embassy-nrf/src/temp.rs index a3b25ce0..1491e426 100644 --- a/embassy-nrf/src/temp.rs +++ b/embassy-nrf/src/temp.rs @@ -2,9 +2,9 @@ use core::task::Poll; -use embassy::waitqueue::AtomicWaker; use embassy_hal_common::drop::OnDrop; use embassy_hal_common::{into_ref, PeripheralRef}; +use embassy_util::waitqueue::AtomicWaker; use fixed::types::I30F2; use futures::future::poll_fn; diff --git a/embassy-nrf/src/time_driver.rs b/embassy-nrf/src/time_driver.rs index f7b3345b..05fa0aea 100644 --- a/embassy-nrf/src/time_driver.rs +++ b/embassy-nrf/src/time_driver.rs @@ -3,9 +3,9 @@ use core::sync::atomic::{compiler_fence, AtomicU32, AtomicU8, Ordering}; use core::{mem, ptr}; use critical_section::CriticalSection; -use embassy::blocking_mutex::raw::CriticalSectionRawMutex; -use embassy::blocking_mutex::CriticalSectionMutex as Mutex; -use embassy::time::driver::{AlarmHandle, Driver}; +use embassy_executor::time::driver::{AlarmHandle, Driver}; +use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex; +use embassy_util::blocking_mutex::CriticalSectionMutex as Mutex; use crate::interrupt::{Interrupt, InterruptExt}; use crate::{interrupt, pac}; @@ -119,7 +119,7 @@ struct RtcDriver { } const ALARM_STATE_NEW: AlarmState = AlarmState::new(); -embassy::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver { +embassy_executor::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver { period: AtomicU32::new(0), alarm_count: AtomicU8::new(0), alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [ALARM_STATE_NEW; ALARM_COUNT]), diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs index 8deecdc0..b3b613db 100644 --- a/embassy-nrf/src/timer.rs +++ b/embassy-nrf/src/timer.rs @@ -3,9 +3,9 @@ use core::marker::PhantomData; use core::task::Poll; -use embassy::waitqueue::AtomicWaker; use embassy_hal_common::drop::OnDrop; use embassy_hal_common::{into_ref, PeripheralRef}; +use embassy_util::waitqueue::AtomicWaker; use futures::future::poll_fn; use crate::interrupt::{Interrupt, InterruptExt}; @@ -40,8 +40,8 @@ macro_rules! impl_timer { fn regs() -> &'static pac::timer0::RegisterBlock { unsafe { &*(pac::$pac_type::ptr() as *const pac::timer0::RegisterBlock) } } - fn waker(n: usize) -> &'static ::embassy::waitqueue::AtomicWaker { - use ::embassy::waitqueue::AtomicWaker; + fn waker(n: usize) -> &'static ::embassy_util::waitqueue::AtomicWaker { + use ::embassy_util::waitqueue::AtomicWaker; const NEW_AW: AtomicWaker = AtomicWaker::new(); static WAKERS: [AtomicWaker; $ccs] = [NEW_AW; $ccs]; &WAKERS[n] diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index 6d6eb84e..494abe0c 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs @@ -11,11 +11,11 @@ use core::sync::atomic::compiler_fence; use core::sync::atomic::Ordering::SeqCst; use core::task::Poll; -#[cfg(feature = "time")] -use embassy::time::{Duration, Instant}; -use embassy::waitqueue::AtomicWaker; use embassy_embedded_hal::SetConfig; +#[cfg(feature = "time")] +use embassy_executor::time::{Duration, Instant}; use embassy_hal_common::{into_ref, PeripheralRef}; +use embassy_util::waitqueue::AtomicWaker; use futures::future::poll_fn; use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 792b8ecc..0d24cf65 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs @@ -932,7 +932,7 @@ impl<'d, U: Instance, T: TimerInstance> UarteRxWithIdle<'d, U, T> { pub(crate) mod sealed { use core::sync::atomic::AtomicU8; - use embassy::waitqueue::AtomicWaker; + use embassy_util::waitqueue::AtomicWaker; use super::*; diff --git a/embassy-nrf/src/usb.rs b/embassy-nrf/src/usb.rs index 37849285..ee99a9a6 100644 --- a/embassy-nrf/src/usb.rs +++ b/embassy-nrf/src/usb.rs @@ -6,11 +6,11 @@ use core::sync::atomic::{compiler_fence, AtomicBool, AtomicU32, Ordering}; use core::task::Poll; use cortex_m::peripheral::NVIC; -use embassy::waitqueue::AtomicWaker; use embassy_hal_common::{into_ref, PeripheralRef}; pub use embassy_usb; use embassy_usb::driver::{self, EndpointError, Event, Unsupported}; use embassy_usb::types::{EndpointAddress, EndpointInfo, EndpointType, UsbDirection}; +use embassy_util::waitqueue::AtomicWaker; use futures::future::poll_fn; use futures::Future; use pac::usbd::RegisterBlock; diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index 6529e1a3..303617ff 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -20,14 +20,15 @@ flavors = [ unstable-pac = [] # Enable nightly-only features -nightly = ["embassy/nightly", "embedded-hal-1", "embedded-hal-async", "embassy-embedded-hal/nightly"] +nightly = ["embassy-executor/nightly", "embedded-hal-1", "embedded-hal-async", "embassy-embedded-hal/nightly"] # Implement embedded-hal 1.0 alpha traits. # Implement embedded-hal-async traits if `nightly` is set as well. unstable-traits = ["embedded-hal-1"] [dependencies] -embassy = { version = "0.1.0", path = "../embassy", features = [ "time-tick-1mhz" ] } +embassy-util = { version = "0.1.0", path = "../embassy-util" } +embassy-executor = { version = "0.1.0", path = "../embassy-executor", features = [ "time-tick-1mhz" ] } embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]} embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index 5db1a690..9779f137 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs @@ -3,9 +3,9 @@ use core::future::Future; use core::pin::Pin as FuturePin; use core::task::{Context, Poll}; -use embassy::waitqueue::AtomicWaker; use embassy_cortex_m::interrupt::{Interrupt, InterruptExt}; use embassy_hal_common::{impl_peripheral, into_ref, PeripheralRef}; +use embassy_util::waitqueue::AtomicWaker; use crate::pac::common::{Reg, RW}; use crate::pac::SIO; diff --git a/embassy-rp/src/timer.rs b/embassy-rp/src/timer.rs index 6c4c258b..142fd410 100644 --- a/embassy-rp/src/timer.rs +++ b/embassy-rp/src/timer.rs @@ -2,9 +2,9 @@ use core::cell::Cell; use atomic_polyfill::{AtomicU8, Ordering}; use critical_section::CriticalSection; -use embassy::blocking_mutex::raw::CriticalSectionRawMutex; -use embassy::blocking_mutex::Mutex; -use embassy::time::driver::{AlarmHandle, Driver}; +use embassy_executor::time::driver::{AlarmHandle, Driver}; +use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex; +use embassy_util::blocking_mutex::Mutex; use crate::interrupt::{Interrupt, InterruptExt}; use crate::{interrupt, pac}; @@ -26,7 +26,7 @@ struct TimerDriver { next_alarm: AtomicU8, } -embassy::time_driver_impl!(static DRIVER: TimerDriver = TimerDriver{ +embassy_executor::time_driver_impl!(static DRIVER: TimerDriver = TimerDriver{ alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [DUMMY_ALARM; ALARM_COUNT]), next_alarm: AtomicU8::new(0), }); diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index e9c3fdf4..ff228cc8 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -10,7 +10,7 @@ src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-stm32 # TODO: sdmmc # TODO: net # TODO: subghz -features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "embassy/time-tick-32768hz"] +features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "embassy-executor/time-tick-32768hz"] flavors = [ { regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" }, { regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" }, @@ -31,7 +31,8 @@ flavors = [ ] [dependencies] -embassy = { version = "0.1.0", path = "../embassy" } +embassy-util = { version = "0.1.0", path = "../embassy-util" } +embassy-executor = { version = "0.1.0", path = "../embassy-executor" } embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-4"]} embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["stm32"] } embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } @@ -72,7 +73,7 @@ quote = "1.0.15" stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", default-features = false, features = ["metadata"]} [features] -defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy/defmt", "embassy-embedded-hal/defmt", "embedded-io?/defmt", "embassy-usb?/defmt"] +defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy-util/defmt", "embassy-executor/defmt", "embassy-embedded-hal/defmt", "embedded-io?/defmt", "embassy-usb?/defmt"] sdmmc-rs = ["embedded-sdmmc"] net = ["embassy-net" ] memory-x = ["stm32-metapac/memory-x"] @@ -81,7 +82,7 @@ exti = [] # Features starting with `_` are for internal use only. They're not intended # to be enabled by other crates, and are not covered by semver guarantees. -_time-driver = ["embassy/time"] +_time-driver = ["embassy-executor/time"] time-driver-any = ["_time-driver"] time-driver-tim2 = ["_time-driver"] time-driver-tim3 = ["_time-driver"] @@ -91,7 +92,7 @@ time-driver-tim12 = ["_time-driver"] time-driver-tim15 = ["_time-driver"] # Enable nightly-only features -nightly = ["embassy/nightly", "embedded-hal-1", "embedded-hal-async", "embedded-storage-async", "dep:embedded-io", "dep:embassy-usb", "embassy-embedded-hal/nightly"] +nightly = ["embassy-executor/nightly", "embedded-hal-1", "embedded-hal-async", "embedded-storage-async", "dep:embedded-io", "dep:embassy-usb", "embassy-embedded-hal/nightly"] # Reexport stm32-metapac at `embassy_stm32::pac`. # This is unstable because semver-minor (non-breaking) releases of embassy-stm32 may major-bump (breaking) the stm32-metapac version. diff --git a/embassy-stm32/src/dcmi.rs b/embassy-stm32/src/dcmi.rs index e2822542..bbb9a12c 100644 --- a/embassy-stm32/src/dcmi.rs +++ b/embassy-stm32/src/dcmi.rs @@ -1,7 +1,7 @@ use core::task::Poll; -use embassy::waitqueue::AtomicWaker; use embassy_hal_common::{into_ref, PeripheralRef}; +use embassy_util::waitqueue::AtomicWaker; use futures::future::poll_fn; use crate::gpio::sealed::AFType; diff --git a/embassy-stm32/src/dma/bdma.rs b/embassy-stm32/src/dma/bdma.rs index c87f3ac4..bd2cd5b5 100644 --- a/embassy-stm32/src/dma/bdma.rs +++ b/embassy-stm32/src/dma/bdma.rs @@ -3,7 +3,7 @@ use core::sync::atomic::{fence, Ordering}; use core::task::Waker; -use embassy::waitqueue::AtomicWaker; +use embassy_util::waitqueue::AtomicWaker; use super::{TransferOptions, Word, WordSize}; use crate::_generated::BDMA_CHANNEL_COUNT; diff --git a/embassy-stm32/src/dma/dma.rs b/embassy-stm32/src/dma/dma.rs index e8e589de..0c66005c 100644 --- a/embassy-stm32/src/dma/dma.rs +++ b/embassy-stm32/src/dma/dma.rs @@ -1,7 +1,7 @@ use core::sync::atomic::{fence, Ordering}; use core::task::Waker; -use embassy::waitqueue::AtomicWaker; +use embassy_util::waitqueue::AtomicWaker; use super::{Burst, FlowControl, Request, TransferOptions, Word, WordSize}; use crate::_generated::DMA_CHANNEL_COUNT; diff --git a/embassy-stm32/src/dma/gpdma.rs b/embassy-stm32/src/dma/gpdma.rs index 8e901d72..1aea6c65 100644 --- a/embassy-stm32/src/dma/gpdma.rs +++ b/embassy-stm32/src/dma/gpdma.rs @@ -1,7 +1,7 @@ use core::sync::atomic::{fence, Ordering}; use core::task::Waker; -use embassy::waitqueue::AtomicWaker; +use embassy_util::waitqueue::AtomicWaker; use super::{Request, TransferOptions, Word, WordSize}; use crate::_generated::GPDMA_CHANNEL_COUNT; diff --git a/embassy-stm32/src/eth/v1/mod.rs b/embassy-stm32/src/eth/v1/mod.rs index 5e31c32b..37593914 100644 --- a/embassy-stm32/src/eth/v1/mod.rs +++ b/embassy-stm32/src/eth/v1/mod.rs @@ -4,10 +4,10 @@ use core::marker::PhantomData; use core::sync::atomic::{fence, Ordering}; use core::task::Waker; -use embassy::waitqueue::AtomicWaker; use embassy_cortex_m::peripheral::{PeripheralMutex, PeripheralState, StateStorage}; use embassy_hal_common::{into_ref, PeripheralRef}; use embassy_net::{Device, DeviceCapabilities, LinkState, PacketBuf, MTU}; +use embassy_util::waitqueue::AtomicWaker; use crate::gpio::sealed::{AFType, Pin as __GpioPin}; use crate::gpio::{AnyPin, Speed}; diff --git a/embassy-stm32/src/eth/v2/mod.rs b/embassy-stm32/src/eth/v2/mod.rs index 2b4a9367..1bc1fb72 100644 --- a/embassy-stm32/src/eth/v2/mod.rs +++ b/embassy-stm32/src/eth/v2/mod.rs @@ -2,10 +2,10 @@ use core::marker::PhantomData; use core::sync::atomic::{fence, Ordering}; use core::task::Waker; -use embassy::waitqueue::AtomicWaker; use embassy_cortex_m::peripheral::{PeripheralMutex, PeripheralState, StateStorage}; use embassy_hal_common::{into_ref, PeripheralRef}; use embassy_net::{Device, DeviceCapabilities, LinkState, PacketBuf, MTU}; +use embassy_util::waitqueue::AtomicWaker; use crate::gpio::sealed::{AFType, Pin as _}; use crate::gpio::{AnyPin, Speed}; diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index 3b8d9390..ecb180bb 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs @@ -3,8 +3,8 @@ use core::marker::PhantomData; use core::pin::Pin; use core::task::{Context, Poll}; -use embassy::waitqueue::AtomicWaker; use embassy_hal_common::impl_peripheral; +use embassy_util::waitqueue::AtomicWaker; use crate::gpio::{AnyPin, Input, Pin as GpioPin}; use crate::pac::exti::regs::Lines; diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs index dec92cc8..f8067e8b 100644 --- a/embassy-stm32/src/i2c/v2.rs +++ b/embassy-stm32/src/i2c/v2.rs @@ -2,10 +2,10 @@ use core::cmp; use core::task::Poll; use atomic_polyfill::{AtomicUsize, Ordering}; -use embassy::waitqueue::AtomicWaker; use embassy_embedded_hal::SetConfig; use embassy_hal_common::drop::OnDrop; use embassy_hal_common::{into_ref, PeripheralRef}; +use embassy_util::waitqueue::AtomicWaker; use futures::future::poll_fn; use crate::dma::NoDma; diff --git a/embassy-stm32/src/rng.rs b/embassy-stm32/src/rng.rs index 2b0ee713..81e28f35 100644 --- a/embassy-stm32/src/rng.rs +++ b/embassy-stm32/src/rng.rs @@ -2,8 +2,8 @@ use core::task::Poll; -use embassy::waitqueue::AtomicWaker; use embassy_hal_common::{into_ref, PeripheralRef}; +use embassy_util::waitqueue::AtomicWaker; use futures::future::poll_fn; use rand_core::{CryptoRng, RngCore}; diff --git a/embassy-stm32/src/sdmmc/mod.rs b/embassy-stm32/src/sdmmc/mod.rs index b9dff8fa..1de4b2aa 100644 --- a/embassy-stm32/src/sdmmc/mod.rs +++ b/embassy-stm32/src/sdmmc/mod.rs @@ -3,9 +3,9 @@ use core::default::Default; use core::task::Poll; -use embassy::waitqueue::AtomicWaker; use embassy_hal_common::drop::OnDrop; use embassy_hal_common::{into_ref, PeripheralRef}; +use embassy_util::waitqueue::AtomicWaker; use futures::future::poll_fn; use sdio_host::{BusWidth, CardCapacity, CardStatus, CurrentState, SDStatus, CID, CSD, OCR, SCR}; @@ -1507,8 +1507,8 @@ foreach_peripheral!( INNER } - fn state() -> &'static ::embassy::waitqueue::AtomicWaker { - static WAKER: ::embassy::waitqueue::AtomicWaker = ::embassy::waitqueue::AtomicWaker::new(); + fn state() -> &'static ::embassy_util::waitqueue::AtomicWaker { + static WAKER: ::embassy_util::waitqueue::AtomicWaker = ::embassy_util::waitqueue::AtomicWaker::new(); &WAKER } } diff --git a/embassy-stm32/src/subghz/mod.rs b/embassy-stm32/src/subghz/mod.rs index f02fc140..4e53efed 100644 --- a/embassy-stm32/src/subghz/mod.rs +++ b/embassy-stm32/src/subghz/mod.rs @@ -504,7 +504,7 @@ impl<'d> SubGhz<'d, NoDma, NoDma> { /// /// sg.set_standby(StandbyClk::Rc)?; /// unsafe { sg.set_sleep(SleepCfg::default())? }; - /// embassy::time::Timer::after(embassy::time::Duration::from_micros(500)).await; + /// embassy_executor::time::Timer::after(embassy_executor::time::Duration::from_micros(500)).await; /// unsafe { wakeup() }; /// # Ok::<(), embassy_stm32::subghz::Error>(()) /// ``` diff --git a/embassy-stm32/src/subghz/timeout.rs b/embassy-stm32/src/subghz/timeout.rs index 9dbdc637..b8d6ad8f 100644 --- a/embassy-stm32/src/subghz/timeout.rs +++ b/embassy-stm32/src/subghz/timeout.rs @@ -439,9 +439,9 @@ impl From for [u8; 3] { } } -impl From for embassy::time::Duration { +impl From for embassy_executor::time::Duration { fn from(to: Timeout) -> Self { - embassy::time::Duration::from_micros(to.as_micros().into()) + embassy_executor::time::Duration::from_micros(to.as_micros().into()) } } diff --git a/embassy-stm32/src/subghz/tx_params.rs b/embassy-stm32/src/subghz/tx_params.rs index 5194a837..a72c060f 100644 --- a/embassy-stm32/src/subghz/tx_params.rs +++ b/embassy-stm32/src/subghz/tx_params.rs @@ -44,17 +44,17 @@ impl From for core::time::Duration { } } -impl From for embassy::time::Duration { +impl From for embassy_executor::time::Duration { fn from(rt: RampTime) -> Self { match rt { - RampTime::Micros10 => embassy::time::Duration::from_micros(10), - RampTime::Micros20 => embassy::time::Duration::from_micros(20), - RampTime::Micros40 => embassy::time::Duration::from_micros(40), - RampTime::Micros80 => embassy::time::Duration::from_micros(80), - RampTime::Micros200 => embassy::time::Duration::from_micros(200), - RampTime::Micros800 => embassy::time::Duration::from_micros(800), - RampTime::Micros1700 => embassy::time::Duration::from_micros(1700), - RampTime::Micros3400 => embassy::time::Duration::from_micros(3400), + RampTime::Micros10 => embassy_executor::time::Duration::from_micros(10), + RampTime::Micros20 => embassy_executor::time::Duration::from_micros(20), + RampTime::Micros40 => embassy_executor::time::Duration::from_micros(40), + RampTime::Micros80 => embassy_executor::time::Duration::from_micros(80), + RampTime::Micros200 => embassy_executor::time::Duration::from_micros(200), + RampTime::Micros800 => embassy_executor::time::Duration::from_micros(800), + RampTime::Micros1700 => embassy_executor::time::Duration::from_micros(1700), + RampTime::Micros3400 => embassy_executor::time::Duration::from_micros(3400), } } } diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index 38a4adc1..6cea43f1 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs @@ -4,10 +4,10 @@ use core::sync::atomic::{compiler_fence, Ordering}; use core::{mem, ptr}; use atomic_polyfill::{AtomicU32, AtomicU8}; -use embassy::blocking_mutex::raw::CriticalSectionRawMutex; -use embassy::blocking_mutex::Mutex; -use embassy::time::driver::{AlarmHandle, Driver}; -use embassy::time::TICKS_PER_SECOND; +use embassy_executor::time::driver::{AlarmHandle, Driver}; +use embassy_executor::time::TICKS_PER_SECOND; +use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex; +use embassy_util::blocking_mutex::Mutex; use stm32_metapac::timer::regs; use crate::interrupt::{CriticalSection, InterruptExt}; @@ -133,7 +133,7 @@ struct RtcDriver { const ALARM_STATE_NEW: AlarmState = AlarmState::new(); -embassy::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver { +embassy_executor::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver { period: AtomicU32::new(0), alarm_count: AtomicU8::new(0), alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [ALARM_STATE_NEW; ALARM_COUNT]), diff --git a/embassy-stm32/src/usart/buffered.rs b/embassy-stm32/src/usart/buffered.rs index 4e47ef73..0e8d0d68 100644 --- a/embassy-stm32/src/usart/buffered.rs +++ b/embassy-stm32/src/usart/buffered.rs @@ -2,9 +2,9 @@ use core::future::Future; use core::task::Poll; use atomic_polyfill::{compiler_fence, Ordering}; -use embassy::waitqueue::WakerRegistration; use embassy_cortex_m::peripheral::{PeripheralMutex, PeripheralState, StateStorage}; use embassy_hal_common::ring_buffer::RingBuffer; +use embassy_util::waitqueue::WakerRegistration; use futures::future::poll_fn; use super::*; diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index 11ef7595..764b2146 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs @@ -5,11 +5,11 @@ use core::sync::atomic::Ordering; use core::task::Poll; use atomic_polyfill::{AtomicBool, AtomicU8}; -use embassy::time::{block_for, Duration}; -use embassy::waitqueue::AtomicWaker; +use embassy_executor::time::{block_for, Duration}; use embassy_hal_common::into_ref; use embassy_usb::driver::{self, EndpointAllocError, EndpointError, Event, Unsupported}; use embassy_usb::types::{EndpointAddress, EndpointInfo, EndpointType, UsbDirection}; +use embassy_util::waitqueue::AtomicWaker; use futures::future::poll_fn; use futures::Future; use pac::common::{Reg, RW}; diff --git a/embassy-usb-hid/Cargo.toml b/embassy-usb-hid/Cargo.toml index b8185fa5..53b6db3d 100644 --- a/embassy-usb-hid/Cargo.toml +++ b/embassy-usb-hid/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-usb-hid-v$VERSION/embassy-usb-hid/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-usb-hid/src/" -features = ["defmt", "embassy/time-tick-1mhz"] +features = ["defmt", "embassy-executor/time-tick-1mhz"] flavors = [ { name = "default", target = "thumbv7em-none-eabihf" }, ] @@ -16,7 +16,7 @@ default = ["usbd-hid"] usbd-hid = ["dep:usbd-hid", "ssmarshal"] [dependencies] -embassy = { version = "0.1.0", path = "../embassy" } +embassy-util = { version = "0.1.0", path = "../embassy-util" } embassy-usb = { version = "0.1.0", path = "../embassy-usb" } defmt = { version = "0.3", optional = true } diff --git a/embassy-usb-hid/src/lib.rs b/embassy-usb-hid/src/lib.rs index b87f5748..5fee60bb 100644 --- a/embassy-usb-hid/src/lib.rs +++ b/embassy-usb-hid/src/lib.rs @@ -11,7 +11,6 @@ use core::mem::MaybeUninit; use core::ops::Range; use core::sync::atomic::{AtomicUsize, Ordering}; -use embassy::time::Duration; use embassy_usb::control::{ControlHandler, InResponse, OutResponse, Request, RequestType}; use embassy_usb::driver::{Driver, Endpoint, EndpointError, EndpointIn, EndpointOut}; use embassy_usb::Builder; @@ -373,7 +372,7 @@ pub trait RequestHandler { /// If `id` is `None`, get the idle rate for all reports. Returning `None` /// will reject the control request. Any duration at or above 1.024 seconds /// or below 4ms will be returned as an indefinite idle rate. - fn get_idle(&self, id: Option) -> Option { + fn get_idle_ms(&self, id: Option) -> Option { let _ = id; None } @@ -381,9 +380,9 @@ pub trait RequestHandler { /// Set the idle rate for `id` to `dur`. /// /// If `id` is `None`, set the idle rate of all input reports to `dur`. If - /// an indefinite duration is requested, `dur` will be set to `Duration::MAX`. - fn set_idle(&self, id: Option, dur: Duration) { - let _ = (id, dur); + /// an indefinite duration is requested, `dur` will be set to `u32::MAX`. + fn set_idle_ms(&self, id: Option, duration_ms: u32) { + let _ = (id, duration_ms); } } @@ -447,13 +446,9 @@ impl<'d> ControlHandler for Control<'d> { if let Some(handler) = self.request_handler { let id = req.value as u8; let id = (id != 0).then(|| ReportId::In(id)); - let dur = u64::from(req.value >> 8); - let dur = if dur == 0 { - Duration::MAX - } else { - Duration::from_millis(4 * dur) - }; - handler.set_idle(id, dur); + let dur = u32::from(req.value >> 8); + let dur = if dur == 0 { u32::MAX } else { 4 * dur }; + handler.set_idle_ms(id, dur); } OutResponse::Accepted } @@ -495,8 +490,8 @@ impl<'d> ControlHandler for Control<'d> { if let Some(handler) = self.request_handler { let id = req.value as u8; let id = (id != 0).then(|| ReportId::In(id)); - if let Some(dur) = handler.get_idle(id) { - let dur = u8::try_from(dur.as_millis() / 4).unwrap_or(0); + if let Some(dur) = handler.get_idle_ms(id) { + let dur = u8::try_from(dur / 4).unwrap_or(0); buf[0] = dur; InResponse::Accepted(&buf[0..1]) } else { diff --git a/embassy-usb-ncm/Cargo.toml b/embassy-usb-ncm/Cargo.toml index 636a81c2..fa6fa017 100644 --- a/embassy-usb-ncm/Cargo.toml +++ b/embassy-usb-ncm/Cargo.toml @@ -12,7 +12,7 @@ flavors = [ ] [dependencies] -embassy = { version = "0.1.0", path = "../embassy" } +embassy-util = { version = "0.1.0", path = "../embassy-util" } embassy-usb = { version = "0.1.0", path = "../embassy-usb" } defmt = { version = "0.3", optional = true } diff --git a/embassy-usb-serial/Cargo.toml b/embassy-usb-serial/Cargo.toml index 682707af..495dd9fe 100644 --- a/embassy-usb-serial/Cargo.toml +++ b/embassy-usb-serial/Cargo.toml @@ -12,7 +12,7 @@ flavors = [ ] [dependencies] -embassy = { version = "0.1.0", path = "../embassy" } +embassy-util = { version = "0.1.0", path = "../embassy-util" } embassy-usb = { version = "0.1.0", path = "../embassy-usb" } defmt = { version = "0.3", optional = true } diff --git a/embassy-usb-serial/src/lib.rs b/embassy-usb-serial/src/lib.rs index a23d62e6..e561be9d 100644 --- a/embassy-usb-serial/src/lib.rs +++ b/embassy-usb-serial/src/lib.rs @@ -9,11 +9,11 @@ use core::cell::Cell; use core::mem::{self, MaybeUninit}; use core::sync::atomic::{AtomicBool, Ordering}; -use embassy::blocking_mutex::CriticalSectionMutex; use embassy_usb::control::{self, ControlHandler, InResponse, OutResponse, Request}; use embassy_usb::driver::{Driver, Endpoint, EndpointError, EndpointIn, EndpointOut}; use embassy_usb::types::*; use embassy_usb::Builder; +use embassy_util::blocking_mutex::CriticalSectionMutex; /// This should be used as `device_class` when building the `UsbDevice`. pub const USB_CLASS_CDC: u8 = 0x02; diff --git a/embassy-usb/Cargo.toml b/embassy-usb/Cargo.toml index 513dc8c1..98734e98 100644 --- a/embassy-usb/Cargo.toml +++ b/embassy-usb/Cargo.toml @@ -12,7 +12,7 @@ flavors = [ ] [dependencies] -embassy = { version = "0.1.0", path = "../embassy" } +embassy-util = { version = "0.1.0", path = "../embassy-util" } defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } diff --git a/embassy-usb/src/lib.rs b/embassy-usb/src/lib.rs index 82ff4e32..3f6e1347 100644 --- a/embassy-usb/src/lib.rs +++ b/embassy-usb/src/lib.rs @@ -12,7 +12,7 @@ mod descriptor_reader; pub mod driver; pub mod types; -use embassy::util::{select, Either}; +use embassy_util::{select, Either}; use heapless::Vec; pub use self::builder::{Builder, Config}; diff --git a/embassy-util/Cargo.toml b/embassy-util/Cargo.toml new file mode 100644 index 00000000..32b796c0 --- /dev/null +++ b/embassy-util/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "embassy-util" +version = "0.1.0" +edition = "2021" + +[package.metadata.embassy_docs] +src_base = "https://github.com/embassy-rs/embassy/blob/embassy-util-v$VERSION/embassy-util/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-util/src/" +features = ["nightly", "defmt", "unstable-traits", "time", "time-tick-1mhz"] +flavors = [ + { name = "default", target = "x86_64-unknown-linux-gnu" }, +] + +[dependencies] +defmt = { version = "0.3", optional = true } +log = { version = "0.4.14", optional = true } + +futures-util = { version = "0.3.17", default-features = false } +atomic-polyfill = "0.1.5" +critical-section = "0.2.5" +heapless = "0.7.5" +cfg-if = "1.0.0" + +[dev-dependencies] +futures-executor = { version = "0.3.17", features = [ "thread-pool" ] } +futures-test = "0.3.17" +futures-timer = "3.0.2" +futures-util = { version = "0.3.17", features = [ "channel" ] } diff --git a/embassy-util/build.rs b/embassy-util/build.rs new file mode 100644 index 00000000..6fe82b44 --- /dev/null +++ b/embassy-util/build.rs @@ -0,0 +1,29 @@ +use std::env; + +fn main() { + let target = env::var("TARGET").unwrap(); + + if target.starts_with("thumbv6m-") { + println!("cargo:rustc-cfg=cortex_m"); + println!("cargo:rustc-cfg=armv6m"); + } else if target.starts_with("thumbv7m-") { + println!("cargo:rustc-cfg=cortex_m"); + println!("cargo:rustc-cfg=armv7m"); + } else if target.starts_with("thumbv7em-") { + println!("cargo:rustc-cfg=cortex_m"); + println!("cargo:rustc-cfg=armv7m"); + println!("cargo:rustc-cfg=armv7em"); // (not currently used) + } else if target.starts_with("thumbv8m.base") { + println!("cargo:rustc-cfg=cortex_m"); + println!("cargo:rustc-cfg=armv8m"); + println!("cargo:rustc-cfg=armv8m_base"); + } else if target.starts_with("thumbv8m.main") { + println!("cargo:rustc-cfg=cortex_m"); + println!("cargo:rustc-cfg=armv8m"); + println!("cargo:rustc-cfg=armv8m_main"); + } + + if target.ends_with("-eabihf") { + println!("cargo:rustc-cfg=has_fpu"); + } +} diff --git a/embassy/src/blocking_mutex/mod.rs b/embassy-util/src/blocking_mutex/mod.rs similarity index 95% rename from embassy/src/blocking_mutex/mod.rs rename to embassy-util/src/blocking_mutex/mod.rs index c9db89f0..8a4a4c64 100644 --- a/embassy/src/blocking_mutex/mod.rs +++ b/embassy-util/src/blocking_mutex/mod.rs @@ -34,7 +34,6 @@ unsafe impl Sync for Mutex {} impl Mutex { /// Creates a new mutex in an unlocked state ready for use. - #[cfg(feature = "nightly")] #[inline] pub const fn new(val: T) -> Mutex { Mutex { @@ -43,16 +42,6 @@ impl Mutex { } } - /// Creates a new mutex in an unlocked state ready for use. - #[cfg(not(feature = "nightly"))] - #[inline] - pub fn new(val: T) -> Mutex { - Mutex { - raw: R::INIT, - data: UnsafeCell::new(val), - } - } - /// Creates a critical section and grants temporary access to the protected data. pub fn lock(&self, f: impl FnOnce(&T) -> U) -> U { self.raw.lock(|| { diff --git a/embassy/src/blocking_mutex/raw.rs b/embassy-util/src/blocking_mutex/raw.rs similarity index 97% rename from embassy/src/blocking_mutex/raw.rs rename to embassy-util/src/blocking_mutex/raw.rs index 669a23e3..15796f1b 100644 --- a/embassy/src/blocking_mutex/raw.rs +++ b/embassy-util/src/blocking_mutex/raw.rs @@ -141,7 +141,8 @@ mod thread_mode { return Some("main") == std::thread::current().name(); #[cfg(not(feature = "std"))] - return cortex_m::peripheral::SCB::vect_active() == cortex_m::peripheral::scb::VectActive::ThreadMode; + // ICSR.VECTACTIVE == 0 + return unsafe { (0xE000ED04 as *const u32).read_volatile() } & 0x1FF == 0; } } #[cfg(any(cortex_m, feature = "std"))] diff --git a/embassy/src/channel/mod.rs b/embassy-util/src/channel/mod.rs similarity index 100% rename from embassy/src/channel/mod.rs rename to embassy-util/src/channel/mod.rs diff --git a/embassy/src/channel/mpmc.rs b/embassy-util/src/channel/mpmc.rs similarity index 95% rename from embassy/src/channel/mpmc.rs rename to embassy-util/src/channel/mpmc.rs index ca2214bb..535f77e6 100644 --- a/embassy/src/channel/mpmc.rs +++ b/embassy-util/src/channel/mpmc.rs @@ -19,10 +19,10 @@ //! use core::cell::RefCell; +use core::future::Future; use core::pin::Pin; use core::task::{Context, Poll}; -use futures::Future; use heapless::Deque; use crate::blocking_mutex::raw::RawMutex; @@ -373,35 +373,18 @@ where /// Establish a new bounded channel. For example, to create one with a NoopMutex: /// /// ``` - /// use embassy::channel::mpmc::Channel; - /// use embassy::blocking_mutex::raw::NoopRawMutex; + /// use embassy_util::channel::mpmc::Channel; + /// use embassy_util::blocking_mutex::raw::NoopRawMutex; /// /// // Declare a bounded channel of 3 u32s. /// let mut channel = Channel::::new(); /// ``` - #[cfg(feature = "nightly")] pub const fn new() -> Self { Self { inner: Mutex::new(RefCell::new(ChannelState::new())), } } - /// Establish a new bounded channel. For example, to create one with a NoopMutex: - /// - /// ``` - /// use embassy::channel::mpmc::Channel; - /// use embassy::blocking_mutex::raw::NoopRawMutex; - /// - /// // Declare a bounded channel of 3 u32s. - /// let mut channel = Channel::::new(); - /// ``` - #[cfg(not(feature = "nightly"))] - pub fn new() -> Self { - Self { - inner: Mutex::new(RefCell::new(ChannelState::new())), - } - } - fn lock(&self, f: impl FnOnce(&mut ChannelState) -> R) -> R { self.inner.lock(|rc| f(&mut *rc.borrow_mut())) } @@ -485,13 +468,13 @@ where mod tests { use core::time::Duration; - use futures::task::SpawnExt; use futures_executor::ThreadPool; use futures_timer::Delay; + use futures_util::task::SpawnExt; use super::*; use crate::blocking_mutex::raw::{CriticalSectionRawMutex, NoopRawMutex}; - use crate::util::Forever; + use crate::Forever; fn capacity(c: &ChannelState) -> usize { c.queue.capacity() - c.queue.len() diff --git a/embassy/src/channel/pubsub/mod.rs b/embassy-util/src/channel/pubsub/mod.rs similarity index 99% rename from embassy/src/channel/pubsub/mod.rs rename to embassy-util/src/channel/pubsub/mod.rs index 64a72a52..ecc8fbd8 100644 --- a/embassy/src/channel/pubsub/mod.rs +++ b/embassy-util/src/channel/pubsub/mod.rs @@ -33,9 +33,9 @@ pub use subscriber::{DynSubscriber, Subscriber}; /// ## Example /// /// ``` -/// # use embassy::blocking_mutex::raw::NoopRawMutex; -/// # use embassy::channel::pubsub::WaitResult; -/// # use embassy::channel::pubsub::PubSubChannel; +/// # use embassy_util::blocking_mutex::raw::NoopRawMutex; +/// # use embassy_util::channel::pubsub::WaitResult; +/// # use embassy_util::channel::pubsub::PubSubChannel; /// # use futures_executor::block_on; /// # let test = async { /// // Create the channel. This can be static as well diff --git a/embassy/src/channel/pubsub/publisher.rs b/embassy-util/src/channel/pubsub/publisher.rs similarity index 99% rename from embassy/src/channel/pubsub/publisher.rs rename to embassy-util/src/channel/pubsub/publisher.rs index 53b0d43b..705797f6 100644 --- a/embassy/src/channel/pubsub/publisher.rs +++ b/embassy-util/src/channel/pubsub/publisher.rs @@ -1,12 +1,11 @@ //! Implementation of anything directly publisher related +use core::future::Future; use core::marker::PhantomData; use core::ops::{Deref, DerefMut}; use core::pin::Pin; use core::task::{Context, Poll}; -use futures::Future; - use super::{PubSubBehavior, PubSubChannel}; use crate::blocking_mutex::raw::RawMutex; diff --git a/embassy/src/channel/pubsub/subscriber.rs b/embassy-util/src/channel/pubsub/subscriber.rs similarity index 97% rename from embassy/src/channel/pubsub/subscriber.rs rename to embassy-util/src/channel/pubsub/subscriber.rs index 23c4938d..b9a2cbe1 100644 --- a/embassy/src/channel/pubsub/subscriber.rs +++ b/embassy-util/src/channel/pubsub/subscriber.rs @@ -1,12 +1,11 @@ //! Implementation of anything directly subscriber related +use core::future::Future; use core::marker::PhantomData; use core::ops::{Deref, DerefMut}; use core::pin::Pin; use core::task::{Context, Poll}; -use futures::Future; - use super::{PubSubBehavior, PubSubChannel, WaitResult}; use crate::blocking_mutex::raw::RawMutex; @@ -77,7 +76,7 @@ impl<'a, PSB: PubSubBehavior + ?Sized, T: Clone> Unpin for Sub<'a, PSB, T> {} /// Warning: The stream implementation ignores lag results and returns all messages. /// This might miss some messages without you knowing it. -impl<'a, PSB: PubSubBehavior + ?Sized, T: Clone> futures::Stream for Sub<'a, PSB, T> { +impl<'a, PSB: PubSubBehavior + ?Sized, T: Clone> futures_util::Stream for Sub<'a, PSB, T> { type Item = T; fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { diff --git a/embassy/src/channel/signal.rs b/embassy-util/src/channel/signal.rs similarity index 96% rename from embassy/src/channel/signal.rs rename to embassy-util/src/channel/signal.rs index 3f3c482f..a58469c4 100644 --- a/embassy/src/channel/signal.rs +++ b/embassy-util/src/channel/signal.rs @@ -19,7 +19,7 @@ use core::task::{Context, Poll, Waker}; /// Signals are generally declared as `static`s and then borrowed as required. /// /// ``` -/// use embassy::channel::signal::Signal; +/// use embassy_util::channel::signal::Signal; /// /// enum SomeCommand { /// On, @@ -89,7 +89,7 @@ impl Signal { /// Future that completes when this Signal has been signaled. pub fn wait(&self) -> impl Future + '_ { - futures::future::poll_fn(move |cx| self.poll_wait(cx)) + futures_util::future::poll_fn(move |cx| self.poll_wait(cx)) } /// non-blocking method to check whether this signal has been signaled. diff --git a/embassy-util/src/fmt.rs b/embassy-util/src/fmt.rs new file mode 100644 index 00000000..f8bb0a03 --- /dev/null +++ b/embassy-util/src/fmt.rs @@ -0,0 +1,228 @@ +#![macro_use] +#![allow(unused_macros)] + +#[cfg(all(feature = "defmt", feature = "log"))] +compile_error!("You may not enable both `defmt` and `log` features."); + +macro_rules! assert { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::assert!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::assert!($($x)*); + } + }; +} + +macro_rules! assert_eq { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::assert_eq!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::assert_eq!($($x)*); + } + }; +} + +macro_rules! assert_ne { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::assert_ne!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::assert_ne!($($x)*); + } + }; +} + +macro_rules! debug_assert { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::debug_assert!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::debug_assert!($($x)*); + } + }; +} + +macro_rules! debug_assert_eq { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::debug_assert_eq!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::debug_assert_eq!($($x)*); + } + }; +} + +macro_rules! debug_assert_ne { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::debug_assert_ne!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::debug_assert_ne!($($x)*); + } + }; +} + +macro_rules! todo { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::todo!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::todo!($($x)*); + } + }; +} + +macro_rules! unreachable { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::unreachable!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::unreachable!($($x)*); + } + }; +} + +macro_rules! panic { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::panic!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::panic!($($x)*); + } + }; +} + +macro_rules! trace { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::trace!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::trace!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +macro_rules! debug { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::debug!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::debug!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +macro_rules! info { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::info!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::info!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +macro_rules! warn { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::warn!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::warn!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +macro_rules! error { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::error!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::error!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +#[cfg(feature = "defmt")] +macro_rules! unwrap { + ($($x:tt)*) => { + ::defmt::unwrap!($($x)*) + }; +} + +#[cfg(not(feature = "defmt"))] +macro_rules! unwrap { + ($arg:expr) => { + match $crate::fmt::Try::into_result($arg) { + ::core::result::Result::Ok(t) => t, + ::core::result::Result::Err(e) => { + ::core::panic!("unwrap of `{}` failed: {:?}", ::core::stringify!($arg), e); + } + } + }; + ($arg:expr, $($msg:expr),+ $(,)? ) => { + match $crate::fmt::Try::into_result($arg) { + ::core::result::Result::Ok(t) => t, + ::core::result::Result::Err(e) => { + ::core::panic!("unwrap of `{}` failed: {}: {:?}", ::core::stringify!($arg), ::core::format_args!($($msg,)*), e); + } + } + } +} + +#[cfg(feature = "defmt-timestamp-uptime")] +defmt::timestamp! {"{=u64:us}", crate::time::Instant::now().as_micros() } + +#[derive(Debug, Copy, Clone, Eq, PartialEq)] +pub struct NoneError; + +pub trait Try { + type Ok; + type Error; + fn into_result(self) -> Result; +} + +impl Try for Option { + type Ok = T; + type Error = NoneError; + + #[inline] + fn into_result(self) -> Result { + self.ok_or(NoneError) + } +} + +impl Try for Result { + type Ok = T; + type Error = E; + + #[inline] + fn into_result(self) -> Self { + self + } +} diff --git a/embassy/src/util/forever.rs b/embassy-util/src/forever.rs similarity index 99% rename from embassy/src/util/forever.rs rename to embassy-util/src/forever.rs index 3d2af38b..4f369821 100644 --- a/embassy/src/util/forever.rs +++ b/embassy-util/src/forever.rs @@ -12,7 +12,7 @@ use atomic_polyfill::{AtomicBool, Ordering}; /// Note: IF a global mutable variable is desired, use a CriticalSectionMutex or ThreadModeMutex instead. /// /// ``` -/// use embassy::util::Forever; +/// use embassy_util::Forever; /// // Using an integer for the sake of keeping this example self-contained, /// // see https://github.com/embassy-rs/embassy/wiki/Getting-Started for a more "proper" example. /// static SOME_INT: Forever =Forever::new(); diff --git a/embassy-util/src/lib.rs b/embassy-util/src/lib.rs new file mode 100644 index 00000000..07b1633e --- /dev/null +++ b/embassy-util/src/lib.rs @@ -0,0 +1,22 @@ +#![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] +#![cfg_attr(feature = "nightly", feature(generic_associated_types, type_alias_impl_trait))] +#![cfg_attr(all(feature = "nightly", target_arch = "xtensa"), feature(asm_experimental_arch))] +#![allow(clippy::new_without_default)] +#![doc = include_str!("../../README.md")] +#![warn(missing_docs)] + +// This mod MUST go first, so that the others see its macros. +pub(crate) mod fmt; + +pub mod blocking_mutex; +pub mod channel; +pub mod mutex; +pub mod waitqueue; + +mod forever; +mod select; +mod yield_now; + +pub use forever::*; +pub use select::*; +pub use yield_now::*; diff --git a/embassy/src/mutex.rs b/embassy-util/src/mutex.rs similarity index 91% rename from embassy/src/mutex.rs rename to embassy-util/src/mutex.rs index 9cfaaa84..75a6e8dd 100644 --- a/embassy/src/mutex.rs +++ b/embassy-util/src/mutex.rs @@ -5,7 +5,7 @@ use core::cell::{RefCell, UnsafeCell}; use core::ops::{Deref, DerefMut}; use core::task::Poll; -use futures::future::poll_fn; +use futures_util::future::poll_fn; use crate::blocking_mutex::raw::RawMutex; use crate::blocking_mutex::Mutex as BlockingMutex; @@ -54,7 +54,6 @@ where M: RawMutex, { /// Create a new mutex with the given value. - #[cfg(feature = "nightly")] pub const fn new(value: T) -> Self { Self { inner: UnsafeCell::new(value), @@ -64,18 +63,6 @@ where })), } } - - /// Create a new mutex with the given value. - #[cfg(not(feature = "nightly"))] - pub fn new(value: T) -> Self { - Self { - inner: UnsafeCell::new(value), - state: BlockingMutex::new(RefCell::new(State { - locked: false, - waker: WakerRegistration::new(), - })), - } - } } impl Mutex diff --git a/embassy/src/util/select.rs b/embassy-util/src/select.rs similarity index 100% rename from embassy/src/util/select.rs rename to embassy-util/src/select.rs diff --git a/embassy/src/waitqueue/mod.rs b/embassy-util/src/waitqueue/mod.rs similarity index 59% rename from embassy/src/waitqueue/mod.rs rename to embassy-util/src/waitqueue/mod.rs index 5c4e1bc3..6661a6b6 100644 --- a/embassy/src/waitqueue/mod.rs +++ b/embassy-util/src/waitqueue/mod.rs @@ -1,6 +1,5 @@ //! Async low-level wait queues -#[cfg_attr(feature = "executor-agnostic", path = "waker_agnostic.rs")] mod waker; pub use waker::*; diff --git a/embassy/src/waitqueue/multi_waker.rs b/embassy-util/src/waitqueue/multi_waker.rs similarity index 100% rename from embassy/src/waitqueue/multi_waker.rs rename to embassy-util/src/waitqueue/multi_waker.rs diff --git a/embassy/src/waitqueue/waker_agnostic.rs b/embassy-util/src/waitqueue/waker.rs similarity index 100% rename from embassy/src/waitqueue/waker_agnostic.rs rename to embassy-util/src/waitqueue/waker.rs diff --git a/embassy/src/util/yield_now.rs b/embassy-util/src/yield_now.rs similarity index 100% rename from embassy/src/util/yield_now.rs rename to embassy-util/src/yield_now.rs diff --git a/embassy/src/util/mod.rs b/embassy/src/util/mod.rs deleted file mode 100644 index 3ad760cd..00000000 --- a/embassy/src/util/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -//! Misc utilities - -mod forever; -mod select; -mod yield_now; - -pub use forever::*; -pub use select::*; -pub use yield_now::*; diff --git a/embassy/src/waitqueue/waker.rs b/embassy/src/waitqueue/waker.rs deleted file mode 100644 index cdc96507..00000000 --- a/embassy/src/waitqueue/waker.rs +++ /dev/null @@ -1,97 +0,0 @@ -use core::ptr::{self, NonNull}; -use core::task::Waker; - -use atomic_polyfill::{compiler_fence, AtomicPtr, Ordering}; - -use crate::executor::raw::{task_from_waker, wake_task, TaskHeader}; - -/// Utility struct to register and wake a waker. -/// -/// # Safety -/// -/// This type is optimized for (and only works with) embassy tasks. -#[derive(Debug)] -pub struct WakerRegistration { - waker: Option>, -} - -impl WakerRegistration { - /// Create a new `WakerRegistration`. - pub const fn new() -> Self { - Self { waker: None } - } - - /// Register a waker. Overwrites the previous waker, if any. - pub fn register(&mut self, w: &Waker) { - let w = task_from_waker(w); - match self.waker { - // Optimization: If both the old and new Wakers wake the same task, do nothing. - Some(w2) if w == w2 => {} - Some(w2) => { - // We had a waker registered for another task. Wake it, so the other task can - // reregister itself if it's still interested. - // - // If two tasks are waiting on the same thing concurrently, this will cause them - // to wake each other in a loop fighting over this WakerRegistration. This wastes - // CPU but things will still work. - // - // If the user wants to have two tasks waiting on the same thing they should use - // a more appropriate primitive that can store multiple wakers. - - unsafe { wake_task(w2) } - self.waker = Some(w); - } - None => self.waker = Some(w), - } - } - - /// Wake the registered waker, if any. - pub fn wake(&mut self) { - if let Some(w) = self.waker.take() { - unsafe { wake_task(w) } - } - } - - /// Returns true if a waker is currently registered - pub fn occupied(&self) -> bool { - self.waker.is_some() - } -} - -// SAFETY: `WakerRegistration` effectively contains an `Option`, -// which is `Send` and `Sync`. -unsafe impl Send for WakerRegistration {} -unsafe impl Sync for WakerRegistration {} - -/// Utility struct to atomically register and wake a waker. -/// -/// # Safety -/// -/// This type is optimized for (and only works with) embassy tasks. -pub struct AtomicWaker { - waker: AtomicPtr, -} - -impl AtomicWaker { - /// Create a new `AtomicWaker`. - pub const fn new() -> Self { - Self { - waker: AtomicPtr::new(ptr::null_mut()), - } - } - - /// Register a waker. Overwrites the previous waker, if any. - pub fn register(&self, w: &Waker) { - let w = task_from_waker(w); - self.waker.store(w.as_ptr(), Ordering::Relaxed); - compiler_fence(Ordering::SeqCst); - } - - /// Wake the registered waker, if any. - pub fn wake(&self) { - let w2 = self.waker.load(Ordering::Relaxed); - if let Some(w2) = NonNull::new(w2) { - unsafe { wake_task(w2) }; - } - } -} diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index 0ae7163c..dd9bcc09 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-boot-nrf-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly"] } +embassy-util = { version = "0.1.0", path = "../../../../embassy-util" } +embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly"] } embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] } embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/nrf/src/bin/a.rs b/examples/boot/application/nrf/src/bin/a.rs index 0b9715e4..3044645a 100644 --- a/examples/boot/application/nrf/src/bin/a.rs +++ b/examples/boot/application/nrf/src/bin/a.rs @@ -13,8 +13,8 @@ use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); -#[embassy::main] -async fn main(_s: embassy::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { let mut button = Input::new(p.P0_11, Pull::Up); let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); diff --git a/examples/boot/application/nrf/src/bin/b.rs b/examples/boot/application/nrf/src/bin/b.rs index a06c20f8..2f76d20c 100644 --- a/examples/boot/application/nrf/src/bin/b.rs +++ b/examples/boot/application/nrf/src/bin/b.rs @@ -4,13 +4,13 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] -use embassy::time::{Duration, Timer}; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::Peripherals; use panic_reset as _; -#[embassy::main] -async fn main(_s: embassy::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml index 36fc135f..313808a0 100644 --- a/examples/boot/application/stm32f3/Cargo.toml +++ b/examples/boot/application/stm32f3/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-boot-stm32f3-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32f3/src/bin/a.rs b/examples/boot/application/stm32f3/src/bin/a.rs index 4ff18d7c..fd18e937 100644 --- a/examples/boot/application/stm32f3/src/bin/a.rs +++ b/examples/boot/application/stm32f3/src/bin/a.rs @@ -14,8 +14,8 @@ use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); -#[embassy::main] -async fn main(_s: embassy::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32f3/src/bin/b.rs b/examples/boot/application/stm32f3/src/bin/b.rs index 4487e586..934f862d 100644 --- a/examples/boot/application/stm32f3/src/bin/b.rs +++ b/examples/boot/application/stm32f3/src/bin/b.rs @@ -4,13 +4,13 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PA5, Level::High, Speed::Low); diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml index ad4a6fa7..2a4741dc 100644 --- a/examples/boot/application/stm32f7/Cargo.toml +++ b/examples/boot/application/stm32f7/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-boot-stm32f7-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32f7/src/bin/a.rs b/examples/boot/application/stm32f7/src/bin/a.rs index 9c7921a1..10d709cf 100644 --- a/examples/boot/application/stm32f7/src/bin/a.rs +++ b/examples/boot/application/stm32f7/src/bin/a.rs @@ -14,8 +14,8 @@ use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); -#[embassy::main] -async fn main(_s: embassy::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32f7/src/bin/b.rs b/examples/boot/application/stm32f7/src/bin/b.rs index aa05bbcd..c89e8a31 100644 --- a/examples/boot/application/stm32f7/src/bin/b.rs +++ b/examples/boot/application/stm32f7/src/bin/b.rs @@ -4,13 +4,13 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { Timer::after(Duration::from_millis(300)).await; let mut led = Output::new(p.PB7, Level::High, Speed::Low); diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml index 5dff770a..c6420e8a 100644 --- a/examples/boot/application/stm32h7/Cargo.toml +++ b/examples/boot/application/stm32h7/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-boot-stm32h7-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32h7/src/bin/a.rs b/examples/boot/application/stm32h7/src/bin/a.rs index 704979db..cc363bb3 100644 --- a/examples/boot/application/stm32h7/src/bin/a.rs +++ b/examples/boot/application/stm32h7/src/bin/a.rs @@ -14,8 +14,8 @@ use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); -#[embassy::main] -async fn main(_s: embassy::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32h7/src/bin/b.rs b/examples/boot/application/stm32h7/src/bin/b.rs index ea014025..3fa63bdc 100644 --- a/examples/boot/application/stm32h7/src/bin/b.rs +++ b/examples/boot/application/stm32h7/src/bin/b.rs @@ -4,13 +4,13 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { Timer::after(Duration::from_millis(300)).await; let mut led = Output::new(p.PB14, Level::High, Speed::Low); diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml index de7bea47..a6936419 100644 --- a/examples/boot/application/stm32l0/Cargo.toml +++ b/examples/boot/application/stm32l0/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-boot-stm32l0-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32l0/src/bin/a.rs b/examples/boot/application/stm32l0/src/bin/a.rs index ce620347..fcf3f2ef 100644 --- a/examples/boot/application/stm32l0/src/bin/a.rs +++ b/examples/boot/application/stm32l0/src/bin/a.rs @@ -4,9 +4,9 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy::time::{Duration, Timer}; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; @@ -15,8 +15,8 @@ use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); -#[embassy::main] -async fn main(_s: embassy::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32l0/src/bin/b.rs b/examples/boot/application/stm32l0/src/bin/b.rs index 0b585a14..46e394c4 100644 --- a/examples/boot/application/stm32l0/src/bin/b.rs +++ b/examples/boot/application/stm32l0/src/bin/b.rs @@ -4,13 +4,13 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PB6, Level::High, Speed::Low); diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml index 3fd6f639..5e53cd5f 100644 --- a/examples/boot/application/stm32l1/Cargo.toml +++ b/examples/boot/application/stm32l1/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-boot-stm32l1-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs index ce620347..fcf3f2ef 100644 --- a/examples/boot/application/stm32l1/src/bin/a.rs +++ b/examples/boot/application/stm32l1/src/bin/a.rs @@ -4,9 +4,9 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy::time::{Duration, Timer}; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; @@ -15,8 +15,8 @@ use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); -#[embassy::main] -async fn main(_s: embassy::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32l1/src/bin/b.rs b/examples/boot/application/stm32l1/src/bin/b.rs index 0b585a14..46e394c4 100644 --- a/examples/boot/application/stm32l1/src/bin/b.rs +++ b/examples/boot/application/stm32l1/src/bin/b.rs @@ -4,13 +4,13 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PB6, Level::High, Speed::Low); diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml index 7284af66..bbb5e7e1 100644 --- a/examples/boot/application/stm32l4/Cargo.toml +++ b/examples/boot/application/stm32l4/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-boot-stm32l4-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs index bf609935..f092f023 100644 --- a/examples/boot/application/stm32l4/src/bin/a.rs +++ b/examples/boot/application/stm32l4/src/bin/a.rs @@ -14,8 +14,8 @@ use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); -#[embassy::main] -async fn main(_s: embassy::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32l4/src/bin/b.rs b/examples/boot/application/stm32l4/src/bin/b.rs index 4487e586..934f862d 100644 --- a/examples/boot/application/stm32l4/src/bin/b.rs +++ b/examples/boot/application/stm32l4/src/bin/b.rs @@ -4,13 +4,13 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PA5, Level::High, Speed::Low); diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml index ca22e613..62123a87 100644 --- a/examples/boot/application/stm32wl/Cargo.toml +++ b/examples/boot/application/stm32wl/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-boot-stm32wl-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs index dc1eb9be..14408a90 100644 --- a/examples/boot/application/stm32wl/src/bin/a.rs +++ b/examples/boot/application/stm32wl/src/bin/a.rs @@ -14,8 +14,8 @@ use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); -#[embassy::main] -async fn main(_s: embassy::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32wl/src/bin/b.rs b/examples/boot/application/stm32wl/src/bin/b.rs index f2344bd5..e565fd7c 100644 --- a/examples/boot/application/stm32wl/src/bin/b.rs +++ b/examples/boot/application/stm32wl/src/bin/b.rs @@ -4,13 +4,13 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PB15, Level::High, Speed::Low); diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml index 8eb98623..9683bff1 100644 --- a/examples/boot/bootloader/nrf/Cargo.toml +++ b/examples/boot/bootloader/nrf/Cargo.toml @@ -8,7 +8,6 @@ description = "Bootloader for nRF chips" defmt = { version = "0.3", optional = true } defmt-rtt = { version = "0.3", optional = true } -embassy = { path = "../../../../embassy", default-features = false } embassy-nrf = { path = "../../../../embassy-nrf", default-features = false, features = ["nightly"] } embassy-boot-nrf = { path = "../../../../embassy-boot/nrf", default-features = false } cortex-m = { version = "0.7" } diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml index b99a8fbc..4a331952 100644 --- a/examples/boot/bootloader/stm32/Cargo.toml +++ b/examples/boot/bootloader/stm32/Cargo.toml @@ -8,7 +8,6 @@ description = "Example bootloader for STM32 chips" defmt = { version = "0.3", optional = true } defmt-rtt = { version = "0.3", optional = true } -embassy = { path = "../../../../embassy", default-features = false } embassy-stm32 = { path = "../../../../embassy-stm32", default-features = false, features = ["nightly"] } embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32", default-features = false } cortex-m = { version = "0.7" } diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index 0cba7769..91edbd36 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml @@ -5,10 +5,11 @@ version = "0.1.0" [features] default = ["nightly"] -nightly = ["embassy-nrf/nightly", "embassy-nrf/unstable-traits", "embassy-usb", "embassy-usb-serial", "embassy-usb-hid", "embassy-usb-ncm", "embedded-io/async", "embassy-net"] +nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unstable-traits", "embassy-usb", "embassy-usb-serial", "embassy-usb-hid", "embassy-usb-ncm", "embedded-io/async", "embassy-net"] [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true } diff --git a/examples/nrf/src/bin/awaitable_timer.rs b/examples/nrf/src/bin/awaitable_timer.rs index 34a657cb..f2c1d9fa 100644 --- a/examples/nrf/src/bin/awaitable_timer.rs +++ b/examples/nrf/src/bin/awaitable_timer.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::timer::Timer; use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut t = Timer::new_awaitable(p.TIMER0, interrupt::take!(TIMER0)); // default frequency is 1MHz, so this triggers every second diff --git a/examples/nrf/src/bin/blinky.rs b/examples/nrf/src/bin/blinky.rs index 23d16f79..98db6546 100644 --- a/examples/nrf/src/bin/blinky.rs +++ b/examples/nrf/src/bin/blinky.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); diff --git a/examples/nrf/src/bin/buffered_uart.rs b/examples/nrf/src/bin/buffered_uart.rs index 18dd698b..f02b7d84 100644 --- a/examples/nrf/src/bin/buffered_uart.rs +++ b/examples/nrf/src/bin/buffered_uart.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::buffered_uarte::{BufferedUarte, State}; use embassy_nrf::{interrupt, uarte, Peripherals}; use embedded_io::asynch::{BufRead, Write}; use futures::pin_mut; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut config = uarte::Config::default(); config.parity = uarte::Parity::EXCLUDED; diff --git a/examples/nrf/src/bin/channel.rs b/examples/nrf/src/bin/channel.rs index c57b91a4..e97c6c5e 100644 --- a/examples/nrf/src/bin/channel.rs +++ b/examples/nrf/src/bin/channel.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::unwrap; -use embassy::blocking_mutex::raw::ThreadModeRawMutex; -use embassy::channel::mpmc::Channel; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::Peripherals; +use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_util::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; enum LedState { @@ -18,7 +18,7 @@ enum LedState { static CHANNEL: Channel = Channel::new(); -#[embassy::task] +#[embassy_executor::task] async fn my_task() { loop { CHANNEL.send(LedState::On).await; @@ -28,7 +28,7 @@ async fn my_task() { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); diff --git a/examples/nrf/src/bin/channel_sender_receiver.rs b/examples/nrf/src/bin/channel_sender_receiver.rs index 847ce238..bca7bb24 100644 --- a/examples/nrf/src/bin/channel_sender_receiver.rs +++ b/examples/nrf/src/bin/channel_sender_receiver.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::unwrap; -use embassy::blocking_mutex::raw::NoopRawMutex; -use embassy::channel::mpmc::{Channel, Receiver, Sender}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; -use embassy::util::Forever; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; use embassy_nrf::Peripherals; +use embassy_util::blocking_mutex::raw::NoopRawMutex; +use embassy_util::channel::mpmc::{Channel, Receiver, Sender}; +use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; enum LedState { @@ -19,7 +19,7 @@ enum LedState { static CHANNEL: Forever> = Forever::new(); -#[embassy::task] +#[embassy_executor::task] async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) { loop { sender.send(LedState::On).await; @@ -29,7 +29,7 @@ async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) { } } -#[embassy::task] +#[embassy_executor::task] async fn recv_task(led: AnyPin, receiver: Receiver<'static, NoopRawMutex, LedState, 1>) { let mut led = Output::new(led, Level::Low, OutputDrive::Standard); @@ -41,7 +41,7 @@ async fn recv_task(led: AnyPin, receiver: Receiver<'static, NoopRawMutex, LedSta } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { let channel = CHANNEL.put(Channel::new()); diff --git a/examples/nrf/src/bin/executor_fairness_test.rs b/examples/nrf/src/bin/executor_fairness_test.rs index 5a422151..b9845493 100644 --- a/examples/nrf/src/bin/executor_fairness_test.rs +++ b/examples/nrf/src/bin/executor_fairness_test.rs @@ -5,12 +5,12 @@ use core::task::Poll; use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Instant, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Instant, Timer}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task] +#[embassy_executor::task] async fn run1() { loop { info!("DING DONG"); @@ -18,14 +18,14 @@ async fn run1() { } } -#[embassy::task] +#[embassy_executor::task] async fn run2() { loop { Timer::at(Instant::from_ticks(0)).await; } } -#[embassy::task] +#[embassy_executor::task] async fn run3() { futures::future::poll_fn(|cx| { cx.waker().wake_by_ref(); @@ -34,7 +34,7 @@ async fn run3() { .await; } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, _p: Peripherals) { unwrap!(spawner.spawn(run1())); unwrap!(spawner.spawn(run2())); diff --git a/examples/nrf/src/bin/gpiote_channel.rs b/examples/nrf/src/bin/gpiote_channel.rs index ad8f37c6..65c7b4df 100644 --- a/examples/nrf/src/bin/gpiote_channel.rs +++ b/examples/nrf/src/bin/gpiote_channel.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Starting!"); diff --git a/examples/nrf/src/bin/gpiote_port.rs b/examples/nrf/src/bin/gpiote_port.rs index 30b87b3a..7746a7f9 100644 --- a/examples/nrf/src/bin/gpiote_port.rs +++ b/examples/nrf/src/bin/gpiote_port.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task(pool_size = 4)] +#[embassy_executor::task(pool_size = 4)] async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) { loop { pin.wait_for_low().await; @@ -18,7 +18,7 @@ async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { info!("Starting!"); diff --git a/examples/nrf/src/bin/multiprio.rs b/examples/nrf/src/bin/multiprio.rs index 1a4598e2..7050da37 100644 --- a/examples/nrf/src/bin/multiprio.rs +++ b/examples/nrf/src/bin/multiprio.rs @@ -59,14 +59,14 @@ use cortex_m_rt::entry; use defmt::{info, unwrap}; -use embassy::time::{Duration, Instant, Timer}; -use embassy::util::Forever; +use embassy_executor::time::{Duration, Instant, Timer}; use embassy_nrf::executor::{Executor, InterruptExecutor}; use embassy_nrf::interrupt; use embassy_nrf::interrupt::InterruptExt; +use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task] +#[embassy_executor::task] async fn run_high() { loop { info!(" [high] tick!"); @@ -74,7 +74,7 @@ async fn run_high() { } } -#[embassy::task] +#[embassy_executor::task] async fn run_med() { loop { let start = Instant::now(); @@ -91,7 +91,7 @@ async fn run_med() { } } -#[embassy::task] +#[embassy_executor::task] async fn run_low() { loop { let start = Instant::now(); diff --git a/examples/nrf/src/bin/mutex.rs b/examples/nrf/src/bin/mutex.rs index 92e01976..5fe7eadb 100644 --- a/examples/nrf/src/bin/mutex.rs +++ b/examples/nrf/src/bin/mutex.rs @@ -3,16 +3,16 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::blocking_mutex::raw::ThreadModeRawMutex; -use embassy::executor::Spawner; -use embassy::mutex::Mutex; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::Peripherals; +use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_util::mutex::Mutex; use {defmt_rtt as _, panic_probe as _}; static MUTEX: Mutex = Mutex::new(0); -#[embassy::task] +#[embassy_executor::task] async fn my_task() { loop { { @@ -29,7 +29,7 @@ async fn my_task() { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, _p: Peripherals) { unwrap!(spawner.spawn(my_task())); diff --git a/examples/nrf/src/bin/nvmc.rs b/examples/nrf/src/bin/nvmc.rs index b55ef1f6..1d4387de 100644 --- a/examples/nrf/src/bin/nvmc.rs +++ b/examples/nrf/src/bin/nvmc.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::nvmc::Nvmc; use embassy_nrf::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello NVMC!"); diff --git a/examples/nrf/src/bin/ppi.rs b/examples/nrf/src/bin/ppi.rs index 004a1bfa..9a60cc0a 100644 --- a/examples/nrf/src/bin/ppi.rs +++ b/examples/nrf/src/bin/ppi.rs @@ -5,7 +5,7 @@ use core::future::pending; use defmt::info; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity}; use embassy_nrf::ppi::Ppi; @@ -13,7 +13,7 @@ use embassy_nrf::Peripherals; use gpiote::{OutputChannel, OutputChannelPolarity}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Starting!"); diff --git a/examples/nrf/src/bin/pubsub.rs b/examples/nrf/src/bin/pubsub.rs index 2c3a355c..5f33f3e0 100644 --- a/examples/nrf/src/bin/pubsub.rs +++ b/examples/nrf/src/bin/pubsub.rs @@ -3,10 +3,10 @@ #![feature(type_alias_impl_trait)] use defmt::unwrap; -use embassy::blocking_mutex::raw::ThreadModeRawMutex; -use embassy::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; +use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_util::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; use {defmt_rtt as _, panic_probe as _}; /// Create the message bus. It has a queue of 4, supports 3 subscribers and 1 publisher @@ -19,7 +19,7 @@ enum Message { C, } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, _p: embassy_nrf::Peripherals) { defmt::info!("Hello World!"); @@ -64,7 +64,7 @@ async fn main(spawner: Spawner, _p: embassy_nrf::Peripherals) { /// A logger task that just awaits the messages it receives /// /// This takes the generic `Subscriber`. This is most performant, but requires you to write down all of the generics -#[embassy::task] +#[embassy_executor::task] async fn fast_logger(mut messages: Subscriber<'static, ThreadModeRawMutex, Message, 4, 3, 1>) { loop { let message = messages.next_message().await; @@ -76,7 +76,7 @@ async fn fast_logger(mut messages: Subscriber<'static, ThreadModeRawMutex, Messa /// Because of this, depeding on how the messages were published, the subscriber might miss some messages /// /// This takes the dynamic `DynSubscriber`. This is not as performant as the generic version, but let's you ignore some of the generics -#[embassy::task] +#[embassy_executor::task] async fn slow_logger(mut messages: DynSubscriber<'static, Message>) { loop { // Do some work @@ -93,7 +93,7 @@ async fn slow_logger(mut messages: DynSubscriber<'static, Message>) { } /// Same as `slow_logger` but it ignores lag results -#[embassy::task] +#[embassy_executor::task] async fn slow_logger_pure(mut messages: DynSubscriber<'static, Message>) { loop { // Do some work diff --git a/examples/nrf/src/bin/pwm.rs b/examples/nrf/src/bin/pwm.rs index aec5dd73..c8a08329 100644 --- a/examples/nrf/src/bin/pwm.rs +++ b/examples/nrf/src/bin/pwm.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{Prescaler, SimplePwm}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; @@ -70,7 +70,7 @@ static DUTY: [u16; 1024] = [ 7255, 7331, 7407, 7484, 7561, 7638, 7716, 7794, 7873, 7952, 8031, 8111, ]; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut pwm = SimplePwm::new_4ch(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15); pwm.set_prescaler(Prescaler::Div1); diff --git a/examples/nrf/src/bin/pwm_double_sequence.rs b/examples/nrf/src/bin/pwm_double_sequence.rs index facafa77..cfd8db86 100644 --- a/examples/nrf/src/bin/pwm_double_sequence.rs +++ b/examples/nrf/src/bin/pwm_double_sequence.rs @@ -3,15 +3,15 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{ Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence, }; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let seq_words_0: [u16; 5] = [1000, 250, 100, 50, 0]; let seq_words_1: [u16; 4] = [50, 100, 250, 1000]; diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index b7cb385c..b7a04c03 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let seq_words: [u16; 5] = [1000, 250, 100, 50, 0]; diff --git a/examples/nrf/src/bin/pwm_sequence_ppi.rs b/examples/nrf/src/bin/pwm_sequence_ppi.rs index d98e2ca7..f5c587c3 100644 --- a/examples/nrf/src/bin/pwm_sequence_ppi.rs +++ b/examples/nrf/src/bin/pwm_sequence_ppi.rs @@ -5,7 +5,7 @@ use core::future::pending; use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; use embassy_nrf::ppi::Ppi; @@ -13,7 +13,7 @@ use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSeq use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let seq_words: [u16; 5] = [1000, 250, 100, 50, 0]; diff --git a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs index 0dee8c94..d6b3f005 100644 --- a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs +++ b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{ Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer, }; @@ -26,7 +26,7 @@ const RES: u16 = 0x8000; // Provides data to a WS2812b (Neopixel) LED and makes it go blue. The data // line is assumed to be P1_05. -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut config = Config::default(); config.sequence_load = SequenceLoad::Common; diff --git a/examples/nrf/src/bin/pwm_servo.rs b/examples/nrf/src/bin/pwm_servo.rs index 71a90a94..d28a5a17 100644 --- a/examples/nrf/src/bin/pwm_servo.rs +++ b/examples/nrf/src/bin/pwm_servo.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{Prescaler, SimplePwm}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut pwm = SimplePwm::new_1ch(p.PWM0, p.P0_05); // sg90 microervo requires 50hz or 20ms period diff --git a/examples/nrf/src/bin/qdec.rs b/examples/nrf/src/bin/qdec.rs index 9529c7bb..6bda82f7 100644 --- a/examples/nrf/src/bin/qdec.rs +++ b/examples/nrf/src/bin/qdec.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::qdec::{self, Qdec}; use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let irq = interrupt::take!(QDEC); let config = qdec::Config::default(); diff --git a/examples/nrf/src/bin/qspi.rs b/examples/nrf/src/bin/qspi.rs index 96c90f9c..57e0fdbe 100644 --- a/examples/nrf/src/bin/qspi.rs +++ b/examples/nrf/src/bin/qspi.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::{assert_eq, info, unwrap}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::{interrupt, qspi, Peripherals}; use {defmt_rtt as _, panic_probe as _}; @@ -14,7 +14,7 @@ const PAGE_SIZE: usize = 4096; #[repr(C, align(4))] struct AlignedBuf([u8; 4096]); -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { // Config for the MX25R64 present in the nRF52840 DK let mut config = qspi::Config::default(); diff --git a/examples/nrf/src/bin/qspi_lowpower.rs b/examples/nrf/src/bin/qspi_lowpower.rs index ce2e40b2..080b27a1 100644 --- a/examples/nrf/src/bin/qspi_lowpower.rs +++ b/examples/nrf/src/bin/qspi_lowpower.rs @@ -5,8 +5,8 @@ use core::mem; use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::{interrupt, qspi, Peripherals}; use {defmt_rtt as _, panic_probe as _}; @@ -15,7 +15,7 @@ use {defmt_rtt as _, panic_probe as _}; #[repr(C, align(4))] struct AlignedBuf([u8; 64]); -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, mut p: Peripherals) { let mut irq = interrupt::take!(QSPI); diff --git a/examples/nrf/src/bin/raw_spawn.rs b/examples/nrf/src/bin/raw_spawn.rs index d564b6b2..9199d3ae 100644 --- a/examples/nrf/src/bin/raw_spawn.rs +++ b/examples/nrf/src/bin/raw_spawn.rs @@ -5,10 +5,10 @@ use core::mem; use cortex_m_rt::entry; use defmt::{info, unwrap}; -use embassy::executor::raw::TaskStorage; -use embassy::executor::Executor; -use embassy::time::{Duration, Timer}; -use embassy::util::Forever; +use embassy_executor::executor::raw::TaskStorage; +use embassy_executor::executor::Executor; +use embassy_executor::time::{Duration, Timer}; +use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; async fn run1() { diff --git a/examples/nrf/src/bin/rng.rs b/examples/nrf/src/bin/rng.rs index 08d3abe1..a4314e8b 100644 --- a/examples/nrf/src/bin/rng.rs +++ b/examples/nrf/src/bin/rng.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::rng::Rng; use embassy_nrf::{interrupt, Peripherals}; use rand::Rng as _; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut rng = Rng::new(p.RNG, interrupt::take!(RNG)); diff --git a/examples/nrf/src/bin/saadc.rs b/examples/nrf/src/bin/saadc.rs index cb928978..65c78d84 100644 --- a/examples/nrf/src/bin/saadc.rs +++ b/examples/nrf/src/bin/saadc.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, mut p: Peripherals) { let config = Config::default(); let channel_config = ChannelConfig::single_ended(&mut p.P0_02); diff --git a/examples/nrf/src/bin/saadc_continuous.rs b/examples/nrf/src/bin/saadc_continuous.rs index 234294ea..d0305736 100644 --- a/examples/nrf/src/bin/saadc_continuous.rs +++ b/examples/nrf/src/bin/saadc_continuous.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; -use embassy::time::Duration; +use embassy_executor::executor::Spawner; +use embassy_executor::time::Duration; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc, SamplerState}; use embassy_nrf::timer::Frequency; use embassy_nrf::{interrupt, Peripherals}; @@ -12,7 +12,7 @@ use {defmt_rtt as _, panic_probe as _}; // Demonstrates both continuous sampling and scanning multiple channels driven by a PPI linked timer -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, mut p: Peripherals) { let config = Config::default(); let channel_1_config = ChannelConfig::single_ended(&mut p.P0_02); @@ -27,7 +27,7 @@ async fn main(_spawner: Spawner, mut p: Peripherals) { // This delay demonstrates that starting the timer prior to running // the task sampler is benign given the calibration that follows. - embassy::time::Timer::after(Duration::from_millis(500)).await; + embassy_executor::time::Timer::after(Duration::from_millis(500)).await; saadc.calibrate().await; let mut bufs = [[[0; 3]; 500]; 2]; diff --git a/examples/nrf/src/bin/self_spawn.rs b/examples/nrf/src/bin/self_spawn.rs index 4b8ac04b..e0152802 100644 --- a/examples/nrf/src/bin/self_spawn.rs +++ b/examples/nrf/src/bin/self_spawn.rs @@ -3,19 +3,19 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task(pool_size = 2)] +#[embassy_executor::task(pool_size = 2)] async fn my_task(spawner: Spawner, n: u32) { Timer::after(Duration::from_secs(1)).await; info!("Spawning self! {}", n); unwrap!(spawner.spawn(my_task(spawner, n + 1))); } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, _p: Peripherals) { info!("Hello World!"); unwrap!(spawner.spawn(my_task(spawner, 0))); diff --git a/examples/nrf/src/bin/self_spawn_current_executor.rs b/examples/nrf/src/bin/self_spawn_current_executor.rs index 3c3379ce..1d8309d7 100644 --- a/examples/nrf/src/bin/self_spawn_current_executor.rs +++ b/examples/nrf/src/bin/self_spawn_current_executor.rs @@ -3,19 +3,19 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task(pool_size = 2)] +#[embassy_executor::task(pool_size = 2)] async fn my_task(n: u32) { Timer::after(Duration::from_secs(1)).await; info!("Spawning self! {}", n); unwrap!(Spawner::for_current_executor().await.spawn(my_task(n + 1))); } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, _p: Peripherals) { info!("Hello World!"); unwrap!(spawner.spawn(my_task(0))); diff --git a/examples/nrf/src/bin/spim.rs b/examples/nrf/src/bin/spim.rs index 62040168..fd741b21 100644 --- a/examples/nrf/src/bin/spim.rs +++ b/examples/nrf/src/bin/spim.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::{interrupt, spim, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("running!"); diff --git a/examples/nrf/src/bin/temp.rs b/examples/nrf/src/bin/temp.rs index 939cb39e..654098e0 100644 --- a/examples/nrf/src/bin/temp.rs +++ b/examples/nrf/src/bin/temp.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::temp::Temp; use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let irq = interrupt::take!(TEMP); let mut temp = Temp::new(p.TEMP, irq); diff --git a/examples/nrf/src/bin/timer.rs b/examples/nrf/src/bin/timer.rs index 64376dd7..61ff1d6d 100644 --- a/examples/nrf/src/bin/timer.rs +++ b/examples/nrf/src/bin/timer.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task] +#[embassy_executor::task] async fn run1() { loop { info!("BIG INFREQUENT TICK"); @@ -16,7 +16,7 @@ async fn run1() { } } -#[embassy::task] +#[embassy_executor::task] async fn run2() { loop { info!("tick"); @@ -24,7 +24,7 @@ async fn run2() { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, _p: Peripherals) { unwrap!(spawner.spawn(run1())); unwrap!(spawner.spawn(run2())); diff --git a/examples/nrf/src/bin/twim.rs b/examples/nrf/src/bin/twim.rs index fb8372a1..bb7ee9db 100644 --- a/examples/nrf/src/bin/twim.rs +++ b/examples/nrf/src/bin/twim.rs @@ -7,14 +7,14 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::twim::{self, Twim}; use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x50; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Initializing TWI..."); let config = twim::Config::default(); diff --git a/examples/nrf/src/bin/twim_lowpower.rs b/examples/nrf/src/bin/twim_lowpower.rs index c9c2d503..ebf3d710 100644 --- a/examples/nrf/src/bin/twim_lowpower.rs +++ b/examples/nrf/src/bin/twim_lowpower.rs @@ -11,15 +11,15 @@ use core::mem; use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::twim::{self, Twim}; use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x50; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, mut p: Peripherals) { info!("Started!"); let mut irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); diff --git a/examples/nrf/src/bin/uart.rs b/examples/nrf/src/bin/uart.rs index c8c4a67a..5f363b69 100644 --- a/examples/nrf/src/bin/uart.rs +++ b/examples/nrf/src/bin/uart.rs @@ -3,11 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::{interrupt, uarte, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut config = uarte::Config::default(); config.parity = uarte::Parity::EXCLUDED; diff --git a/examples/nrf/src/bin/uart_idle.rs b/examples/nrf/src/bin/uart_idle.rs index 6679b28d..0f455dff 100644 --- a/examples/nrf/src/bin/uart_idle.rs +++ b/examples/nrf/src/bin/uart_idle.rs @@ -3,11 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::{interrupt, uarte, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut config = uarte::Config::default(); config.parity = uarte::Parity::EXCLUDED; diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs index 1ffb6370..2de5f90c 100644 --- a/examples/nrf/src/bin/uart_split.rs +++ b/examples/nrf/src/bin/uart_split.rs @@ -3,17 +3,17 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::blocking_mutex::raw::ThreadModeRawMutex; -use embassy::channel::mpmc::Channel; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::peripherals::UARTE0; use embassy_nrf::uarte::UarteRx; use embassy_nrf::{interrupt, uarte, Peripherals}; +use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_util::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; static CHANNEL: Channel = Channel::new(); -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { let mut config = uarte::Config::default(); config.parity = uarte::Parity::EXCLUDED; @@ -48,7 +48,7 @@ async fn main(spawner: Spawner, p: Peripherals) { } } -#[embassy::task] +#[embassy_executor::task] async fn reader(mut rx: UarteRx<'static, UARTE0>) { let mut buf = [0; 8]; loop { diff --git a/examples/nrf/src/bin/usb_ethernet.rs b/examples/nrf/src/bin/usb_ethernet.rs index e57cdaf6..93cb0590 100644 --- a/examples/nrf/src/bin/usb_ethernet.rs +++ b/examples/nrf/src/bin/usb_ethernet.rs @@ -8,10 +8,7 @@ use core::sync::atomic::{AtomicBool, Ordering}; use core::task::Waker; use defmt::*; -use embassy::blocking_mutex::raw::ThreadModeRawMutex; -use embassy::channel::mpmc::Channel; -use embassy::executor::Spawner; -use embassy::util::Forever; +use embassy_executor::executor::Spawner; use embassy_net::tcp::TcpSocket; use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; use embassy_nrf::rng::Rng; @@ -19,6 +16,9 @@ use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac, peripherals, Peripherals}; use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; +use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_util::channel::mpmc::Channel; +use embassy_util::Forever; use embedded_io::asynch::{Read, Write}; use {defmt_rtt as _, panic_probe as _}; @@ -32,12 +32,12 @@ macro_rules! forever { }}; } -#[embassy::task] +#[embassy_executor::task] async fn usb_task(mut device: UsbDevice<'static, MyDriver>) -> ! { device.run().await } -#[embassy::task] +#[embassy_executor::task] async fn usb_ncm_rx_task(mut class: Receiver<'static, MyDriver>) { loop { warn!("WAITING for connection"); @@ -66,7 +66,7 @@ async fn usb_ncm_rx_task(mut class: Receiver<'static, MyDriver>) { } } -#[embassy::task] +#[embassy_executor::task] async fn usb_ncm_tx_task(mut class: Sender<'static, MyDriver>) { loop { let pkt = TX_CHANNEL.recv().await; @@ -76,12 +76,12 @@ async fn usb_ncm_tx_task(mut class: Sender<'static, MyDriver>) { } } -#[embassy::task] +#[embassy_executor::task] async fn net_task(stack: &'static Stack) -> ! { stack.run().await } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { let clock: pac::CLOCK = unsafe { mem::transmute(()) }; diff --git a/examples/nrf/src/bin/usb_hid_keyboard.rs b/examples/nrf/src/bin/usb_hid_keyboard.rs index 539ae6f1..863f3e5d 100644 --- a/examples/nrf/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf/src/bin/usb_hid_keyboard.rs @@ -7,23 +7,22 @@ use core::mem; use core::sync::atomic::{AtomicBool, Ordering}; use defmt::*; -use embassy::channel::signal::Signal; -use embassy::executor::Spawner; -use embassy::time::Duration; -use embassy::util::{select, Either}; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Pin, Pull}; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac, Peripherals}; use embassy_usb::control::OutResponse; use embassy_usb::{Builder, Config, DeviceStateHandler}; use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State}; +use embassy_util::channel::signal::Signal; +use embassy_util::{select, Either}; use futures::future::join; use usbd_hid::descriptor::{KeyboardReport, SerializedDescriptor}; use {defmt_rtt as _, panic_probe as _}; static SUSPENDED: AtomicBool = AtomicBool::new(false); -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let clock: pac::CLOCK = unsafe { mem::transmute(()) }; @@ -154,11 +153,11 @@ impl RequestHandler for MyRequestHandler { OutResponse::Accepted } - fn set_idle(&self, id: Option, dur: Duration) { + fn set_idle_ms(&self, id: Option, dur: u32) { info!("Set idle rate for {:?} to {:?}", id, dur); } - fn get_idle(&self, id: Option) -> Option { + fn get_idle_ms(&self, id: Option) -> Option { info!("Get idle rate for {:?}", id); None } diff --git a/examples/nrf/src/bin/usb_hid_mouse.rs b/examples/nrf/src/bin/usb_hid_mouse.rs index 516e7ea9..88bf87bd 100644 --- a/examples/nrf/src/bin/usb_hid_mouse.rs +++ b/examples/nrf/src/bin/usb_hid_mouse.rs @@ -6,8 +6,8 @@ use core::mem; use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac, Peripherals}; use embassy_usb::control::OutResponse; @@ -17,7 +17,7 @@ use futures::future::join; use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let clock: pac::CLOCK = unsafe { mem::transmute(()) }; @@ -113,11 +113,11 @@ impl RequestHandler for MyRequestHandler { OutResponse::Accepted } - fn set_idle(&self, id: Option, dur: Duration) { + fn set_idle_ms(&self, id: Option, dur: u32) { info!("Set idle rate for {:?} to {:?}", id, dur); } - fn get_idle(&self, id: Option) -> Option { + fn get_idle_ms(&self, id: Option) -> Option { info!("Get idle rate for {:?}", id); None } diff --git a/examples/nrf/src/bin/usb_serial.rs b/examples/nrf/src/bin/usb_serial.rs index d2200dc5..7d233d24 100644 --- a/examples/nrf/src/bin/usb_serial.rs +++ b/examples/nrf/src/bin/usb_serial.rs @@ -6,7 +6,7 @@ use core::mem; use defmt::{info, panic}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::usb::{Driver, Instance, PowerUsb, UsbSupply}; use embassy_nrf::{interrupt, pac, Peripherals}; use embassy_usb::driver::EndpointError; @@ -15,7 +15,7 @@ use embassy_usb_serial::{CdcAcmClass, State}; use futures::future::join; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let clock: pac::CLOCK = unsafe { mem::transmute(()) }; diff --git a/examples/nrf/src/bin/usb_serial_multitask.rs b/examples/nrf/src/bin/usb_serial_multitask.rs index 3806da5a..95631532 100644 --- a/examples/nrf/src/bin/usb_serial_multitask.rs +++ b/examples/nrf/src/bin/usb_serial_multitask.rs @@ -6,23 +6,23 @@ use core::mem; use defmt::{info, panic, unwrap}; -use embassy::executor::Spawner; -use embassy::util::Forever; +use embassy_executor::executor::Spawner; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac, peripherals, Peripherals}; use embassy_usb::driver::EndpointError; use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb_serial::{CdcAcmClass, State}; +use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>; -#[embassy::task] +#[embassy_executor::task] async fn usb_task(mut device: UsbDevice<'static, MyDriver>) { device.run().await; } -#[embassy::task] +#[embassy_executor::task] async fn echo_task(mut class: CdcAcmClass<'static, MyDriver>) { loop { class.wait_connection().await; @@ -32,7 +32,7 @@ async fn echo_task(mut class: CdcAcmClass<'static, MyDriver>) { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { let clock: pac::CLOCK = unsafe { mem::transmute(()) }; diff --git a/examples/nrf/src/bin/wdt.rs b/examples/nrf/src/bin/wdt.rs index 280e23bc..560cb356 100644 --- a/examples/nrf/src/bin/wdt.rs +++ b/examples/nrf/src/bin/wdt.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::wdt::{Config, Watchdog}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index d0704f20..94c3d801 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime"] } embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac"] } atomic-polyfill = "0.1.5" diff --git a/examples/rp/src/bin/blinky.rs b/examples/rp/src/bin/blinky.rs index 35612a4c..e53fca1a 100644 --- a/examples/rp/src/bin/blinky.rs +++ b/examples/rp/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_rp::{gpio, Peripherals}; use gpio::{Level, Output}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PIN_25, Level::Low); diff --git a/examples/rp/src/bin/button.rs b/examples/rp/src/bin/button.rs index 980e54ea..02cbc941 100644 --- a/examples/rp/src/bin/button.rs +++ b/examples/rp/src/bin/button.rs @@ -2,12 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_rp::gpio::{Input, Level, Output, Pull}; use embassy_rp::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let button = Input::new(p.PIN_28, Pull::Up); let mut led = Output::new(p.PIN_25, Level::Low); diff --git a/examples/rp/src/bin/gpio_async.rs b/examples/rp/src/bin/gpio_async.rs index e0f2aa96..ba905b01 100644 --- a/examples/rp/src/bin/gpio_async.rs +++ b/examples/rp/src/bin/gpio_async.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_rp::{gpio, Peripherals}; use gpio::{Input, Level, Output, Pull}; use {defmt_rtt as _, panic_probe as _}; @@ -19,7 +19,7 @@ use {defmt_rtt as _, panic_probe as _}; /// high signal on PIN 16. Once the high event/signal occurs the program will /// continue and turn off the LED, and then wait for 2 seconds before completing /// the loop and starting over again. -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PIN_25, Level::Low); let mut async_input = Input::new(p.PIN_16, Pull::None); diff --git a/examples/rp/src/bin/spi.rs b/examples/rp/src/bin/spi.rs index d97aa94b..a3160c10 100644 --- a/examples/rp/src/bin/spi.rs +++ b/examples/rp/src/bin/spi.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_rp::spi::Spi; use embassy_rp::{gpio, spi, Peripherals}; use gpio::{Level, Output}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/rp/src/bin/spi_display.rs b/examples/rp/src/bin/spi_display.rs index f4a411ba..2760b23f 100644 --- a/examples/rp/src/bin/spi_display.rs +++ b/examples/rp/src/bin/spi_display.rs @@ -5,8 +5,8 @@ use core::cell::RefCell; use defmt::*; -use embassy::executor::Spawner; -use embassy::time::Delay; +use embassy_executor::executor::Spawner; +use embassy_executor::time::Delay; use embassy_rp::gpio::{Level, Output}; use embassy_rp::spi::Spi; use embassy_rp::{spi, Peripherals}; @@ -27,7 +27,7 @@ use crate::touch::Touch; //const DISPLAY_FREQ: u32 = 64_000_000; const TOUCH_FREQ: u32 = 200_000; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/rp/src/bin/uart.rs b/examples/rp/src/bin/uart.rs index 99072253..0d295489 100644 --- a/examples/rp/src/bin/uart.rs +++ b/examples/rp/src/bin/uart.rs @@ -2,11 +2,11 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_rp::{uart, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let config = uart::Config::default(); let mut uart = uart::Uart::new(p.UART0, p.PIN_0, p.PIN_1, p.PIN_2, p.PIN_3, config); diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 8787f3c9..54499796 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-std-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["log", "std", "time", "nightly"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "std", "time", "nightly"] } embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "tcp", "dhcpv4", "pool-16"] } embedded-io = { version = "0.3.0", features = ["async", "std", "futures"] } diff --git a/examples/std/src/bin/net.rs b/examples/std/src/bin/net.rs index 74073ee8..20258528 100644 --- a/examples/std/src/bin/net.rs +++ b/examples/std/src/bin/net.rs @@ -1,10 +1,10 @@ #![feature(type_alias_impl_trait)] use clap::Parser; -use embassy::executor::{Executor, Spawner}; -use embassy::util::Forever; +use embassy_executor::executor::{Executor, Spawner}; use embassy_net::tcp::TcpSocket; use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, Stack, StackResources}; +use embassy_util::Forever; use embedded_io::asynch::Write; use heapless::Vec; use log::*; @@ -34,12 +34,12 @@ struct Opts { static_ip: bool, } -#[embassy::task] +#[embassy_executor::task] async fn net_task(stack: &'static Stack) -> ! { stack.run().await } -#[embassy::task] +#[embassy_executor::task] async fn main_task(spawner: Spawner) { let opts: Opts = Opts::parse(); diff --git a/examples/std/src/bin/serial.rs b/examples/std/src/bin/serial.rs index b1e5b014..b803d1ef 100644 --- a/examples/std/src/bin/serial.rs +++ b/examples/std/src/bin/serial.rs @@ -4,15 +4,15 @@ mod serial_port; use async_io::Async; -use embassy::executor::Executor; -use embassy::util::Forever; +use embassy_executor::executor::Executor; +use embassy_util::Forever; use embedded_io::asynch::Read; use log::*; use nix::sys::termios; use self::serial_port::SerialPort; -#[embassy::task] +#[embassy_executor::task] async fn run() { // Open the serial port. let baudrate = termios::BaudRate::B115200; diff --git a/examples/std/src/bin/tick.rs b/examples/std/src/bin/tick.rs index bed9d7dc..9ca900df 100644 --- a/examples/std/src/bin/tick.rs +++ b/examples/std/src/bin/tick.rs @@ -1,10 +1,10 @@ #![feature(type_alias_impl_trait)] -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use log::*; -#[embassy::task] +#[embassy_executor::task] async fn run() { loop { info!("tick"); @@ -12,7 +12,7 @@ async fn run() { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner) { env_logger::builder() .filter_level(log::LevelFilter::Debug) diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index 61580325..3ba29763 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml @@ -11,6 +11,7 @@ cortex-m-rt = "0.7.0" defmt = "0.3" defmt-rtt = "0.3" panic-probe = "0.3" -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f030f4", "time-driver-any"] } diff --git a/examples/stm32f0/src/bin/hello.rs b/examples/stm32f0/src/bin/hello.rs index 225f1c3a..c9081ea1 100644 --- a/examples/stm32f0/src/bin/hello.rs +++ b/examples/stm32f0/src/bin/hello.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, _p: Peripherals) -> ! { loop { Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml index fb0e605d..9ce553b6 100644 --- a/examples/stm32f1/Cargo.toml +++ b/examples/stm32f1/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-stm32f1-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"] } diff --git a/examples/stm32f1/src/bin/adc.rs b/examples/stm32f1/src/bin/adc.rs index 09904d4c..e54593fe 100644 --- a/examples/stm32f1/src/bin/adc.rs +++ b/examples/stm32f1/src/bin/adc.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Delay, Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Delay, Duration, Timer}; use embassy_stm32::adc::Adc; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f1/src/bin/blinky.rs b/examples/stm32f1/src/bin/blinky.rs index c98d0cda..5171043e 100644 --- a/examples/stm32f1/src/bin/blinky.rs +++ b/examples/stm32f1/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f1/src/bin/hello.rs b/examples/stm32f1/src/bin/hello.rs index 82f11bc2..549d1bfb 100644 --- a/examples/stm32f1/src/bin/hello.rs +++ b/examples/stm32f1/src/bin/hello.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::time::Hertz; use embassy_stm32::{Config, Peripherals}; use {defmt_rtt as _, panic_probe as _}; @@ -15,7 +15,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, _p: Peripherals) -> ! { loop { info!("Hello World!"); diff --git a/examples/stm32f1/src/bin/usb_serial.rs b/examples/stm32f1/src/bin/usb_serial.rs index d06315d7..cf7facb7 100644 --- a/examples/stm32f1/src/bin/usb_serial.rs +++ b/examples/stm32f1/src/bin/usb_serial.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::{panic, *}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::time::Hertz; use embassy_stm32::usb::{Driver, Instance}; @@ -23,7 +23,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, mut p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index 6ea6add1..a3fb736d 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-stm32f2-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } defmt = "0.3" diff --git a/examples/stm32f2/src/bin/blinky.rs b/examples/stm32f2/src/bin/blinky.rs index dd20ba85..48ae2e71 100644 --- a/examples/stm32f2/src/bin/blinky.rs +++ b/examples/stm32f2/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f2/src/bin/pll.rs b/examples/stm32f2/src/bin/pll.rs index b09d64b0..01e63b15 100644 --- a/examples/stm32f2/src/bin/pll.rs +++ b/examples/stm32f2/src/bin/pll.rs @@ -5,8 +5,8 @@ use core::convert::TryFrom; use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::rcc::{ APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLL48Div, PLLConfig, PLLMainDiv, PLLMul, PLLPreDiv, PLLSrc, }; @@ -43,7 +43,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, _p: Peripherals) { loop { Timer::after(Duration::from_millis(1000)).await; diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index 6912ba76..410e9b3e 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-stm32f3-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"] } diff --git a/examples/stm32f3/src/bin/blinky.rs b/examples/stm32f3/src/bin/blinky.rs index 4d0b33f6..7146eaa5 100644 --- a/examples/stm32f3/src/bin/blinky.rs +++ b/examples/stm32f3/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index 45862ddc..ef511031 100644 --- a/examples/stm32f3/src/bin/button_events.rs +++ b/examples/stm32f3/src/bin/button_events.rs @@ -11,14 +11,14 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::blocking_mutex::raw::ThreadModeRawMutex; -use embassy::channel::mpmc::Channel; -use embassy::executor::Spawner; -use embassy::time::{with_timeout, Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{with_timeout, Duration, Timer}; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; use embassy_stm32::peripherals::PA0; use embassy_stm32::Peripherals; +use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_util::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; struct Leds<'a> { @@ -99,7 +99,7 @@ enum ButtonEvent { static CHANNEL: Channel = Channel::new(); -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { let button = Input::new(p.PA0, Pull::Down); let button = ExtiInput::new(button, p.EXTI0); @@ -120,14 +120,14 @@ async fn main(spawner: Spawner, p: Peripherals) { spawner.spawn(led_blinker(leds)).unwrap(); } -#[embassy::task] +#[embassy_executor::task] async fn led_blinker(mut leds: Leds<'static>) { loop { leds.show().await; } } -#[embassy::task] +#[embassy_executor::task] async fn button_waiter(mut button: ExtiInput<'static, PA0>) { const DOUBLE_CLICK_DELAY: u64 = 250; const HOLD_DELAY: u64 = 1000; diff --git a/examples/stm32f3/src/bin/button_exti.rs b/examples/stm32f3/src/bin/button_exti.rs index add6712b..dee06e5d 100644 --- a/examples/stm32f3/src/bin/button_exti.rs +++ b/examples/stm32f3/src/bin/button_exti.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f3/src/bin/flash.rs b/examples/stm32f3/src/bin/flash.rs index ce16f6de..be2f6f67 100644 --- a/examples/stm32f3/src/bin/flash.rs +++ b/examples/stm32f3/src/bin/flash.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::flash::Flash; use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello Flash!"); diff --git a/examples/stm32f3/src/bin/hello.rs b/examples/stm32f3/src/bin/hello.rs index 3b89f1c7..bd9953a0 100644 --- a/examples/stm32f3/src/bin/hello.rs +++ b/examples/stm32f3/src/bin/hello.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::time::Hertz; use embassy_stm32::{Config, Peripherals}; use {defmt_rtt as _, panic_probe as _}; @@ -16,7 +16,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, _p: Peripherals) -> ! { loop { info!("Hello World!"); diff --git a/examples/stm32f3/src/bin/multiprio.rs b/examples/stm32f3/src/bin/multiprio.rs index 4f2cf9a6..fba5b286 100644 --- a/examples/stm32f3/src/bin/multiprio.rs +++ b/examples/stm32f3/src/bin/multiprio.rs @@ -59,14 +59,14 @@ use cortex_m_rt::entry; use defmt::*; -use embassy::time::{Duration, Instant, Timer}; -use embassy::util::Forever; +use embassy_executor::time::{Duration, Instant, Timer}; use embassy_stm32::executor::{Executor, InterruptExecutor}; use embassy_stm32::interrupt; use embassy_stm32::interrupt::InterruptExt; +use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task] +#[embassy_executor::task] async fn run_high() { loop { info!(" [high] tick!"); @@ -74,7 +74,7 @@ async fn run_high() { } } -#[embassy::task] +#[embassy_executor::task] async fn run_med() { loop { let start = Instant::now(); @@ -91,7 +91,7 @@ async fn run_med() { } } -#[embassy::task] +#[embassy_executor::task] async fn run_low() { loop { let start = Instant::now(); diff --git a/examples/stm32f3/src/bin/spi_dma.rs b/examples/stm32f3/src/bin/spi_dma.rs index ece1ae6f..f554c509 100644 --- a/examples/stm32f3/src/bin/spi_dma.rs +++ b/examples/stm32f3/src/bin/spi_dma.rs @@ -6,14 +6,14 @@ use core::fmt::Write; use core::str::from_utf8; use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; use heapless::String; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f3/src/bin/usart_dma.rs b/examples/stm32f3/src/bin/usart_dma.rs index 4660f812..62d16502 100644 --- a/examples/stm32f3/src/bin/usart_dma.rs +++ b/examples/stm32f3/src/bin/usart_dma.rs @@ -5,14 +5,14 @@ use core::fmt::Write; use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; use heapless::String; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f3/src/bin/usb_serial.rs b/examples/stm32f3/src/bin/usb_serial.rs index 463d561e..87b1138f 100644 --- a/examples/stm32f3/src/bin/usb_serial.rs +++ b/examples/stm32f3/src/bin/usb_serial.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::{panic, *}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::time::mhz; use embassy_stm32::usb::{Driver, Instance}; @@ -27,7 +27,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index 100c0e60..37464b1e 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti"] } defmt = "0.3" diff --git a/examples/stm32f4/src/bin/adc.rs b/examples/stm32f4/src/bin/adc.rs index 84ddbfd3..27ed4fcc 100644 --- a/examples/stm32f4/src/bin/adc.rs +++ b/examples/stm32f4/src/bin/adc.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Delay, Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Delay, Duration, Timer}; use embassy_stm32::adc::Adc; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs index 907492b3..f71fe098 100644 --- a/examples/stm32f4/src/bin/blinky.rs +++ b/examples/stm32f4/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs index 24ece992..60dfb362 100644 --- a/examples/stm32f4/src/bin/button_exti.rs +++ b/examples/stm32f4/src/bin/button_exti.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f4/src/bin/flash.rs b/examples/stm32f4/src/bin/flash.rs index 13fd2c90..4f780656 100644 --- a/examples/stm32f4/src/bin/flash.rs +++ b/examples/stm32f4/src/bin/flash.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::flash::Flash; use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello Flash!"); diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs index 8e69e89d..f957656e 100644 --- a/examples/stm32f4/src/bin/hello.rs +++ b/examples/stm32f4/src/bin/hello.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::time::Hertz; use embassy_stm32::{Config, Peripherals}; use {defmt_rtt as _, panic_probe as _}; @@ -15,7 +15,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, _p: Peripherals) -> ! { loop { info!("Hello World!"); diff --git a/examples/stm32f4/src/bin/multiprio.rs b/examples/stm32f4/src/bin/multiprio.rs index 4f2cf9a6..fba5b286 100644 --- a/examples/stm32f4/src/bin/multiprio.rs +++ b/examples/stm32f4/src/bin/multiprio.rs @@ -59,14 +59,14 @@ use cortex_m_rt::entry; use defmt::*; -use embassy::time::{Duration, Instant, Timer}; -use embassy::util::Forever; +use embassy_executor::time::{Duration, Instant, Timer}; use embassy_stm32::executor::{Executor, InterruptExecutor}; use embassy_stm32::interrupt; use embassy_stm32::interrupt::InterruptExt; +use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task] +#[embassy_executor::task] async fn run_high() { loop { info!(" [high] tick!"); @@ -74,7 +74,7 @@ async fn run_high() { } } -#[embassy::task] +#[embassy_executor::task] async fn run_med() { loop { let start = Instant::now(); @@ -91,7 +91,7 @@ async fn run_med() { } } -#[embassy::task] +#[embassy_executor::task] async fn run_low() { loop { let start = Instant::now(); diff --git a/examples/stm32f4/src/bin/pwm.rs b/examples/stm32f4/src/bin/pwm.rs index b39bbbe2..0b352c2b 100644 --- a/examples/stm32f4/src/bin/pwm.rs +++ b/examples/stm32f4/src/bin/pwm.rs @@ -3,15 +3,15 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; use embassy_stm32::pwm::Channel; use embassy_stm32::time::khz; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs index 752ad57b..6eef1996 100644 --- a/examples/stm32f4/src/bin/sdmmc.rs +++ b/examples/stm32f4/src/bin/sdmmc.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config, Peripherals}; @@ -15,7 +15,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) -> ! { info!("Hello World!"); diff --git a/examples/stm32f4/src/bin/spi_dma.rs b/examples/stm32f4/src/bin/spi_dma.rs index f3c0f2cd..023ca097 100644 --- a/examples/stm32f4/src/bin/spi_dma.rs +++ b/examples/stm32f4/src/bin/spi_dma.rs @@ -6,14 +6,14 @@ use core::fmt::Write; use core::str::from_utf8; use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; use heapless::String; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f4/src/bin/usart_buffered.rs b/examples/stm32f4/src/bin/usart_buffered.rs index 039e43bd..2555998c 100644 --- a/examples/stm32f4/src/bin/usart_buffered.rs +++ b/examples/stm32f4/src/bin/usart_buffered.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; use embassy_stm32::{interrupt, Peripherals}; use embedded_io::asynch::BufRead; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f4/src/bin/usart_dma.rs b/examples/stm32f4/src/bin/usart_dma.rs index 8d06f843..7859ba2a 100644 --- a/examples/stm32f4/src/bin/usart_dma.rs +++ b/examples/stm32f4/src/bin/usart_dma.rs @@ -5,14 +5,14 @@ use core::fmt::Write; use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; use heapless::String; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f4/src/bin/wdt.rs b/examples/stm32f4/src/bin/wdt.rs index bfc487c3..48394f4f 100644 --- a/examples/stm32f4/src/bin/wdt.rs +++ b/examples/stm32f4/src/bin/wdt.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::wdg::IndependentWatchdog; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index b0a548a3..081bed84 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-stm32f7-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "net", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] } embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"] } embedded-io = { version = "0.3.0", features = ["async"] } diff --git a/examples/stm32f7/src/bin/adc.rs b/examples/stm32f7/src/bin/adc.rs index fc835962..2a813c05 100644 --- a/examples/stm32f7/src/bin/adc.rs +++ b/examples/stm32f7/src/bin/adc.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Delay, Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Delay, Duration, Timer}; use embassy_stm32::adc::Adc; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f7/src/bin/blinky.rs b/examples/stm32f7/src/bin/blinky.rs index 907492b3..f71fe098 100644 --- a/examples/stm32f7/src/bin/blinky.rs +++ b/examples/stm32f7/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f7/src/bin/button_exti.rs b/examples/stm32f7/src/bin/button_exti.rs index 24ece992..60dfb362 100644 --- a/examples/stm32f7/src/bin/button_exti.rs +++ b/examples/stm32f7/src/bin/button_exti.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index 177683c3..33504af7 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs @@ -3,9 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; -use embassy::util::Forever; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_net::tcp::TcpSocket; use embassy_net::{Ipv4Address, Stack, StackResources}; use embassy_stm32::eth::generic_smi::GenericSMI; @@ -14,6 +13,7 @@ use embassy_stm32::peripherals::ETH; use embassy_stm32::rng::Rng; use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_util::Forever; use embedded_io::asynch::Write; use rand_core::RngCore; use {defmt_rtt as _, panic_probe as _}; @@ -28,7 +28,7 @@ macro_rules! forever { type Device = Ethernet<'static, ETH, GenericSMI, 4, 4>; -#[embassy::task] +#[embassy_executor::task] async fn net_task(stack: &'static Stack) -> ! { stack.run().await } @@ -39,7 +39,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(spawner: Spawner, p: Peripherals) -> ! { info!("Hello World!"); diff --git a/examples/stm32f7/src/bin/flash.rs b/examples/stm32f7/src/bin/flash.rs index af66275d..15864cab 100644 --- a/examples/stm32f7/src/bin/flash.rs +++ b/examples/stm32f7/src/bin/flash.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::flash::Flash; use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello Flash!"); diff --git a/examples/stm32f7/src/bin/hello.rs b/examples/stm32f7/src/bin/hello.rs index 8e69e89d..f957656e 100644 --- a/examples/stm32f7/src/bin/hello.rs +++ b/examples/stm32f7/src/bin/hello.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::time::Hertz; use embassy_stm32::{Config, Peripherals}; use {defmt_rtt as _, panic_probe as _}; @@ -15,7 +15,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, _p: Peripherals) -> ! { loop { info!("Hello World!"); diff --git a/examples/stm32f7/src/bin/sdmmc.rs b/examples/stm32f7/src/bin/sdmmc.rs index be1c2b15..1f321df1 100644 --- a/examples/stm32f7/src/bin/sdmmc.rs +++ b/examples/stm32f7/src/bin/sdmmc.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config, Peripherals}; @@ -15,7 +15,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) -> ! { info!("Hello World!"); diff --git a/examples/stm32f7/src/bin/usart_dma.rs b/examples/stm32f7/src/bin/usart_dma.rs index d8551620..9884d163 100644 --- a/examples/stm32f7/src/bin/usart_dma.rs +++ b/examples/stm32f7/src/bin/usart_dma.rs @@ -5,14 +5,14 @@ use core::fmt::Write; use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; use heapless::String; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let config = Config::default(); let mut usart = Uart::new(p.UART7, p.PA8, p.PA15, p.DMA1_CH1, NoDma, config); diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index bf23fa82..3dedeac6 100644 --- a/examples/stm32g0/Cargo.toml +++ b/examples/stm32g0/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-stm32g0-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } defmt = "0.3" diff --git a/examples/stm32g0/src/bin/blinky.rs b/examples/stm32g0/src/bin/blinky.rs index 907492b3..f71fe098 100644 --- a/examples/stm32g0/src/bin/blinky.rs +++ b/examples/stm32g0/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32g0/src/bin/button_exti.rs b/examples/stm32g0/src/bin/button_exti.rs index 924feeb3..0832386e 100644 --- a/examples/stm32g0/src/bin/button_exti.rs +++ b/examples/stm32g0/src/bin/button_exti.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml index d3641c48..60c62ad1 100644 --- a/examples/stm32g4/Cargo.toml +++ b/examples/stm32g4/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-stm32g4-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } embassy-hal-common = {version = "0.1.0", path = "../../embassy-hal-common" } diff --git a/examples/stm32g4/src/bin/blinky.rs b/examples/stm32g4/src/bin/blinky.rs index cd488327..ea3c563b 100644 --- a/examples/stm32g4/src/bin/blinky.rs +++ b/examples/stm32g4/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32g4/src/bin/button_exti.rs b/examples/stm32g4/src/bin/button_exti.rs index 24ece992..60dfb362 100644 --- a/examples/stm32g4/src/bin/button_exti.rs +++ b/examples/stm32g4/src/bin/button_exti.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32g4/src/bin/pwm.rs b/examples/stm32g4/src/bin/pwm.rs index dc4e164a..7c16d0a3 100644 --- a/examples/stm32g4/src/bin/pwm.rs +++ b/examples/stm32g4/src/bin/pwm.rs @@ -3,15 +3,15 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; use embassy_stm32::pwm::Channel; use embassy_stm32::time::khz; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index d905031d..8b1999b3 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-stm32h7-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "net", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"] } embedded-io = { version = "0.3.0", features = ["async"] } diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs index d8a5d23d..f50976a3 100644 --- a/examples/stm32h7/src/bin/adc.rs +++ b/examples/stm32h7/src/bin/adc.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Delay, Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Delay, Duration, Timer}; use embassy_stm32::adc::{Adc, SampleTime}; use embassy_stm32::rcc::AdcClockSource; use embassy_stm32::time::mhz; @@ -20,7 +20,7 @@ pub fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, mut p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index 7982f4a0..98ce15cc 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32h7/src/bin/button_exti.rs b/examples/stm32h7/src/bin/button_exti.rs index 24ece992..60dfb362 100644 --- a/examples/stm32h7/src/bin/button_exti.rs +++ b/examples/stm32h7/src/bin/button_exti.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index 0d0179e6..69187182 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs @@ -2,8 +2,8 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::dcmi::{self, *}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::i2c::I2c; @@ -32,7 +32,7 @@ const HEIGHT: usize = 100; static mut FRAME: [u32; WIDTH * HEIGHT / 2] = [0u32; WIDTH * HEIGHT / 2]; -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { defmt::info!("Hello World!"); let mco = Mco::new(p.MCO1, p.PA8, Mco1Source::Hsi, McoClock::Divided(3)); @@ -78,7 +78,7 @@ mod ov7725 { use core::marker::PhantomData; use defmt::Format; - use embassy::time::{Duration, Timer}; + use embassy_executor::time::{Duration, Timer}; use embassy_stm32::rcc::{Mco, McoInstance}; use embedded_hal_async::i2c::I2c; diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 556d472b..4282fced 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs @@ -3,9 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; -use embassy::util::Forever; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_net::tcp::TcpSocket; use embassy_net::{Ipv4Address, Stack, StackResources}; use embassy_stm32::eth::generic_smi::GenericSMI; @@ -14,6 +13,7 @@ use embassy_stm32::peripherals::ETH; use embassy_stm32::rng::Rng; use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_util::Forever; use embedded_io::asynch::Write; use rand_core::RngCore; use {defmt_rtt as _, panic_probe as _}; @@ -28,7 +28,7 @@ macro_rules! forever { type Device = Ethernet<'static, ETH, GenericSMI, 4, 4>; -#[embassy::task] +#[embassy_executor::task] async fn net_task(stack: &'static Stack) -> ! { stack.run().await } @@ -41,7 +41,7 @@ pub fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(spawner: Spawner, p: Peripherals) -> ! { info!("Hello World!"); diff --git a/examples/stm32h7/src/bin/flash.rs b/examples/stm32h7/src/bin/flash.rs index 5f97d2b3..0c477deb 100644 --- a/examples/stm32h7/src/bin/flash.rs +++ b/examples/stm32h7/src/bin/flash.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::flash::Flash; use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello Flash!"); diff --git a/examples/stm32h7/src/bin/fmc.rs b/examples/stm32h7/src/bin/fmc.rs index 27c715ab..5140a6e2 100644 --- a/examples/stm32h7/src/bin/fmc.rs +++ b/examples/stm32h7/src/bin/fmc.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Delay, Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Delay, Duration, Timer}; use embassy_stm32::fmc::Fmc; use embassy_stm32::time::mhz; use embassy_stm32::{Config, Peripherals}; @@ -18,7 +18,7 @@ pub fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index d7c6da5b..f2477c7a 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::low_level::AFType; use embassy_stm32::gpio::Speed; use embassy_stm32::pwm::*; @@ -24,7 +24,7 @@ pub fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs index 6f03b547..83ba3742 100644 --- a/examples/stm32h7/src/bin/mco.rs +++ b/examples/stm32h7/src/bin/mco.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index 730f637e..36ed2e4a 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; use embassy_stm32::pwm::Channel; use embassy_stm32::time::{khz, mhz}; @@ -23,7 +23,7 @@ pub fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32h7/src/bin/rng.rs b/examples/stm32h7/src/bin/rng.rs index 2b42a6af..81fb3d16 100644 --- a/examples/stm32h7/src/bin/rng.rs +++ b/examples/stm32h7/src/bin/rng.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::rng::Rng; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs index 163807d8..19ae5ade 100644 --- a/examples/stm32h7/src/bin/sdmmc.rs +++ b/examples/stm32h7/src/bin/sdmmc.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config, Peripherals}; @@ -15,7 +15,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) -> ! { info!("Hello World!"); diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs index f798b1c9..2fc75c7a 100644 --- a/examples/stm32h7/src/bin/signal.rs +++ b/examples/stm32h7/src/bin/signal.rs @@ -3,15 +3,15 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::channel::signal::Signal; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::Peripherals; +use embassy_util::channel::signal::Signal; use {defmt_rtt as _, panic_probe as _}; static SIGNAL: Signal = Signal::new(); -#[embassy::task] +#[embassy_executor::task] async fn my_sending_task() { let mut counter: u32 = 0; @@ -24,7 +24,7 @@ async fn my_sending_task() { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, _p: Peripherals) { unwrap!(spawner.spawn(my_sending_task())); diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index f2eb5a3b..dc8cb7f4 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs @@ -7,12 +7,12 @@ use core::str::from_utf8; use cortex_m_rt::entry; use defmt::*; -use embassy::executor::Executor; -use embassy::util::Forever; +use embassy_executor::executor::Executor; use embassy_stm32::dma::NoDma; use embassy_stm32::peripherals::SPI3; use embassy_stm32::time::mhz; use embassy_stm32::{spi, Config}; +use embassy_util::Forever; use heapless::String; use {defmt_rtt as _, panic_probe as _}; @@ -24,7 +24,7 @@ pub fn config() -> Config { config } -#[embassy::task] +#[embassy_executor::task] async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) { for n in 0u32.. { let mut write: String<128> = String::new(); diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index d72051fd..2631ed30 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs @@ -7,11 +7,11 @@ use core::str::from_utf8; use cortex_m_rt::entry; use defmt::*; -use embassy::executor::Executor; -use embassy::util::Forever; +use embassy_executor::executor::Executor; use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; use embassy_stm32::time::mhz; use embassy_stm32::{spi, Config}; +use embassy_util::Forever; use heapless::String; use {defmt_rtt as _, panic_probe as _}; @@ -23,7 +23,7 @@ pub fn config() -> Config { config } -#[embassy::task] +#[embassy_executor::task] async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) { for n in 0u32.. { let mut write: String<128> = String::new(); diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs index fc3db5a3..e491fb39 100644 --- a/examples/stm32h7/src/bin/usart.rs +++ b/examples/stm32h7/src/bin/usart.rs @@ -4,13 +4,13 @@ use cortex_m_rt::entry; use defmt::*; -use embassy::executor::Executor; -use embassy::util::Forever; +use embassy_executor::executor::Executor; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; +use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task] +#[embassy_executor::task] async fn main_task() { let p = embassy_stm32::init(Default::default()); diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index d3325b0c..aacda45b 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/src/bin/usart_dma.rs @@ -6,14 +6,14 @@ use core::fmt::Write; use cortex_m_rt::entry; use defmt::*; -use embassy::executor::Executor; -use embassy::util::Forever; +use embassy_executor::executor::Executor; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; +use embassy_util::Forever; use heapless::String; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task] +#[embassy_executor::task] async fn main_task() { let p = embassy_stm32::init(Default::default()); diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index 678d8c91..12bb0ce9 100644 --- a/examples/stm32h7/src/bin/usart_split.rs +++ b/examples/stm32h7/src/bin/usart_split.rs @@ -3,16 +3,16 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::blocking_mutex::raw::ThreadModeRawMutex; -use embassy::channel::mpmc::Channel; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::peripherals::{DMA1_CH1, UART7}; use embassy_stm32::usart::{Config, Uart, UartRx}; use embassy_stm32::Peripherals; +use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_util::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task] +#[embassy_executor::task] async fn writer(mut usart: Uart<'static, UART7, NoDma, NoDma>) { unwrap!(usart.blocking_write(b"Hello Embassy World!\r\n")); info!("wrote Hello, starting echo"); @@ -26,7 +26,7 @@ async fn writer(mut usart: Uart<'static, UART7, NoDma, NoDma>) { static CHANNEL: Channel = Channel::new(); -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) -> ! { info!("Hello World!"); @@ -45,7 +45,7 @@ async fn main(spawner: Spawner, p: Peripherals) -> ! { } } -#[embassy::task] +#[embassy_executor::task] async fn reader(mut rx: UartRx<'static, UART7, DMA1_CH1>) { let mut buf = [0; 8]; loop { diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index d6093963..7edda042 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -8,7 +8,8 @@ default = ["nightly"] nightly = ["embassy-stm32/nightly", "embassy-lora", "lorawan-device", "lorawan", "embedded-io/async"] [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt"], optional = true} diff --git a/examples/stm32l0/src/bin/blinky.rs b/examples/stm32l0/src/bin/blinky.rs index e027192b..8cf21eff 100644 --- a/examples/stm32l0/src/bin/blinky.rs +++ b/examples/stm32l0/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32l0/src/bin/button.rs b/examples/stm32l0/src/bin/button.rs index 43ea8c2a..a5e05c3a 100644 --- a/examples/stm32l0/src/bin/button.rs +++ b/examples/stm32l0/src/bin/button.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index d87870a0..22a096af 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; @@ -15,7 +15,7 @@ fn config() -> embassy_stm32::Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { let button = Input::new(p.PB2, Pull::Up); let mut button = ExtiInput::new(button, p.EXTI2); diff --git a/examples/stm32l0/src/bin/flash.rs b/examples/stm32l0/src/bin/flash.rs index a2fec929..7ad5ae3a 100644 --- a/examples/stm32l0/src/bin/flash.rs +++ b/examples/stm32l0/src/bin/flash.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::flash::Flash; use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello Flash!"); diff --git a/examples/stm32l0/src/bin/lorawan.rs b/examples/stm32l0/src/bin/lorawan.rs index da58e2f7..29e54c1b 100644 --- a/examples/stm32l0/src/bin/lorawan.rs +++ b/examples/stm32l0/src/bin/lorawan.rs @@ -24,8 +24,8 @@ fn config() -> embassy_stm32::Config { config } -#[embassy::main(config = "config()")] -async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { +#[embassy_executor::main(config = "config()")] +async fn main(_spawner: embassy_executor::executor::Spawner, p: Peripherals) { // SPI for sx127x let spi = spi::Spi::new( p.SPI1, diff --git a/examples/stm32l0/src/bin/raw_spawn.rs b/examples/stm32l0/src/bin/raw_spawn.rs index dfe2cddb..cd711a43 100644 --- a/examples/stm32l0/src/bin/raw_spawn.rs +++ b/examples/stm32l0/src/bin/raw_spawn.rs @@ -5,10 +5,10 @@ use core::mem; use cortex_m_rt::entry; use defmt::*; -use embassy::executor::raw::TaskStorage; -use embassy::executor::Executor; -use embassy::time::{Duration, Timer}; -use embassy::util::Forever; +use embassy_executor::executor::raw::TaskStorage; +use embassy_executor::executor::Executor; +use embassy_executor::time::{Duration, Timer}; +use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; async fn run1() { diff --git a/examples/stm32l0/src/bin/spi.rs b/examples/stm32l0/src/bin/spi.rs index dba0b281..74694295 100644 --- a/examples/stm32l0/src/bin/spi.rs +++ b/examples/stm32l0/src/bin/spi.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; @@ -11,7 +11,7 @@ use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World, folks!"); diff --git a/examples/stm32l0/src/bin/usart_dma.rs b/examples/stm32l0/src/bin/usart_dma.rs index 86124163..1c5ce94d 100644 --- a/examples/stm32l0/src/bin/usart_dma.rs +++ b/examples/stm32l0/src/bin/usart_dma.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut usart = Uart::new(p.USART1, p.PB7, p.PB6, p.DMA1_CH2, p.DMA1_CH3, Config::default()); diff --git a/examples/stm32l0/src/bin/usart_irq.rs b/examples/stm32l0/src/bin/usart_irq.rs index 09b1b0b0..b77d97f8 100644 --- a/examples/stm32l0/src/bin/usart_irq.rs +++ b/examples/stm32l0/src/bin/usart_irq.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; use embassy_stm32::{interrupt, Peripherals}; use embedded_io::asynch::{Read, Write}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hi!"); diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index 7fec6057..d69de9c5 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-stm32l1-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } defmt = "0.3" diff --git a/examples/stm32l1/src/bin/blinky.rs b/examples/stm32l1/src/bin/blinky.rs index bace53d9..58306be9 100644 --- a/examples/stm32l1/src/bin/blinky.rs +++ b/examples/stm32l1/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32l1/src/bin/flash.rs b/examples/stm32l1/src/bin/flash.rs index fc519b07..78938fe3 100644 --- a/examples/stm32l1/src/bin/flash.rs +++ b/examples/stm32l1/src/bin/flash.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::flash::Flash; use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello Flash!"); diff --git a/examples/stm32l1/src/bin/spi.rs b/examples/stm32l1/src/bin/spi.rs index 81ccba4e..05e869e7 100644 --- a/examples/stm32l1/src/bin/spi.rs +++ b/examples/stm32l1/src/bin/spi.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; @@ -11,7 +11,7 @@ use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World, folks!"); diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 7d89bf94..8ac974c9 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml @@ -6,7 +6,8 @@ version = "0.1.0" [features] [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5vi", "time-driver-any", "exti", "unstable-traits"] } diff --git a/examples/stm32l4/src/bin/adc.rs b/examples/stm32l4/src/bin/adc.rs index 499ea47d..93a20d5e 100644 --- a/examples/stm32l4/src/bin/adc.rs +++ b/examples/stm32l4/src/bin/adc.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::time::Delay; +use embassy_executor::time::Delay; use embassy_stm32::adc::{Adc, Resolution}; use embassy_stm32::pac; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs index 54f8e03b..3d689b5e 100644 --- a/examples/stm32l4/src/bin/blinky.rs +++ b/examples/stm32l4/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs index 924feeb3..0832386e 100644 --- a/examples/stm32l4/src/bin/button_exti.rs +++ b/examples/stm32l4/src/bin/button_exti.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32l4/src/bin/i2c.rs b/examples/stm32l4/src/bin/i2c.rs index a22b5218..058529ec 100644 --- a/examples/stm32l4/src/bin/i2c.rs +++ b/examples/stm32l4/src/bin/i2c.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::i2c::I2c; use embassy_stm32::time::Hertz; @@ -13,7 +13,7 @@ use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) -> ! { let irq = interrupt::take!(I2C2_EV); let mut i2c = I2c::new(p.I2C2, p.PB10, p.PB11, irq, NoDma, NoDma, Hertz(100_000)); diff --git a/examples/stm32l4/src/bin/i2c_blocking_async.rs b/examples/stm32l4/src/bin/i2c_blocking_async.rs index 6c4a8670..2dae9c2d 100644 --- a/examples/stm32l4/src/bin/i2c_blocking_async.rs +++ b/examples/stm32l4/src/bin/i2c_blocking_async.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; use embassy_embedded_hal::adapter::BlockingAsync; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::i2c::I2c; use embassy_stm32::time::Hertz; @@ -15,7 +15,7 @@ use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) -> ! { let irq = interrupt::take!(I2C2_EV); let i2c = I2c::new(p.I2C2, p.PB10, p.PB11, irq, NoDma, NoDma, Hertz(100_000)); diff --git a/examples/stm32l4/src/bin/i2c_dma.rs b/examples/stm32l4/src/bin/i2c_dma.rs index 48d2e92c..9e71d404 100644 --- a/examples/stm32l4/src/bin/i2c_dma.rs +++ b/examples/stm32l4/src/bin/i2c_dma.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::i2c::I2c; use embassy_stm32::time::Hertz; use embassy_stm32::{interrupt, Peripherals}; @@ -12,7 +12,7 @@ use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) -> ! { let irq = interrupt::take!(I2C2_EV); let mut i2c = I2c::new(p.I2C2, p.PB10, p.PB11, irq, p.DMA1_CH4, p.DMA1_CH5, Hertz(100_000)); diff --git a/examples/stm32l4/src/bin/rng.rs b/examples/stm32l4/src/bin/rng.rs index 7aaa122e..ed47fc6c 100644 --- a/examples/stm32l4/src/bin/rng.rs +++ b/examples/stm32l4/src/bin/rng.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; use embassy_stm32::rng::Rng; use embassy_stm32::{Config, Peripherals}; @@ -22,7 +22,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs index 20a2ff80..e06b29b8 100644 --- a/examples/stm32l4/src/bin/spi_blocking_async.rs +++ b/examples/stm32l4/src/bin/spi_blocking_async.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; use embassy_embedded_hal::adapter::BlockingAsync; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::spi::{Config, Spi}; @@ -13,7 +13,7 @@ use embassy_stm32::Peripherals; use embedded_hal_async::spi::SpiBus; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index d0c3609a..e44754be 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32l4/src/bin/usart_dma.rs b/examples/stm32l4/src/bin/usart_dma.rs index 7ae7e9e1..fdd5a85e 100644 --- a/examples/stm32l4/src/bin/usart_dma.rs +++ b/examples/stm32l4/src/bin/usart_dma.rs @@ -5,14 +5,14 @@ use core::fmt::Write; use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; use heapless::String; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 85eac7b8..6466994e 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml @@ -6,7 +6,8 @@ version = "0.1.0" [features] [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"] } diff --git a/examples/stm32l5/src/bin/button_exti.rs b/examples/stm32l5/src/bin/button_exti.rs index c7a6cfa2..99462e59 100644 --- a/examples/stm32l5/src/bin/button_exti.rs +++ b/examples/stm32l5/src/bin/button_exti.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32l5/src/bin/rng.rs b/examples/stm32l5/src/bin/rng.rs index d3627d2c..45094374 100644 --- a/examples/stm32l5/src/bin/rng.rs +++ b/examples/stm32l5/src/bin/rng.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; use embassy_stm32::rng::Rng; use embassy_stm32::{Config, Peripherals}; @@ -21,7 +21,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index d711616e..9e1df15d 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs @@ -7,10 +7,7 @@ use core::sync::atomic::{AtomicBool, Ordering}; use core::task::Waker; use defmt::*; -use embassy::blocking_mutex::raw::ThreadModeRawMutex; -use embassy::channel::mpmc::Channel; -use embassy::executor::Spawner; -use embassy::util::Forever; +use embassy_executor::executor::Spawner; use embassy_net::tcp::TcpSocket; use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; use embassy_stm32::rcc::*; @@ -20,6 +17,9 @@ use embassy_stm32::usb::Driver; use embassy_stm32::{interrupt, Config, Peripherals}; use embassy_usb::{Builder, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; +use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_util::channel::mpmc::Channel; +use embassy_util::Forever; use embedded_io::asynch::{Read, Write}; use rand_core::RngCore; use {defmt_rtt as _, panic_probe as _}; @@ -34,12 +34,12 @@ macro_rules! forever { }}; } -#[embassy::task] +#[embassy_executor::task] async fn usb_task(mut device: UsbDevice<'static, MyDriver>) -> ! { device.run().await } -#[embassy::task] +#[embassy_executor::task] async fn usb_ncm_rx_task(mut class: Receiver<'static, MyDriver>) { loop { warn!("WAITING for connection"); @@ -68,7 +68,7 @@ async fn usb_ncm_rx_task(mut class: Receiver<'static, MyDriver>) { } } -#[embassy::task] +#[embassy_executor::task] async fn usb_ncm_tx_task(mut class: Sender<'static, MyDriver>) { loop { let pkt = TX_CHANNEL.recv().await; @@ -78,7 +78,7 @@ async fn usb_ncm_tx_task(mut class: Sender<'static, MyDriver>) { } } -#[embassy::task] +#[embassy_executor::task] async fn net_task(stack: &'static Stack) -> ! { stack.run().await } @@ -93,7 +93,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(spawner: Spawner, p: Peripherals) { // Create the driver, from the HAL. let irq = interrupt::take!(USB_FS); diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs index d139e6bb..6aac0088 100644 --- a/examples/stm32l5/src/bin/usb_hid_mouse.rs +++ b/examples/stm32l5/src/bin/usb_hid_mouse.rs @@ -4,8 +4,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::rcc::*; use embassy_stm32::time::Hertz; use embassy_stm32::usb::Driver; @@ -27,7 +27,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { // Create the driver, from the HAL. let irq = interrupt::take!(USB_FS); diff --git a/examples/stm32l5/src/bin/usb_serial.rs b/examples/stm32l5/src/bin/usb_serial.rs index 8dab001c..508bce8a 100644 --- a/examples/stm32l5/src/bin/usb_serial.rs +++ b/examples/stm32l5/src/bin/usb_serial.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::{panic, *}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::rcc::*; use embassy_stm32::time::Hertz; use embassy_stm32::usb::{Driver, Instance}; @@ -24,7 +24,7 @@ fn config() -> Config { config } -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml index 22e2e09a..4ce95be4 100644 --- a/examples/stm32u5/Cargo.toml +++ b/examples/stm32u5/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-stm32u5-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } defmt = "0.3" diff --git a/examples/stm32u5/src/bin/blinky.rs b/examples/stm32u5/src/bin/blinky.rs index 4910e0b9..4f3eabc5 100644 --- a/examples/stm32u5/src/bin/blinky.rs +++ b/examples/stm32u5/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) -> ! { info!("Hello World!"); diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index 812d638f..dc9107dd 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-stm32wb-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55cc", "time-driver-any", "exti"] } defmt = "0.3" diff --git a/examples/stm32wb/src/bin/blinky.rs b/examples/stm32wb/src/bin/blinky.rs index 8ab9b749..3d8e8391 100644 --- a/examples/stm32wb/src/bin/blinky.rs +++ b/examples/stm32wb/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32wb/src/bin/button_exti.rs b/examples/stm32wb/src/bin/button_exti.rs index 2ddeb887..41afaf4d 100644 --- a/examples/stm32wb/src/bin/button_exti.rs +++ b/examples/stm32wb/src/bin/button_exti.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 6be36073..00d63f02 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-stm32wl-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "subghz", "unstable-pac", "exti"] } embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt"] } diff --git a/examples/stm32wl/src/bin/blinky.rs b/examples/stm32wl/src/bin/blinky.rs index 9393af1c..e764b4cc 100644 --- a/examples/stm32wl/src/bin/blinky.rs +++ b/examples/stm32wl/src/bin/blinky.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32wl/src/bin/button_exti.rs b/examples/stm32wl/src/bin/button_exti.rs index 7d5c1b3c..9f143597 100644 --- a/examples/stm32wl/src/bin/button_exti.rs +++ b/examples/stm32wl/src/bin/button_exti.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs index 6531feae..46183b8a 100644 --- a/examples/stm32wl/src/bin/flash.rs +++ b/examples/stm32wl/src/bin/flash.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::flash::Flash; use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello Flash!"); diff --git a/examples/stm32wl/src/bin/lorawan.rs b/examples/stm32wl/src/bin/lorawan.rs index 158c17e1..2db022ea 100644 --- a/examples/stm32wl/src/bin/lorawan.rs +++ b/examples/stm32wl/src/bin/lorawan.rs @@ -23,8 +23,8 @@ fn config() -> embassy_stm32::Config { config } -#[embassy::main(config = "config()")] -async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { +#[embassy_executor::main(config = "config()")] +async fn main(_spawner: embassy_executor::executor::Spawner, p: Peripherals) { unsafe { pac::RCC.ccipr().modify(|w| w.set_rngsel(0b01)) } let ctrl1 = Output::new(p.PC3.degrade(), Level::High, Speed::High); diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs index c5f6e502..775dfbbf 100644 --- a/examples/stm32wl/src/bin/subghz.rs +++ b/examples/stm32wl/src/bin/subghz.rs @@ -6,13 +6,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::channel::signal::Signal; use embassy_stm32::dma::NoDma; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::interrupt::{Interrupt, InterruptExt}; use embassy_stm32::subghz::*; use embassy_stm32::{interrupt, Peripherals}; +use embassy_util::channel::signal::Signal; use {defmt_rtt as _, panic_probe as _}; const PING_DATA: &str = "PING"; @@ -57,8 +57,8 @@ fn config() -> embassy_stm32::Config { config } -#[embassy::main(config = "config()")] -async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { +#[embassy_executor::main(config = "config()")] +async fn main(_spawner: embassy_executor::executor::Spawner, p: Peripherals) { let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); let mut led2 = Output::new(p.PB9, Level::Low, Speed::Low); let mut led3 = Output::new(p.PB11, Level::Low, Speed::Low); diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml index 347252fa..4e26f023 100644 --- a/examples/wasm/Cargo.toml +++ b/examples/wasm/Cargo.toml @@ -7,7 +7,8 @@ version = "0.1.0" crate-type = ["cdylib"] [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["log", "wasm", "nightly"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "wasm", "nightly"] } wasm-logger = "0.2.0" wasm-bindgen = "0.2" diff --git a/examples/wasm/src/lib.rs b/examples/wasm/src/lib.rs index 61757ebd..2e961e65 100644 --- a/examples/wasm/src/lib.rs +++ b/examples/wasm/src/lib.rs @@ -1,10 +1,10 @@ #![feature(type_alias_impl_trait)] #![allow(incomplete_features)] -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; -#[embassy::task] +#[embassy_executor::task] async fn ticker() { let window = web_sys::window().expect("no global `window` exists"); @@ -24,7 +24,7 @@ async fn ticker() { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner) { wasm_logger::init(wasm_logger::Config::default()); spawner.spawn(ticker()).unwrap(); diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index fe791d0d..d19243b9 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -4,7 +4,8 @@ name = "embassy-rp-tests" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt"] } embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits"] } defmt = "0.3.0" diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index 0be9d9f2..6f6baf77 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::{assert, *}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_rp::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull}; use embassy_rp::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/tests/rp/src/bin/gpio_async.rs b/tests/rp/src/bin/gpio_async.rs index 46df4105..1098682a 100644 --- a/tests/rp/src/bin/gpio_async.rs +++ b/tests/rp/src/bin/gpio_async.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::{assert, *}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Instant, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Instant, Timer}; use embassy_rp::gpio::{Input, Level, Output, Pull}; use embassy_rp::Peripherals; use futures::future::join; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("embassy-rp gpio_async test"); diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index df8d6444..c1cca99d 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -13,7 +13,8 @@ stm32wb55rg = ["embassy-stm32/stm32wb55rg"] # Nucleo stm32u585ai = ["embassy-stm32/stm32u585ai"] # IoT board [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "time-tick-32768hz"] } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "memory-x", "time-driver-tim2"] } defmt = "0.3.0" diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index 37cfe7cf..8eab731b 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -5,12 +5,12 @@ #[path = "../example_common.rs"] mod example_common; use defmt::assert; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull, Speed}; use embassy_stm32::Peripherals; use example_common::*; -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index 049ba1e9..6d38b0bb 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs @@ -5,14 +5,14 @@ #[path = "../example_common.rs"] mod example_common; use defmt::assert_eq; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::spi::{self, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; use example_common::*; -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index 64337886..8147c5f0 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs @@ -5,13 +5,13 @@ #[path = "../example_common.rs"] mod example_common; use defmt::assert_eq; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::spi::{self, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; use example_common::*; -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/tests/stm32/src/bin/timer.rs b/tests/stm32/src/bin/timer.rs index 002a8a4d..76b07ca1 100644 --- a/tests/stm32/src/bin/timer.rs +++ b/tests/stm32/src/bin/timer.rs @@ -5,12 +5,12 @@ #[path = "../example_common.rs"] mod example_common; use defmt::assert; -use embassy::executor::Spawner; -use embassy::time::{Duration, Instant, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Instant, Timer}; use embassy_stm32::Peripherals; use example_common::*; -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, _p: Peripherals) { info!("Hello World!"); diff --git a/tests/stm32/src/bin/usart.rs b/tests/stm32/src/bin/usart.rs index c3468290..7b60e4b2 100644 --- a/tests/stm32/src/bin/usart.rs +++ b/tests/stm32/src/bin/usart.rs @@ -5,13 +5,13 @@ #[path = "../example_common.rs"] mod example_common; use defmt::assert_eq; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; use example_common::*; -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); diff --git a/tests/stm32/src/bin/usart_dma.rs b/tests/stm32/src/bin/usart_dma.rs index 9946f4a5..323c41ca 100644 --- a/tests/stm32/src/bin/usart_dma.rs +++ b/tests/stm32/src/bin/usart_dma.rs @@ -5,12 +5,12 @@ #[path = "../example_common.rs"] mod example_common; use defmt::assert_eq; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; use example_common::*; -#[embassy::main(config = "config()")] +#[embassy_executor::main(config = "config()")] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!");