Skip to content

Commit d95285e

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

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

Diff for: Cargo.toml

+7-4
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"] }
20-
volatile-register = "0.2.0"
21-
bitfield = "0.13.2"
22-
embedded-hal = "0.2.4"
19+
bare-metal = { version = "^0.2.5", features = ["const-fn"], optional = true }
20+
volatile-register = "^0.2.1"
21+
bitfield = "^0.13.2"
22+
embedded-hal = { version = "^0.2.6", 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"]

Diff for: src/lib.rs

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

80-
extern crate bare_metal;
80+
//extern crate bare_metal;
8181
extern crate volatile_register;
8282

8383
#[macro_use]
@@ -88,12 +88,18 @@ mod macros;
8888
pub mod asm;
8989
#[cfg(armv8m)]
9090
pub mod cmse;
91+
92+
#[cfg(feature = "delay")]
9193
pub mod delay;
94+
#[cfg(feature = "interrupt")]
9295
pub mod interrupt;
9396
#[cfg(all(not(armv6m), not(armv8m_base)))]
9497
pub mod itm;
9598
pub mod peripheral;
99+
100+
#[cfg(feature = "delay")]
96101
pub mod prelude;
102+
97103
pub mod register;
98104

99105
pub use crate::peripheral::Peripherals;

Diff for: 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 } {

Diff for: 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
///

Diff for: 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)