| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Enumerations | Functions
MIDI Class Host Mode Driver
MIDI Class Driver

## Detailed Description

# Module Source Dependencies

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

- LPCUSBlib/Drivers/USB/Class/Host/MIDI.c (Makefile source module name: LPCUSBlib_SRC_USBCLASS)

# Module Description

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

## Data Structures
struct | USB_ClassInfo_MIDI_Host_t
| MIDI Class Host Mode Configuration and State Structure. More...

## Enumerations
enum | MIDI_Host_EnumerationFailure_ErrorCodes_t { MIDI_ENUMERROR_NoError = 0, MIDI_ENUMERROR_InvalidConfigDescriptor = 1, MIDI_ENUMERROR_NoCompatibleInterfaceFound = 2, MIDI_ENUMERROR_PipeConfigurationFailed = 3 }

## Functions
uint8_t | MIDI_Host_ConfigurePipes (USB_ClassInfo_MIDI_Host_t *const MIDIInterfaceInfo, uint16_t ConfigDescriptorSize, void *DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3)
| Host interface configuration routine, to configure a given MIDI host interface instance using the Configuration Descriptor read from an attached USB device. This function automatically updates the given MIDI Host instance's state values and configures the pipes required to communicate with the interface if it is found within the device. This should be called once after the stack has enumerated the attached device, while the host state machine is in the Addressed state.
void | MIDI_Host_USBTask (USB_ClassInfo_MIDI_Host_t *const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1)
| General management task for a given MIDI host 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_Host_SendEventPacket (USB_ClassInfo_MIDI_Host_t *const MIDIInterfaceInfo, MIDI_EventPacket_t *const Event) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2)
| Sends a MIDI event packet to the device. If no device is connected, the event packet is discarded.
uint8_t | MIDI_Host_Flush (USB_ClassInfo_MIDI_Host_t *const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1)
| Flushes the MIDI send buffer, sending any queued MIDI events to the device. This should be called to override the MIDI_Host_SendEventPacket() function's packing behaviour, to flush queued events. Events are queued into the pipe bank until either the pipe bank is full, or MIDI_Host_Flush() is called. This allows for multiple MIDI events to be packed into a single pipe packet, increasing data throughput.
bool | MIDI_Host_ReceiveEventPacket (USB_ClassInfo_MIDI_Host_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 device.

## Enumeration Type Documentation

enum MIDI_Host_EnumerationFailure_ErrorCodes_t

Enum for the possible error codes returned by the MIDI_Host_ConfigurePipes() function.

Enumerator:

  MIDI_ENUMERROR_NoError | Configuration Descriptor was processed successfully.
  MIDI_ENUMERROR_InvalidConfigDescriptor | The device returned an invalid Configuration Descriptor.
  MIDI_ENUMERROR_NoCompatibleInterfaceFound | A compatible MIDI interface was not found in the device's Configuration Descriptor.
  MIDI_ENUMERROR_PipeConfigurationFailed | One or more pipes for the specified interface could not be configured correctly.

Definition at line 103 of file MIDIClassHost.h.

## Function Documentation

uint8_t MIDI_Host_ConfigurePipes | ( | USB_ClassInfo_MIDI_Host_t *const | MIDIInterfaceInfo,
|  | uint16_t | ConfigDescriptorSize,
|  | void * | DeviceConfigDescriptor
| ) |  |

Host interface configuration routine, to configure a given MIDI host interface instance using the Configuration Descriptor read from an attached USB device. This function automatically updates the given MIDI Host instance's state values and configures the pipes required to communicate with the interface if it is found within the device. This should be called once after the stack has enumerated the attached device, while the host state machine is in the Addressed state.

Parameters

  MIDIInterfaceInfo | : Pointer to a structure containing an MIDI Class host configuration and state.
  ConfigDescriptorSize | : Length of the attached device's Configuration Descriptor.
  DeviceConfigDescriptor | : Pointer to a buffer containing the attached device's Configuration Descriptor.

Returns
  A value from the MIDI_Host_EnumerationFailure_ErrorCodes_t enum.

Definition at line 42 of file MIDIClassHost.c.

uint8_t MIDI_Host_Flush | ( | USB_ClassInfo_MIDI_Host_t *const | MIDIInterfaceInfo | ) |

Flushes the MIDI send buffer, sending any queued MIDI events to the device. This should be called to override the MIDI_Host_SendEventPacket() function's packing behaviour, to flush queued events. Events are queued into the pipe bank until either the pipe bank is full, or MIDI_Host_Flush() is called. This allows for multiple MIDI events to be packed into a single pipe packet, increasing data throughput.

Parameters

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

Returns
  A value from the Pipe_WaitUntilReady_ErrorCodes_t enum.

Definition at line 180 of file MIDIClassHost.c.

bool MIDI_Host_ReceiveEventPacket | ( | USB_ClassInfo_MIDI_Host_t *const | MIDIInterfaceInfo,
|  | MIDI_EventPacket_t *const | Event
| ) |  |

Receives a MIDI event packet from the device.

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 219 of file MIDIClassHost.c.

uint8_t MIDI_Host_SendEventPacket | ( | USB_ClassInfo_MIDI_Host_t *const | MIDIInterfaceInfo,
|  | MIDI_EventPacket_t *const | Event
| ) |  |

Sends a MIDI event packet to the device. If no device is connected, the event packet is discarded.

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 USB_MIDI_EventPacket_t structure containing the MIDI event to send.

Returns
  A value from the Pipe_Stream_RW_ErrorCodes_t enum.

Definition at line 200 of file MIDIClassHost.c.

void MIDI_Host_USBTask | ( | USB_ClassInfo_MIDI_Host_t *const | MIDIInterfaceInfo | ) |

General management task for a given MIDI host 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 an MIDI Class host configuration and state.

Returns
  Nothing

Definition at line 170 of file MIDIClassHost.c.