add TTC driver
This commit is contained in:
@ -23,6 +23,7 @@ pub mod slcr;
|
||||
pub mod spi;
|
||||
pub mod time;
|
||||
pub mod uart;
|
||||
pub mod ttc;
|
||||
|
||||
/// This enumeration encodes the various boot sources.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
|
45
zynq7000-hal/src/ttc.rs
Normal file
45
zynq7000-hal/src/ttc.rs
Normal file
@ -0,0 +1,45 @@
|
||||
//! Triple-timer counter (TTC) high-level driver.
|
||||
|
||||
use arbitrary_int::u3;
|
||||
|
||||
use crate::gpio::{IoPeriph, Mio30, Mio31, MioPin, MuxConf, PinMode};
|
||||
#[cfg(not(feature = "7z010-7z007s-clg225"))]
|
||||
use crate::gpio::{Mio18, Mio19, Mio42, Mio43};
|
||||
|
||||
/// Each TTC consists of three independent timers/counters.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum TtcId {
|
||||
Ttc0 = 0,
|
||||
Ttc1 = 1,
|
||||
}
|
||||
|
||||
pub const TTC_MUX_CONF: MuxConf = MuxConf::new_with_l3(u3::new(0b110));
|
||||
|
||||
pub trait ClockInPin {
|
||||
const ID: TtcId;
|
||||
}
|
||||
|
||||
pub trait WaveOutPin {
|
||||
const ID: TtcId;
|
||||
}
|
||||
|
||||
macro_rules! into_ttc {
|
||||
($($Mio:ident),+) => {
|
||||
$(
|
||||
impl <M: PinMode> MioPin<$Mio, M> {
|
||||
/// Convert the pin into a TTC pin by configuring the pin routing via the
|
||||
/// MIO multiplexer bits.
|
||||
pub fn into_ttck(self) -> MioPin<$Mio, IoPeriph> {
|
||||
// Enable pull-ups for the I2C pins.
|
||||
self.into_io_periph(TTC_MUX_CONF, None)
|
||||
}
|
||||
}
|
||||
)+
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "7z010-7z007s-clg225"))]
|
||||
into_ttc!(Mio18, Mio19, Mio42, Mio43);
|
||||
into_ttc!(Mio30, Mio31);
|
||||
|
||||
pub struct Pwm {}
|
Reference in New Issue
Block a user