Re-export the esp_hal_procmacros::main macro from esp-hal-embassy instead of esp-hal (#1828)

* Re-export the `main` procmacro from `esp-hal-embassy` rather than `esp-hal`

* Fix documentation warnings

* Flatten the `time_driver` module

* clippy

* Update `CHANGELOG.md`
This commit is contained in:
Jesse Braham 2024-07-18 09:31:03 +00:00 committed by GitHub
parent 02c99786f9
commit 776f34cff1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
32 changed files with 38 additions and 43 deletions

View File

@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- This package now re-exports the `esp_hal_procmacros::main` macro (#1828)
### Changed ### Changed
### Fixed ### Fixed

View File

@ -19,6 +19,7 @@ embassy-executor = { version = "0.5.0", optional = true }
embassy-time-driver = { version = "0.1.0", features = [ "tick-hz-1_000_000" ] } embassy-time-driver = { version = "0.1.0", features = [ "tick-hz-1_000_000" ] }
esp-hal = { version = "0.19.0", path = "../esp-hal" } esp-hal = { version = "0.19.0", path = "../esp-hal" }
log = { version = "0.4.22", optional = true } log = { version = "0.4.22", optional = true }
macros = { version = "0.12.0", features = ["embassy"], package = "esp-hal-procmacros", path = "../esp-hal-procmacros" }
portable-atomic = "1.6.0" portable-atomic = "1.6.0"
[build-dependencies] [build-dependencies]

View File

@ -97,12 +97,14 @@ impl<const SWI: u8> InterruptExecutor<SWI> {
/// The executor keeps running in the background through the interrupt. /// The executor keeps running in the background through the interrupt.
/// ///
/// This returns a [`SendSpawner`] you can use to spawn tasks on it. A /// This returns a [`SendSpawner`] you can use to spawn tasks on it. A
/// [`SendSpawner`] is returned instead of a [`Spawner`] because the /// [`SendSpawner`] is returned instead of a
/// [`Spawner`](embassy_executor::Spawner) because the
/// executor effectively runs in a different "thread" (the interrupt), /// executor effectively runs in a different "thread" (the interrupt),
/// so spawning tasks on it is effectively sending them. /// so spawning tasks on it is effectively sending them.
/// ///
/// To obtain a [`Spawner`] for this executor, use /// To obtain a [`Spawner`](embassy_executor::Spawner) for this executor,
/// [`Spawner::for_current_executor()`] from a task running in it. /// use [`Spawner::for_current_executor`](embassy_executor::Spawner::for_current_executor)
/// from a task running in it.
pub fn start(&'static mut self, priority: interrupt::Priority) -> SendSpawner { pub fn start(&'static mut self, priority: interrupt::Priority) -> SendSpawner {
if self if self
.core .core

View File

@ -37,6 +37,7 @@
mod fmt; mod fmt;
use esp_hal::clock::Clocks; use esp_hal::clock::Clocks;
pub use macros::main;
#[cfg(feature = "executors")] #[cfg(feature = "executors")]
pub use self::executor::{Executor, InterruptExecutor}; pub use self::executor::{Executor, InterruptExecutor};

View File

@ -157,7 +157,7 @@ pub(crate) mod main {
pub fn main() -> TokenStream { pub fn main() -> TokenStream {
quote! { quote! {
#[entry] #[esp_hal::entry]
fn main() -> ! { fn main() -> ! {
let mut executor = ::esp_hal_embassy::Executor::new(); let mut executor = ::esp_hal_embassy::Executor::new();
let executor = unsafe { __make_static(&mut executor) }; let executor = unsafe { __make_static(&mut executor) };

View File

@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed ### Removed
- This package no longer re-exports the `esp_hal_procmacros::main` macro (#1828)
## [0.19.0] - 2024-07-15 ## [0.19.0] - 2024-07-15
### Added ### Added

View File

@ -42,7 +42,7 @@ log = { version = "0.4.22", optional = true }
nb = "1.1.0" nb = "1.1.0"
paste = "1.0.15" paste = "1.0.15"
portable-atomic = { version = "1.6.0", default-features = false } portable-atomic = { version = "1.6.0", default-features = false }
procmacros = { version = "0.12.0", features = ["embassy", "enum-dispatch", "interrupt", "ram"], package = "esp-hal-procmacros", path = "../esp-hal-procmacros" } procmacros = { version = "0.12.0", features = ["enum-dispatch", "interrupt", "ram"], package = "esp-hal-procmacros", path = "../esp-hal-procmacros" }
riscv = { version = "0.11.1", optional = true } riscv = { version = "0.11.1", optional = true }
strum = { version = "0.26.3", default-features = false, features = ["derive"] } strum = { version = "0.26.3", default-features = false, features = ["derive"] }
void = { version = "1.0.2", default-features = false } void = { version = "1.0.2", default-features = false }

View File

@ -15,7 +15,6 @@ use esp_backtrace as _;
use esp_hal::{ use esp_hal::{
clock::ClockControl, clock::ClockControl,
peripherals::Peripherals, peripherals::Peripherals,
prelude::*,
system::SystemControl, system::SystemControl,
timer::{timg::TimerGroup, ErasedTimer, OneShotTimer}, timer::{timg::TimerGroup, ErasedTimer, OneShotTimer},
}; };
@ -38,7 +37,7 @@ async fn run() {
} }
} }
#[main] #[esp_hal_embassy::main]
async fn main(spawner: Spawner) { async fn main(spawner: Spawner) {
esp_println::logger::init_logger_from_env(); esp_println::logger::init_logger_from_env();

View File

@ -40,7 +40,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM); let system = SystemControl::new(peripherals.SYSTEM);

View File

@ -40,7 +40,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM); let system = SystemControl::new(peripherals.SYSTEM);

View File

@ -42,7 +42,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
println!("Init!"); println!("Init!");
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();

View File

@ -64,7 +64,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
println!("Init!"); println!("Init!");
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();

View File

@ -63,7 +63,7 @@ async fn control_led(
} }
} }
#[main] #[esp_hal_embassy::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM); let system = SystemControl::new(peripherals.SYSTEM);

View File

@ -11,7 +11,7 @@
//! demonstrates that this task will continue to run even while the low //! demonstrates that this task will continue to run even while the low
//! priority blocking task is running. //! priority blocking task is running.
// The thread-executor is created by the `#[main]` macro and is used to spawn `low_prio_async` and `low_prio_blocking`. // The thread-executor is created by the `#[esp_hal_embassy::main]` macro and is used to spawn `low_prio_async` and `low_prio_blocking`.
// The interrupt-executor is created in `main` and is used to spawn `high_prio`. // The interrupt-executor is created in `main` and is used to spawn `high_prio`.
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
@ -27,7 +27,6 @@ use esp_hal::{
clock::ClockControl, clock::ClockControl,
interrupt::Priority, interrupt::Priority,
peripherals::Peripherals, peripherals::Peripherals,
prelude::*,
system::SystemControl, system::SystemControl,
timer::{/*systimer::SystemTimer,*/ timg::TimerGroup, ErasedTimer, OneShotTimer}, timer::{/*systimer::SystemTimer,*/ timg::TimerGroup, ErasedTimer, OneShotTimer},
}; };
@ -80,7 +79,7 @@ async fn low_prio_async() {
} }
} }
#[main] #[esp_hal_embassy::main]
async fn main(low_prio_spawner: Spawner) { async fn main(low_prio_spawner: Spawner) {
esp_println::logger::init_logger_from_env(); esp_println::logger::init_logger_from_env();
println!("Init!"); println!("Init!");

View File

@ -36,7 +36,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
esp_println::println!("Init!"); esp_println::println!("Init!");
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();

View File

@ -47,7 +47,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
esp_println::println!("Init!"); esp_println::println!("Init!");
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();

View File

@ -49,7 +49,7 @@ async fn signal_task(mut pin: Output<'static, Gpio5>) {
} }
} }
#[main] #[esp_hal_embassy::main]
async fn main(spawner: Spawner) { async fn main(spawner: Spawner) {
println!("Init!"); println!("Init!");
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();

View File

@ -35,7 +35,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
println!("Init!"); println!("Init!");
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();

View File

@ -16,7 +16,6 @@ use esp_hal::{
clock::ClockControl, clock::ClockControl,
gpio::Io, gpio::Io,
peripherals::{Peripherals, UART0}, peripherals::{Peripherals, UART0},
prelude::*,
system::SystemControl, system::SystemControl,
timer::{timg::TimerGroup, ErasedTimer, OneShotTimer}, timer::{timg::TimerGroup, ErasedTimer, OneShotTimer},
uart::{ uart::{
@ -88,7 +87,7 @@ async fn reader(
} }
} }
#[main] #[esp_hal_embassy::main]
async fn main(spawner: Spawner) { async fn main(spawner: Spawner) {
esp_println::println!("Init!"); esp_println::println!("Init!");
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();

View File

@ -46,7 +46,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
esp_println::println!("Init!"); esp_println::println!("Init!");
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();

View File

@ -29,7 +29,6 @@ use esp_hal::{
gpio::Io, gpio::Io,
interrupt, interrupt,
peripherals::{self, Peripherals, TWAI0}, peripherals::{self, Peripherals, TWAI0},
prelude::*,
system::SystemControl, system::SystemControl,
timer::{timg::TimerGroup, ErasedTimer, OneShotTimer}, timer::{timg::TimerGroup, ErasedTimer, OneShotTimer},
twai::{self, EspTwaiFrame, TwaiRx, TwaiTx}, twai::{self, EspTwaiFrame, TwaiRx, TwaiTx},
@ -93,7 +92,7 @@ async fn transmitter(
} }
} }
#[main] #[esp_hal_embassy::main]
async fn main(spawner: Spawner) { async fn main(spawner: Spawner) {
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM); let system = SystemControl::new(peripherals.SYSTEM);

View File

@ -43,7 +43,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(_spawner: Spawner) -> () { async fn main(_spawner: Spawner) -> () {
esp_println::println!("Init!"); esp_println::println!("Init!");
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();

View File

@ -14,7 +14,6 @@ use esp_backtrace as _;
use esp_hal::{ use esp_hal::{
clock::ClockControl, clock::ClockControl,
peripherals::Peripherals, peripherals::Peripherals,
prelude::*,
system::SystemControl, system::SystemControl,
timer::{timg::TimerGroup, ErasedTimer, OneShotTimer}, timer::{timg::TimerGroup, ErasedTimer, OneShotTimer},
usb_serial_jtag::{UsbSerialJtag, UsbSerialJtagRx, UsbSerialJtagTx}, usb_serial_jtag::{UsbSerialJtag, UsbSerialJtagRx, UsbSerialJtagTx},
@ -73,7 +72,7 @@ async fn reader(
} }
} }
#[main] #[esp_hal_embassy::main]
async fn main(spawner: Spawner) -> () { async fn main(spawner: Spawner) -> () {
esp_println::println!("Init!"); esp_println::println!("Init!");
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();

View File

@ -15,7 +15,6 @@ use esp_hal::{
clock::ClockControl, clock::ClockControl,
gpio::{Input, Io, Pull}, gpio::{Input, Io, Pull},
peripherals::Peripherals, peripherals::Peripherals,
prelude::*,
system::SystemControl, system::SystemControl,
timer::{timg::TimerGroup, ErasedTimer, OneShotTimer}, timer::{timg::TimerGroup, ErasedTimer, OneShotTimer},
}; };
@ -30,7 +29,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
esp_println::println!("Init!"); esp_println::println!("Init!");
let peripherals = Peripherals::take(); let peripherals = Peripherals::take();

View File

@ -30,7 +30,6 @@ use esp_backtrace as _;
use esp_hal::{ use esp_hal::{
clock::ClockControl, clock::ClockControl,
peripherals::Peripherals, peripherals::Peripherals,
prelude::*,
rng::Rng, rng::Rng,
system::SystemControl, system::SystemControl,
timer::{ErasedTimer, OneShotTimer, PeriodicTimer}, timer::{ErasedTimer, OneShotTimer, PeriodicTimer},
@ -60,7 +59,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(spawner: Spawner) -> ! { async fn main(spawner: Spawner) -> ! {
esp_println::logger::init_logger_from_env(); esp_println::logger::init_logger_from_env();

View File

@ -33,7 +33,6 @@ use esp_backtrace as _;
use esp_hal::{ use esp_hal::{
clock::ClockControl, clock::ClockControl,
peripherals::Peripherals, peripherals::Peripherals,
prelude::*,
rng::Rng, rng::Rng,
system::SystemControl, system::SystemControl,
timer::{ErasedTimer, OneShotTimer, PeriodicTimer}, timer::{ErasedTimer, OneShotTimer, PeriodicTimer},
@ -68,7 +67,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(spawner: Spawner) -> ! { async fn main(spawner: Spawner) -> ! {
esp_println::logger::init_logger_from_env(); esp_println::logger::init_logger_from_env();

View File

@ -24,7 +24,6 @@ use esp_backtrace as _;
use esp_hal::{ use esp_hal::{
clock::ClockControl, clock::ClockControl,
peripherals::Peripherals, peripherals::Peripherals,
prelude::*,
rng::Rng, rng::Rng,
system::SystemControl, system::SystemControl,
timer::{ErasedTimer, OneShotTimer, PeriodicTimer}, timer::{ErasedTimer, OneShotTimer, PeriodicTimer},
@ -70,7 +69,7 @@ const UPLOAD_DOWNLOAD_PORT: u16 = 4323;
static mut RX_BUFFER: [u8; RX_BUFFER_SIZE] = [0; RX_BUFFER_SIZE]; static mut RX_BUFFER: [u8; RX_BUFFER_SIZE] = [0; RX_BUFFER_SIZE];
static mut TX_BUFFER: [u8; TX_BUFFER_SIZE] = [0; TX_BUFFER_SIZE]; static mut TX_BUFFER: [u8; TX_BUFFER_SIZE] = [0; TX_BUFFER_SIZE];
#[main] #[esp_hal_embassy::main]
async fn main(spawner: Spawner) -> ! { async fn main(spawner: Spawner) -> ! {
esp_println::logger::init_logger_from_env(); esp_println::logger::init_logger_from_env();

View File

@ -30,7 +30,6 @@ use esp_hal::{
clock::ClockControl, clock::ClockControl,
gpio::{Input, Io, Pull}, gpio::{Input, Io, Pull},
peripherals::*, peripherals::*,
prelude::*,
rng::Rng, rng::Rng,
system::SystemControl, system::SystemControl,
timer::{ErasedTimer, OneShotTimer, PeriodicTimer}, timer::{ErasedTimer, OneShotTimer, PeriodicTimer},
@ -48,7 +47,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(_spawner: Spawner) -> ! { async fn main(_spawner: Spawner) -> ! {
esp_println::logger::init_logger_from_env(); esp_println::logger::init_logger_from_env();

View File

@ -20,7 +20,6 @@ use esp_backtrace as _;
use esp_hal::{ use esp_hal::{
clock::ClockControl, clock::ClockControl,
peripherals::Peripherals, peripherals::Peripherals,
prelude::*,
rng::Rng, rng::Rng,
system::SystemControl, system::SystemControl,
timer::{ErasedTimer, OneShotTimer, PeriodicTimer}, timer::{ErasedTimer, OneShotTimer, PeriodicTimer},
@ -53,7 +52,7 @@ macro_rules! mk_static {
const SSID: &str = env!("SSID"); const SSID: &str = env!("SSID");
const PASSWORD: &str = env!("PASSWORD"); const PASSWORD: &str = env!("PASSWORD");
#[main] #[esp_hal_embassy::main]
async fn main(spawner: Spawner) -> ! { async fn main(spawner: Spawner) -> ! {
esp_println::logger::init_logger_from_env(); esp_println::logger::init_logger_from_env();

View File

@ -17,7 +17,6 @@ use esp_backtrace as _;
use esp_hal::{ use esp_hal::{
clock::ClockControl, clock::ClockControl,
peripherals::Peripherals, peripherals::Peripherals,
prelude::*,
rng::Rng, rng::Rng,
system::SystemControl, system::SystemControl,
timer::{ErasedTimer, OneShotTimer, PeriodicTimer}, timer::{ErasedTimer, OneShotTimer, PeriodicTimer},
@ -39,7 +38,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(_spawner: Spawner) -> ! { async fn main(_spawner: Spawner) -> ! {
esp_println::logger::init_logger_from_env(); esp_println::logger::init_logger_from_env();

View File

@ -17,7 +17,6 @@ use esp_backtrace as _;
use esp_hal::{ use esp_hal::{
clock::ClockControl, clock::ClockControl,
peripherals::Peripherals, peripherals::Peripherals,
prelude::*,
rng::Rng, rng::Rng,
system::SystemControl, system::SystemControl,
timer::{ErasedTimer, OneShotTimer, PeriodicTimer}, timer::{ErasedTimer, OneShotTimer, PeriodicTimer},
@ -39,7 +38,7 @@ macro_rules! mk_static {
}}; }};
} }
#[main] #[esp_hal_embassy::main]
async fn main(spawner: Spawner) -> ! { async fn main(spawner: Spawner) -> ! {
esp_println::logger::init_logger_from_env(); esp_println::logger::init_logger_from_env();