fixed compilation errors - runtime compiles now

This commit is contained in:
mwojcik 2021-07-27 12:40:55 +02:00
parent 76b085333f
commit 4e5f1a0673
6 changed files with 25 additions and 9 deletions

View File

@ -3,6 +3,8 @@ use libconfig::Config;
use pl::csr; // <- check if it works in the same way use pl::csr; // <- check if it works in the same way
use core::fmt; use core::fmt;
use log::{warn, info};
#[cfg(has_drtio_routing)] #[cfg(has_drtio_routing)]
pub const DEST_COUNT: usize = 256; pub const DEST_COUNT: usize = 256;
#[cfg(not(has_drtio_routing))] #[cfg(not(has_drtio_routing))]
@ -55,7 +57,9 @@ impl fmt::Display for RoutingTable {
pub fn config_routing_table(default_n_links: usize, cfg: Config) -> RoutingTable { pub fn config_routing_table(default_n_links: usize, cfg: Config) -> RoutingTable {
let mut ret = RoutingTable::default_master(default_n_links); let mut ret = RoutingTable::default_master(default_n_links);
if let Ok(data) = cfg.read("routing_table").ok() && data.len() == DEST_COUNT*MAX_HOPS { if let Ok(data) = cfg.read("routing_table") {
if data.len() == DEST_COUNT*MAX_HOPS
{
for i in 0..DEST_COUNT { for i in 0..DEST_COUNT {
for j in 0..MAX_HOPS { for j in 0..MAX_HOPS {
ret.0[i][j] = data[i*MAX_HOPS+j]; ret.0[i][j] = data[i*MAX_HOPS+j];
@ -65,6 +69,10 @@ pub fn config_routing_table(default_n_links: usize, cfg: Config) -> RoutingTable
else { else {
warn!("could not read routing table from configuration, using default"); warn!("could not read routing table from configuration, using default");
} }
}
else {
warn!("could not read routing table from configuration, using default");
}
info!("routing table: {}", ret); info!("routing table: {}", ret);
ret ret
} }

View File

@ -1,5 +1,11 @@
#![no_std] #![no_std]
extern crate log;
extern crate libboard_zynq;
extern crate libconfig;
extern crate libcortex_a9;
extern crate log_buffer;
// has csr; taken from runtime main // has csr; taken from runtime main
#[path = "../../../build/pl.rs"] #[path = "../../../build/pl.rs"]
pub mod pl; pub mod pl;

View File

@ -93,6 +93,7 @@ fn write(i2c: &mut I2c, reg: u8, val: u8) -> Result<()> {
Ok(()) Ok(())
} }
#[allow(dead_code)]
fn write_no_ack_value(i2c: &mut I2c, reg: u8, val: u8) -> Result<()> { fn write_no_ack_value(i2c: &mut I2c, reg: u8, val: u8) -> Result<()> {
i2c.start().unwrap(); i2c.start().unwrap();
if !i2c.write(ADDRESS << 1).unwrap() { if !i2c.write(ADDRESS << 1).unwrap() {
@ -134,7 +135,7 @@ fn ident(i2c: &mut I2c) -> Result<u16> {
Ok(((read(i2c, 134)? as u16) << 8) | (read(i2c, 135)? as u16)) Ok(((read(i2c, 134)? as u16) << 8) | (read(i2c, 135)? as u16))
} }
fn soft_reset(i2c: &mut I2c) -> Result<()> { fn soft_reset(_i2c: &mut I2c) -> Result<()> {
//TODO write_no_ack_value(i2c, 136, read(136)? | 0x80)?; //TODO write_no_ack_value(i2c, 136, read(136)? | 0x80)?;
//TODO clock::spin_us(10_000); //TODO clock::spin_us(10_000);
Ok(()) Ok(())

View File

@ -11,9 +11,9 @@ use alloc;
#[cfg(feature = "byteorder")] #[cfg(feature = "byteorder")]
extern crate byteorder; extern crate byteorder;
mod cursor; pub mod cursor;
#[cfg(feature = "byteorder")] #[cfg(feature = "byteorder")]
mod proto; pub mod proto;
pub use cursor::Cursor; pub use cursor::Cursor;
#[cfg(feature = "byteorder")] #[cfg(feature = "byteorder")]

View File

@ -23,8 +23,9 @@ use embedded_hal::blocking::delay::DelayMs;
use libconfig::Config; use libconfig::Config;
use libregister::RegisterW; use libregister::RegisterW;
use libcortex_a9::l2c::enable_l2_cache; use libcortex_a9::l2c::enable_l2_cache;
use libboard_artiq::logger;
#[cfg(feature = "target_kasli_soc")] #[cfg(feature = "target_kasli_soc")]
use libboard_artiq::{si5324, logger}; use libboard_artiq::si5324;
mod proto_async; mod proto_async;
mod comms; mod comms;

View File

@ -16,12 +16,12 @@ mod repeater;
fn identifier_read(buf: &mut [u8]) -> &str { fn identifier_read(buf: &mut [u8]) -> &str {
unsafe { unsafe {
pl::csr::identifier::address_write(0); csr::identifier::address_write(0);
let len = pl::csr::identifier::data_read(); let len = csr::identifier::data_read();
let len = cmp::min(len, buf.len() as u8); let len = cmp::min(len, buf.len() as u8);
for i in 0..len { for i in 0..len {
pl::csr::identifier::address_write(1 + i); csr::identifier::address_write(1 + i);
buf[i as usize] = pl::csr::identifier::data_read(); buf[i as usize] = csr::identifier::data_read();
} }
str::from_utf8_unchecked(&buf[..len as usize]) str::from_utf8_unchecked(&buf[..len as usize])
} }