embassy-macros: Use defmt::unwrap!
when spawning embassy::main
But only when `defmt` feature is enabled.
This commit is contained in:
parent
40e7176e13
commit
a3b56a3764
2 changed files with 9 additions and 1 deletions
|
@ -364,7 +364,7 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
#chip_setup
|
#chip_setup
|
||||||
|
|
||||||
executor.run(|spawner| {
|
executor.run(|spawner| {
|
||||||
spawner.spawn(__embassy_main(spawner, p)).unwrap();
|
spawner.must_spawn(__embassy_main(spawner, p));
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,14 @@ impl Spawner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Used by the `embassy_macros::main!` macro to throw an error when spawn
|
||||||
|
/// fails. This is here to allow conditional use of `defmt::unwrap!`
|
||||||
|
/// without introducing a `defmt` feature in the `embassy_macros` package,
|
||||||
|
/// which would require use of `-Z namespaced-features`.
|
||||||
|
pub fn must_spawn<F>(&self, token: SpawnToken<F>) -> () {
|
||||||
|
unwrap!(self.spawn(token));
|
||||||
|
}
|
||||||
|
|
||||||
/// Convert this Spawner to a SendSpawner. This allows you to send the
|
/// Convert this Spawner to a SendSpawner. This allows you to send the
|
||||||
/// spawner to other threads, but the spawner loses the ability to spawn
|
/// spawner to other threads, but the spawner loses the ability to spawn
|
||||||
/// non-Send tasks.
|
/// non-Send tasks.
|
||||||
|
|
Loading…
Reference in a new issue