From 4b6ea1904987e0bbe80b68610c8ad5be1ad69c66 Mon Sep 17 00:00:00 2001 From: Russell Gallop Date: Fri, 26 Aug 2011 15:35:17 +0100 Subject: [PATCH] Get iAP reset from decouple. Currently just done a initialisation. --- module_usb_aud_shared/usb_buffer/decouple.xc | 4 ++- module_usb_midi/src/usb_midi.xc | 29 ++++++++++++-------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/module_usb_aud_shared/usb_buffer/decouple.xc b/module_usb_aud_shared/usb_buffer/decouple.xc index 815b4e8a..4c65a405 100644 --- a/module_usb_aud_shared/usb_buffer/decouple.xc +++ b/module_usb_aud_shared/usb_buffer/decouple.xc @@ -671,6 +671,7 @@ void decouple(chanend c_mix_out, xc_ptr zero_buffer = array_to_xc_ptr(g_zero_buffer); int is_ack_iap; + int is_reset; unsigned int datum_iap; int iap_data_remaining_to_device = 0; int iap_data_collected_from_device = 0; @@ -763,6 +764,7 @@ void decouple(chanend c_mix_out, // send the current host -> device buffer out of the fifo XUD_SetReady(iap_from_host_usb_ep, 1); + iap_send_reset(c_iap); #endif #endif @@ -1233,7 +1235,7 @@ void decouple(chanend c_mix_out, select { /* Received word from iap thread - Check for ACK or Data */ - case iap_get_ack_or_data(c_iap, is_ack_iap, datum_iap): + case iap_get_ack_or_reset_or_data(c_iap, is_ack_iap, is_reset, datum_iap): if (is_ack_iap) { /* An ack from the iap/uart thread means it has accepted some data we sent it diff --git a/module_usb_midi/src/usb_midi.xc b/module_usb_midi/src/usb_midi.xc index 3b51de14..5966a95a 100644 --- a/module_usb_midi/src/usb_midi.xc +++ b/module_usb_midi/src/usb_midi.xc @@ -155,21 +155,11 @@ chanend c_iap, chanend ?c_i2c // iOS stuff // Initialise buffers init_queue(to_host_fifo, to_host_arr, 256); init_queue(from_host_fifo, from_host_arr, 256); - // Start buffer with StartIDPS message in - iap_bufferlen = StartIDPS(iap_buffer); - port32A_set(P32A_I2C_NOTMIDI); - for (int i = 0; i != iap_bufferlen; i++) { - enqueue(to_host_fifo, iap_buffer[i]); - } - //dump(to_host_fifo); - // Start the ball rolling (so I will be expecting an ack) - outuint(c_iap, dequeue(to_host_fifo)); - ith_count++; - while (1) { int is_ack; + int is_reset; unsigned int datum; select { // Input to read the start bit @@ -329,7 +319,21 @@ chanend c_iap, chanend ?c_i2c // iOS stuff #endif } break; - case !(isTX || isRX) => iap_get_ack_or_data(c_iap, is_ack, datum): + case !(isTX || isRX) => iap_get_ack_or_reset_or_data(c_iap, is_ack, is_reset, datum): + if (is_reset) { +authenticating = 1; + // Start buffer with StartIDPS message in + iap_bufferlen = StartIDPS(iap_buffer); + port32A_set(P32A_I2C_NOTMIDI); + for (int i = 0; i != iap_bufferlen; i++) { + enqueue(to_host_fifo, iap_buffer[i]); + } + //dump(to_host_fifo); + // Start the ball rolling (so I will be expecting an ack) + outuint(c_iap, dequeue(to_host_fifo)); + ith_count++; + + } else { //printstrln("iap_get_ack_or_data"); if (is_ack) { // have we got more data to send @@ -378,6 +382,7 @@ chanend c_iap, chanend ?c_i2c // iOS stuff // printstrln("Completed authentication"); p_midi_in :> void; // Change port around to input again after authenticating } + } break; }