artiq/artiq/runtime/rtio.c

41 lines
1.2 KiB
C
Raw Normal View History

2014-08-28 16:56:48 +08:00
#include <generated/csr.h>
#include "rtio.h"
void rtio_init(void)
{
2014-11-30 00:13:54 +08:00
rtio_reset_write(1);
rtio_reset_write(0);
rtio_reset_phy_write(0);
2014-08-28 16:56:48 +08:00
}
long long int rtio_get_counter(void)
2014-08-28 16:56:48 +08:00
{
rtio_counter_update_write(1);
return rtio_counter_read();
2014-09-11 23:14:45 +08:00
}
2015-07-29 19:43:35 +08:00
void rtio_process_exceptional_status(int status, long long int timestamp, int channel)
{
if(status & RTIO_O_STATUS_FULL)
while(rtio_o_status_read() & RTIO_O_STATUS_FULL);
if(status & RTIO_O_STATUS_UNDERFLOW) {
rtio_o_underflow_reset_write(1);
2015-11-07 14:44:20 +08:00
artiq_raise_from_c("RTIOUnderflow",
"RTIO underflow at {0} mu, channel {1}, counter {2}",
2015-07-29 19:43:35 +08:00
timestamp, channel, rtio_get_counter());
}
if(status & RTIO_O_STATUS_SEQUENCE_ERROR) {
rtio_o_sequence_error_reset_write(1);
2015-11-07 14:44:20 +08:00
artiq_raise_from_c("RTIOSequenceError",
"RTIO sequence error at {0} mu, channel {1}",
2015-07-29 19:43:35 +08:00
timestamp, channel, 0);
}
if(status & RTIO_O_STATUS_COLLISION_ERROR) {
rtio_o_collision_error_reset_write(1);
2015-11-07 14:44:20 +08:00
artiq_raise_from_c("RTIOCollisionError",
"RTIO collision error at {0} mu, channel {1}",
2015-07-29 19:43:35 +08:00
timestamp, channel, 0);
}
}