forked from M-Labs/artiq
1
0
Fork 0

runtime/test_mode: support setting O and OE separately

This commit is contained in:
Sebastien Bourdeauducq 2015-05-02 12:16:09 +08:00
parent a61d701d47
commit 8fe5c7ac01
3 changed files with 56 additions and 10 deletions

View File

@ -20,12 +20,20 @@ void bridge_main(void)
while(1) { while(1) {
umsg = mailbox_wait_and_receive(); umsg = mailbox_wait_and_receive();
switch(umsg->type) { switch(umsg->type) {
case MESSAGE_TYPE_BRG_TTL_OUT: { case MESSAGE_TYPE_BRG_TTL_OE: {
struct msg_brg_ttl_out *msg;
msg = (struct msg_brg_ttl_out *)umsg;
rtio_init();
rtio_set_oe(rtio_get_counter() + 8000, msg->channel, msg->value);
mailbox_acknowledge();
break;
}
case MESSAGE_TYPE_BRG_TTL_O: {
struct msg_brg_ttl_out *msg; struct msg_brg_ttl_out *msg;
msg = (struct msg_brg_ttl_out *)umsg; msg = (struct msg_brg_ttl_out *)umsg;
rtio_init(); rtio_init();
rtio_set_oe(rtio_get_counter() + 8000, msg->channel, 1);
rtio_set_o(rtio_get_counter() + 8000, msg->channel, msg->value); rtio_set_o(rtio_get_counter() + 8000, msg->channel, msg->value);
mailbox_acknowledge(); mailbox_acknowledge();
break; break;

View File

@ -14,7 +14,8 @@ enum {
MESSAGE_TYPE_LOG, MESSAGE_TYPE_LOG,
MESSAGE_TYPE_BRG_READY, MESSAGE_TYPE_BRG_READY,
MESSAGE_TYPE_BRG_TTL_OUT, MESSAGE_TYPE_BRG_TTL_O,
MESSAGE_TYPE_BRG_TTL_OE,
MESSAGE_TYPE_BRG_DDS_SEL, MESSAGE_TYPE_BRG_DDS_SEL,
MESSAGE_TYPE_BRG_DDS_RESET, MESSAGE_TYPE_BRG_DDS_RESET,
MESSAGE_TYPE_BRG_DDS_READ_REQUEST, MESSAGE_TYPE_BRG_DDS_READ_REQUEST,
@ -71,6 +72,7 @@ struct msg_log {
/* bridge messages */ /* bridge messages */
struct msg_brg_ttl_out { struct msg_brg_ttl_out {
/* used for OE and O */
int type; int type;
int channel; int channel;
int value; int value;

View File

@ -35,11 +35,21 @@ static void amp_bridge_init(void)
} }
} }
static void p_ttlout(int n, int value) static void p_ttloe(int n, int value)
{ {
struct msg_brg_ttl_out msg; struct msg_brg_ttl_out msg;
msg.type = MESSAGE_TYPE_BRG_TTL_OUT; msg.type = MESSAGE_TYPE_BRG_TTL_OE;
msg.channel = n;
msg.value = value;
mailbox_send_and_wait(&msg);
}
static void p_ttlo(int n, int value)
{
struct msg_brg_ttl_out msg;
msg.type = MESSAGE_TYPE_BRG_TTL_O;
msg.channel = n; msg.channel = n;
msg.value = value; msg.value = value;
mailbox_send_and_wait(&msg); mailbox_send_and_wait(&msg);
@ -142,13 +152,13 @@ static void clksrc(char *value)
rtiocrg_clock_sel_write(value2); rtiocrg_clock_sel_write(value2);
} }
static void ttlout(char *n, char *value) static void ttloe(char *n, char *value)
{ {
char *c; char *c;
unsigned int n2, value2; unsigned int n2, value2;
if((*n == 0)||(*value == 0)) { if((*n == 0)||(*value == 0)) {
printf("ttlout <n> <value>\n"); printf("ttloe <n> <value>\n");
return; return;
} }
@ -163,7 +173,31 @@ static void ttlout(char *n, char *value)
return; return;
} }
p_ttlout(n2, value2); p_ttloe(n2, value2);
}
static void ttlo(char *n, char *value)
{
char *c;
unsigned int n2, value2;
if((*n == 0)||(*value == 0)) {
printf("ttlo <n> <value>\n");
return;
}
n2 = strtoul(n, &c, 0);
if(*c != 0) {
printf("incorrect channel\n");
return;
}
value2 = strtoul(value, &c, 0);
if(*c != 0) {
printf("incorrect value\n");
return;
}
p_ttlo(n2, value2);
} }
static void ddssel(char *n) static void ddssel(char *n)
@ -341,7 +375,8 @@ static void help(void)
puts("Available commands:"); puts("Available commands:");
puts("help - this message"); puts("help - this message");
puts("clksrc <n> - select RTIO clock source"); puts("clksrc <n> - select RTIO clock source");
puts("ttlout <n> <v> - output TTL"); puts("ttloe <n> <v> - set TTL output enable");
puts("ttlo <n> <v> - set TTL output value");
puts("ddssel <n> - select a DDS"); puts("ddssel <n> - select a DDS");
puts("ddsinit - reset, config, FUD DDS"); puts("ddsinit - reset, config, FUD DDS");
puts("ddsreset - reset DDS"); puts("ddsreset - reset DDS");
@ -418,7 +453,8 @@ static void do_command(char *c)
else if(strcmp(token, "clksrc") == 0) clksrc(get_token(&c)); else if(strcmp(token, "clksrc") == 0) clksrc(get_token(&c));
else if(strcmp(token, "ttlout") == 0) ttlout(get_token(&c), get_token(&c)); else if(strcmp(token, "ttloe") == 0) ttloe(get_token(&c), get_token(&c));
else if(strcmp(token, "ttlo") == 0) ttlo(get_token(&c), get_token(&c));
else if(strcmp(token, "ddssel") == 0) ddssel(get_token(&c)); else if(strcmp(token, "ddssel") == 0) ddssel(get_token(&c));
else if(strcmp(token, "ddsw") == 0) ddsw(get_token(&c), get_token(&c)); else if(strcmp(token, "ddsw") == 0) ddsw(get_token(&c), get_token(&c));