From 8f6653ef72bb6a3839efef8c681e1be9191af1da Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Wed, 9 Mar 2016 17:58:42 +0100 Subject: [PATCH] test_spi: simplify test, add collision vs busy test --- artiq/test/coredevice/test_spi.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/artiq/test/coredevice/test_spi.py b/artiq/test/coredevice/test_spi.py index ac1838d5d..436f720d9 100644 --- a/artiq/test/coredevice/test_spi.py +++ b/artiq/test/coredevice/test_spi.py @@ -2,6 +2,19 @@ from artiq.experiment import * from artiq.test.hardware_testbench import ExperimentCase +class Collision(EnvExperiment): + def build(self): + self.setattr_device("core") + self.setattr_device("spi0") + + @kernel + def run(self): + t = now_mu() + self.spi0.set_config_mu() + at_mu(t) + self.spi0.set_config_mu() + + class Busy(EnvExperiment): def build(self): self.setattr_device("core") @@ -10,8 +23,9 @@ class Busy(EnvExperiment): @kernel def run(self): + t = now_mu() self.spi0.set_config_mu() - delay(-8*ns) + at_mu(t + self.spi0.ref_period_mu) self.spi0.set_config_mu() # causes the error self.led.on() self.led.sync() # registers the error @@ -20,5 +34,10 @@ class Busy(EnvExperiment): class SPITest(ExperimentCase): + def test_collision(self): + with self.assertRaises(RTIOCollision): + self.execute(Collision) + def test_busy(self): - self.execute(Busy) + with self.assertRaises(RTIOBusy): + self.execute(Busy)