ON Semiconductor / mbed-os

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Embed: (wiki syntax)

« Back to documentation index

USBMIDI Class Reference

USBMIDI Class Reference

USBMIDI example. More...

#include <USBMIDI.h>

Inherits USBDevice.

Public Member Functions

 USBMIDI (uint16_t vendor_id=0x0700, uint16_t product_id=0x0101, uint16_t product_release=0x0001)
 Constructor.
void write (MIDIMessage m)
 Send a MIDIMessage.
void attach (void(*fptr)(MIDIMessage))
 Attach a callback for when a MIDIEvent is received.
void connect (void)
void configureDevice (void)

Detailed Description

USBMIDI example.

 #include "mbed.h"
 #include "USBMIDI.h"

 USBMIDI midi;

 int main() {
    while (1) {
        for(int i=48; i<83; i++) {     // send some messages!
            midi.write(MIDIMessage::NoteOn(i));
            wait(0.25);
            midi.write(MIDIMessage::NoteOff(i));
            wait(0.5);
        }
    }
 }

Definition at line 53 of file USBMIDI.h.


Constructor & Destructor Documentation

USBMIDI ( uint16_t  vendor_id = 0x0700,
uint16_t  product_id = 0x0101,
uint16_t  product_release = 0x0001 
)

Constructor.

Parameters:
vendor_idYour vendor_id
product_idYour product_id
product_releaseYour preoduct_release

Definition at line 23 of file USBMIDI.cpp.


Member Function Documentation

void attach ( void(*)(MIDIMessage fptr )

Attach a callback for when a MIDIEvent is received.

Parameters:
fptrfunction pointer

Definition at line 76 of file USBMIDI.cpp.

void configureDevice ( void   ) [inherited]

In USBDevice.cpp > USBDevice::requestSetConfiguration, configureDevice() is called after realiseEndpoint() (in USBCallback_setConfiguration()). So we have the following USB buffer management policy: 1. Allocate for CEP on connect(). 2. Allocate for EPX in realiseEndpoint(). 3. Deallocate all except for CEP in unconfigureDevice().

Definition at line 320 of file USBHAL_EFM32.cpp.

void connect ( void   ) [inherited]

Control Transfer Packet Size Constraints low-speed: 8 full-speed: 8, 16, 32, 64 high-speed: 64

Definition at line 280 of file USBHAL_EFM32.cpp.

void write ( MIDIMessage  m )

Send a MIDIMessage.

Parameters:
mThe MIDIMessage to send

Definition at line 31 of file USBMIDI.cpp.