Skip to content

Commit

Permalink
Use features to allow users to better manage their dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
hydra committed Sep 21, 2021
1 parent bb49576 commit d95285e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ edition = "2018"
links = "cortex-m" # prevent multiple versions of this crate to be linked together

[dependencies]
bare-metal = { version = "0.2.0", features = ["const-fn"] }
volatile-register = "0.2.0"
bitfield = "0.13.2"
embedded-hal = "0.2.4"
bare-metal = { version = "^0.2.5", features = ["const-fn"], optional = true }
volatile-register = "^0.2.1"
bitfield = "^0.13.2"
embedded-hal = { version = "^0.2.6", optional = true }

[features]
default = ["interrupt", "delay"]
cm7-r0p1 = []
inline-asm = []
linker-plugin-lto = []
interrupt = ["bare-metal"]
delay = ["embedded-hal"]

[workspace]
members = ["xtask", "cortex-m-semihosting", "panic-semihosting", "panic-itm"]
Expand Down
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
// to be applied to the struct).
#![deny(clippy::missing_inline_in_public_items)]

extern crate bare_metal;
//extern crate bare_metal;
extern crate volatile_register;

#[macro_use]
Expand All @@ -88,12 +88,18 @@ mod macros;
pub mod asm;
#[cfg(armv8m)]
pub mod cmse;

#[cfg(feature = "delay")]
pub mod delay;
#[cfg(feature = "interrupt")]
pub mod interrupt;
#[cfg(all(not(armv6m), not(armv8m_base)))]
pub mod itm;
pub mod peripheral;

#[cfg(feature = "delay")]
pub mod prelude;

pub mod register;

pub use crate::peripheral::Peripherals;
2 changes: 2 additions & 0 deletions src/peripheral/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
use core::marker::PhantomData;
use core::ops;

#[cfg(feature = "interrupt")]
use crate::interrupt;

#[cfg(not(armv6m))]
Expand Down Expand Up @@ -156,6 +157,7 @@ static mut TAKEN: bool = false;
impl Peripherals {
/// Returns all the core peripherals *once*
#[inline]
#[cfg(feature = "interrupt")]
pub fn take() -> Option<Self> {
interrupt::free(|_| {
if unsafe { TAKEN } {
Expand Down
3 changes: 3 additions & 0 deletions src/peripheral/nvic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use volatile_register::RW;
#[cfg(not(armv6m))]
use volatile_register::{RO, WO};

#[cfg(feature = "interrupt")]
use crate::interrupt::InterruptNumber;
#[cfg(feature = "interrupt")]
use crate::peripheral::NVIC;

/// Register block
Expand Down Expand Up @@ -74,6 +76,7 @@ pub struct RegisterBlock {
pub stir: WO<u32>,
}

#[cfg(feature = "interrupt")]
impl NVIC {
/// Request an IRQ in software
///
Expand Down
1 change: 1 addition & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Prelude

#[cfg(feature = "delay")]
pub use embedded_hal::prelude::*;

0 comments on commit d95285e

Please sign in to comment.