From 6982ac2612c12af9fa65437bf4279007d734cc59 Mon Sep 17 00:00:00 2001 From: "adam@algroup.co.uk" Date: Fri, 29 Jan 2010 09:28:47 +0000 Subject: [PATCH] fix USB send data timing issue in CMD_DOWNLOADED_SIM_SAMPLES_125K --- armsrc/appmain.c | 3 +++ client/command.c | 26 +++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 674c8917..4321d946 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -716,9 +716,12 @@ void UsbPacketReceived(BYTE *packet, int len) } case CMD_DOWNLOADED_SIM_SAMPLES_125K: { + UsbCommand ack; BYTE *b = (BYTE *)BigBuf; memcpy(b+c->arg[0], c->d.asBytes, 48); //Dbprintf("copied 48 bytes to %i",b+c->arg[0]); + ack.cmd = CMD_ACK; + UsbSendPacket((BYTE*)&ack, sizeof(ack)); break; } diff --git a/client/command.c b/client/command.c index 8ecbc684..0d954258 100644 --- a/client/command.c +++ b/client/command.c @@ -688,6 +688,7 @@ static void CmdLosim(char *str) /* convert to bitstream if necessary */ ChkBitstream(str); + PrintToScrollback("Sending data, please wait..."); for (i = 0; i < GraphTraceLen; i += 48) { UsbCommand c={CMD_DOWNLOADED_SIM_SAMPLES_125K, {i, 0, 0}}; int j; @@ -695,8 +696,10 @@ static void CmdLosim(char *str) c.d.asBytes[j] = GraphBuffer[i+j]; } SendCommand(&c); + wait_for_response(CMD_ACK); } + PrintToScrollback("Starting simulator..."); UsbCommand c={CMD_SIMULATE_TAG_125K, {GraphTraceLen, gap, 0}}; SendCommand(&c); } @@ -3063,14 +3066,19 @@ void UsbCommandReceived(UsbCommand *c) /* Maybe it's a response: */ switch(current_command) { case CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K: - if (c->cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) goto unexpected_response; - int i; - for(i=0; i<48; i++) sample_buf[i] = c->d.asBytes[i]; - received_command = c->cmd; - return; - default: - unexpected_response: - PrintToScrollback("unrecognized command %08x\n", c->cmd); - break; + if (c->cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) goto unexpected_response; + int i; + for(i=0; i<48; i++) sample_buf[i] = c->d.asBytes[i]; + received_command = c->cmd; + return; + case CMD_DOWNLOADED_SIM_SAMPLES_125K: + if (c->cmd != CMD_ACK) goto unexpected_response; + // got ACK + received_command = c->cmd; + return; + default: + unexpected_response: + PrintToScrollback("unrecognized command %08x\n", c->cmd); + break; } } -- 2.39.2