From 133bb2b74ff2652792107e5c9b7c50ea06517740 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 12 Mar 2024 13:54:07 +0800 Subject: [PATCH] fix a few minor details missing in the tests also update docs and completion tracker --- libs/xous-bio/src/bio_tests/mod.rs | 8 ++++---- libs/xous-bio/src/bio_tests/spi.rs | 17 ++++++++++++++++- libs/xous-bio/src/bio_tests/units.rs | 4 +++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/libs/xous-bio/src/bio_tests/mod.rs b/libs/xous-bio/src/bio_tests/mod.rs index 6cde70760..f1e8901c9 100644 --- a/libs/xous-bio/src/bio_tests/mod.rs +++ b/libs/xous-bio/src/bio_tests/mod.rs @@ -102,18 +102,18 @@ pub fn bio_tests() { // -[x] Host FIFO stall on empty test. Core stalls until host provides data. // -[x] Host FIFO stall on full test. Core stall until host reads data. // -[x] GPIO input path test -// -[ ] Extclk as x20 stall source -// -[ ] Check Extclk:gpio pin mapping (make sure bit ordering is not swapped) +// -[x] Extclk as x20 stall source +// -[x] Check Extclk:gpio pin mapping (make sure bit ordering is not swapped) // -[ ] GPIO direction control test // -[ ] FIFO level trigger test - eq, gt, lt on various channels, at various fullness levels // -[x] Stall on event - register bit test, between cores // -[x] Stall on event - register bit test, to host // -[x] Stall on event - FIFO level test // -[ ] Host IRQ generation test - some combination with event tests above to confirm IRQ generation -// -[ ] Core ID read test +// -[x] Core ID read test // -[ ] Core aclk counter test // Application tests: -// -[ ] SPI loopback test - implement using extclk as spi clk for input +// -[x] SPI loopback test - implement using extclk as spi clk for input // -[ ] I2C loopback test // -[ ] IR controller test // -[ ] Arithmetic test, utilizing load/store on core 0 diff --git a/libs/xous-bio/src/bio_tests/spi.rs b/libs/xous-bio/src/bio_tests/spi.rs index 00d7effb3..8ab9f284b 100644 --- a/libs/xous-bio/src/bio_tests/spi.rs +++ b/libs/xous-bio/src/bio_tests/spi.rs @@ -33,7 +33,11 @@ pub fn spi_test() { // this actually shouldn't matter, but set it to be "fast" for testing bio_ss.bio.wo(utra::bio::SFR_QDIV3, 0x1_0000); // snap GPIO outputs - bio_ss.bio.wo(utra::bio::SFR_CONFIG, 1); + bio_ss.bio.wo( + utra::bio::SFR_CONFIG, + bio_ss.bio.ms(utra::bio::SFR_CONFIG_SNAP_OUTPUT_TO_QUANTUM, 1) + | bio_ss.bio.ms(utra::bio::SFR_CONFIG_SNAP_OUTPUT_TO_WHICH, 2) + ); // bypass sync on all but clock bio_ss.bio.wo(utra::bio::SFR_SYNC_BYPASS, 0x500); @@ -82,6 +86,17 @@ pub fn spi_test() { report_api(0x51C0_600D); } +// This is written to also test some additional features: +// - loading word out of RAM (the random mask at the top) +// - machine ID based dispatch +// - how fast the SPI could run, hence the unrolled loop +// - Receive clock triggering a code event (quanta register x20 +// is remapped to a GPIO input instead of the clock divider) +// - Branch on quanta read (saves one clock cycle for a tight loop; +// not strictly necessary but we use the idiom here to cap Tx loop) +// This runs at about a 25MHz SPI clock rate, assuming an 800MHz +// core clock for the complex. The Rx loop is potentially much faster +// than the Tx loop. #[rustfmt::skip] bio_code!( spi_driver, diff --git a/libs/xous-bio/src/bio_tests/units.rs b/libs/xous-bio/src/bio_tests/units.rs index ebce63211..bc50000b0 100644 --- a/libs/xous-bio/src/bio_tests/units.rs +++ b/libs/xous-bio/src/bio_tests/units.rs @@ -51,7 +51,7 @@ pub fn hello_multiverse() { bio_ss.bio.wo( utra::bio::SFR_CONFIG, bio_ss.bio.ms(utra::bio::SFR_CONFIG_SNAP_OUTPUT_TO_QUANTUM, 1) - | bio_ss.bio.ms(utra::bio::SFR_CONFIG_SNAP_OUTPUT_TO_QUANTUM, 2), /* arbitrary choice, they + | bio_ss.bio.ms(utra::bio::SFR_CONFIG_SNAP_OUTPUT_TO_QUANTUM, 1), /* arbitrary choice, they * should all be the same */ ); // start all the machines, all at once @@ -236,6 +236,8 @@ pub fn host_fifo_tests() { bio_ss.bio.wo(utra::bio::SFR_CTRL, 0x0); let code = fifo_host_bitbang(); bio_ss.load_code(code, 0); + // reset all the fifos + bio_ss.bio.wo(utra::bio::SFR_FIFO_CLR, 0xF); // configure & run the 0th machine // clock it slowly, so the fifo builds up back pressure