Rearrange outputting case to make outputted_symbol work again. Handle empty fifo at end of symbol, don't go around again to do this.

This commit is contained in:
Russell Gallop
2011-08-12 14:39:10 +01:00
parent 49563dda0c
commit cb99f0ee4f

View File

@@ -178,12 +178,11 @@ void usb_midi(in port ?p_midi_in, out port ?p_midi_out,
// This code will leave the output high afterwards due to the stop bit added with makeSymbol // This code will leave the output high afterwards due to the stop bit added with makeSymbol
case outputting => t when timerafter(txT) :> int _: case outputting => t when timerafter(txT) :> int _:
if (symbol == 0) { if (symbol == 0) {
// Got something to output but not mid-symbol.
// Start sending symbol. // Start sending symbol.
// This case is reached when a symbol has been received from the host but not started AND // This case is reached when a symbol has been received from the host but not started AND
// When it has just finished sending a symbol // When it has just finished sending a symbol
// have we got another symbol to send to uart?
if (!isempty(symbol_fifo)) { // FIFO not empty
// Take from FIFO // Take from FIFO
outputting_symbol = dequeue(symbol_fifo); outputting_symbol = dequeue(symbol_fifo);
symbol = makeSymbol(outputting_symbol); symbol = makeSymbol(outputting_symbol);
@@ -198,19 +197,21 @@ void usb_midi(in port ?p_midi_in, out port ?p_midi_out,
t :> txT; t :> txT;
txT += bit_time; txT += bit_time;
txPT += bit_time; txPT += bit_time;
// leave outputting set outputting = 1;
} else
outputting = 0;
} else { } else {
// Mid-symbol
txT += bit_time; txT += bit_time;
txPT += bit_time; txPT += bit_time;
p_midi_out @ txPT <: (symbol & 1); p_midi_out @ txPT <: (symbol & 1);
// printstr("mout2\n"); // printstr("mout2\n");
symbol >>= 1; symbol >>= 1;
if (symbol == 0) { if (symbol == 0) {
// Finished sending // Finished sending byte
uout_count++; uout_count++;
outputted_symbol = outputting_symbol; outputted_symbol = outputting_symbol;
if (isempty(symbol_fifo)) { // FIFO empty
outputting = 0;
}
} }
} }
break; break;
@@ -260,7 +261,7 @@ void usb_midi(in port ?p_midi_in, out port ?p_midi_out,
} else { } else {
midi_from_host_overflow = 1; midi_from_host_overflow = 1;
} }
// Could this drop through to the outputting case instead...... // Drop through to the outputting guarded case
if (!outputting) { if (!outputting) {
t :> txT; // Should be enough to trigger the other case t :> txT; // Should be enough to trigger the other case
outputting = 1; outputting = 1;