artiq-zynq/src/libboard_artiq/src/lib.rs

48 lines
1.0 KiB
Rust

#![no_std]
#![feature(never_type)]
extern crate log;
extern crate crc;
extern crate failure;
extern crate failure_derive;
extern crate libboard_zynq;
extern crate libconfig;
extern crate libcortex_a9;
extern crate log_buffer;
extern crate io;
// has csr; taken from runtime main
#[path = "../../../build/pl.rs"]
pub mod pl;
#[cfg(has_drtio)]
pub mod drtioaux;
// for now, memory map is only needed for DRTIO firmware
#[cfg(has_drtio)]
#[path = "../../../build/mem.rs"]
pub mod mem;
pub mod drtio_routing;
pub mod logger;
#[cfg(has_si5324)]
pub mod si5324;
#[cfg(has_siphaser)]
pub mod siphaser;
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])
}
}