share identifier_read between runtime and satman
This commit is contained in:
parent
4e5f1a0673
commit
4540b8ec98
|
@ -15,3 +15,18 @@ pub mod drtioaux;
|
|||
pub mod drtio_routing;
|
||||
pub mod si5324;
|
||||
pub mod logger;
|
||||
|
||||
use core::{cmp, str};
|
||||
|
||||
pub fn identifier_read(buf: &mut [u8]) -> &str {
|
||||
unsafe {
|
||||
pl::csr::identifier::address_write(0);
|
||||
let len = pl::csr::identifier::data_read();
|
||||
let len = cmp::min(len, buf.len() as u8);
|
||||
for i in 0..len {
|
||||
pl::csr::identifier::address_write(1 + i);
|
||||
buf[i as usize] = pl::csr::identifier::data_read();
|
||||
}
|
||||
str::from_utf8_unchecked(&buf[..len as usize])
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
extern crate alloc;
|
||||
|
||||
use core::{cmp, str};
|
||||
use log::{info, warn, error};
|
||||
|
||||
use libboard_zynq::{timer::GlobalTimer, mpcore, gic, slcr};
|
||||
|
@ -23,7 +22,7 @@ use embedded_hal::blocking::delay::DelayMs;
|
|||
use libconfig::Config;
|
||||
use libregister::RegisterW;
|
||||
use libcortex_a9::l2c::enable_l2_cache;
|
||||
use libboard_artiq::logger;
|
||||
use libboard_artiq::{logger, identifier_read};
|
||||
#[cfg(feature = "target_kasli_soc")]
|
||||
use libboard_artiq::si5324;
|
||||
|
||||
|
@ -71,19 +70,6 @@ fn init_gateware() {
|
|||
});
|
||||
}
|
||||
|
||||
fn identifier_read(buf: &mut [u8]) -> &str {
|
||||
unsafe {
|
||||
pl::csr::identifier::address_write(0);
|
||||
let len = pl::csr::identifier::data_read();
|
||||
let len = cmp::min(len, buf.len() as u8);
|
||||
for i in 0..len {
|
||||
pl::csr::identifier::address_write(1 + i);
|
||||
buf[i as usize] = pl::csr::identifier::data_read();
|
||||
}
|
||||
str::from_utf8_unchecked(&buf[..len as usize])
|
||||
}
|
||||
}
|
||||
|
||||
fn init_rtio(timer: &mut GlobalTimer, cfg: &Config) {
|
||||
let clock_sel =
|
||||
if let Ok(rtioclk) = cfg.read_str("rtioclk") {
|
||||
|
|
|
@ -10,23 +10,10 @@ use libboard_zynq::timer::GlobalTimer;
|
|||
#[cfg(has_si5324)]
|
||||
use libboard_artiq::si5324;
|
||||
use board_artiq::spi; // <- port?, use libboard_zynq (if spi available/necessary)
|
||||
use libboard_artiq::{pl::csr, drtio_routing, drtioaux, logger};
|
||||
use libboard_artiq::{pl::csr, drtio_routing, drtioaux, logger, identifier_read};
|
||||
|
||||
mod repeater;
|
||||
|
||||
fn identifier_read(buf: &mut [u8]) -> &str {
|
||||
unsafe {
|
||||
csr::identifier::address_write(0);
|
||||
let len = csr::identifier::data_read();
|
||||
let len = cmp::min(len, buf.len() as u8);
|
||||
for i in 0..len {
|
||||
csr::identifier::address_write(1 + i);
|
||||
buf[i as usize] = csr::identifier::data_read();
|
||||
}
|
||||
str::from_utf8_unchecked(&buf[..len as usize])
|
||||
}
|
||||
}
|
||||
|
||||
fn drtiosat_reset(reset: bool) {
|
||||
unsafe {
|
||||
csr::drtiosat::reset_write(if reset { 1 } else { 0 });
|
||||
|
|
Loading…
Reference in New Issue