2020-01-20 19:26:29 +08:00
|
|
|
use libregister::*;
|
2020-03-25 20:02:01 +08:00
|
|
|
use crate::slcr;
|
2020-01-20 19:26:29 +08:00
|
|
|
mod regs;
|
|
|
|
|
|
|
|
pub struct DevC {
|
|
|
|
regs: &'static mut regs::RegisterBlock,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DevC {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
DevC {
|
|
|
|
regs: regs::RegisterBlock::devc(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn enable(&mut self) {
|
|
|
|
self.regs.control.modify(|_, w| {
|
|
|
|
w.pcap_mode(true)
|
|
|
|
.pcap_pr(true)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
pub fn disable(&mut self) {
|
|
|
|
self.regs.control.modify(|_, w| {
|
|
|
|
w.pcap_mode(false)
|
|
|
|
.pcap_pr(false)
|
|
|
|
})
|
|
|
|
}
|
2020-03-25 20:02:01 +08:00
|
|
|
|
|
|
|
pub fn program(&mut self) {
|
|
|
|
slcr::RegisterBlock::unlocked(|slcr| {
|
|
|
|
slcr.init_preload_fpga();
|
|
|
|
});
|
|
|
|
|
|
|
|
while !self.regs.int_sts.read().ixr_pcfg_done() {}
|
|
|
|
|
|
|
|
slcr::RegisterBlock::unlocked(|slcr| {
|
|
|
|
slcr.init_postload_fpga();
|
|
|
|
});
|
|
|
|
}
|
2020-01-20 19:26:29 +08:00
|
|
|
}
|