Pārlūkot izejas kodu

Simplify customizing USB - no longer need to edit interface .h files

main
PaulStoffregen pirms 9 gadiem
vecāks
revīzija
2f14babf7d
13 mainītis faili ar 296 papildinājumiem un 29 dzēšanām
  1. +1
    -0
      teensy3/WProgram.h
  2. +1
    -0
      teensy3/usb_desc.c
  3. +3
    -6
      teensy3/usb_desc.h
  4. +5
    -3
      teensy3/usb_dev.h
  5. +13
    -3
      teensy3/usb_flightsim.h
  6. +5
    -2
      teensy3/usb_joystick.h
  7. +5
    -2
      teensy3/usb_keyboard.h
  8. +5
    -2
      teensy3/usb_midi.h
  9. +5
    -2
      teensy3/usb_mouse.h
  10. +5
    -2
      teensy3/usb_rawhid.h
  11. +5
    -4
      teensy3/usb_seremu.h
  12. +10
    -3
      teensy3/usb_serial.h
  13. +233
    -0
      teensy3/usb_undef.h

+ 1
- 0
teensy3/WProgram.h Parādīt failu

@@ -29,6 +29,7 @@
#include "usb_midi.h"
#include "usb_rawhid.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 "WString.h"

+ 1
- 0
teensy3/usb_desc.c Parādīt failu

@@ -30,6 +30,7 @@

#if F_CPU >= 20000000

#define USB_DESC_LIST_DEFINE
#include "usb_desc.h"
#ifdef NUM_ENDPOINTS
#include "usb_names.h"

+ 3
- 6
teensy3/usb_desc.h Parādīt failu

@@ -90,11 +90,6 @@ 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.

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
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,
@@ -313,7 +308,8 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports

#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)
extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS];

@@ -326,6 +322,7 @@ typedef struct {

extern const usb_descriptor_list_t usb_descriptor_list[];
#endif // NUM_ENDPOINTS
#endif // USB_DESC_LIST_DEFINE

#endif // F_CPU >= 20 MHz


+ 5
- 3
teensy3/usb_dev.h Parādīt failu

@@ -31,8 +31,10 @@
#ifndef _usb_dev_h_
#define _usb_dev_h_

#define USB_DESC_LIST_DEFINE
#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
// user sketches in Arduino. The low-level functions
@@ -102,7 +104,7 @@ extern void usb_flightsim_flush_callback(void);
}
#endif

#else // F_CPU >= 20000000 && defined(NUM_ENDPOINTS)
#else // F_CPU < 20000000

#ifdef __cplusplus
extern "C" {
@@ -115,6 +117,6 @@ void usb_init(void);
#endif


#endif // F_CPU >= 20000000 && defined(NUM_ENDPOINTS)
#endif // F_CPU

#endif

+ 13
- 3
teensy3/usb_flightsim.h Parādīt failu

@@ -31,11 +31,19 @@
#ifndef 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 "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 FlightSimCommand;
class FlightSimInteger;
@@ -180,6 +188,8 @@ public:

extern FlightSimClass FlightSim;

#endif // __cplusplus

#endif // FLIGHTSIM_INTERFACE

#endif
#endif
#endif // USBflightsim_h_

+ 5
- 2
teensy3/usb_joystick.h Parādīt failu

@@ -31,7 +31,9 @@
#ifndef USBjoystick_h_
#define USBjoystick_h_

#if defined(USB_HID) || defined(USB_SERIAL_HID)
#include "usb_desc.h"

#if defined(JOYSTICK_INTERFACE)

#include <inttypes.h>

@@ -129,6 +131,7 @@ extern usb_joystick_class Joystick;

#endif // __cplusplus

#endif // USB_HID || USB_SERIAL_HID
#endif // JOYSTICK_INTERFACE

#endif // USBjoystick_h_


+ 5
- 2
teensy3/usb_keyboard.h Parādīt failu

@@ -31,9 +31,11 @@
#ifndef USBkeyboard_h_
#define USBkeyboard_h_

#include "usb_desc.h"

#include "keylayouts.h"

#if defined(USB_HID) || defined(USB_SERIAL_HID)
#if defined(KEYBOARD_INTERFACE)

#include <inttypes.h>

@@ -94,5 +96,6 @@ extern usb_keyboard_class Keyboard;

#endif // __cplusplus

#endif // USB_HID || USB_SERIAL_HID
#endif // KEYBOARD_INTERFACE

#endif // USBkeyboard_h_

+ 5
- 2
teensy3/usb_midi.h Parādīt failu

@@ -31,7 +31,9 @@
#ifndef USBmidi_h_
#define USBmidi_h_

#if defined(USB_MIDI)
#include "usb_desc.h"

#if defined(MIDI_INTERFACE)

#include <inttypes.h>

@@ -179,6 +181,7 @@ extern usb_midi_class usbMIDI;

#endif // __cplusplus

#endif // USB_MIDI
#endif // MIDI_INTERFACE

#endif // USBmidi_h_


+ 5
- 2
teensy3/usb_mouse.h Parādīt failu

@@ -31,7 +31,9 @@
#ifndef USBmouse_h_
#define USBmouse_h_

#if defined(USB_HID) || defined(USB_SERIAL_HID)
#include "usb_desc.h"

#if defined(MOUSE_INTERFACE)

#include <inttypes.h>

@@ -98,5 +100,6 @@ extern usb_mouse_class Mouse;

#endif // __cplusplus

#endif // USB_HID || USB_SERIAL_HID
#endif // MOUSE_INTERFACE

#endif // USBmouse_h_

+ 5
- 2
teensy3/usb_rawhid.h Parādīt failu

@@ -31,7 +31,9 @@
#ifndef USBrawhid_h_
#define USBrawhid_h_

#if defined(USB_RAWHID)
#include "usb_desc.h"

#if defined(RAWHID_INTERFACE)

#include <inttypes.h>

@@ -61,5 +63,6 @@ extern usb_rawhid_class RawHID;

#endif // __cplusplus

#endif // USB_HID
#endif // RAWHID_INTERFACE

#endif // USBrawhid_h_

+ 5
- 4
teensy3/usb_seremu.h Parādīt failu

@@ -31,7 +31,9 @@
#ifndef 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>

@@ -127,9 +129,8 @@ extern usb_seremu_class Serial;
extern void serialEvent(void);
#endif // __cplusplus

#endif // F_CPU

#endif // F_CPU >= 20 MHz

#endif // USB_HID
#endif // SEREMU_INTERFACE

#endif // USBseremu_h_

+ 10
- 3
teensy3/usb_serial.h Parādīt failu

@@ -31,9 +31,13 @@
#ifndef USBserial_h_
#define USBserial_h_

#include "usb_desc.h"

#if defined(CDC_DATA_INTERFACE)

#include <inttypes.h>

#if (F_CPU >= 20000000) && (defined(USB_SERIAL) || defined(USB_SERIAL_HID))
#if F_CPU >= 20000000

// C language implementation
#ifdef __cplusplus
@@ -104,7 +108,7 @@ extern void serialEvent(void);
#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.
#ifdef __cplusplus
@@ -140,6 +144,9 @@ extern usb_serial_class Serial;
extern void serialEvent(void);
#endif // __cplusplus

#endif // F_CPU && USB_SERIAL || USB_SERIAL_HID

#endif // F_CPU

#endif // CDC_DATA_INTERFACE

#endif // USBserial_h_

+ 233
- 0
teensy3/usb_undef.h Parādīt failu

@@ -0,0 +1,233 @@
// 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


Notiek ielāde…
Atcelt
Saglabāt