mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
commit
31738d94ef
3 changed files with 27 additions and 19 deletions
|
|
@ -151,7 +151,7 @@ struct DeviceDescriptor {
|
||||||
pub b_num_configurations: u8,
|
pub b_num_configurations: u8,
|
||||||
}
|
}
|
||||||
const VENDOR_ID: u16 = 0x1d50;
|
const VENDOR_ID: u16 = 0x1d50;
|
||||||
const PRODUCT_ID: u16 = 0x6196; // This is pending acceptance of a PR to the openmoko registry
|
const PRODUCT_ID: u16 = 0x6196;
|
||||||
const MANUFACTURER: &'static str = "Baochip";
|
const MANUFACTURER: &'static str = "Baochip";
|
||||||
const PRODUCT: &'static str = "Baochip-1x";
|
const PRODUCT: &'static str = "Baochip-1x";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ use utralib::*;
|
||||||
use xous_bio_bdma::*;
|
use xous_bio_bdma::*;
|
||||||
|
|
||||||
// pinmask 29 is not mapped out. This is tested by pushing the button to allow boot
|
// pinmask 29 is not mapped out. This is tested by pushing the button to allow boot
|
||||||
const DABAO_PINMASK: u32 = 0b0001_1111_1000_1111_0111_1000_0011_1110; // 0x1F8F783E;
|
// pinmask 12 & 13 not mapped out. This is tested by tx/rx with the tester
|
||||||
|
const DABAO_PINMASK: u32 = 0b0001_1111_1000_1111_0001_1000_0011_1110; // 0x1F8F183E;
|
||||||
|
|
||||||
pub fn dabao_selftest() {
|
pub fn dabao_selftest() {
|
||||||
let one_way = bao1x_hal::acram::OneWayCounter::new();
|
let one_way = bao1x_hal::acram::OneWayCounter::new();
|
||||||
|
|
@ -14,34 +15,23 @@ pub fn dabao_selftest() {
|
||||||
|
|
||||||
let mut bio_ss = BioSharedState::new();
|
let mut bio_ss = BioSharedState::new();
|
||||||
let iox = bao1x_hal::iox::Iox::new(utra::iox::HW_IOX_BASE as *mut u32);
|
let iox = bao1x_hal::iox::Iox::new(utra::iox::HW_IOX_BASE as *mut u32);
|
||||||
iox.set_ports_from_bio_bitmask(DABAO_PINMASK);
|
iox.set_ports_from_bio_bitmask(DABAO_PINMASK, bao1x_api::bio::IoConfigMode::Overwrite);
|
||||||
bio_ss.init();
|
bio_ss.init();
|
||||||
bio_ss.load_code(db_pin_test_code(), 0, BioCore::Core0);
|
bio_ss.load_code(db_pin_test_code(), 0, BioCore::Core0);
|
||||||
bio_ss.bio.wo(utra::bio_bdma::SFR_QDIV0, 0x1_0001);
|
bio_ss.bio.wo(utra::bio_bdma::SFR_QDIV0, 0x1_0001);
|
||||||
bio_ss.set_core_run_states([true, false, false, false]);
|
bio_ss.set_core_run_states([true, false, false, false]);
|
||||||
|
|
||||||
let pin_ordering: [u32; 19] = [28, 27, 26, 25, 24, 23, 19, 18, 17, 16, 14, 13, 12, 11, 1, 2, 3, 4, 5];
|
let pin_ordering: [u32; 17] = [28, 27, 26, 25, 24, 23, 19, 18, 17, 16, 12, 11, 1, 2, 3, 4, 5];
|
||||||
|
|
||||||
crate::println!(
|
|
||||||
"Starting dabao mini self-test: sets each pin sequentially, in a counter-clockwise order."
|
|
||||||
);
|
|
||||||
crate::usb::flush();
|
|
||||||
crate::delay(30);
|
crate::delay(30);
|
||||||
const TOTAL_ITERS: usize = 2;
|
const TOTAL_ITERS: usize = 4;
|
||||||
for i in 0..TOTAL_ITERS {
|
for i in 0..TOTAL_ITERS {
|
||||||
crate::println!("Iter {}/{}", i + 1, TOTAL_ITERS);
|
|
||||||
crate::usb::flush();
|
|
||||||
for pin in pin_ordering {
|
for pin in pin_ordering {
|
||||||
crate::print!("{} ", pin);
|
|
||||||
crate::usb::flush();
|
|
||||||
bio_ss.bio.wo(utra::bio_bdma::SFR_TXF0, 1u32 << pin);
|
bio_ss.bio.wo(utra::bio_bdma::SFR_TXF0, 1u32 << pin);
|
||||||
crate::delay(100);
|
crate::delay(50);
|
||||||
}
|
}
|
||||||
crate::println!("");
|
|
||||||
}
|
}
|
||||||
crate::println!("Done; pin state reverted");
|
iox.set_ports_from_bio_bitmask(0x0, bao1x_api::bio::IoConfigMode::Overwrite);
|
||||||
crate::usb::flush();
|
|
||||||
iox.set_ports_from_bio_bitmask(0x0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
|
@ -50,7 +40,7 @@ bio_code!(db_pin_test_code, BM_PIN_TEST_START, BM_PIN_TEST_END,
|
||||||
"li a0, -1",
|
"li a0, -1",
|
||||||
"mv x26, a0", // mask
|
"mv x26, a0", // mask
|
||||||
"mv x25, a0", // inputs
|
"mv x25, a0", // inputs
|
||||||
"li a1, 0x3F8F783E", // connected pin mask
|
"li a1, 0x1F8F183E", // connected pin mask
|
||||||
"mv x24, a1", // select pins as outputs
|
"mv x24, a1", // select pins as outputs
|
||||||
// receive data from the FIFO, update it to the pins
|
// receive data from the FIFO, update it to the pins
|
||||||
"10:",
|
"10:",
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ use num_traits::ToPrimitive;
|
||||||
use xous::MemoryRange;
|
use xous::MemoryRange;
|
||||||
|
|
||||||
use crate::IoxPort;
|
use crate::IoxPort;
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
use crate::bio_resources::ResourceSpec;
|
||||||
|
|
||||||
pub const BIO_SERVER_NAME: &'static str = "_BIO server_";
|
pub const BIO_SERVER_NAME: &'static str = "_BIO server_";
|
||||||
|
|
||||||
|
|
@ -401,6 +403,22 @@ impl Default for IoConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
impl IoConfig {
|
||||||
|
pub fn from_resource_spec(spec: &ResourceSpec, mode: &Option<IoConfigMode>) -> Result<Self, String> {
|
||||||
|
let mut mask: u32 = 0;
|
||||||
|
for &pin in spec.static_pins.iter() {
|
||||||
|
if pin > 31 {
|
||||||
|
return Err(format!("Pin {} exceeds maximum bit position of 31", pin));
|
||||||
|
}
|
||||||
|
mask |= 1u32 << pin;
|
||||||
|
}
|
||||||
|
let mut ret = IoConfig::default();
|
||||||
|
ret.mapped = mask;
|
||||||
|
ret.mode = mode.unwrap_or(IoConfigMode::Overwrite);
|
||||||
|
Ok(ret)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[bitfield(u8)]
|
#[bitfield(u8)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue