runtime: add rtio_oe and rtio_get syscalls

This commit is contained in:
Sebastien Bourdeauducq 2014-09-14 23:30:33 +08:00
parent 6ae88d6caf
commit f529361c8b
4 changed files with 27 additions and 0 deletions

View File

@ -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",
}

View File

@ -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;
}

View File

@ -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 */

View File

@ -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}
};