Compare commits
2 Commits
4e5f1a0673
...
97d95c37f5
Author | SHA1 | Date | |
---|---|---|---|
97d95c37f5 | |||
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") {
|
||||
|
@ -5,28 +5,15 @@
|
||||
extern crate log;
|
||||
|
||||
use core::convert::TryFrom;
|
||||
use libboard_zynq::i2c::I2c; // not using a wrapper like runtime
|
||||
use libboard_zynq::i2c::I2c;
|
||||
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_zynq::spi; // not yet supported in board/csr
|
||||
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 });
|
||||
@ -279,24 +266,29 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||
|
||||
drtioaux::Packet::SpiSetConfigRequest { destination: _destination, busno, flags, length, div, cs } => {
|
||||
forward!(_routing_table, _destination, *_rank, _repeaters, &packet);
|
||||
let succeeded = spi::set_config(busno, flags, length, div, cs).is_ok();
|
||||
// todo: reimplement when SPI is available
|
||||
//let succeeded = spi::set_config(busno, flags, length, div, cs).is_ok();
|
||||
drtioaux::send(0,
|
||||
&drtioaux::Packet::SpiBasicReply { succeeded: succeeded })
|
||||
&drtioaux::Packet::SpiBasicReply { succeeded: false})
|
||||
},
|
||||
drtioaux::Packet::SpiWriteRequest { destination: _destination, busno, data } => {
|
||||
forward!(_routing_table, _destination, *_rank, _repeaters, &packet);
|
||||
let succeeded = spi::write(busno, data).is_ok();
|
||||
// todo: reimplement when SPI is available
|
||||
//let succeeded = spi::write(busno, data).is_ok();
|
||||
drtioaux::send(0,
|
||||
&drtioaux::Packet::SpiBasicReply { succeeded: succeeded })
|
||||
&drtioaux::Packet::SpiBasicReply { succeeded: false })
|
||||
}
|
||||
drtioaux::Packet::SpiReadRequest { destination: _destination, busno } => {
|
||||
forward!(_routing_table, _destination, *_rank, _repeaters, &packet);
|
||||
match spi::read(busno) {
|
||||
Ok(data) => drtioaux::send(0,
|
||||
&drtioaux::Packet::SpiReadReply { succeeded: true, data: data }),
|
||||
Err(_) => drtioaux::send(0,
|
||||
&drtioaux::Packet::SpiReadReply { succeeded: false, data: 0 })
|
||||
}
|
||||
// todo: reimplement when SPI is available
|
||||
// match spi::read(busno) {
|
||||
// Ok(data) => drtioaux::send(0,
|
||||
// &drtioaux::Packet::SpiReadReply { succeeded: true, data: data }),
|
||||
// Err(_) => drtioaux::send(0,
|
||||
// &drtioaux::Packet::SpiReadReply { succeeded: false, data: 0 })
|
||||
// }
|
||||
drtioaux::send(0,
|
||||
&drtioaux::Packet::SpiReadReply { succeeded: false, data: 0 })
|
||||
}
|
||||
|
||||
drtioaux::Packet::JdacBasicRequest { destination: _destination, dacno: _dacno,
|
||||
|
Loading…
Reference in New Issue
Block a user