diff --git a/soc/runtime/bridge.c b/soc/runtime/bridge.c index aa55fc94a..79b3ba758 100644 --- a/soc/runtime/bridge.c +++ b/soc/runtime/bridge.c @@ -20,12 +20,20 @@ void bridge_main(void) while(1) { umsg = mailbox_wait_and_receive(); 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; msg = (struct msg_brg_ttl_out *)umsg; rtio_init(); - rtio_set_oe(rtio_get_counter() + 8000, msg->channel, 1); rtio_set_o(rtio_get_counter() + 8000, msg->channel, msg->value); mailbox_acknowledge(); break; diff --git a/soc/runtime/messages.h b/soc/runtime/messages.h index 6706abbf7..1f008150d 100644 --- a/soc/runtime/messages.h +++ b/soc/runtime/messages.h @@ -14,7 +14,8 @@ enum { MESSAGE_TYPE_LOG, 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_RESET, MESSAGE_TYPE_BRG_DDS_READ_REQUEST, @@ -71,6 +72,7 @@ struct msg_log { /* bridge messages */ struct msg_brg_ttl_out { + /* used for OE and O */ int type; int channel; int value; diff --git a/soc/runtime/test_mode.c b/soc/runtime/test_mode.c index 17124efa9..5b018c4d9 100644 --- a/soc/runtime/test_mode.c +++ b/soc/runtime/test_mode.c @@ -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; - 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.value = value; mailbox_send_and_wait(&msg); @@ -142,13 +152,13 @@ static void clksrc(char *value) rtiocrg_clock_sel_write(value2); } -static void ttlout(char *n, char *value) +static void ttloe(char *n, char *value) { char *c; unsigned int n2, value2; if((*n == 0)||(*value == 0)) { - printf("ttlout \n"); + printf("ttloe \n"); return; } @@ -163,7 +173,31 @@ static void ttlout(char *n, char *value) 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"); + 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) @@ -341,7 +375,8 @@ static void help(void) puts("Available commands:"); puts("help - this message"); puts("clksrc - select RTIO clock source"); - puts("ttlout - output TTL"); + puts("ttloe - set TTL output enable"); + puts("ttlo - set TTL output value"); puts("ddssel - select a DDS"); puts("ddsinit - reset, config, FUD 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, "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, "ddsw") == 0) ddsw(get_token(&c), get_token(&c));