|
|
@@ -47,30 +47,67 @@ |
|
|
|
#define ENDPOINT_TRANSMIT_AND_RECEIVE 0x1D |
|
|
|
|
|
|
|
/* |
|
|
|
To modify a USB Type to have different interfaces, start in this |
|
|
|
file. Delete the XYZ_INTERFACE lines for any interfaces you |
|
|
|
wish to remove, and copy them from another USB Type for any you |
|
|
|
want to add. |
|
|
|
Each group of #define lines below corresponds to one of the |
|
|
|
settings in the Tools > USB Type menu. This file defines what |
|
|
|
type of USB device is actually created for each of those menu |
|
|
|
options. |
|
|
|
|
|
|
|
Each "interface" is a set of functionality your PC or Mac will |
|
|
|
use and treat as if it is a unique device. Within each interface, |
|
|
|
the "endpoints" are the actual communication channels. Most |
|
|
|
interfaces use 1, 2 or 3 endpoints. By editing only this file, |
|
|
|
you can customize the USB Types to be any collection of interfaces. |
|
|
|
|
|
|
|
To modify a USB Type, delete the XYZ_INTERFACE lines for any |
|
|
|
interfaces you wish to remove, and copy them from another USB Type |
|
|
|
for any you want to add. |
|
|
|
|
|
|
|
Give each interface a unique number, and edit NUM_INTERFACE to |
|
|
|
reflect the number of interfaces. |
|
|
|
reflect the total number of interfaces. |
|
|
|
|
|
|
|
Next, assign unique endpoint numbers to all the endpoints across |
|
|
|
all the interfaces your device has. You can reuse an endpoint |
|
|
|
number for transmit and receive, but the same endpoint number must |
|
|
|
not be used twice to transmit, or twice to receive. |
|
|
|
|
|
|
|
Most endpoints also require their maximum size, and some also |
|
|
|
need an interval specification (the number of milliseconds the |
|
|
|
PC will check for data from that endpoint). For existing |
|
|
|
interfaces, usually these other settings should not be changed. |
|
|
|
|
|
|
|
Within each interface, make sure it uses a unique set of endpoints. |
|
|
|
Edit NUM_ENDPOINTS to be at least the largest endpoint number used. |
|
|
|
Then edit the ENDPOINT*_CONFIG lines so each endpoint is configured |
|
|
|
|
|
|
|
Edit NUM_USB_BUFFERS to control how much memory the USB stack will |
|
|
|
allocate. At least 2 should be used for each endpoint. More |
|
|
|
memory will allow higher throughput for user programs that have |
|
|
|
high latency (eg, spending time doing things other than interacting |
|
|
|
with the USB). |
|
|
|
|
|
|
|
Edit the ENDPOINT*_CONFIG lines so each endpoint is configured |
|
|
|
the proper way (transmit, receive, or both). |
|
|
|
|
|
|
|
The CONFIG_DESC_SIZE and any XYZ_DESC_OFFSET numbers must be |
|
|
|
edited to the correct sizes. See usb_desc.c for the giant array |
|
|
|
of bytes. Someday these may be done automatically..... (but how?) |
|
|
|
If you are using existing interfaces (making your own device with |
|
|
|
a different set of interfaces) the code in all other files should |
|
|
|
automatically adapt to the new endpoints you specify here. |
|
|
|
|
|
|
|
If you are using existing interfaces, the code in each file should |
|
|
|
automatically adapt to the changes you specify. If you need to |
|
|
|
create a new type of interface, you'll need to write the code which |
|
|
|
sends and receives packets, and presents an API to the user. |
|
|
|
However, the .h files for each interface, which define the API |
|
|
|
visible to user programs, may need to be edited. At the top of |
|
|
|
each .h file is #if defined(USB_XYZ). These may need to be edited |
|
|
|
to make the interface API appear to your program. |
|
|
|
|
|
|
|
Finally, edit usb_inst.cpp, which creats instances of the C++ |
|
|
|
objects for each combination. |
|
|
|
If you need to create a new type of interface, you'll need to write |
|
|
|
the code which sends and receives packets, and presents an API to |
|
|
|
the user. Usually, a pair of files are added for the actual code, |
|
|
|
and code is also added in usb_dev.c for any control transfers, |
|
|
|
interrupt-level code, or other very low-level stuff not possible |
|
|
|
from the packet send/receive functons. Code also is added in |
|
|
|
usb_inst.c to create an instance of your C++ object. |
|
|
|
|
|
|
|
You may edit the Vendor and Product ID numbers, and strings. If |
|
|
|
the numbers are changed, Teensyduino may not be able to automatically |
|
|
|
find and reboot your board when you click the Upload button in |
|
|
|
the Arduino IDE. You will need to press the Program button on |
|
|
|
Teensy to initiate programming. |
|
|
|
|
|
|
|
Some operating systems, especially Windows, may cache USB device |
|
|
|
info. Changes to the device name may not update on the same |
|
|
@@ -82,7 +119,6 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(USB_SERIAL) |
|
|
|
#define VENDOR_ID 0x16C0 |
|
|
|
#define PRODUCT_ID 0x0483 |
|
|
@@ -103,7 +139,6 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports |
|
|
|
#define CDC_ACM_SIZE 16 |
|
|
|
#define CDC_RX_SIZE 64 |
|
|
|
#define CDC_TX_SIZE 64 |
|
|
|
#define CONFIG_DESC_SIZE (9+9+5+5+4+5+7+9+7+7) |
|
|
|
#define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY |
|
|
|
#define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY |
|
|
|
#define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY |
|
|
@@ -138,11 +173,6 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports |
|
|
|
#define JOYSTICK_ENDPOINT 4 |
|
|
|
#define JOYSTICK_SIZE 16 |
|
|
|
#define JOYSTICK_INTERVAL 2 |
|
|
|
#define KEYBOARD_DESC_OFFSET (9 + 9) |
|
|
|
#define MOUSE_DESC_OFFSET (9 + 9+9+7 + 9) |
|
|
|
#define SEREMU_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 9) |
|
|
|
#define JOYSTICK_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 9+9+7+7 + 9) |
|
|
|
#define CONFIG_DESC_SIZE (9 + 9+9+7 + 9+9+7 + 9+9+7+7 + 9+9+7) |
|
|
|
#define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY |
|
|
|
#define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY |
|
|
|
#define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY |
|
|
@@ -184,10 +214,6 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports |
|
|
|
#define JOYSTICK_ENDPOINT 6 |
|
|
|
#define JOYSTICK_SIZE 16 |
|
|
|
#define JOYSTICK_INTERVAL 1 |
|
|
|
#define KEYBOARD_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9) |
|
|
|
#define MOUSE_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9) |
|
|
|
#define JOYSTICK_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9) |
|
|
|
#define CONFIG_DESC_SIZE (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9+9+7) |
|
|
|
#define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY |
|
|
|
#define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY |
|
|
|
#define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY |
|
|
@@ -218,8 +244,6 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports |
|
|
|
#define MIDI_TX_SIZE 64 |
|
|
|
#define MIDI_RX_ENDPOINT 4 |
|
|
|
#define MIDI_RX_SIZE 64 |
|
|
|
#define SEREMU_DESC_OFFSET (9 + 9+7+6+6+9+9+9+5+9+5 + 9) |
|
|
|
#define CONFIG_DESC_SIZE (9 + 9+7+6+6+9+9+9+5+9+5 + 9+9+7+7) |
|
|
|
#define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY |
|
|
|
#define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY |
|
|
|
#define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY |
|
|
@@ -252,9 +276,6 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports |
|
|
|
#define SEREMU_RX_ENDPOINT 2 |
|
|
|
#define SEREMU_RX_SIZE 32 |
|
|
|
#define SEREMU_RX_INTERVAL 2 |
|
|
|
#define RAWHID_DESC_OFFSET (9 + 9) |
|
|
|
#define SEREMU_DESC_OFFSET (9 + 9+9+7+7 + 9) |
|
|
|
#define CONFIG_DESC_SIZE (9 + 9+9+7+7 + 9+9+7+7) |
|
|
|
#define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY |
|
|
|
#define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY |
|
|
|
#define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY |
|
|
@@ -285,9 +306,6 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports |
|
|
|
#define SEREMU_RX_ENDPOINT 2 |
|
|
|
#define SEREMU_RX_SIZE 32 |
|
|
|
#define SEREMU_RX_INTERVAL 2 |
|
|
|
#define FLIGHTSIM_DESC_OFFSET (9 + 9) |
|
|
|
#define SEREMU_DESC_OFFSET (9 + 9+9+7+7 + 9) |
|
|
|
#define CONFIG_DESC_SIZE (9 + 9+9+7+7 + 9+9+7+7) |
|
|
|
#define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY |
|
|
|
#define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY |
|
|
|
#define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY |