Arduino_STM32/STM32F1/libraries/USBComposite
arpruss e8d8cdb75e update to latest version of USBComposite 2018-06-13 15:28:36 -05:00
..
examples update to latest version of USBComposite 2018-06-13 15:28:36 -05:00
AbsMouse.cpp usbcomposite library 2018-04-12 20:45:59 -05:00
BootKeyboard.cpp usbcomposite library 2018-04-12 20:45:59 -05:00
Consumer.cpp usbcomposite library 2018-04-12 20:45:59 -05:00
HIDReports.cpp usbcomposite library 2018-04-12 20:45:59 -05:00
Joystick.cpp usbcomposite library 2018-04-12 20:45:59 -05:00
Keyboard.cpp usbcomposite library 2018-04-12 20:45:59 -05:00
LICENSE usbcomposite library 2018-04-12 20:45:59 -05:00
MidiSpecs.h usbcomposite library 2018-04-12 20:45:59 -05:00
MinSysex.c usbcomposite library 2018-04-12 20:45:59 -05:00
MinSysex.h usbcomposite library 2018-04-12 20:45:59 -05:00
Mouse.cpp usbcomposite library 2018-04-12 20:45:59 -05:00
README.md usbcomposite library 2018-04-12 20:45:59 -05:00
USBComposite.cpp usbcomposite library 2018-04-12 20:45:59 -05:00
USBComposite.h usbcomposite library 2018-04-12 20:45:59 -05:00
USBCompositeSerial.cpp update to latest version of USBComposite 2018-06-13 15:28:36 -05:00
USBCompositeSerial.h update to latest version of USBComposite 2018-06-13 15:28:36 -05:00
USBHID.cpp update to latest version of USBComposite 2018-06-13 15:28:36 -05:00
USBHID.h usbcomposite library 2018-04-12 20:45:59 -05:00
USBMIDI.cpp usbcomposite library 2018-04-12 20:45:59 -05:00
USBMIDI.h usbcomposite library 2018-04-12 20:45:59 -05:00
USBMassStorage.cpp update to latest version of USBComposite 2018-06-13 15:28:36 -05:00
USBMassStorage.h usbcomposite library 2018-04-12 20:45:59 -05:00
USBXBox360.cpp usbcomposite library 2018-04-12 20:45:59 -05:00
USBXBox360.h usbcomposite library 2018-04-12 20:45:59 -05:00
keywords.txt usbcomposite library 2018-04-12 20:45:59 -05:00
library.properties update to latest version of USBComposite 2018-06-13 15:28:36 -05:00
usb_composite_serial.c update to latest version of USBComposite 2018-06-13 15:28:36 -05:00
usb_composite_serial.h update to latest version of USBComposite 2018-06-13 15:28:36 -05:00
usb_generic.c usbcomposite library 2018-04-12 20:45:59 -05:00
usb_generic.h usbcomposite library 2018-04-12 20:45:59 -05:00
usb_hid.c usbcomposite library 2018-04-12 20:45:59 -05:00
usb_hid.h usbcomposite library 2018-04-12 20:45:59 -05:00
usb_mass.c usbcomposite library 2018-04-12 20:45:59 -05:00
usb_mass.h usbcomposite library 2018-04-12 20:45:59 -05:00
usb_mass_internal.h usbcomposite library 2018-04-12 20:45:59 -05:00
usb_mass_mal.c usbcomposite library 2018-04-12 20:45:59 -05:00
usb_mass_mal.h usbcomposite library 2018-04-12 20:45:59 -05:00
usb_midi_device.c update to latest version of USBComposite 2018-06-13 15:28:36 -05:00
usb_midi_device.h usbcomposite library 2018-04-12 20:45:59 -05:00
usb_scsi.c usbcomposite library 2018-04-12 20:45:59 -05:00
usb_scsi.h usbcomposite library 2018-04-12 20:45:59 -05:00
usb_scsi_data.c usbcomposite library 2018-04-12 20:45:59 -05:00
usb_setup.cpp update to latest version of USBComposite 2018-06-13 15:28:36 -05:00
usb_x360.c usbcomposite library 2018-04-12 20:45:59 -05:00
usb_x360.h usbcomposite library 2018-04-12 20:45:59 -05:00

README.md

USB Composite library for STM32F1

Protocols supported

  • standard USB HID, with many built-in profiles, and customizable with more

  • MIDI over USB

  • XBox360 controller (only controller-to-host is currently supported)

  • Mass storage

Basic concepts

Start with:

#include <USBComposite.h>

The library defines several crucial objects. The central object is:

extern USBCompositeDevice USBComposite;

This controls USB device identification as well as registers the plugins that are connected to it.

Plugin objects included in the library are:

extern USBHIDDevice USBHID;
extern USBMidi USBMIDI;
extern USBXBox360 XBox360;
extern USBMassStorageDevice MassStorage;
extern USBCompositeSerial CompositeSerial;

You can also create your own customized instances of these plugin classes or their subclasses.

If you want to make a simple (non-composite) USB device, you can just call the plugin's begin() method, and it will take care of registering itself with USBComposite and starting up USBComposite. If you want to make a composite USB device, however, you need to control the device with USBComposite:

USBComposite.clear(); // clear any plugins previously registered
plugin1.registerComponent(); 
plugin2.registerComponent();
USBComposite.begin();

Of course, you may need to do some further configuring of the plugins or the USBComposite device before the USBComposite.begin() call.

Finally, there are a number of objects that implement particular protocols for the USBHID plugin:

extern HIDMouse Mouse;
extern HIDKeyboard Keyboard;
extern HIDJoystick Joystick;
extern HIDKeyboard BootKeyboard;

And you can customize with more. Moreover, the USBHID plugin itself allows for compositing multiple HID profiles, e.g., Mouse / Keyboard / three joysticks.

Not all combinations will fit within the constraints of the STM32F1 USB system, and not all combinations will be supported by all operating systems.

Simple USB device configuration

A simple USB device uses a single plugin. You just need to call any setup methods for the plugin and the begin() method for the plugin. For instance, to inject keyboard data, you can do:

USBHID.begin(HID_KEYBOARD);

and then call Keyboard.print("TextToInject") to inject keyboard data. Some plugin configurations may require further initialization code or further code that needs to be called inside the Arduino loop() function.

See the BootKeyboard, midiout and x360 example code for this procedure.

Additionally, for backwards compatibility reasons, the USBHID plugin has a convenience USBHID_begin_with_serial() function which works just like USBHID.begin() except that it also composites a CompositeSerial plugin.

However, if you want a USB device using more than one plugin, then you will NOT call the plugin's begin() method.