LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
MIDI Class Device Mode Driver

Data Structures

struct  USB_ClassInfo_MIDI_Device_t
 MIDI Class Device Mode Configuration and State Structure. More...
 

Functions

bool MIDI_Device_ConfigureEndpoints (USB_ClassInfo_MIDI_Device_t *const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1)
 Configures the endpoints of a given MIDI interface, ready for use. This should be linked to the library EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the given MIDI interface is selected.
 
void MIDI_Device_USBTask (USB_ClassInfo_MIDI_Device_t *const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1)
 General management task for a given MIDI class interface, required for the correct operation of the interface. This should be called frequently in the main program loop, before the master USB management task USB_USBTask().
 
uint8_t MIDI_Device_SendEventPacket (USB_ClassInfo_MIDI_Device_t *const MIDIInterfaceInfo, const MIDI_EventPacket_t *const Event) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2)
 Sends a MIDI event packet to the host. If no host is connected, the event packet is discarded. Events are queued into the endpoint bank until either the endpoint bank is full, or MIDI_Device_Flush() is called. This allows for multiple MIDI events to be packed into a single endpoint packet, increasing data throughput.
 
uint8_t MIDI_Device_Flush (USB_ClassInfo_MIDI_Device_t *const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1)
 Flushes the MIDI send buffer, sending any queued MIDI events to the host. This should be called to override the MIDI_Device_SendEventPacket() function's packing behaviour, to flush queued events.
 
bool MIDI_Device_ReceiveEventPacket (USB_ClassInfo_MIDI_Device_t *const MIDIInterfaceInfo, MIDI_EventPacket_t *const Event) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2)
 Receives a MIDI event packet from the host. Events are unpacked from the endpoint, thus if the endpoint bank contains multiple MIDI events from the host in the one packet, multiple calls to this function will return each individual event.
 
static void MIDI_Device_ProcessControlRequest (USB_ClassInfo_MIDI_Device_t *const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1)
 Processes incoming control requests from the host, that are directed to the given MIDI class interface. This should be linked to the library EVENT_USB_Device_ControlRequest() event.
 

Detailed Description

Module Source Dependencies

The following files must be built with any user project that uses this module:

Module Description

Device Mode USB Class driver framework interface, for the MIDI USB Class driver.

Function Documentation

bool MIDI_Device_ConfigureEndpoints ( USB_ClassInfo_MIDI_Device_t *const  MIDIInterfaceInfo)

Configures the endpoints of a given MIDI interface, ready for use. This should be linked to the library EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the given MIDI interface is selected.

Parameters
MIDIInterfaceInfo: Pointer to a structure containing a MIDI Class configuration and state.
Returns
Boolean true if the endpoints were successfully configured, false otherwise.

Definition at line 43 of file MIDIClassDevice.c.

uint8_t MIDI_Device_Flush ( USB_ClassInfo_MIDI_Device_t *const  MIDIInterfaceInfo)

Flushes the MIDI send buffer, sending any queued MIDI events to the host. This should be called to override the MIDI_Device_SendEventPacket() function's packing behaviour, to flush queued events.

Parameters
MIDIInterfaceInfo: Pointer to a structure containing a MIDI Class configuration and state.
Returns
A value from the Endpoint_WaitUntilReady_ErrorCodes_t enum.

Definition at line 112 of file MIDIClassDevice.c.

static void MIDI_Device_ProcessControlRequest ( USB_ClassInfo_MIDI_Device_t *const  MIDIInterfaceInfo)
inlinestatic

Processes incoming control requests from the host, that are directed to the given MIDI class interface. This should be linked to the library EVENT_USB_Device_ControlRequest() event.

Parameters
MIDIInterfaceInfo: Pointer to a structure containing a MIDI Class configuration and state.

Definition at line 170 of file MIDIClassDevice.h.

bool MIDI_Device_ReceiveEventPacket ( USB_ClassInfo_MIDI_Device_t *const  MIDIInterfaceInfo,
MIDI_EventPacket_t *const  Event 
)

Receives a MIDI event packet from the host. Events are unpacked from the endpoint, thus if the endpoint bank contains multiple MIDI events from the host in the one packet, multiple calls to this function will return each individual event.

Precondition
This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the call will fail.
Parameters
MIDIInterfaceInfo: Pointer to a structure containing a MIDI Class configuration and state.
Event: Pointer to a USB_MIDI_EventPacket_t structure where the received MIDI event is to be placed.
Returns
Boolean true if a MIDI event packet was received, false otherwise.

Definition at line 132 of file MIDIClassDevice.c.

uint8_t MIDI_Device_SendEventPacket ( USB_ClassInfo_MIDI_Device_t *const  MIDIInterfaceInfo,
const MIDI_EventPacket_t *const  Event 
)

Sends a MIDI event packet to the host. If no host is connected, the event packet is discarded. Events are queued into the endpoint bank until either the endpoint bank is full, or MIDI_Device_Flush() is called. This allows for multiple MIDI events to be packed into a single endpoint packet, increasing data throughput.

Precondition
This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the call will fail.
Parameters
MIDIInterfaceInfo: Pointer to a structure containing a MIDI Class configuration and state.
Event: Pointer to a populated MIDI_EventPacket_t structure containing the MIDI event to send.
Returns
A value from the Endpoint_Stream_RW_ErrorCodes_t enum.

Definition at line 93 of file MIDIClassDevice.c.

void MIDI_Device_USBTask ( USB_ClassInfo_MIDI_Device_t *const  MIDIInterfaceInfo)

General management task for a given MIDI class interface, required for the correct operation of the interface. This should be called frequently in the main program loop, before the master USB management task USB_USBTask().

Parameters
MIDIInterfaceInfo: Pointer to a structure containing a MIDI Class configuration and state.
Returns
Nothing

Definition at line 83 of file MIDIClassDevice.c.