Skip to content

Commit a50bd7b

Browse files
author
Sebastien Bourdeauducq
committedDec 15, 2011
MIDI: support new uart core, correctly this time
1 parent 533b374 commit a50bd7b

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed
 

‎src/tests_midi.c

+18-13
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ static int loopback(void)
2626
{
2727
unsigned int c = 0;
2828
char e;
29+
int timeout;
2930
int result = TEST_STATUS_PASSED;
3031

31-
printf("press 'e' exit MIDI test\n");
32-
irq_ack(IRQ_MIDI);
32+
printf("Press 'e' to terminate the MIDI test\n");
3333
while(1) {
34-
if (c == 256) {
35-
printf("0 ~ 255 sent out, press 'e' for exit\n");
34+
if(c == 256) {
35+
printf("Sending 0 ~ 255...\n");
3636
c = 0;
3737
}
3838
CSR_MIDI_RXTX = c;
@@ -44,17 +44,22 @@ static int loopback(void)
4444
}
4545
CSR_MIDI_STAT = MIDI_STAT_TX_EVT;
4646

47-
48-
if(CSR_MIDI_STAT & MIDI_STAT_RX_EVT) {
49-
printf("Failed: RX receive problem\n");
50-
result = TEST_STATUS_FAILED;
47+
timeout = 10000;
48+
while(!(CSR_MIDI_STAT & MIDI_STAT_RX_EVT)) {
49+
if(timeout-- == 0) {
50+
printf("Test failed: RX timeout\n");
51+
result = TEST_STATUS_FAILED;
52+
break;
53+
}
5154
}
52-
53-
if(CSR_MIDI_RXTX != c) {
54-
printf("Failed: TX: %d, but RX: %d\n", c, CSR_MIDI_RXTX);
55-
result = TEST_STATUS_FAILED;
55+
56+
if(timeout > 0) {
57+
if(CSR_MIDI_RXTX != c) {
58+
printf("Failed: TX: %d, but RX: %d\n", c, CSR_MIDI_RXTX);
59+
result = TEST_STATUS_FAILED;
60+
}
61+
CSR_MIDI_STAT = MIDI_STAT_RX_EVT;
5662
}
57-
CSR_MIDI_STAT = MIDI_STAT_RX_EVT;
5863
c++;
5964
}
6065

0 commit comments

Comments
 (0)
Please sign in to comment.