Skip to content

Commit 33a6310

Browse files
committed
Use features to allow users to better manage their dependencies.
1 parent bb49576 commit 33a6310

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

Cargo.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ edition = "2018"
1616
links = "cortex-m" # prevent multiple versions of this crate to be linked together
1717

1818
[dependencies]
19-
bare-metal = { version = "0.2.0", features = ["const-fn"] }
19+
bare-metal = { version = "0.2.0", features = ["const-fn"], optional = true }
2020
volatile-register = "0.2.0"
2121
bitfield = "0.13.2"
22-
embedded-hal = "0.2.4"
22+
embedded-hal = { version = "0.2.4", optional = true }
2323

2424
[features]
25+
default = ["interrupt", "delay"]
2526
cm7-r0p1 = []
2627
inline-asm = []
2728
linker-plugin-lto = []
29+
interrupt = ["bare-metal"]
30+
delay = ["embedded-hal"]
2831

2932
[workspace]
3033
members = ["xtask", "cortex-m-semihosting", "panic-semihosting", "panic-itm"]

src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@
7777
// to be applied to the struct).
7878
#![deny(clippy::missing_inline_in_public_items)]
7979

80+
#[cfg(feature = "interrupt")]
8081
extern crate bare_metal;
82+
8183
extern crate volatile_register;
8284

8385
#[macro_use]
@@ -88,12 +90,18 @@ mod macros;
8890
pub mod asm;
8991
#[cfg(armv8m)]
9092
pub mod cmse;
93+
94+
#[cfg(feature = "delay")]
9195
pub mod delay;
96+
#[cfg(feature = "interrupt")]
9297
pub mod interrupt;
9398
#[cfg(all(not(armv6m), not(armv8m_base)))]
9499
pub mod itm;
95100
pub mod peripheral;
101+
102+
#[cfg(feature = "delay")]
96103
pub mod prelude;
104+
97105
pub mod register;
98106

99107
pub use crate::peripheral::Peripherals;

src/peripheral/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
use core::marker::PhantomData;
5959
use core::ops;
6060

61+
#[cfg(feature = "interrupt")]
6162
use crate::interrupt;
6263

6364
#[cfg(not(armv6m))]
@@ -156,6 +157,7 @@ static mut TAKEN: bool = false;
156157
impl Peripherals {
157158
/// Returns all the core peripherals *once*
158159
#[inline]
160+
#[cfg(feature = "interrupt")]
159161
pub fn take() -> Option<Self> {
160162
interrupt::free(|_| {
161163
if unsafe { TAKEN } {

src/peripheral/nvic.rs

+3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use volatile_register::RW;
44
#[cfg(not(armv6m))]
55
use volatile_register::{RO, WO};
66

7+
#[cfg(feature = "interrupt")]
78
use crate::interrupt::InterruptNumber;
9+
#[cfg(feature = "interrupt")]
810
use crate::peripheral::NVIC;
911

1012
/// Register block
@@ -74,6 +76,7 @@ pub struct RegisterBlock {
7476
pub stir: WO<u32>,
7577
}
7678

79+
#[cfg(feature = "interrupt")]
7780
impl NVIC {
7881
/// Request an IRQ in software
7982
///

src/prelude.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
//! Prelude
22
3+
#[cfg(feature = "delay")]
34
pub use embedded_hal::prelude::*;

0 commit comments

Comments
 (0)