forked from PAWPAW-Mirror/lib_xua
Use CT_END instead of CT_PAUSE for MIDI handshake
This commit is contained in:
@@ -58,23 +58,26 @@ INLINE void midi_get_ack_or_data(chanend c, int &is_ack, unsigned int &datum) {
|
|||||||
if (testct(c)) {
|
if (testct(c)) {
|
||||||
is_ack = 1;
|
is_ack = 1;
|
||||||
(void) inct(c); // read 1-bytes control token
|
(void) inct(c); // read 1-bytes control token
|
||||||
(void) inuchar(c);
|
chkct(c, XS1_CT_END);
|
||||||
(void) inuchar(c);
|
|
||||||
(void) inuchar(c);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
is_ack = 0;
|
is_ack = 0;
|
||||||
datum = inuint(c);
|
datum = inuint(c);
|
||||||
|
chkct(c, XS1_CT_END);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INLINE void midi_send_ack(chanend c) {
|
INLINE void midi_send_ack(chanend c) {
|
||||||
outct(c, MIDI_ACK);
|
outct(c, MIDI_ACK);
|
||||||
outuchar(c, 0);
|
outct(c, XS1_CT_END);
|
||||||
outuchar(c, 0);
|
|
||||||
outuchar(c, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INLINE void midi_send_data(chanend c, unsigned int datum) {
|
||||||
|
outuint(c, datum);
|
||||||
|
outct(c, XS1_CT_END);
|
||||||
|
}
|
||||||
|
|
||||||
#define MIDI_RATE (31250)
|
#define MIDI_RATE (31250)
|
||||||
#define MIDI_BITTIME (XS1_TIMER_MHZ * 1000000 / MIDI_RATE)
|
#define MIDI_BITTIME (XS1_TIMER_MHZ * 1000000 / MIDI_RATE)
|
||||||
#define MIDI_BITTIME_2 (MIDI_BITTIME>>1)
|
#define MIDI_BITTIME_2 (MIDI_BITTIME>>1)
|
||||||
|
|||||||
@@ -839,7 +839,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
|||||||
if (midi_data_remaining_to_device)
|
if (midi_data_remaining_to_device)
|
||||||
{
|
{
|
||||||
read_via_xc_ptr(datum, midi_from_host_rdptr);
|
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_from_host_rdptr += 4;
|
||||||
midi_data_remaining_to_device -= 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 another word from the fifo and output it to MIDI thread */
|
||||||
read_via_xc_ptr(datum, midi_from_host_rdptr);
|
read_via_xc_ptr(datum, midi_from_host_rdptr);
|
||||||
outuint(c_midi, datum);
|
midi_send_data(c_midi, datum);
|
||||||
outct(c_midi, XS1_CT_PAUSE);
|
|
||||||
midi_from_host_rdptr += 4;
|
midi_from_host_rdptr += 4;
|
||||||
midi_data_remaining_to_device -= 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 */
|
/* The midi/uart thread has sent us some data - handshake back */
|
||||||
midi_send_ack(c_midi);
|
midi_send_ack(c_midi);
|
||||||
outct(c_midi, XS1_CT_PAUSE);
|
|
||||||
if (midi_data_collected_from_device < MIDI_USB_BUFFER_TO_HOST_SIZE)
|
if (midi_data_collected_from_device < MIDI_USB_BUFFER_TO_HOST_SIZE)
|
||||||
{
|
{
|
||||||
/* There is room in the collecting buffer for the data */
|
/* There is room in the collecting buffer for the data */
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ void usb_midi(
|
|||||||
{
|
{
|
||||||
// send data
|
// send data
|
||||||
// printstr("uart->decouple: ");
|
// printstr("uart->decouple: ");
|
||||||
outuint(c_midi, event);
|
midi_send_data(c_midi, event);
|
||||||
waiting_for_ack = 1;
|
waiting_for_ack = 1;
|
||||||
th_count++;
|
th_count++;
|
||||||
}
|
}
|
||||||
@@ -272,7 +272,7 @@ void usb_midi(
|
|||||||
// have we got more data to send
|
// have we got more data to send
|
||||||
if (!queue_is_empty(midi_to_host_fifo))
|
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++;
|
th_count++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -296,7 +296,7 @@ void usb_midi(
|
|||||||
{
|
{
|
||||||
// send data
|
// send data
|
||||||
event = byterev(event);
|
event = byterev(event);
|
||||||
outuint(c_midi, event);
|
midi_send_data(c_midi, event);
|
||||||
th_count++;
|
th_count++;
|
||||||
waiting_for_ack = 1;
|
waiting_for_ack = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user