diff --git a/bao1x-boot/boot1/src/platform/bao1x/usb/mod.rs b/bao1x-boot/boot1/src/platform/bao1x/usb/mod.rs index 247f06dfe..c7b6abd40 100644 --- a/bao1x-boot/boot1/src/platform/bao1x/usb/mod.rs +++ b/bao1x-boot/boot1/src/platform/bao1x/usb/mod.rs @@ -151,7 +151,7 @@ struct DeviceDescriptor { pub b_num_configurations: u8, } 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 PRODUCT: &'static str = "Baochip-1x"; diff --git a/baremetal/src/platform/bao1x/dabao_selftest.rs b/baremetal/src/platform/bao1x/dabao_selftest.rs index efe52d72c..851c61d1d 100644 --- a/baremetal/src/platform/bao1x/dabao_selftest.rs +++ b/baremetal/src/platform/bao1x/dabao_selftest.rs @@ -2,7 +2,8 @@ use utralib::*; use xous_bio_bdma::*; // 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() { let one_way = bao1x_hal::acram::OneWayCounter::new(); @@ -14,34 +15,23 @@ pub fn dabao_selftest() { let mut bio_ss = BioSharedState::new(); 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.load_code(db_pin_test_code(), 0, BioCore::Core0); bio_ss.bio.wo(utra::bio_bdma::SFR_QDIV0, 0x1_0001); 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); - const TOTAL_ITERS: usize = 2; + const TOTAL_ITERS: usize = 4; for i in 0..TOTAL_ITERS { - crate::println!("Iter {}/{}", i + 1, TOTAL_ITERS); - crate::usb::flush(); for pin in pin_ordering { - crate::print!("{} ", pin); - crate::usb::flush(); 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"); - crate::usb::flush(); - iox.set_ports_from_bio_bitmask(0x0); + iox.set_ports_from_bio_bitmask(0x0, bao1x_api::bio::IoConfigMode::Overwrite); } #[rustfmt::skip] @@ -50,7 +40,7 @@ bio_code!(db_pin_test_code, BM_PIN_TEST_START, BM_PIN_TEST_END, "li a0, -1", "mv x26, a0", // mask "mv x25, a0", // inputs - "li a1, 0x3F8F783E", // connected pin mask + "li a1, 0x1F8F183E", // connected pin mask "mv x24, a1", // select pins as outputs // receive data from the FIFO, update it to the pins "10:", diff --git a/libs/bao1x-api/src/bio.rs b/libs/bao1x-api/src/bio.rs index 74c549f3a..e4c31bd6b 100644 --- a/libs/bao1x-api/src/bio.rs +++ b/libs/bao1x-api/src/bio.rs @@ -18,6 +18,8 @@ use num_traits::ToPrimitive; use xous::MemoryRange; use crate::IoxPort; +#[cfg(feature = "std")] +use crate::bio_resources::ResourceSpec; 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) -> Result { + 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)] #[derive(Debug)]