Skip to content

Commit

Permalink
Put timer module behind Cargo feature
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrgn committed Jan 6, 2023
1 parent f7db23d commit 1c254ea
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,20 @@ jobs:
rustc --version
cargo --version
# Build main crate
- name: Build
run: cargo build
- name: Build (all features)
if: ${{ matrix.toolchain == 'nightly' }}
run: cargo build --all-features
# Check crate
- name: Check
run: cargo check
- name: Check (no default features)
run: cargo check --no-default-features
- name: Check (all features)
run: cargo check --all-features

# Test main crate
# Test crate
- name: Test
if: ${{ matrix.toolchain != 'nightly' }}
run: cargo test
- name: Test (no default features)
run: cargo test --no-default-features
- name: Test (all features)
if: ${{ matrix.toolchain == 'nightly' }}
run: cargo test --all-features

# Check code formatting
Expand Down
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ edition = "2021"

[dependencies]
embedded-hal = { version = "0.2.7", features = ["unproven"] }
embedded-time = "0.12"
void = "^1.0"
embedded-time = { version = "0.12", optional = true }
void = { version = "^1.0", optional = true }
nb = "0.1.1"

[features]
default = ["embedded-time"]
embedded-time = ["dep:embedded-time", "dep:void"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This crate requires Rust 1.56+!
- [ ] RNG
- [x] I/O pins (including PWM)
- [x] ADC
- [x] Timers
- [x] Timers (with `embedded-time` Cargo feature)
- [ ] ...

Pull requests for more mock implementations are welcome! :)
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
//!
//! See module-level docs for more information.
//!
//! ## Cargo Features
//!
//! There are currently the following cargo features:
//!
//! - `embedded-time`: Enable the `timer` module (enabled by default)
//!
//! ## no\_std
//!
//! Currently this crate is not `no_std`. If you think this is important, let
Expand All @@ -27,4 +33,5 @@ pub mod i2c;
pub mod pin;
pub mod serial;
pub mod spi;
#[cfg(feature = "embedded-time")]
pub mod timer;

0 comments on commit 1c254ea

Please sign in to comment.