mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
pretty-print spi
This commit is contained in:
parent
ccc342d9f3
commit
e0f3ee8e49
1 changed files with 10 additions and 11 deletions
|
|
@ -4,8 +4,7 @@ use super::report_api;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
pub fn spi_test() {
|
pub fn spi_test() {
|
||||||
report_api(0x1310_5000);
|
print!("SPI test\r");
|
||||||
report_api(0x51C0_0000);
|
|
||||||
|
|
||||||
// clear prior test config state
|
// clear prior test config state
|
||||||
let mut test_cfg = CSR::new(utra::main::HW_MAIN_BASE as *mut u32);
|
let mut test_cfg = CSR::new(utra::main::HW_MAIN_BASE as *mut u32);
|
||||||
|
|
@ -15,7 +14,7 @@ pub fn spi_test() {
|
||||||
// stop all the machines, so that code can be loaded
|
// stop all the machines, so that code can be loaded
|
||||||
bio_ss.bio.wo(utra::bio::SFR_CTRL, 0x0);
|
bio_ss.bio.wo(utra::bio::SFR_CTRL, 0x0);
|
||||||
let code = spi_driver();
|
let code = spi_driver();
|
||||||
report_api(code.len() as u32);
|
print!("code length {}\r", code.len());
|
||||||
bio_ss.load_code(code, 0);
|
bio_ss.load_code(code, 0);
|
||||||
|
|
||||||
// configure fifo trigger levels
|
// configure fifo trigger levels
|
||||||
|
|
@ -36,7 +35,7 @@ pub fn spi_test() {
|
||||||
bio_ss.bio.wo(
|
bio_ss.bio.wo(
|
||||||
utra::bio::SFR_CONFIG,
|
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, 1)
|
||||||
| bio_ss.bio.ms(utra::bio::SFR_CONFIG_SNAP_OUTPUT_TO_WHICH, 2)
|
| bio_ss.bio.ms(utra::bio::SFR_CONFIG_SNAP_OUTPUT_TO_WHICH, 2),
|
||||||
);
|
);
|
||||||
|
|
||||||
// bypass sync on all but clock
|
// bypass sync on all but clock
|
||||||
|
|
@ -45,7 +44,7 @@ pub fn spi_test() {
|
||||||
bio_ss.bio.wo(
|
bio_ss.bio.wo(
|
||||||
utra::bio::SFR_EXTCLOCK,
|
utra::bio::SFR_EXTCLOCK,
|
||||||
bio_ss.bio.ms(utra::bio::SFR_EXTCLOCK_USE_EXTCLK, 0b1000)
|
bio_ss.bio.ms(utra::bio::SFR_EXTCLOCK_USE_EXTCLK, 0b1000)
|
||||||
| bio_ss.bio.ms(utra::bio::SFR_EXTCLOCK_EXTCLK_GPIO_3, 9)
|
| bio_ss.bio.ms(utra::bio::SFR_EXTCLOCK_EXTCLK_GPIO_3, 9),
|
||||||
);
|
);
|
||||||
|
|
||||||
// start cores 2 & 3
|
// start cores 2 & 3
|
||||||
|
|
@ -75,10 +74,10 @@ pub fn spi_test() {
|
||||||
while bio_ss.bio.rf(SFR_FLEVEL_PCLK_REGFIFO_LEVEL1) == 0 {} // wait until there's something there
|
while bio_ss.bio.rf(SFR_FLEVEL_PCLK_REGFIFO_LEVEL1) == 0 {} // wait until there's something there
|
||||||
retvals[j] = bio_ss.bio.r(utra::bio::SFR_RXF1);
|
retvals[j] = bio_ss.bio.r(utra::bio::SFR_RXF1);
|
||||||
j += 1;
|
j += 1;
|
||||||
report_api(j as u32);
|
print!("iter {}", j);
|
||||||
}
|
}
|
||||||
for (index, &val) in retvals.iter().enumerate() {
|
for (index, &val) in retvals.iter().enumerate() {
|
||||||
report_api(val);
|
print!("SPI rbk {:x}", val);
|
||||||
// the XOR to 0xAAAA is just a mask we threw in to test immediate loads
|
// the XOR to 0xAAAA is just a mask we threw in to test immediate loads
|
||||||
assert!(val == ((0xAA00 | index as u32) ^ 0xAAAA));
|
assert!(val == ((0xAA00 | index as u32) ^ 0xAAAA));
|
||||||
}
|
}
|
||||||
|
|
@ -90,10 +89,10 @@ pub fn spi_test() {
|
||||||
// - loading word out of RAM (the random mask at the top)
|
// - loading word out of RAM (the random mask at the top)
|
||||||
// - machine ID based dispatch
|
// - machine ID based dispatch
|
||||||
// - how fast the SPI could run, hence the unrolled loop
|
// - how fast the SPI could run, hence the unrolled loop
|
||||||
// - Receive clock triggering a code event (quanta register x20
|
// - Receive clock triggering a code event (quanta register x20 is remapped to a GPIO input instead of the
|
||||||
// is remapped to a GPIO input instead of the clock divider)
|
// clock divider)
|
||||||
// - Branch on quanta read (saves one clock cycle for a tight loop;
|
// - Branch on quanta read (saves one clock cycle for a tight loop; not strictly necessary but we use the
|
||||||
// not strictly necessary but we use the idiom here to cap Tx loop)
|
// idiom here to cap Tx loop)
|
||||||
// This runs at about a 25MHz SPI clock rate, assuming an 800MHz
|
// This runs at about a 25MHz SPI clock rate, assuming an 800MHz
|
||||||
// core clock for the complex. The Rx loop is potentially much faster
|
// core clock for the complex. The Rx loop is potentially much faster
|
||||||
// than the Tx loop.
|
// than the Tx loop.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue