@@ -26,13 +26,13 @@ static int loopback(void)
26
26
{
27
27
unsigned int c = 0 ;
28
28
char e ;
29
+ int timeout ;
29
30
int result = TEST_STATUS_PASSED ;
30
31
31
- printf ("press 'e' exit MIDI test\n" );
32
- irq_ack (IRQ_MIDI );
32
+ printf ("Press 'e' to terminate the MIDI test\n" );
33
33
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" );
36
36
c = 0 ;
37
37
}
38
38
CSR_MIDI_RXTX = c ;
@@ -44,17 +44,22 @@ static int loopback(void)
44
44
}
45
45
CSR_MIDI_STAT = MIDI_STAT_TX_EVT ;
46
46
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
+ }
51
54
}
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 ;
56
62
}
57
- CSR_MIDI_STAT = MIDI_STAT_RX_EVT ;
58
63
c ++ ;
59
64
}
60
65
0 commit comments