#include "usb_midi.h" | #include "usb_midi.h" | ||||
#include "usb_rawhid.h" | #include "usb_rawhid.h" | ||||
#include "usb_flightsim.h" | #include "usb_flightsim.h" | ||||
#include "usb_undef.h" // do not allow usb_desc.h stuff to leak to user programs | |||||
//#include "WCharacter.h" | //#include "WCharacter.h" | ||||
#include "WString.h" | #include "WString.h" |
#if F_CPU >= 20000000 | #if F_CPU >= 20000000 | ||||
#define USB_DESC_LIST_DEFINE | |||||
#include "usb_desc.h" | #include "usb_desc.h" | ||||
#ifdef NUM_ENDPOINTS | #ifdef NUM_ENDPOINTS | ||||
#include "usb_names.h" | #include "usb_names.h" |
a different set of interfaces) the code in all other files should | a different set of interfaces) the code in all other files should | ||||
automatically adapt to the new endpoints you specify here. | automatically adapt to the new endpoints you specify here. | ||||
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. | |||||
If you need to create a new type of interface, you'll need to write | 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 code which sends and receives packets, and presents an API to | ||||
the user. Usually, a pair of files are added for the actual code, | the user. Usually, a pair of files are added for the actual code, | ||||
#endif | #endif | ||||
#ifdef NUM_ENDPOINTS | |||||
#ifdef USB_DESC_LIST_DEFINE | |||||
#if defined(NUM_ENDPOINTS) && NUM_ENDPOINTS > 0 | |||||
// NUM_ENDPOINTS = number of non-zero endpoints (0 to 15) | // NUM_ENDPOINTS = number of non-zero endpoints (0 to 15) | ||||
extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS]; | extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS]; | ||||
extern const usb_descriptor_list_t usb_descriptor_list[]; | extern const usb_descriptor_list_t usb_descriptor_list[]; | ||||
#endif // NUM_ENDPOINTS | #endif // NUM_ENDPOINTS | ||||
#endif // USB_DESC_LIST_DEFINE | |||||
#endif // F_CPU >= 20 MHz | #endif // F_CPU >= 20 MHz | ||||
#ifndef _usb_dev_h_ | #ifndef _usb_dev_h_ | ||||
#define _usb_dev_h_ | #define _usb_dev_h_ | ||||
#define USB_DESC_LIST_DEFINE | |||||
#include "usb_desc.h" | #include "usb_desc.h" | ||||
#if F_CPU >= 20000000 && defined(NUM_ENDPOINTS) | |||||
#if F_CPU >= 20000000 | |||||
// This header is NOT meant to be included when compiling | // This header is NOT meant to be included when compiling | ||||
// user sketches in Arduino. The low-level functions | // user sketches in Arduino. The low-level functions | ||||
} | } | ||||
#endif | #endif | ||||
#else // F_CPU >= 20000000 && defined(NUM_ENDPOINTS) | |||||
#else // F_CPU < 20000000 | |||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
extern "C" { | extern "C" { | ||||
#endif | #endif | ||||
#endif // F_CPU >= 20000000 && defined(NUM_ENDPOINTS) | |||||
#endif // F_CPU | |||||
#endif | #endif |
#ifndef USBflightsim_h_ | #ifndef USBflightsim_h_ | ||||
#define USBflightsim_h_ | #define USBflightsim_h_ | ||||
#if defined(USB_FLIGHTSIM) && defined(__cplusplus) | |||||
#include "usb_desc.h" | |||||
#if defined(FLIGHTSIM_INTERFACE) | |||||
#ifdef __cplusplus | |||||
#include <inttypes.h> | #include <inttypes.h> | ||||
#include "elapsedMillis.h" | #include "elapsedMillis.h" | ||||
// workaround for elapsedMillis.h bringing in WProgram.h which brings usb_undef.h | |||||
#undef USB_DESC_LIST_DEFINE | |||||
#include "usb_desc.h" | |||||
class FlightSimClass; | class FlightSimClass; | ||||
class FlightSimCommand; | class FlightSimCommand; | ||||
class FlightSimInteger; | class FlightSimInteger; | ||||
extern FlightSimClass FlightSim; | extern FlightSimClass FlightSim; | ||||
#endif // __cplusplus | |||||
#endif // FLIGHTSIM_INTERFACE | |||||
#endif | |||||
#endif | |||||
#endif // USBflightsim_h_ |
#ifndef USBjoystick_h_ | #ifndef USBjoystick_h_ | ||||
#define USBjoystick_h_ | #define USBjoystick_h_ | ||||
#if defined(USB_HID) || defined(USB_SERIAL_HID) | |||||
#include "usb_desc.h" | |||||
#if defined(JOYSTICK_INTERFACE) | |||||
#include <inttypes.h> | #include <inttypes.h> | ||||
#endif // __cplusplus | #endif // __cplusplus | ||||
#endif // USB_HID || USB_SERIAL_HID | |||||
#endif // JOYSTICK_INTERFACE | |||||
#endif // USBjoystick_h_ | #endif // USBjoystick_h_ | ||||
#ifndef USBkeyboard_h_ | #ifndef USBkeyboard_h_ | ||||
#define USBkeyboard_h_ | #define USBkeyboard_h_ | ||||
#include "usb_desc.h" | |||||
#include "keylayouts.h" | #include "keylayouts.h" | ||||
#if defined(USB_HID) || defined(USB_SERIAL_HID) | |||||
#if defined(KEYBOARD_INTERFACE) | |||||
#include <inttypes.h> | #include <inttypes.h> | ||||
#endif // __cplusplus | #endif // __cplusplus | ||||
#endif // USB_HID || USB_SERIAL_HID | |||||
#endif // KEYBOARD_INTERFACE | |||||
#endif // USBkeyboard_h_ | #endif // USBkeyboard_h_ |
#ifndef USBmidi_h_ | #ifndef USBmidi_h_ | ||||
#define USBmidi_h_ | #define USBmidi_h_ | ||||
#if defined(USB_MIDI) | |||||
#include "usb_desc.h" | |||||
#if defined(MIDI_INTERFACE) | |||||
#include <inttypes.h> | #include <inttypes.h> | ||||
#endif // __cplusplus | #endif // __cplusplus | ||||
#endif // USB_MIDI | |||||
#endif // MIDI_INTERFACE | |||||
#endif // USBmidi_h_ | #endif // USBmidi_h_ | ||||
#ifndef USBmouse_h_ | #ifndef USBmouse_h_ | ||||
#define USBmouse_h_ | #define USBmouse_h_ | ||||
#if defined(USB_HID) || defined(USB_SERIAL_HID) | |||||
#include "usb_desc.h" | |||||
#if defined(MOUSE_INTERFACE) | |||||
#include <inttypes.h> | #include <inttypes.h> | ||||
#endif // __cplusplus | #endif // __cplusplus | ||||
#endif // USB_HID || USB_SERIAL_HID | |||||
#endif // MOUSE_INTERFACE | |||||
#endif // USBmouse_h_ | #endif // USBmouse_h_ |
#ifndef USBrawhid_h_ | #ifndef USBrawhid_h_ | ||||
#define USBrawhid_h_ | #define USBrawhid_h_ | ||||
#if defined(USB_RAWHID) | |||||
#include "usb_desc.h" | |||||
#if defined(RAWHID_INTERFACE) | |||||
#include <inttypes.h> | #include <inttypes.h> | ||||
#endif // __cplusplus | #endif // __cplusplus | ||||
#endif // USB_HID | |||||
#endif // RAWHID_INTERFACE | |||||
#endif // USBrawhid_h_ | #endif // USBrawhid_h_ |
#ifndef USBseremu_h_ | #ifndef USBseremu_h_ | ||||
#define USBseremu_h_ | #define USBseremu_h_ | ||||
#if defined(USB_HID) || defined(USB_MIDI) || defined(USB_RAWHID) || defined(USB_FLIGHTSIM) | |||||
#include "usb_desc.h" | |||||
#if defined(SEREMU_INTERFACE) | |||||
#include <inttypes.h> | #include <inttypes.h> | ||||
extern void serialEvent(void); | extern void serialEvent(void); | ||||
#endif // __cplusplus | #endif // __cplusplus | ||||
#endif // F_CPU | |||||
#endif // F_CPU >= 20 MHz | |||||
#endif // USB_HID | |||||
#endif // SEREMU_INTERFACE | |||||
#endif // USBseremu_h_ | #endif // USBseremu_h_ |
#ifndef USBserial_h_ | #ifndef USBserial_h_ | ||||
#define USBserial_h_ | #define USBserial_h_ | ||||
#include "usb_desc.h" | |||||
#if defined(CDC_DATA_INTERFACE) | |||||
#include <inttypes.h> | #include <inttypes.h> | ||||
#if (F_CPU >= 20000000) && (defined(USB_SERIAL) || defined(USB_SERIAL_HID)) | |||||
#if F_CPU >= 20000000 | |||||
// C language implementation | // C language implementation | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
#endif // __cplusplus | #endif // __cplusplus | ||||
#elif (F_CPU < 20000000) && (defined(USB_SERIAL) || defined(USB_SERIAL_HID)) | |||||
#else // F_CPU < 20000000 | |||||
// Allow Arduino programs using Serial to compile, but Serial will do nothing. | // Allow Arduino programs using Serial to compile, but Serial will do nothing. | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
extern void serialEvent(void); | extern void serialEvent(void); | ||||
#endif // __cplusplus | #endif // __cplusplus | ||||
#endif // F_CPU && USB_SERIAL || USB_SERIAL_HID | |||||
#endif // F_CPU | |||||
#endif // CDC_DATA_INTERFACE | |||||
#endif // USBserial_h_ | #endif // USBserial_h_ |
// This header is meant to undo the effect of having included | |||||
// usb_desc.h. Everything usb_desc.h, usb_undef.h undefines. | |||||
// This stuff is not supposed to be made visible to user level | |||||
// programs, but it's nice if we can use it within the headers | |||||
// included by user programs, to automatically define only the | |||||
// appropriate APIs for the types of USB interfaces used. | |||||
#ifdef _usb_desc_h_ | |||||
#undef _usb_desc_h_ | |||||
#endif | |||||
#ifdef ENDPOINT_UNUSED | |||||
#undef ENDPOINT_UNUSED | |||||
#endif | |||||
#ifdef ENDPOINT_TRANSIMIT_ONLY | |||||
#undef ENDPOINT_TRANSIMIT_ONLY | |||||
#endif | |||||
#ifdef ENDPOINT_RECEIVE_ONLY | |||||
#undef ENDPOINT_RECEIVE_ONLY | |||||
#endif | |||||
#ifdef ENDPOINT_TRANSMIT_AND_RECEIVE | |||||
#undef ENDPOINT_TRANSMIT_AND_RECEIVE | |||||
#endif | |||||
#ifdef VENDOR_ID | |||||
#undef VENDOR_ID | |||||
#endif | |||||
#ifdef PRODUCT_ID | |||||
#undef PRODUCT_ID | |||||
#endif | |||||
#ifdef DEVICE_CLASS | |||||
#undef DEVICE_CLASS | |||||
#endif | |||||
#ifdef MANUFACTURER_NAME | |||||
#undef MANUFACTURER_NAME | |||||
#endif | |||||
#ifdef MANUFACTURER_NAME_LEN | |||||
#undef MANUFACTURER_NAME_LEN | |||||
#endif | |||||
#ifdef PRODUCT_NAME | |||||
#undef PRODUCT_NAME | |||||
#endif | |||||
#ifdef PRODUCT_NAME_LEN | |||||
#undef PRODUCT_NAME_LEN | |||||
#endif | |||||
#ifdef EP0_SIZE | |||||
#undef EP0_SIZE | |||||
#endif | |||||
#ifdef NUM_ENDPOINTS | |||||
#undef NUM_ENDPOINTS | |||||
#endif | |||||
#ifdef NUM_USB_BUFFERS | |||||
#undef NUM_USB_BUFFERS | |||||
#endif | |||||
#ifdef NUM_INTERFACE | |||||
#undef NUM_INTERFACE | |||||
#endif | |||||
#ifdef CDC_STATUS_INTERFACE | |||||
#undef CDC_STATUS_INTERFACE | |||||
#endif | |||||
#ifdef CDC_DATA_INTERFACE | |||||
#undef CDC_DATA_INTERFACE | |||||
#endif | |||||
#ifdef CDC_ACM_ENDPOINT | |||||
#undef CDC_ACM_ENDPOINT | |||||
#endif | |||||
#ifdef CDC_RX_ENDPOINT | |||||
#undef CDC_RX_ENDPOINT | |||||
#endif | |||||
#ifdef CDC_TX_ENDPOINT | |||||
#undef CDC_TX_ENDPOINT | |||||
#endif | |||||
#ifdef CDC_ACM_SIZE | |||||
#undef CDC_ACM_SIZE | |||||
#endif | |||||
#ifdef CDC_RX_SIZE | |||||
#undef CDC_RX_SIZE | |||||
#endif | |||||
#ifdef CDC_TX_SIZE | |||||
#undef CDC_TX_SIZE | |||||
#endif | |||||
#ifdef SEREMU_INTERFACE | |||||
#undef SEREMU_INTERFACE | |||||
#endif | |||||
#ifdef SEREMU_TX_ENDPOINT | |||||
#undef SEREMU_TX_ENDPOINT | |||||
#endif | |||||
#ifdef SEREMU_TX_SIZE | |||||
#undef SEREMU_TX_SIZE | |||||
#endif | |||||
#ifdef SEREMU_TX_INTERVAL | |||||
#undef SEREMU_TX_INTERVAL | |||||
#endif | |||||
#ifdef SEREMU_RX_ENDPOINT | |||||
#undef SEREMU_RX_ENDPOINT | |||||
#endif | |||||
#ifdef SEREMU_RX_SIZE | |||||
#undef SEREMU_RX_SIZE | |||||
#endif | |||||
#ifdef SEREMU_RX_INTERVAL | |||||
#undef SEREMU_RX_INTERVAL | |||||
#endif | |||||
#ifdef KEYBOARD_INTERFACE | |||||
#undef KEYBOARD_INTERFACE | |||||
#endif | |||||
#ifdef KEYBOARD_ENDPOINT | |||||
#undef KEYBOARD_ENDPOINT | |||||
#endif | |||||
#ifdef KEYBOARD_SIZE | |||||
#undef KEYBOARD_SIZE | |||||
#endif | |||||
#ifdef KEYBOARD_INTERVAL | |||||
#undef KEYBOARD_INTERVAL | |||||
#endif | |||||
#ifdef MOUSE_INTERFACE | |||||
#undef MOUSE_INTERFACE | |||||
#endif | |||||
#ifdef MOUSE_ENDPOINT | |||||
#undef MOUSE_ENDPOINT | |||||
#endif | |||||
#ifdef MOUSE_SIZE | |||||
#undef MOUSE_SIZE | |||||
#endif | |||||
#ifdef MOUSE_INTERVAL | |||||
#undef MOUSE_INTERVAL | |||||
#endif | |||||
#ifdef JOYSTICK_INTERFACE | |||||
#undef JOYSTICK_INTERFACE | |||||
#endif | |||||
#ifdef JOYSTICK_ENDPOINT | |||||
#undef JOYSTICK_ENDPOINT | |||||
#endif | |||||
#ifdef JOYSTICK_SIZE | |||||
#undef JOYSTICK_SIZE | |||||
#endif | |||||
#ifdef JOYSTICK_INTERVAL | |||||
#undef JOYSTICK_INTERVAL | |||||
#endif | |||||
#ifdef CDC_IAD_DESCRIPTOR | |||||
#undef CDC_IAD_DESCRIPTOR | |||||
#endif | |||||
#ifdef MIDI_INTERFACE | |||||
#undef MIDI_TX_ENDPOINT | |||||
#endif | |||||
#ifdef MIDI_TX_SIZE | |||||
#undef MIDI_TX_SIZE | |||||
#endif | |||||
#ifdef MIDI_RX_ENDPOINT | |||||
#undef MIDI_RX_ENDPOINT | |||||
#endif | |||||
#ifdef MIDI_RX_SIZE | |||||
#undef MIDI_RX_SIZE | |||||
#endif | |||||
#ifdef RAWHID_INTERFACE | |||||
#undef RAWHID_INTERFACE | |||||
#endif | |||||
#ifdef RAWHID_TX_ENDPOINT | |||||
#undef RAWHID_TX_ENDPOINT | |||||
#endif | |||||
#ifdef RAWHID_TX_SIZE | |||||
#undef RAWHID_TX_SIZE | |||||
#endif | |||||
#ifdef RAWHID_TX_INTERVAL | |||||
#undef RAWHID_TX_INTERVAL | |||||
#endif | |||||
#ifdef RAWHID_RX_ENDPOINT | |||||
#undef RAWHID_RX_ENDPOINT | |||||
#endif | |||||
#ifdef RAWHID_RX_SIZE | |||||
#undef RAWHID_RX_SIZE | |||||
#endif | |||||
#ifdef RAWHID_RX_INTERVAL | |||||
#undef RAWHID_RX_INTERVAL | |||||
#endif | |||||
#ifdef FLIGHTSIM_INTERFACE | |||||
#undef FLIGHTSIM_TX_ENDPOINT | |||||
#endif | |||||
#ifdef FLIGHTSIM_TX_SIZE | |||||
#undef FLIGHTSIM_TX_SIZE | |||||
#endif | |||||
#ifdef FLIGHTSIM_TX_INTERVAL | |||||
#undef FLIGHTSIM_TX_INTERVAL | |||||
#endif | |||||
#ifdef FLIGHTSIM_RX_ENDPOINT | |||||
#undef FLIGHTSIM_RX_ENDPOINT | |||||
#endif | |||||
#ifdef FLIGHTSIM_RX_SIZE | |||||
#undef FLIGHTSIM_RX_SIZE | |||||
#endif | |||||
#ifdef ENDPOINT1_CONFIG | |||||
#undef ENDPOINT1_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT2_CONFIG | |||||
#undef ENDPOINT2_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT3_CONFIG | |||||
#undef ENDPOINT3_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT4_CONFIG | |||||
#undef ENDPOINT4_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT5_CONFIG | |||||
#undef ENDPOINT5_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT6_CONFIG | |||||
#undef ENDPOINT6_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT7_CONFIG | |||||
#undef ENDPOINT7_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT8_CONFIG | |||||
#undef ENDPOINT8_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT9_CONFIG | |||||
#undef ENDPOINT9_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT10_CONFIG | |||||
#undef ENDPOINT10_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT11_CONFIG | |||||
#undef ENDPOINT11_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT12_CONFIG | |||||
#undef ENDPOINT12_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT13_CONFIG | |||||
#undef ENDPOINT13_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT14_CONFIG | |||||
#undef ENDPOINT14_CONFIG | |||||
#endif | |||||
#ifdef ENDPOINT15_CONFIG | |||||
#undef ENDPOINT15_CONFIG | |||||
#endif | |||||