Hi,
could someone of you tell me how is it possible to transmit some audio- and midi-date from my x86 processor (working with visual studio c++) to my LPC-USB-Device? Is there also a specific headerfile / library like the hid.h / hid.lib (using WriteFile() ReadFile() methods)?
My USB-Audio-Device-Class is already successfull installed and registrated in the windows device manager.
best regards Jens
Hi Tsuneo,
I got the sysex messages (with 6bytes) working. But how can I determine (know) that I can already send a second usb-message, including the last three bytes of the sysex message?
Is there an interrupt-possibility or a method where I can set a flag which indiciates that another usb-pkt if available could be send?
/* first sysex-message */ USB_WriteEP(0x81, (unsigned char *) &midi_testdata[0], 4* sizeof(unsigned char)); delay_ms(1000); /* second sysex message */ USB_WriteEP(0x81, (unsigned char *) &midi_testdata[4], 4* sizeof(unsigned char));
Ah, I remember. A bulk transaction can hold multiple USB-MIDI packets (4 bytes). A single bulk transaction (ie. single USB_WriteEP() call) sends up to 64 bytes. 16 USB-MIDI packets can be put into a 64 bytes buffer sequentially, and this buffer is sent to host at a time. Therefore, you may send two USB-MIDI packets, which holds SysEx message, in single USB_WriteEP() call. > Is there an interrupt-possibility or a method where I can set a flag which indiciates that another usb-pkt if available could be send?
There are two ways to know if the bulk IN endpoint is available or not. As the background, the bulk endpoints of NXP LPC USB MCUs has double buffers. You may put two transactions to these endpoints, at a time.
a) Using a counter We place a counting semaphore as a global variable. This variable is initialized at USB_Configure_Event() At the transaction completion (USB_EndPointX() call back), this variable increments.
usbuser.c U8 bulk_EP_TX_counter = 0; // a global variable to hold available number of transactions #if USB_CONFIGURE_EVENT void USB_Configure_Event (void) { if (USB_Configuration) { /* Check if USB is configured */ bulk_EP_TX_counter = 2; // two transactions are available } } #endif void USB_EndPoint2 (U32 event) { switch (event) { case USB_EVT_IN: // a bulk IN transaction completes ++bulk_EP_TX_counter; // we may put another transaction break; } }
In your code, the variable decrements.
if ( bulk_EP_TX_counter ) { --bulk_EP_TX_counter; // decrement the semaphore USB_WriteEP( 0x82, buffer, number_of_bytes_to_send ); }
b) Using SIE command "Select Endpoint" command returns the endpoint status. FE bit (Full/Empty: bit0) of this status indicates availability of either of endpoint buffers. SIE command takes more execution time than above method.
#define BULK_IN_EP 0x82 ep_status = RdCmdDat( CMD_SEL_EP(EPAdr( BULK_IN_EP )) );
Umm.. You are using an interrupt EP (0x81), instead of a bulk EP. It's OK, but interrupt EPs have just single buffer.
Tsuneo