Thanks Thorsten, i finally got to try and implement the code, still no midi ports though at least this doesn't appear as a "composite device" which - as i've understood - is part of the problem. I'm thinking that i've done something seriously wrong here since none of the code i've tried so far has worked - even though they've apparently worked for other people. I'm wondering if i need to get a class-specific request (which i never get as far as i can see) before windows decides to install the midiports. Maybe the buffersize is incorrect, though i've tried changing the size in the descriptor so far without luck. Okay, this is the only changes i've made to the HID example to make it go midi: * Changing descriptor * Adding typedefs for calculating the descriptor size microchip-style * Changed the ClassReqHandler[1] to point at a function of my own (USBCheckMIDIStreamRequest) * Changed the initializationroutine for the endpoints * Changed ProcessIO to look for incoming events * Changed EP0_BUFF_SIZE to 64 (i tried 8 as well, but i guess it should be 64 with this descriptor, right?) Right now i'm just looking for some kind of request that is not directed to an interface, or a request that is not a STANDARD_REQUEST type deal. Just anything. Here's a piece of the code i've changed, it might not be fully functioning, just a brief explanation of what i'm trying to do:
#define MIDI_UEP UEP1
#define MIDI_BD_OUT ep1Bo
#define MIDI_BD_IN ep1Bi
#define MIDI_BD_OUT ep1Bo
#define MIDI_BD_IN ep1Bi
//Called when we get Set Config Handler request and Configured State
void MIDIInitEP(void) {
MIDI_UEP = EP_OUT_IN|HSHK_EN; // Enable 2 data pipes
MIDI_BD_OUT.Cnt = sizeof(midi_out); // Set buffer size
MIDI_BD_OUT.ADR = (byte*)&midi_out; // Set buffer address
MIDI_BD_OUT.Stat._byte = _USIE|_DAT0|_DTSEN; // Set status
MIDI_BD_IN.Cnt = sizeof(midi_in); // Set buffer size
MIDI_BD_IN.ADR = (byte*)&midi_in; // Set buffer address
MIDI_BD_IN.Stat._byte = _UCPU|_DAT1; // Set status
}
void USBCheckMIDIStreamRequest(void) {
if(SetupPkt.Recipient != RCPT_INTF) return;
/* Use debug functions here to show that we've got something that is *not* directed to an interface
for once. I also tried if(SetupPkt.RequestType == STANDARD) return; just to see if i could get
*anything*
*/
}
#define mMIDITxIsBusy() MIDI_BD_IN.Stat.UOWN
#define mMIDIRxIsBusy() MIDI_BD_OUT.Stat.UOWN
void ProcessIO(void) {
if((usb_device_state < CONFIGURED_STATE)||(UCONbits.SUSPND==1)) return;
if(usb_device_state == DETACHED_STATE) return;
if(UCONbits.SUSPND==1) return;
if (!MIDI_BD_OUT.Stat.UOWN) { // == 0) { hdebug('R','x',' ',' ') }
if (!MIDI_BD_IN.Stat.UOWN) { //== 1) { hdebug('T','x',' ',' ') }
}
A few things are a little unclear to me, for one i can't quite wrap my head around how to monitor the UOWN bit, also the whole buffer deal is a little uncertain for me now. I might have forgot to add something in the code, but hopefully not. Oh, also, i'm using the pic18f2455 but that shouldn't be a problem i guess. Thanks Knas