From d22c30650d8ff55b1f02217204edd4fd24fe6e0e Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 14 Oct 2014 15:54:10 +0800 Subject: [PATCH] rtio: add timestamp function --- artiq/devices/rtio_core.py | 10 ++++++++++ soc/runtime/rtio.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/artiq/devices/rtio_core.py b/artiq/devices/rtio_core.py index 4c95cc4fa..02eabe634 100644 --- a/artiq/devices/rtio_core.py +++ b/artiq/devices/rtio_core.py @@ -137,3 +137,13 @@ class RTIOIn(_RTIOBase): while syscall("rtio_get", self.channel) >= 0: count += 1 return count + + @kernel + def timestamp(self): + """Poll the RTIO input and returns an event timestamp, according to + the gating. + + If the gate is permanently closed, returns a negative value. + + """ + return cycles_to_time(syscall("rtio_get", self.channel)) diff --git a/soc/runtime/rtio.c b/soc/runtime/rtio.c index 2b172d890..0033a6ccd 100644 --- a/soc/runtime/rtio.c +++ b/soc/runtime/rtio.c @@ -60,7 +60,7 @@ long long int rtio_get(int channel) rtio_chan_sel_write(channel); while(rtio_i_readable_read() || (rtio_o_level_read() != 0)) { if(rtio_i_readable_read()) { - r = rtio_i_value_read(); + r = rtio_i_timestamp_read(); rtio_i_re_write(1); return r; }