From 85d5e6980d2b0da2207456dfd7e584ee03b5ad78 Mon Sep 17 00:00:00 2001 From: Russell Gallop Date: Thu, 11 Aug 2011 15:02:53 +0100 Subject: [PATCH] Add comments --- module_usb_midi/src/usb_midi.h | 2 +- module_usb_midi/src/usb_midi.xc | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/module_usb_midi/src/usb_midi.h b/module_usb_midi/src/usb_midi.h index 0ea1e7c5..215def1d 100644 --- a/module_usb_midi/src/usb_midi.h +++ b/module_usb_midi/src/usb_midi.h @@ -39,7 +39,7 @@ void midi_get_ack_or_data(chanend c, int &is_ack, unsigned int &datum); INLINE void midi_get_ack_or_data(chanend c, int &is_ack, unsigned int &datum) { if (testct(c)) { is_ack = 1; - (void) inct(c); + (void) inct(c); // read 1-bytes control token (void) inuchar(c); (void) inuchar(c); (void) inuchar(c); diff --git a/module_usb_midi/src/usb_midi.xc b/module_usb_midi/src/usb_midi.xc index 41ce169d..5737a968 100644 --- a/module_usb_midi/src/usb_midi.xc +++ b/module_usb_midi/src/usb_midi.xc @@ -18,8 +18,8 @@ static unsigned bit_time = XS1_TIMER_MHZ * 1000000 / (unsigned) RATE; static unsigned bit_time_2 = (XS1_TIMER_MHZ * 1000000 / (unsigned) RATE) / 2; // For debugging -int mr_count = 0; -int th_count = 0; +int mr_count = 0; // MIDI received (from HOST) +int th_count = 0; // MIDI sent (To Host) #ifdef MIDI_LOOPBACK static inline void handle_byte_from_uart(chanend c_midi, struct midi_in_parse_state &mips, int cable_number, @@ -49,19 +49,17 @@ static inline void handle_byte_from_uart(chanend c_midi, struct midi_in_parse_ } #endif -int uout_count = 0; -int uin_count = 0; +int uout_count = 0; // UART bytes out +int uin_count = 0; // UART bytes in void usb_midi(in port ?p_midi_in, out port ?p_midi_out, clock ?clk_midi, chanend c_midi, unsigned cable_number) { - int is_ack; - unsigned int datum; - unsigned symbol = 0x0; - unsigned outputting = 0; - unsigned time; + unsigned symbol = 0x0; // Symbol in progress of being sent out + unsigned outputting = 0; // Guard when outputting data + unsigned time; // Timer value used for outputting //unsigned inputPortState, newInputPortState; int waiting_for_ack = 0; // Receiver @@ -106,6 +104,8 @@ void usb_midi(in port ?p_midi_in, out port ?p_midi_out, #endif while (1) { + int is_ack; + unsigned int datum; select { // Input to read the start bit