rtio: raise input overflow exception

This commit is contained in:
Sebastien Bourdeauducq 2014-10-21 23:41:02 +08:00
parent 9a14081031
commit 5105b88302
3 changed files with 17 additions and 2 deletions

View File

@ -13,7 +13,8 @@ class OutOfMemory(RuntimeException):
class RTIOUnderflow(RuntimeException):
"""Raised when the CPU fails to submit a RTIO event early enough (with respect to the event's timestamp).
"""Raised when the CPU fails to submit a RTIO event early enough
(with respect to the event's timestamp).
"""
eid = 1
@ -28,6 +29,14 @@ class RTIOSequenceError(RuntimeException):
eid = 2
class RTIOOverflow(RuntimeException):
"""Raised when at least one event could not be registered into the RTIO
input FIFO because it was full (CPU not reading fast enough).
"""
eid = 3
exception_map = {e.eid: e for e in globals().values()
if inspect.isclass(e)
and issubclass(e, RuntimeException)

View File

@ -4,7 +4,8 @@
enum {
EID_OUT_OF_MEMORY = 0,
EID_RTIO_UNDERFLOW = 1,
EID_RTIO_SEQUENCE_ERROR = 2
EID_RTIO_SEQUENCE_ERROR = 2,
EID_RTIO_OVERFLOW = 3,
};
int exception_setjmp(void *jb) __attribute__((returns_twice));

View File

@ -59,6 +59,11 @@ 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_overflow_read()) {
rtio_reset_logic_write(1);
rtio_reset_logic_write(0);
exception_raise(EID_RTIO_OVERFLOW);
}
if(rtio_i_readable_read()) {
r = rtio_i_timestamp_read();
rtio_i_re_write(1);