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

@@ -172,45 +172,46 @@ void usb_midi(in port ?p_midi_in, out port ?p_midi_out,
} }
break; break;
// Output // Output
// If outputting then feed the bits out one at a time // If outputting then feed the bits out one at a time
// until symbol is zero expect pattern like 10'b1dddddddd0 // until symbol is zero expect pattern like 10'b1dddddddd0
// 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? // Take from FIFO
if (!isempty(symbol_fifo)) { // FIFO not empty outputting_symbol = dequeue(symbol_fifo);
// Take from FIFO symbol = makeSymbol(outputting_symbol);
outputting_symbol = dequeue(symbol_fifo);
symbol = makeSymbol(outputting_symbol);
if (space(symbol_fifo) > 3 && midi_from_host_overflow) { if (space(symbol_fifo) > 3 && midi_from_host_overflow) {
midi_from_host_overflow = 0; midi_from_host_overflow = 0;
midi_send_ack(c_midi); midi_send_ack(c_midi);
} }
p_midi_out <: 1 @ txPT; p_midi_out <: 1 @ txPT;
// printstr("mout1\n"); // printstr("mout1\n");
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;