diff --git a/artiq/devices/runtime.py b/artiq/devices/runtime.py index 9e55002de..43114c08f 100644 --- a/artiq/devices/runtime.py +++ b/artiq/devices/runtime.py @@ -9,9 +9,11 @@ lt.initialize_all() _syscalls = { "rpc": "i+:i", "gpio_set": "ii:n", + "rtio_oe": "ii:n", "rtio_set": "Iii:n", "rtio_replace": "Iii:n", "rtio_sync": "i:n", + "rtio_get": "i:I", "dds_program": "iiI:n", } diff --git a/soc/runtime/rtio.c b/soc/runtime/rtio.c index 550e54e45..8ee74dafc 100644 --- a/soc/runtime/rtio.c +++ b/soc/runtime/rtio.c @@ -7,6 +7,12 @@ void rtio_init(void) rtio_reset_write(1); } +void rtio_oe(int channel, int oe) +{ + rtio_chan_sel_write(channel); + rtio_oe_write(oe); +} + void rtio_set(long long int timestamp, int channel, int value) { rtio_reset_write(0); @@ -30,3 +36,18 @@ void rtio_sync(int channel) rtio_chan_sel_write(channel); while(rtio_o_level_read() != 0); } + +long long int rtio_get(int channel) +{ + long long int r; + + 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(); + rtio_i_re_write(1); + return r; + } + } + return -1; +} diff --git a/soc/runtime/rtio.h b/soc/runtime/rtio.h index 619ee9890..bce2602ea 100644 --- a/soc/runtime/rtio.h +++ b/soc/runtime/rtio.h @@ -2,8 +2,10 @@ #define __RTIO_H void rtio_init(void); +void rtio_oe(int channel, int oe); void rtio_set(long long int timestamp, int channel, int value); void rtio_replace(long long int timestamp, int channel, int value); void rtio_sync(int channel); +long long int rtio_get(int channel); #endif /* __RTIO_H */ diff --git a/soc/runtime/symbols.c b/soc/runtime/symbols.c index c2db7bcdd..7b9be97ce 100644 --- a/soc/runtime/symbols.c +++ b/soc/runtime/symbols.c @@ -10,9 +10,11 @@ static const struct symbol syscalls[] = { {"rpc", rpc}, {"gpio_set", gpio_set}, + {"rtio_oe", rtio_oe}, {"rtio_set", rtio_set}, {"rtio_replace", rtio_replace}, {"rtio_sync", rtio_sync}, + {"rtio_get", rtio_get}, {"dds_program", dds_program}, {NULL, NULL} };