void usb_set_configure(void) { UENUM = USB_CDC_EP_ACM; UECONX = 1<<EPEN; UECFG0X = EP_TYPE_INTERRUPT_IN; UECFG1X = EP_SIZE(USB_CDC_EP_ACM_SIZE) | EP_SINGLE_BUFFER; UENUM = USB_CDC_EP_BULK_OUT; UECONX = 1<<EPEN; UECFG0X = EP_TYPE_BULK_OUT; UECFG1X = EP_SIZE(USB_CDC_EP_BULK_OUT_SIZE) | EP_DOUBLE_BUFFER; UEIENX = 1<<RXOUTE; UENUM = USB_CDC_EP_BULK_IN; UECONX = 1<<EPEN; UECFG0X = EP_TYPE_BULK_IN; UECFG1X = EP_SIZE(USB_CDC_EP_BULK_IN_SIZE) | EP_DOUBLE_BUFFER; UEIENX = 1<<TXINE; }
// USB Device Interrupt - handle all device-level events // the transmit buffer flushing is triggered by the start of frame // void usb_gamepad_ISR_USB_GEN_vect() { uint8_t intbits; static uint8_t div4=0; intbits = UDINT; UDINT = 0; if (intbits & (1<<EORSTI)) { UENUM = 0; UECONX = 1; UECFG0X = EP_TYPE_CONTROL; UECFG1X = EP_SIZE(ENDPOINT0_SIZE) | EP_SINGLE_BUFFER; UEIENX = (1<<RXSTPE); usb_configuration = 0; } if ((intbits & (1<<SOFI)) && usb_configuration) { if (gamepad1_idle_config && (++div4 & 3) == 0) { UENUM = GAMEPAD1_ENDPOINT; if (UEINTX & (1<<RWAL)) { gamepad1_idle_count++; if (gamepad1_idle_count == gamepad1_idle_config) { gamepad1_idle_count = 0; send_gamepad1_report(); UEINTX = 0x3A; } } } if (gamepad2_idle_config && (++div4 & 3) == 0) { UENUM = GAMEPAD2_ENDPOINT; if (UEINTX & (1<<RWAL)) { gamepad2_idle_count++; if (gamepad2_idle_count == gamepad2_idle_config) { gamepad2_idle_count = 0; send_gamepad2_report(); UEINTX = 0x3A; } } } } }
**************************************************************************/ // you might want to change the buffer size, up to 64 bytes. // The host reserves your bandwidth because this is an interrupt // endpoint, so it won't be available to other interrupt or isync // endpoints in other devices on the bus. #define ENDPOINT0_SIZE 32 #define DEBUG_TX_ENDPOINT 3 #define DEBUG_TX_SIZE 32 #define DEBUG_TX_BUFFER EP_DOUBLE_BUFFER static const uint8_t PROGMEM endpoint_config_table[] = { 0, 0, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, 0 }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects // this USB device (called "enumeration" in USB lingo). The most commonly // changed items are editable at the top of this file. Changing things // in here should only be done by those who've read chapter 9 of the USB // spec and relevant portions of any USB class specifications!
/************************************************************************** * * Endpoint Buffer Configuration * **************************************************************************/ #define ENDPOINT0_SIZE 64 #define GAMEPAD_INTERFACE 0 #define GAMEPAD_DATA_ENDPOINT 1 #define GAMEPAD_INPUT_BUFFER EP_SINGLE_BUFFER static const uint8_t PROGMEM endpoint_config_table[] = { 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(GAMEPAD_DATA_SIZE) | GAMEPAD_INPUT_BUFFER, 1, EP_TYPE_INTERRUPT_OUT, EP_SIZE(GAMEPAD_DATA_SIZE) | GAMEPAD_INPUT_BUFFER, 0, 0 }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects // this USB device (called "enumeration" in USB lingo). The most commonly // changed items are editable at the top of this file. Changing things // in here should only be done by those who've read chapter 9 of the USB // spec and relevant portions of any USB class specifications!
**************************************************************************/ #define ENDPOINT0_SIZE 16 #define CDC_ACM_ENDPOINT 2 #define CDC_RX_ENDPOINT 3 #define CDC_TX_ENDPOINT 4 #define CDC_ACM_SIZE 16 #define CDC_ACM_BUFFER EP_SINGLE_BUFFER #define CDC_RX_SIZE 64 #define CDC_RX_BUFFER EP_DOUBLE_BUFFER #define CDC_TX_SIZE 64 #define CDC_TX_BUFFER EP_DOUBLE_BUFFER static const uint8_t PROGMEM endpoint_config_table[] = { 0, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(CDC_ACM_SIZE) | CDC_ACM_BUFFER, 1, EP_TYPE_BULK_OUT, EP_SIZE(CDC_RX_SIZE) | CDC_RX_BUFFER, 1, EP_TYPE_BULK_IN, EP_SIZE(CDC_TX_SIZE) | CDC_TX_BUFFER }; /************************************************************************** * * Descriptor Data * **************************************************************************/ static const uint8_t PROGMEM device_descriptor[] = { 18, // bLength 1, // bDescriptorType 0x00, 0x02, // bcdUSB
/************************************************************************** * * Endpoint Buffer Configuration * **************************************************************************/ #define ENDPOINT0_SIZE 32 bool remote_wakeup = false; bool suspend = false; // 0:control endpoint is enabled automatically by controller. static const uint8_t PROGMEM endpoint_config_table[] = { // enable, UECFG0X(type, direction), UECFG1X(size, bank, allocation) 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KBD_SIZE) | KBD_BUFFER, // 1 #ifdef MOUSE_ENABLE 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(MOUSE_SIZE) | MOUSE_BUFFER, // 2 #else 0, // 2 #endif 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, // 3 #ifdef EXTRAKEY_ENABLE 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(EXTRA_SIZE) | EXTRA_BUFFER, // 4 #else 0, // 4 #endif #ifdef NKRO_ENABLE 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KBD2_SIZE) | KBD2_BUFFER, // 5 #else 0, // 5
#include "usb_common.h" #include "usb_private.h" #include "pauls_ugly_debug.h" /************************************************************************** * * Endpoint Buffer Configuration * **************************************************************************/ static const uint8_t PROGMEM endpoint_config_table[] = { 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, 1, EP_TYPE_INTERRUPT_OUT, EP_SIZE(DEBUG_RX_SIZE) | DEBUG_RX_BUFFER, 1, EP_TYPE_BULK_OUT, EP_SIZE(DISK_RX_SIZE) | DISK_RX_BUFFER, 1, EP_TYPE_BULK_IN, EP_SIZE(DISK_TX_SIZE) | DISK_TX_BUFFER, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KEYBOARD_SIZE) | KEYBOARD_BUFFER, 0 }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects
static int usbnet_start_xmit (struct sk_buff *skb, struct net_device *net) { struct usbnet *dev = (struct usbnet *) net->priv; int length = skb->len; int retval = NET_XMIT_SUCCESS; struct urb *urb = 0; struct skb_data *entry; struct driver_info *info = dev->driver_info; unsigned long flags; #ifdef CONFIG_USB_NET1080 struct nc_header *header = 0; struct nc_trailer *trailer = 0; #endif /* CONFIG_USB_NET1080 */ flags = in_interrupt () ? GFP_ATOMIC : GFP_NOIO; /* might be used for nfs */ // some devices want funky USB-level framing, for // win32 driver (usually) and/or hardware quirks if (info->tx_fixup) { skb = info->tx_fixup (dev, skb, flags); if (!skb) { dbg ("can't tx_fixup skb"); goto drop; } } if (!(urb = usb_alloc_urb (0))) { dbg ("no urb"); goto drop; } entry = (struct skb_data *) skb->cb; entry->urb = urb; entry->dev = dev; entry->state = tx_start; entry->length = length; // FIXME: reorganize a bit, so that fixup() fills out NetChip // framing too. (Packet ID update needs the spinlock...) #ifdef CONFIG_USB_NET1080 if (info->flags & FLAG_FRAMING_NC) { header = (struct nc_header *) skb_push (skb, sizeof *header); header->hdr_len = cpu_to_le16 (sizeof (*header)); header->packet_len = cpu_to_le16 (length); if (!((skb->len + sizeof *trailer) & 0x01)) *skb_put (skb, 1) = PAD_BYTE; trailer = (struct nc_trailer *) skb_put (skb, sizeof *trailer); } else #endif /* CONFIG_USB_NET1080 */ /* don't assume the hardware handles USB_ZERO_PACKET */ if ((length % EP_SIZE (dev)) == 0) skb->len++; FILL_BULK_URB (urb, dev->udev, usb_sndbulkpipe (dev->udev, info->out), skb->data, skb->len, tx_complete, skb); urb->transfer_flags |= USB_ASYNC_UNLINK; #ifdef REALLY_QUEUE urb->transfer_flags |= USB_QUEUE_BULK; #endif // FIXME urb->timeout = ... jiffies ... ; spin_lock_irqsave (&dev->txq.lock, flags); #ifdef CONFIG_USB_NET1080 if (info->flags & FLAG_FRAMING_NC) { header->packet_id = cpu_to_le16 (dev->packet_id++); put_unaligned (header->packet_id, &trailer->packet_id); #if 0 devdbg (dev, "frame >tx h %d p %d id %d", header->hdr_len, header->packet_len, header->packet_id); #endif } #endif /* CONFIG_USB_NET1080 */ netif_stop_queue (net); if ((retval = usb_submit_urb (urb)) != 0) { netif_start_queue (net); dbg ("%s tx: submit urb err %d", net->name, retval); } else { net->trans_start = jiffies; __skb_queue_tail (&dev->txq, skb); if (dev->txq.qlen < TX_QLEN) netif_start_queue (net); } spin_unlock_irqrestore (&dev->txq.lock, flags); if (retval) { devdbg (dev, "drop, code %d", retval); drop: retval = NET_XMIT_DROP; dev->stats.tx_dropped++; if (skb) dev_kfree_skb_any (skb); usb_free_urb (urb); #ifdef VERBOSE } else { devdbg (dev, "> tx, len %d, type 0x%x", length, skb->protocol); #endif } return retval; }
#define ENDPOINT0_SIZE 32 #define RAWHID_INTERFACE 0 #define RAWHID_TX_ENDPOINT 1 #define RAWHID_RX_ENDPOINT 2 #if defined(__AVR_AT90USB162__) || defined(__AVR_ATmega32U2__) #define RAWHID_TX_BUFFER EP_SINGLE_BUFFER #define RAWHID_RX_BUFFER EP_SINGLE_BUFFER #else #define RAWHID_TX_BUFFER EP_DOUBLE_BUFFER #define RAWHID_RX_BUFFER EP_DOUBLE_BUFFER #endif static const uint8_t PROGMEM endpoint_config_table[] = { 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(USB_RAWHID_TX_SIZE) | RAWHID_TX_BUFFER, 1, EP_TYPE_INTERRUPT_OUT, EP_SIZE(USB_RAWHID_RX_SIZE) | RAWHID_RX_BUFFER, 0, 0 }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects // this USB device (called "enumeration" in USB lingo). The most commonly // changed items are editable at the top of this file. Changing things
*/ #include "usb_common.h" #include "usb_private.h" /************************************************************************** * * Endpoint Buffer Configuration * **************************************************************************/ static const uint8_t PROGMEM endpoint_config_table[] = { EP_TYPE_INTERRUPT_IN, EP_SIZE(KEYBOARD_SIZE) | KEYBOARD_BUFFER, EP_TYPE_INTERRUPT_IN, EP_SIZE(CDC_ACM_SIZE) | CDC_ACM_BUFFER, EP_TYPE_BULK_OUT, EP_SIZE(CDC_RX_SIZE) | CDC_RX_BUFFER, EP_TYPE_BULK_IN, EP_SIZE(CDC_TX_SIZE) | CDC_TX_BUFFER, EP_TYPE_INTERRUPT_IN, EP_SIZE(MOUSE_SIZE) | MOUSE_BUFFER, EP_TYPE_INTERRUPT_IN, EP_SIZE(JOYSTICK_SIZE) | JOYSTICK_BUFFER, }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects
#define DEBUG_INTERFACE 1 #define DEBUG_TX_ENDPOINT 3 #define DEBUG_TX_SIZE 32 #if defined(__AVR_AT90USB162__) #define RAWHID_TX_BUFFER EP_SINGLE_BUFFER #define RAWHID_RX_BUFFER EP_SINGLE_BUFFER #define DEBUG_TX_BUFFER EP_SINGLE_BUFFER #else #define RAWHID_TX_BUFFER EP_DOUBLE_BUFFER #define RAWHID_RX_BUFFER EP_DOUBLE_BUFFER #define DEBUG_TX_BUFFER EP_DOUBLE_BUFFER #endif static const uint8_t PROGMEM endpoint_config_table[] = { 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(RAWHID_TX_SIZE) | RAWHID_TX_BUFFER, 1, EP_TYPE_INTERRUPT_OUT, EP_SIZE(RAWHID_RX_SIZE) | RAWHID_RX_BUFFER, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, 0 }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects // this USB device (called "enumeration" in USB lingo). The most commonly // changed items are editable at the top of this file. Changing things
/************************************************************************** * * Endpoint Buffer Configuration * **************************************************************************/ #define ENDPOINT0_SIZE 64 #define GAMEPAD_INTERFACE 0 #define GAMEPAD_ENDPOINT 1 #define GAMEPAD_SIZE 64 #define GAMEPAD_BUFFER EP_SINGLE_BUFFER //EP_DOUBLE_BUFFER static const uint8_t PROGMEM endpoint_config_table[] = { 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(GAMEPAD_SIZE) | GAMEPAD_BUFFER, 0, 0, 0 }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects // this USB device (called "enumeration" in USB lingo). The most commonly // changed items are editable at the top of this file. Changing things
**************************************************************************/ #define ENDPOINT0_SIZE 32 #define KEYBOARD_INTERFACE 0 #define KEYBOARD_ENDPOINT 1 #define KEYBOARD_SIZE 8 #define KEYBOARD_BUFFER EP_DOUBLE_BUFFER #define EXTRA_INTERFACE 1 #define EXTRA_ENDPOINT 2 #define EXTRA_SIZE 8 #define EXTRA_BUFFER EP_DOUBLE_BUFFER static const uint8_t PROGMEM endpoint_config_table[] = { 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KEYBOARD_SIZE) | KEYBOARD_BUFFER, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(EXTRA_SIZE) | EXTRA_BUFFER, // 4 0 }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects // this USB device (called "enumeration" in USB lingo). The most commonly // changed items are editable at the top of this file. Changing things // in here should only be done by those who've read chapter 9 of the USB
#define ENDPOINT0_SIZE 32 #define MOUSE_INTERFACE 0 #define MOUSE_ENDPOINT 3 #define MOUSE_SIZE 8 #define MOUSE_BUFFER EP_DOUBLE_BUFFER #define DEBUG_INTERFACE 1 #define DEBUG_TX_ENDPOINT 4 #define DEBUG_TX_SIZE 32 #define DEBUG_TX_BUFFER EP_DOUBLE_BUFFER static const uint8_t PROGMEM endpoint_config_table[] = { 0, 0, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(MOUSE_SIZE) | MOUSE_BUFFER, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects // this USB device (called "enumeration" in USB lingo). The most commonly // changed items are editable at the top of this file. Changing things // in here should only be done by those who've read chapter 9 of the USB // spec and relevant portions of any USB class specifications!
#include "usb_common.h" #include "usb_private.h" /************************************************************************** * * Endpoint Buffer Configuration * **************************************************************************/ static const uint8_t PROGMEM endpoint_config_table[] = { 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, 1, EP_TYPE_INTERRUPT_OUT, EP_SIZE(DEBUG_RX_SIZE) | DEBUG_RX_BUFFER, 1, EP_TYPE_BULK_IN, EP_SIZE(MIDI_TX_SIZE) | MIDI_TX_BUFFER, 1, EP_TYPE_BULK_OUT, EP_SIZE(MIDI_RX_SIZE) | MIDI_RX_BUFFER }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects // this USB device (called "enumeration" in USB lingo). The most commonly // changed items are editable at the top of this file. Changing things
#define ENDPOINT0_SIZE 32 #define GAMEPAD1_INTERFACE 0 #define GAMEPAD1_ENDPOINT 3 #define GAMEPAD1_SIZE 3 #define GAMEPAD1_BUFFER EP_DOUBLE_BUFFER #define GAMEPAD2_INTERFACE 1 #define GAMEPAD2_ENDPOINT 4 #define GAMEPAD2_SIZE 3 #define GAMEPAD2_BUFFER EP_DOUBLE_BUFFER static const uint8_t PROGMEM endpoint_config_table[] = { 0, 0, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(GAMEPAD1_SIZE) | GAMEPAD1_BUFFER, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(GAMEPAD2_SIZE) | GAMEPAD2_BUFFER, }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects // this USB device (called "enumeration" in USB lingo). The most commonly // changed items are editable at the top of this file. Changing things // in here should only be done by those who've read chapter 9 of the USB // spec and relevant portions of any USB class specifications!
#define ENDPOINT0_SIZE 32 #define KEYBOARD_INTERFACE 0 #define KEYBOARD_ENDPOINT 3 #define KEYBOARD_SIZE 8 #define KEYBOARD_BUFFER EP_DOUBLE_BUFFER #define DEBUG_INTERFACE 1 #define DEBUG_TX_ENDPOINT 4 #define DEBUG_TX_SIZE 32 #define DEBUG_TX_BUFFER EP_DOUBLE_BUFFER const const uint8_t PROGMEM endpoint_config_table[] = { 0, 0, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KEYBOARD_SIZE) | KEYBOARD_BUFFER, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects // this USB device (called "enumeration" in USB lingo). The most commonly // changed items are editable at the top of this file. Changing things // in here should only be done by those who've read chapter 9 of the USB // spec and relevant portions of any USB class specifications!
// are required to be able to report which setting is in use. static uint8_t keyboard_protocol = 1; // The idle configuration, how often we send the report to the host (ms * 4) even when it hasn't changed static uint8_t keyboard_idle_config = 125; // Count until idle timeout static uint8_t keyboard_idle_count = 0; // 1=num lock, 2=caps lock, 4=scroll lock, 8=compose, 16=kana volatile uint8_t keyboard_leds = 0; // Endpoint configuration table static const uint8_t PROGMEM endpoint_config_table[] = { 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(RAWHID_TX_SIZE) | RAWHID_TX_BUFFER, 1, EP_TYPE_INTERRUPT_OUT, EP_SIZE(RAWHID_RX_SIZE) | RAWHID_RX_BUFFER, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KEYBOARD_SIZE) | KEYBOARD_BUFFER, 0 }; #ifdef USB_OLED_DEBUG_COMMS /*! \fn displayDebugStatusCode(char* text) * \brief Display a debug status code on the screen to help diagnose usb comms * \param text The text */ void displayDebugStatusCode(char* text) { if (oledIsOn() == TRUE) {
* * Endpoint Buffer Configuration * **************************************************************************/ #define ENDPOINT0_SIZE 32 #define KEYBOARD_INTERFACE 0 #define KEYBOARD_ENDPOINT 3 #define KEYBOARD_SIZE 8 #define KEYBOARD_BUFFER EP_DOUBLE_BUFFER static const uint8_t PROGMEM endpoint_config_table[] = { 0, 0, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KEYBOARD_SIZE) | KEYBOARD_BUFFER, 0 }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects // this USB device (called "enumeration" in USB lingo). The most commonly // changed items are editable at the top of this file. Changing things // in here should only be done by those who've read chapter 9 of the USB // spec and relevant portions of any USB class specifications!
* * Endpoint Buffer Configuration * **************************************************************************/ #define ENDPOINT0_SIZE 32 #define MOUSE_INTERFACE 0 #define MOUSE_ENDPOINT 3 #define MOUSE_SIZE 8 #define MOUSE_BUFFER EP_DOUBLE_BUFFER static const uint8_t PROGMEM endpoint_config_table[] = { 0, 0, 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(MOUSE_SIZE) | MOUSE_BUFFER, 0 }; /************************************************************************** * * Descriptor Data * **************************************************************************/ // Descriptors are the data that your computer reads when it auto-detects // this USB device (called "enumeration" in USB lingo). The most commonly // changed items are editable at the top of this file. Changing things // in here should only be done by those who've read chapter 9 of the USB // spec and relevant portions of any USB class specifications!