Use CT_END instead of CT_PAUSE for MIDI handshake

This commit is contained in:
Shuchita Khare
2024-05-29 14:54:17 +01:00
parent a96a137533
commit 5daee760af
3 changed files with 14 additions and 13 deletions

View File

@@ -58,23 +58,26 @@ INLINE void midi_get_ack_or_data(chanend c, int &is_ack, unsigned int &datum) {
if (testct(c)) {
is_ack = 1;
(void) inct(c); // read 1-bytes control token
(void) inuchar(c);
(void) inuchar(c);
(void) inuchar(c);
chkct(c, XS1_CT_END);
}
else {
is_ack = 0;
datum = inuint(c);
chkct(c, XS1_CT_END);
}
}
#endif
INLINE void midi_send_ack(chanend c) {
outct(c, MIDI_ACK);
outuchar(c, 0);
outuchar(c, 0);
outuchar(c, 0);
outct(c, XS1_CT_END);
}
INLINE void midi_send_data(chanend c, unsigned int datum) {
outuint(c, datum);
outct(c, XS1_CT_END);
}
#define MIDI_RATE (31250)
#define MIDI_BITTIME (XS1_TIMER_MHZ * 1000000 / MIDI_RATE)
#define MIDI_BITTIME_2 (MIDI_BITTIME>>1)

View File

@@ -839,7 +839,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
if (midi_data_remaining_to_device)
{
read_via_xc_ptr(datum, midi_from_host_rdptr);
outuint(c_midi, datum);
midi_send_data(c_midi, datum);
midi_from_host_rdptr += 4;
midi_data_remaining_to_device -= 4;
}
@@ -992,8 +992,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
{
/* Read another word from the fifo and output it to MIDI thread */
read_via_xc_ptr(datum, midi_from_host_rdptr);
outuint(c_midi, datum);
outct(c_midi, XS1_CT_PAUSE);
midi_send_data(c_midi, datum);
midi_from_host_rdptr += 4;
midi_data_remaining_to_device -= 4;
}
@@ -1002,7 +1001,6 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
{
/* The midi/uart thread has sent us some data - handshake back */
midi_send_ack(c_midi);
outct(c_midi, XS1_CT_PAUSE);
if (midi_data_collected_from_device < MIDI_USB_BUFFER_TO_HOST_SIZE)
{
/* There is room in the collecting buffer for the data */

View File

@@ -197,7 +197,7 @@ void usb_midi(
{
// send data
// printstr("uart->decouple: ");
outuint(c_midi, event);
midi_send_data(c_midi, event);
waiting_for_ack = 1;
th_count++;
}
@@ -272,7 +272,7 @@ void usb_midi(
// have we got more data to send
if (!queue_is_empty(midi_to_host_fifo))
{
outuint(c_midi, queue_pop_word(midi_to_host_fifo, midi_to_host_fifo_arr));
midi_send_data(c_midi, queue_pop_word(midi_to_host_fifo, midi_to_host_fifo_arr));
th_count++;
}
else
@@ -296,7 +296,7 @@ void usb_midi(
{
// send data
event = byterev(event);
outuint(c_midi, event);
midi_send_data(c_midi, event);
th_count++;
waiting_for_ack = 1;
}