stm32: consolidate functionality into new pkg

This commit is contained in:
xoviat
2021-03-19 15:26:20 -05:00
parent c8d90f3e75
commit 03ecc91d55
11 changed files with 208 additions and 314 deletions

View File

@ -11,27 +11,27 @@ defmt-info = [ ]
defmt-warn = [ ]
defmt-error = [ ]
stm32f401 = ["stm32f4xx-hal/stm32f401"]
stm32f405 = ["stm32f4xx-hal/stm32f405"]
stm32f407 = ["stm32f4xx-hal/stm32f407"]
stm32f410 = ["stm32f4xx-hal/stm32f410"]
stm32f411 = ["stm32f4xx-hal/stm32f411"]
stm32f412 = ["stm32f4xx-hal/stm32f412"]
stm32f413 = ["stm32f4xx-hal/stm32f413"]
stm32f415 = ["stm32f4xx-hal/stm32f405"]
stm32f417 = ["stm32f4xx-hal/stm32f407"]
stm32f423 = ["stm32f4xx-hal/stm32f413"]
stm32f427 = ["stm32f4xx-hal/stm32f427"]
stm32f429 = ["stm32f4xx-hal/stm32f429"]
stm32f437 = ["stm32f4xx-hal/stm32f427"]
stm32f439 = ["stm32f4xx-hal/stm32f429"]
stm32f446 = ["stm32f4xx-hal/stm32f446"]
stm32f469 = ["stm32f4xx-hal/stm32f469"]
stm32f479 = ["stm32f4xx-hal/stm32f469"]
stm32f401 = ["stm32f4xx-hal/stm32f401", "embassy-stm32/stm32f401"]
stm32f405 = ["stm32f4xx-hal/stm32f405", "embassy-stm32/stm32f405"]
stm32f407 = ["stm32f4xx-hal/stm32f407", "embassy-stm32/stm32f407"]
stm32f410 = ["stm32f4xx-hal/stm32f410", "embassy-stm32/stm32f410"]
stm32f411 = ["stm32f4xx-hal/stm32f411", "embassy-stm32/stm32f411"]
stm32f412 = ["stm32f4xx-hal/stm32f412", "embassy-stm32/stm32f412"]
stm32f413 = ["stm32f4xx-hal/stm32f413", "embassy-stm32/stm32f413"]
stm32f415 = ["stm32f4xx-hal/stm32f405", "embassy-stm32/stm32f415"]
stm32f417 = ["stm32f4xx-hal/stm32f407", "embassy-stm32/stm32f417"]
stm32f423 = ["stm32f4xx-hal/stm32f413", "embassy-stm32/stm32f423"]
stm32f427 = ["stm32f4xx-hal/stm32f427", "embassy-stm32/stm32f427"]
stm32f429 = ["stm32f4xx-hal/stm32f429", "embassy-stm32/stm32f429"]
stm32f437 = ["stm32f4xx-hal/stm32f427", "embassy-stm32/stm32f437"]
stm32f439 = ["stm32f4xx-hal/stm32f429", "embassy-stm32/stm32f439"]
stm32f446 = ["stm32f4xx-hal/stm32f446", "embassy-stm32/stm32f446"]
stm32f469 = ["stm32f4xx-hal/stm32f469", "embassy-stm32/stm32f469"]
stm32f479 = ["stm32f4xx-hal/stm32f469", "embassy-stm32/stm32f479"]
[dependencies]
embassy = { version = "0.1.0", path = "../embassy" }
embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32" }
defmt = { version = "0.2.0", optional = true }
log = { version = "0.4.11", optional = true }
cortex-m-rt = "0.6.13"

View File

@ -1,114 +0,0 @@
#![macro_use]
#![allow(clippy::module_inception)]
#![allow(unused)]
#[cfg(all(feature = "defmt", feature = "log"))]
compile_error!("You may not enable both `defmt` and `log` features.");
pub use fmt::*;
#[cfg(feature = "defmt")]
mod fmt {
pub use defmt::{
assert, assert_eq, assert_ne, debug, debug_assert, debug_assert_eq, debug_assert_ne, error,
info, panic, todo, trace, unreachable, unwrap, warn,
};
}
#[cfg(feature = "log")]
mod fmt {
pub use core::{
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo,
unreachable,
};
pub use log::{debug, error, info, trace, warn};
}
#[cfg(not(any(feature = "defmt", feature = "log")))]
mod fmt {
#![macro_use]
pub use core::{
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo,
unreachable,
};
macro_rules! trace {
($($msg:expr),+ $(,)?) => {
()
};
}
macro_rules! debug {
($($msg:expr),+ $(,)?) => {
()
};
}
macro_rules! info {
($($msg:expr),+ $(,)?) => {
()
};
}
macro_rules! warn {
($($msg:expr),+ $(,)?) => {
()
};
}
macro_rules! error {
($($msg:expr),+ $(,)?) => {
()
};
}
}
#[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);
}
}
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct NoneError;
pub trait Try {
type Ok;
type Error;
fn into_result(self) -> Result<Self::Ok, Self::Error>;
}
impl<T> Try for Option<T> {
type Ok = T;
type Error = NoneError;
#[inline]
fn into_result(self) -> Result<T, NoneError> {
self.ok_or(NoneError)
}
}
impl<T, E> Try for Result<T, E> {
type Ok = T;
type Error = E;
#[inline]
fn into_result(self) -> Self {
self
}
}

File diff suppressed because it is too large Load Diff

View File

@ -307,16 +307,11 @@ compile_error!(
"Multile chip features activated. You must activate exactly one of the following features: "
);
pub use stm32f4xx_hal as hal;
pub use stm32f4xx_hal::stm32 as pac;
// This mod MUST go first, so that the others see its macros.
pub(crate) mod fmt;
pub use embassy_stm32::{fmt, hal, interrupt, pac};
#[cfg(not(any(feature = "stm32f401", feature = "stm32f410", feature = "stm32f411",)))]
pub mod can;
pub mod exti;
pub mod interrupt;
#[cfg(not(feature = "stm32f410"))]
pub mod qei;
pub mod rtc;