Commit 1daa5e16 authored by Dean Camera's avatar Dean Camera

Initial restructuring of the core USB driver module to support multiple...

Initial restructuring of the core USB driver module to support multiple architectures in the future.
parent 3832182f
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -63,7 +63,7 @@
#define __INCLUDE_FROM_AUDIO_DRIVER
/* Includes: */
#include "../HighLevel/USBMode.h"
#include "../Core/USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
#include "Device/Audio.h"
......
......@@ -64,7 +64,7 @@
#define __INCLUDE_FROM_CDC_DRIVER
/* Includes: */
#include "../HighLevel/USBMode.h"
#include "../Core/USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
#include "Device/CDC.h"
......
......@@ -51,7 +51,7 @@
#define _AUDIO_CLASS_COMMON_H_
/* Includes: */
#include "../../HighLevel/StdDescriptors.h"
#include "../../Core/StdDescriptors.h"
#include <string.h>
......
......@@ -51,7 +51,7 @@
#define _CDC_CLASS_COMMON_H_
/* Includes: */
#include "../../HighLevel/StdDescriptors.h"
#include "../../Core/StdDescriptors.h"
#include <string.h>
......
......@@ -51,7 +51,7 @@
#define _HID_CLASS_COMMON_H_
/* Includes: */
#include "../../HighLevel/StdDescriptors.h"
#include "../../Core/StdDescriptors.h"
#include "HIDParser.h"
#include <string.h>
......
......@@ -66,14 +66,13 @@
#define __HIDPARSER_H__
/* Includes: */
#include <string.h>
#include <stdbool.h>
#include "../../../../Common/Common.h"
#include "HIDReportData.h"
#include "../Common/HID.h"
#include "../../../../Common/Common.h"
#include <string.h>
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
......
......@@ -54,7 +54,7 @@
#define __INCLUDE_FROM_AUDIO_DRIVER
/* Includes: */
#include "../../HighLevel/StdDescriptors.h"
#include "../../Core/StdDescriptors.h"
#include "Audio.h"
#include <string.h>
......
......@@ -51,7 +51,7 @@
#define _MS_CLASS_COMMON_H_
/* Includes: */
#include "../../HighLevel/StdDescriptors.h"
#include "../../Core/StdDescriptors.h"
#include <string.h>
......
......@@ -51,7 +51,7 @@
#define _PRINTER_CLASS_COMMON_H_
/* Includes: */
#include "../../HighLevel/StdDescriptors.h"
#include "../../Core/StdDescriptors.h"
#include <string.h>
......
......@@ -54,7 +54,7 @@
#define __INCLUDE_FROM_CDC_DRIVER
/* Includes: */
#include "../../HighLevel/StdDescriptors.h"
#include "../../Core/StdDescriptors.h"
#include "CDC.h"
#include <string.h>
......
......@@ -51,7 +51,7 @@
#define _SI_CLASS_COMMON_H_
/* Includes: */
#include "../../HighLevel/StdDescriptors.h"
#include "../../Core/StdDescriptors.h"
#include <string.h>
......
......@@ -29,7 +29,8 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#include "../../Core/USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
#define __INCLUDE_FROM_AUDIO_DRIVER
......
......@@ -29,7 +29,8 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#include "../../Core/USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
#define __INCLUDE_FROM_CDC_DRIVER
......
......@@ -29,7 +29,8 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#include "../../Core/USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
#define __INCLUDE_FROM_HID_DRIVER
......
......@@ -29,7 +29,8 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#include "../../Core/USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
#define __INCLUDE_FROM_MIDI_DRIVER
......
......@@ -29,7 +29,8 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#include "../../Core/USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
#define __INCLUDE_FROM_MS_DRIVER
......
......@@ -29,7 +29,8 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#include "../../Core/USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
#define __INCLUDE_FROM_RNDIS_DRIVER
......
......@@ -65,7 +65,7 @@
#define __INCLUDE_FROM_HID_DRIVER
/* Includes: */
#include "../HighLevel/USBMode.h"
#include "../Core/USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
#include "Device/HID.h"
......
......@@ -29,7 +29,8 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#include "../../Core/USBMode.h"
#if defined(USB_CAN_BE_HOST)
#define __INCLUDE_FROM_CDC_DRIVER
......
......@@ -29,7 +29,8 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#include "../../Core/USBMode.h"
#if defined(USB_CAN_BE_HOST)
#define __INCLUDE_FROM_HID_DRIVER
......
......@@ -29,7 +29,8 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#include "../../Core/USBMode.h"
#if defined(USB_CAN_BE_HOST)
#define __INCLUDE_FROM_MIDI_DRIVER
......
......@@ -29,7 +29,8 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#include "../../Core/USBMode.h"
#if defined(USB_CAN_BE_HOST)
#define __INCLUDE_FROM_MS_DRIVER
......
......@@ -29,7 +29,8 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#include "../../Core/USBMode.h"
#if defined(USB_CAN_BE_HOST)
#define __INCLUDE_FROM_PRINTER_DRIVER
......
......@@ -29,7 +29,8 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#include "../../Core/USBMode.h"
#if defined(USB_CAN_BE_HOST)
#define __INCLUDE_FROM_RNDIS_DRIVER
......
......@@ -29,7 +29,8 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../../HighLevel/USBMode.h"
#include "../../Core/USBMode.h"
#if defined(USB_CAN_BE_HOST)
#define __INCLUDE_FROM_SI_DRIVER
......
......@@ -67,7 +67,7 @@
#define __INCLUDE_FROM_MIDI_DRIVER
/* Includes: */
#include "../HighLevel/USBMode.h"
#include "../Core/USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
#include "Device/MIDI.h"
......
......@@ -64,7 +64,7 @@
#define __INCLUDE_FROM_MS_DRIVER
/* Includes: */
#include "../HighLevel/USBMode.h"
#include "../Core/USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
#include "Device/MassStorage.h"
......
......@@ -65,7 +65,7 @@
#define __INCLUDE_FROM_PRINTER_DRIVER
/* Includes: */
#include "../HighLevel/USBMode.h"
#include "../Core/USBMode.h"
#if defined(USB_CAN_BE_HOST)
#include "Host/Printer.h"
......
......@@ -64,7 +64,7 @@
#define __INCLUDE_FROM_RNDIS_DRIVER
/* Includes: */
#include "../HighLevel/USBMode.h"
#include "../Core/USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
#include "Device/RNDIS.h"
......
......@@ -63,7 +63,7 @@
#define __INCLUDE_FROM_SI_DRIVER
/* Includes: */
#include "../HighLevel/USBMode.h"
#include "../Core/USBMode.h"
#if defined(USB_CAN_BE_HOST)
#include "Host/StillImage.h"
......
......@@ -29,7 +29,7 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../HighLevel/USBMode.h"
#include "../USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
......
......@@ -29,7 +29,7 @@
*/
/** \file
* \brief USB device mode definitions.
* \brief USB device mode definitions (AVR8)
*
* This file contains structures, function prototypes and macros related to USB device mode.
*
......@@ -37,8 +37,8 @@
* dispatch header located in LUFA/Drivers/USB/USB.h.
*/
/** \ingroup Group_USB
* \defgroup Group_Device Device Management
/** \ingroup Group_Device
* \defgroup Group_Device_AVR8 Device Management (AVR8)
*
* USB Device mode related macros and enums. This module contains macros and enums which are used when
* the USB controller is initialized in device mode.
......@@ -46,18 +46,16 @@
* @{
*/
#ifndef __USBDEVICE_H__
#define __USBDEVICE_H__
#ifndef __USBDEVICE_AVR8_H__
#define __USBDEVICE_AVR8_H__
/* Includes: */
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include "../../../Common/Common.h"
#include "../HighLevel/StdDescriptors.h"
#include "USBInterrupt.h"
#include "Endpoint.h"
#include "../../../../Common/Common.h"
#include "../StdDescriptors.h"
#include "../USBInterrupt.h"
#include "../Endpoint.h"
#include <avr/boot.h>
/* Preprocessor Checks: */
#if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))
......@@ -91,6 +89,24 @@
#define USB_DEVICE_OPT_FULLSPEED (0 << 0)
//@}
#if (!defined(NO_INTERNAL_SERIAL) && \
(defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) || \
defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || \
defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)))
/** String descriptor index for the device's unique serial number string descriptor within the device.
* This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
* number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain
* a unique serial number internally, and setting the device descriptors serial number string index to this value
* will cause it to use the internal serial number.
*
* On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial
* number for the device.
*/
#define USE_INTERNAL_SERIAL 0xDC
#else
#define USE_INTERNAL_SERIAL NO_DESCRIPTOR
#endif
/* Function Prototypes: */
/** Sends a Remote Wakeup request to the host. This signals to the host that the device should
* be taken out of suspended mode, and communications should resume.
......@@ -239,6 +255,38 @@
{
return (UDADDR & (1 << ADDEN));
}
static inline uint8_t USB_Device_GetSerialString(wchar_t* UnicodeString, const uint8_t MaxLen)
{
uint8_t SerialCharNum = 0;
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
uint8_t SigReadAddress = 0x0E;
for (SerialCharNum = 0; SerialCharNum < MIN(MaxLen, 20); SerialCharNum++)
{
if (SerialCharNum == MaxLen)
break;
uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
if (SerialCharNum & 0x01)
{
SerialByte >>= 4;
SigReadAddress++;
}
SerialByte &= 0x0F;
UnicodeString[SerialCharNum] = (SerialByte >= 10) ?
(('A' - 10) + SerialByte) : ('0' + SerialByte);
}
}
return SerialCharNum;
}
#endif
#endif
......
......@@ -29,7 +29,7 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../HighLevel/USBMode.h"
#include "../USBMode.h"
#if defined(USB_CAN_BE_DEVICE)
......
......@@ -29,7 +29,7 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../HighLevel/USBMode.h"
#include "../USBMode.h"
#if defined(USB_CAN_BE_HOST)
......
......@@ -29,7 +29,7 @@
*/
/** \file
* \brief USB host mode definitions.
* \brief USB host mode definitions (AVR8)
*
* This file contains structures, function prototypes and macros related to USB host mode.
*
......@@ -37,8 +37,8 @@
* dispatch header located in LUFA/Drivers/USB/USB.h.
*/
/** \ingroup Group_USB
* \defgroup Group_Host Host Management
/** \ingroup Group_Host
* \defgroup Group_Host_AVR8 Host Management (AVR8)
*
* USB Host mode related macros and enums. This module contains macros and enums which are used when
* the USB controller is initialized in host mode.
......@@ -46,18 +46,14 @@
* @{
*/
#ifndef __USBHOST_H__
#define __USBHOST_H__
#ifndef __USBHOST_AVR8_H__
#define __USBHOST_AVR8_H__
/* Includes: */
#include <avr/io.h>
#include <stdbool.h>
#include <util/delay.h>
#include "../../../Common/Common.h"
#include "../HighLevel/StdDescriptors.h"
#include "Pipe.h"
#include "USBInterrupt.h"
#include "../../../../Common/Common.h"
#include "../StdDescriptors.h"
#include "../Pipe.h"
#include "../USBInterrupt.h"
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
......
......@@ -29,7 +29,7 @@
*/
/** \file
* \brief USB OTG mode definitions.
* \brief USB OTG mode definitions (AVR8)
*
* This file contains structures, function prototypes and macros related to USB OTG mode, where two USB devices
* may be linked directly together and exchange host/device roles as needed.
......@@ -38,8 +38,8 @@
* dispatch header located in LUFA/Drivers/USB/USB.h.
*/
/** \ingroup Group_USB
* \defgroup Group_OTG USB On The Go (OTG) Management
/** \ingroup Group_OTG
* \defgroup Group_OTG_AVR8 USB On The Go (OTG) Management (AVR8)
*
* This module contains macros for embedded USB hosts with dual role On The Go capabilities, for managing role
* exchange. OTG is a way for two USB dual role devices to talk to one another directly without fixed device/host
......@@ -48,14 +48,11 @@
* @{
*/
#ifndef __USBOTG_H__
#define __USBOTG_H__
#ifndef __USBOTG_AVR8_H__
#define __USBOTG_AVR8_H__
/* Includes: */
#include <avr/io.h>
#include <stdbool.h>
#include "../../../Common/Common.h"
#include "../../../../Common/Common.h"
/* Preprocessor Checks: */
#if !defined(__INCLUDE_FROM_USB_DRIVER)
......
......@@ -29,7 +29,7 @@
*/
#define __INCLUDE_FROM_USB_DRIVER
#include "../HighLevel/USBMode.h"
#include "../USBMode.h"
#if defined(USB_CAN_BE_HOST)
......
......@@ -29,7 +29,7 @@
*/
/** \file
* \brief USB low level USB controller definitions.
* \brief USB low level USB controller definitions (AVR8)
*
* This file contains structures, function prototypes and macros related to the low level configuration of the
* USB controller, to start, stop and reset the USB library core.
......@@ -38,43 +38,37 @@
* dispatch header located in LUFA/Drivers/USB/USB.h.
*/
/** \ingroup Group_USB
* \defgroup Group_USBManagement USB Interface Management
/** \ingroup Group_USBManagement
* \defgroup Group_USBManagement_AVR8 USB Interface Management (AVR8)
*
* Functions, macros, variables, enums and types related to the setup and management of the USB interface.
*
* @{
*/
#ifndef __USBCONTROLLER_H__
#define __USBCONTROLLER_H__
#ifndef __USBCONTROLLER_AVR8_H__
#define __USBCONTROLLER_AVR8_H__
/* Includes: */
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdbool.h>
#include "../HighLevel/USBMode.h"
#include "../../../Common/Common.h"
#include "../HighLevel/USBMode.h"
#include "../HighLevel/Events.h"
#include "../HighLevel/USBTask.h"
#include "USBInterrupt.h"
#include "../../../../Common/Common.h"
#include "../USBMode.h"
#include "../Events.h"
#include "../USBTask.h"
#include "../USBInterrupt.h"
#if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)
#include "Host.h"
#include "OTG.h"
#include "Pipe.h"
#include "../HighLevel/HostStandardReq.h"
#include "../HighLevel/PipeStream.h"
#include "../Host.h"
#include "../OTG.h"
#include "../Pipe.h"
#include "../HostStandardReq.h"
#include "../PipeStream.h"
#endif
#if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
#include "Device.h"
#include "Endpoint.h"
#include "../HighLevel/DeviceStandardReq.h"
#include "../HighLevel/EndpointStream.h"
#include "../Device.h"
#include "../Endpoint.h"
#include "../DeviceStandardReq.h"
#include "../EndpointStream.h"
#endif
/* Enable C linkage for C++ Compilers: */
......
......@@ -29,7 +29,7 @@
*/
/** \file
* \brief USB controller interrupt service routine management.
* \brief USB controller interrupt service routine management (AVR8)
*
* This file contains definitions required for the correct handling of low level USB service routine interrupts
* from the USB controller.
......@@ -38,14 +38,11 @@
* dispatch header located in LUFA/Drivers/USB/USB.h.
*/
#ifndef __USBINTERRUPT_H__
#define __USBINTERRUPT_H__
#ifndef __USBINTERRUPT_AVR8_H__
#define __USBINTERRUPT_AVR8_H__
/* Includes: */
#include <avr/io.h>