From 3d8dc360d18199e33d545f3130fe00d8baca4ddd Mon Sep 17 00:00:00 2001 From: Russell Date: Thu, 13 Oct 2011 11:44:24 +0100 Subject: [PATCH] Implement bug 11331 for iOS + MIDI configuration. Ran out of timers so have to be careful about use of init_iAP and polling timer. --- module_usb_midi/src/usb_midi.xc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/module_usb_midi/src/usb_midi.xc b/module_usb_midi/src/usb_midi.xc index 3fe3c404..2cf751f4 100644 --- a/module_usb_midi/src/usb_midi.xc +++ b/module_usb_midi/src/usb_midi.xc @@ -59,6 +59,9 @@ int uin_count = 0; // UART bytes in // state for iAP extern unsigned authenticating; +// state for auto-selecting dock or USB B +extern unsigned polltime; + extern port p_i2c_scl; extern port p_i2c_sda; #define p_midi_out p_i2c_scl @@ -121,8 +124,12 @@ chanend c_iap, chanend ?c_i2c // iOS stuff // printstr("mout0"); #endif - init_iAP(c_i2c); + init_iAP(c_i2c); // uses timer for i2c initialisation pause.. + { + timer poll; // .. so declare this after or don't have enough timers + poll :> polltime; + polltime + XS1_TIMER_HZ / 2; while (1) { int is_ack; int is_reset; @@ -292,7 +299,11 @@ chanend c_iap, chanend ?c_i2c // iOS stuff p_midi_in :> void; // Change port around to input again after authenticating (unique to midi+iAP case) } break; - } + case poll when timerafter(polltime) :> void: + handle_poll_dev_det(poll); + break; + } } + } }