Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 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"] }
bare-metal = { version = "0.2.0", features = ["const-fn"], optional = true }
volatile-register = "0.2.0"
bitfield = "0.13.2"
embedded-hal = "0.2.4"
embedded-hal = { version = "0.2.4", 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: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@
// to be applied to the struct).
#![deny(clippy::missing_inline_in_public_items)]

#[cfg(feature = "interrupt")]
extern crate bare_metal;

extern crate volatile_register;

#[macro_use]
Expand All @@ -88,12 +90,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::*;