Skip to content

Commit

Permalink
refactor(embassy-common): move crate re-exports to a dedicated module
Browse files Browse the repository at this point in the history
  • Loading branch information
ROMemories committed Sep 20, 2024
1 parent 0972799 commit db9ea57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/riot-rs-embassy-common/src/i2c/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl From<NoAcknowledgeSource> for embedded_hal::i2c::NoAcknowledgeSource {
#[macro_export]
macro_rules! impl_async_i2c_for_driver_enum {
($driver_enum:ident, $( $peripheral:ident ),*) => {
impl embedded_hal_async::i2c::I2c for $driver_enum {
impl $crate::reexports::embedded_hal_async::i2c::I2c for $driver_enum {
async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> {
match self {
$(
Expand Down Expand Up @@ -171,13 +171,13 @@ macro_rules! impl_async_i2c_for_driver_enum {
#[macro_export]
macro_rules! handle_i2c_timeout_res {
($i2c:ident, $op:ident, $address:ident, $( $param:ident ),+) => {{
let res = $crate::embassy_futures::select::select(
let res = $crate::reexports::embassy_futures::select::select(
// Disambiguate between the trait methods and the direct methods.
$crate::embedded_hal_async::i2c::I2c::$op(&mut $i2c.twim, $address, $( $param ),+),
$crate::embassy_time::Timer::after($crate::i2c::controller::I2C_TIMEOUT),
$crate::reexports::embedded_hal_async::i2c::I2c::$op(&mut $i2c.twim, $address, $( $param ),+),
$crate::reexports::embassy_time::Timer::after($crate::i2c::controller::I2C_TIMEOUT),
).await;

if let $crate::embassy_futures::select::Either::First(op) = res {
if let $crate::reexports::embassy_futures::select::Either::First(op) = res {
// `from_error` is defined in each arch
op.map_err(from_error)
} else {
Expand Down
11 changes: 7 additions & 4 deletions src/riot-rs-embassy-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ pub mod executor_swi;
#[cfg(feature = "i2c")]
pub mod i2c;

// Used by macros provided by this crate.
pub use embassy_futures;
pub use embassy_time;
pub mod reexports {
//! Crate re-exports.

pub use embedded_hal_async;
// Used by macros provided by this crate.
pub use embassy_futures;
pub use embassy_time;
pub use embedded_hal_async;
}

0 comments on commit db9ea57

Please sign in to comment.