Add a timer trait

This commit is contained in:
Dylan McKay 2017-12-13 22:24:16 +13:00
parent 468289e05f
commit 1f638dbea3
2 changed files with 40 additions and 0 deletions

View File

@ -15,6 +15,7 @@
pub use self::register::{Bitset, Mask, Register, RegisterValue};
pub use self::pin::Pin;
pub use self::timer::Timer8;
pub use self::usart::HardwareUsart;
pub mod prelude;
@ -29,6 +30,7 @@ pub mod config;
mod register;
mod pin;
mod usart;
mod timer;
#[doc(hidden)]
pub mod std_stub;

38
src/timer.rs Normal file
View File

@ -0,0 +1,38 @@
use {Register};
/// An 8-bit timer.
pub trait Timer8 {
/// The first compare register.
/// For example, OCR0A.
type CompareA: Register<u8>;
/// The second compare register.
/// For example, OCR0B.
type CompareB: Register<u8>;
/// The counter register.
///
/// For example, TCNT0.
type Counter: Register<u8>;
/// The first control register.
///
/// For example, TCCR0A.
type ControlA: Register<u8>;
/// The second control register.
///
/// For example, TCCR0B.
type ControlB: Register<u8>;
/// The interrupt mask register.
///
/// For example, TIMSK0.
type InterruptMask: Register<u8>;
/// The interrupt flag register.
///
/// For example, TIFR0.
type InterruptFlag: Register<u8>;
}