From 957c065f41e20a6d44eb1de320d585f13c79dbcb Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 18 Dec 2020 04:35:39 +0800 Subject: [PATCH] push mods for modnoise eval etc. --- services/ticktimer-server/src/main.rs | 23 ++++++++++++++--------- services/trng-tester/src/main.rs | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/services/ticktimer-server/src/main.rs b/services/ticktimer-server/src/main.rs index 427305096..0056bc1a4 100644 --- a/services/ticktimer-server/src/main.rs +++ b/services/ticktimer-server/src/main.rs @@ -102,6 +102,7 @@ mod implementation { (&mut xtt) as *mut XousTickTimer as *mut usize, ) .expect("couldn't claim irq"); + xtt } @@ -157,19 +158,23 @@ mod implementation { pub fn reset_wdt(&mut self) { // disarm the WDT - // why do we write the registers three times? because: + // why do we have this weird interlock dance? // - the WDT is triggered on a "ring oscillator" that's entirely internal to the SoC // (so you can't defeat the WDT by just pausing the external clock sourc) // - the ring oscillator has a tolerance band of 65MHz +/- 50% // - the CPU runs at 100MHz with a tight tolerance - // - presenting the data three times ensures the WDT will pick it up, - // even at the slowest end of tolerance - self.wdt.wfo(utra::wdt::WATCHDOG_RESET_CODE, 0x600d); - self.wdt.wfo(utra::wdt::WATCHDOG_RESET_CODE, 0x600d); - self.wdt.wfo(utra::wdt::WATCHDOG_RESET_CODE, 0x600d); - self.wdt.wfo(utra::wdt::WATCHDOG_RESET_CODE, 0xc0de); - self.wdt.wfo(utra::wdt::WATCHDOG_RESET_CODE, 0xc0de); - self.wdt.wfo(utra::wdt::WATCHDOG_RESET_CODE, 0xc0de); + // - thus we have to confirm the write of the watchdog data before moving to the next state + if self.wdt.rf(utra::wdt::STATE_ENABLED) == 1 { + if self.wdt.rf(utra::wdt::STATE_DISARMED) != 1 { + while self.wdt.rf(utra::wdt::STATE_ARMED1) == 1 { + self.wdt.wfo(utra::wdt::WATCHDOG_RESET_CODE, 0x600d); + } + self.wdt.wfo(utra::wdt::WATCHDOG_RESET_CODE, 0xc0de); + while self.wdt.rf(utra::wdt::STATE_ARMED2) == 1 { + self.wdt.wfo(utra::wdt::WATCHDOG_RESET_CODE, 0xc0de); + } + } + } } } } diff --git a/services/trng-tester/src/main.rs b/services/trng-tester/src/main.rs index febf5357b..e15079c7c 100644 --- a/services/trng-tester/src/main.rs +++ b/services/trng-tester/src/main.rs @@ -107,7 +107,20 @@ mod implementation { | self.server_csr.ms(utra::trng_server::CONTROL_RO_DIS, 1) // disable the RO to characterize only the AV ); // delay in microseconds for avalanche poweron after powersave - self.server_csr.wfo(utra::trng_server::AV_CONFIG_POWERDELAY, 50_000); + // self.server_csr.rmwf(utra::trng_server::AV_CONFIG_POWERDELAY, 50_000); + self.server_csr.wo(utra::trng_server::AV_CONFIG, + self.server_csr.ms(utra::trng_server::AV_CONFIG_POWERDELAY, 50_000) + | self.server_csr.ms(utra::trng_server::AV_CONFIG_SAMPLES, 20) + ); + + /* historical note -- for modular noise variants -- do not remove + self.xadc_csr.rmwf(utra::trng::MODNOISE_CTL_PERIOD, 495); // to set just the period + + self.xadc_csr.wo(utra::trng::MODNOISE_CTL, // to set also the deadtime + self.xadc_csr.ms(utra::trng::MODNOISE_CTL_ENA, 1) + | self.xadc_csr.ms(utra::trng::MODNOISE_CTL_PERIOD, 64) + | self.xadc_csr.ms(utra::trng::MODNOISE_CTL_DEADTIME, 5) + );*/ } pub fn messible_send(&mut self, which: WhichMessible, value: u8) {