Add missing SVN eol-style property to files where it was missing.
This commit is contained in:
parent
a36012fc4b
commit
0c2ad9eb34
105 changed files with 27742 additions and 27742 deletions
|
|
@ -1,159 +1,159 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Common USB Device definitions for all architectures.
|
||||
* \copydetails Group_Device
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USB
|
||||
* \defgroup Group_Device Device Management
|
||||
* \brief USB Device management definitions for USB device mode.
|
||||
*
|
||||
* USB Device mode related definitions common to all architectures. This module contains definitions which
|
||||
* are used when the USB controller is initialized in device mode.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBDEVICE_H__
|
||||
#define __USBDEVICE_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
#include "StdDescriptors.h"
|
||||
#include "USBInterrupt.h"
|
||||
#include "Endpoint.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Enums: */
|
||||
/** Enum for the various states of the USB Device state machine. Only some states are
|
||||
* implemented in the LUFA library - other states are left to the user to implement.
|
||||
*
|
||||
* For information on each possible USB device state, refer to the USB 2.0 specification.
|
||||
*
|
||||
* \see \ref USB_DeviceState, which stores the current device state machine state.
|
||||
*/
|
||||
enum USB_Device_States_t
|
||||
{
|
||||
DEVICE_STATE_Unattached = 0, /**< Internally implemented by the library. This state indicates
|
||||
* that the device is not currently connected to a host.
|
||||
*/
|
||||
DEVICE_STATE_Powered = 1, /**< Internally implemented by the library. This state indicates
|
||||
* that the device is connected to a host, but enumeration has not
|
||||
* yet begun.
|
||||
*/
|
||||
DEVICE_STATE_Default = 2, /**< Internally implemented by the library. This state indicates
|
||||
* that the device's USB bus has been reset by the host and it is
|
||||
* now waiting for the host to begin the enumeration process.
|
||||
*/
|
||||
DEVICE_STATE_Addressed = 3, /**< Internally implemented by the library. This state indicates
|
||||
* that the device has been addressed by the USB Host, but is not
|
||||
* yet configured.
|
||||
*/
|
||||
DEVICE_STATE_Configured = 4, /**< May be implemented by the user project. This state indicates
|
||||
* that the device has been enumerated by the host and is ready
|
||||
* for USB communications to begin.
|
||||
*/
|
||||
DEVICE_STATE_Suspended = 5, /**< May be implemented by the user project. This state indicates
|
||||
* that the USB bus has been suspended by the host, and the device
|
||||
* should power down to a minimal power level until the bus is
|
||||
* resumed.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
/** Function to retrieve a given descriptor's size and memory location from the given descriptor type value,
|
||||
* index and language ID. This function MUST be overridden in the user application (added with full, identical
|
||||
* prototype and name so that the library can call it to retrieve descriptor data.
|
||||
*
|
||||
* \param[in] wValue The type of the descriptor to retrieve in the upper byte, and the index in the
|
||||
* lower byte (when more than one descriptor of the given type exists, such as the
|
||||
* case of string descriptors). The type may be one of the standard types defined
|
||||
* in the DescriptorTypes_t enum, or may be a class-specific descriptor type value.
|
||||
* \param[in] wIndex The language ID of the string to return if the \c wValue type indicates
|
||||
* \ref DTYPE_String, otherwise zero for standard descriptors, or as defined in a
|
||||
* class-specific standards.
|
||||
* \param[out] DescriptorAddress Pointer to the descriptor in memory. This should be set by the routine to
|
||||
* the address of the descriptor.
|
||||
* \param[out] MemoryAddressSpace A value from the \ref USB_DescriptorMemorySpaces_t enum to indicate the memory
|
||||
* space in which the descriptor is stored. This parameter does not exist when one
|
||||
* of the \c USE_*_DESCRIPTORS compile time options is used, or on architectures which
|
||||
* use a unified address space.
|
||||
*
|
||||
* \note By default, the library expects all descriptors to be located in flash memory via the \c PROGMEM attribute.
|
||||
* If descriptors should be located in RAM or EEPROM instead (to speed up access in the case of RAM, or to
|
||||
* allow the descriptors to be changed dynamically at runtime) either the \c USE_RAM_DESCRIPTORS or the
|
||||
* \c USE_EEPROM_DESCRIPTORS tokens may be defined in the project makefile and passed to the compiler by the -D
|
||||
* switch.
|
||||
*
|
||||
* \return Size in bytes of the descriptor if it exists, zero or \ref NO_DESCRIPTOR otherwise.
|
||||
*/
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress
|
||||
#if (defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__)) && \
|
||||
!(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS))
|
||||
, uint8_t* MemoryAddressSpace
|
||||
#endif
|
||||
) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/Device_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/Device_UC3.h"
|
||||
#elif (ARCH == ARCH_XMEGA)
|
||||
#include "XMEGA/Device_XMEGA.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Common USB Device definitions for all architectures.
|
||||
* \copydetails Group_Device
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USB
|
||||
* \defgroup Group_Device Device Management
|
||||
* \brief USB Device management definitions for USB device mode.
|
||||
*
|
||||
* USB Device mode related definitions common to all architectures. This module contains definitions which
|
||||
* are used when the USB controller is initialized in device mode.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBDEVICE_H__
|
||||
#define __USBDEVICE_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
#include "StdDescriptors.h"
|
||||
#include "USBInterrupt.h"
|
||||
#include "Endpoint.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Enums: */
|
||||
/** Enum for the various states of the USB Device state machine. Only some states are
|
||||
* implemented in the LUFA library - other states are left to the user to implement.
|
||||
*
|
||||
* For information on each possible USB device state, refer to the USB 2.0 specification.
|
||||
*
|
||||
* \see \ref USB_DeviceState, which stores the current device state machine state.
|
||||
*/
|
||||
enum USB_Device_States_t
|
||||
{
|
||||
DEVICE_STATE_Unattached = 0, /**< Internally implemented by the library. This state indicates
|
||||
* that the device is not currently connected to a host.
|
||||
*/
|
||||
DEVICE_STATE_Powered = 1, /**< Internally implemented by the library. This state indicates
|
||||
* that the device is connected to a host, but enumeration has not
|
||||
* yet begun.
|
||||
*/
|
||||
DEVICE_STATE_Default = 2, /**< Internally implemented by the library. This state indicates
|
||||
* that the device's USB bus has been reset by the host and it is
|
||||
* now waiting for the host to begin the enumeration process.
|
||||
*/
|
||||
DEVICE_STATE_Addressed = 3, /**< Internally implemented by the library. This state indicates
|
||||
* that the device has been addressed by the USB Host, but is not
|
||||
* yet configured.
|
||||
*/
|
||||
DEVICE_STATE_Configured = 4, /**< May be implemented by the user project. This state indicates
|
||||
* that the device has been enumerated by the host and is ready
|
||||
* for USB communications to begin.
|
||||
*/
|
||||
DEVICE_STATE_Suspended = 5, /**< May be implemented by the user project. This state indicates
|
||||
* that the USB bus has been suspended by the host, and the device
|
||||
* should power down to a minimal power level until the bus is
|
||||
* resumed.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
/** Function to retrieve a given descriptor's size and memory location from the given descriptor type value,
|
||||
* index and language ID. This function MUST be overridden in the user application (added with full, identical
|
||||
* prototype and name so that the library can call it to retrieve descriptor data.
|
||||
*
|
||||
* \param[in] wValue The type of the descriptor to retrieve in the upper byte, and the index in the
|
||||
* lower byte (when more than one descriptor of the given type exists, such as the
|
||||
* case of string descriptors). The type may be one of the standard types defined
|
||||
* in the DescriptorTypes_t enum, or may be a class-specific descriptor type value.
|
||||
* \param[in] wIndex The language ID of the string to return if the \c wValue type indicates
|
||||
* \ref DTYPE_String, otherwise zero for standard descriptors, or as defined in a
|
||||
* class-specific standards.
|
||||
* \param[out] DescriptorAddress Pointer to the descriptor in memory. This should be set by the routine to
|
||||
* the address of the descriptor.
|
||||
* \param[out] MemoryAddressSpace A value from the \ref USB_DescriptorMemorySpaces_t enum to indicate the memory
|
||||
* space in which the descriptor is stored. This parameter does not exist when one
|
||||
* of the \c USE_*_DESCRIPTORS compile time options is used, or on architectures which
|
||||
* use a unified address space.
|
||||
*
|
||||
* \note By default, the library expects all descriptors to be located in flash memory via the \c PROGMEM attribute.
|
||||
* If descriptors should be located in RAM or EEPROM instead (to speed up access in the case of RAM, or to
|
||||
* allow the descriptors to be changed dynamically at runtime) either the \c USE_RAM_DESCRIPTORS or the
|
||||
* \c USE_EEPROM_DESCRIPTORS tokens may be defined in the project makefile and passed to the compiler by the -D
|
||||
* switch.
|
||||
*
|
||||
* \return Size in bytes of the descriptor if it exists, zero or \ref NO_DESCRIPTOR otherwise.
|
||||
*/
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress
|
||||
#if (defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__)) && \
|
||||
!(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS))
|
||||
, uint8_t* MemoryAddressSpace
|
||||
#endif
|
||||
) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/Device_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/Device_UC3.h"
|
||||
#elif (ARCH == ARCH_XMEGA)
|
||||
#include "XMEGA/Device_XMEGA.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,123 +1,123 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Endpoint definitions for all architectures.
|
||||
* \copydetails Group_EndpointManagement
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_EndpointManagement
|
||||
* \defgroup Group_EndpointRW Endpoint Data Reading and Writing
|
||||
* \brief Endpoint data read/write definitions.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to data reading and writing from and to endpoints.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_EndpointRW
|
||||
* \defgroup Group_EndpointPrimitiveRW Read/Write of Primitive Data Types
|
||||
* \brief Endpoint data primitive read/write definitions.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to data reading and writing of primitive data types
|
||||
* from and to endpoints.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_EndpointManagement
|
||||
* \defgroup Group_EndpointPacketManagement Endpoint Packet Management
|
||||
* \brief USB Endpoint package management definitions.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to packet management of endpoints.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USB
|
||||
* \defgroup Group_EndpointManagement Endpoint Management
|
||||
* \brief Endpoint management definitions.
|
||||
*
|
||||
* Functions, macros and enums related to endpoint management when in USB Device mode. This
|
||||
* module contains the endpoint management macros, as well as endpoint interrupt and data
|
||||
* send/receive functions for various data types.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __ENDPOINT_H__
|
||||
#define __ENDPOINT_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's
|
||||
* numerical address in the device.
|
||||
*/
|
||||
#define ENDPOINT_EPNUM_MASK 0x07
|
||||
|
||||
/** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's
|
||||
* direction for comparing with the \c ENDPOINT_DESCRIPTOR_DIR_* masks.
|
||||
*/
|
||||
#define ENDPOINT_EPDIR_MASK 0x80
|
||||
|
||||
/** Endpoint address for the default control endpoint, which always resides in address 0. This is
|
||||
* defined for convenience to give more readable code when used with the endpoint macros.
|
||||
*/
|
||||
#define ENDPOINT_CONTROLEP 0
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/Endpoint_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/Endpoint_UC3.h"
|
||||
#elif (ARCH == ARCH_XMEGA)
|
||||
#include "XMEGA/Endpoint_XMEGA.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Endpoint definitions for all architectures.
|
||||
* \copydetails Group_EndpointManagement
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_EndpointManagement
|
||||
* \defgroup Group_EndpointRW Endpoint Data Reading and Writing
|
||||
* \brief Endpoint data read/write definitions.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to data reading and writing from and to endpoints.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_EndpointRW
|
||||
* \defgroup Group_EndpointPrimitiveRW Read/Write of Primitive Data Types
|
||||
* \brief Endpoint data primitive read/write definitions.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to data reading and writing of primitive data types
|
||||
* from and to endpoints.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_EndpointManagement
|
||||
* \defgroup Group_EndpointPacketManagement Endpoint Packet Management
|
||||
* \brief USB Endpoint package management definitions.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to packet management of endpoints.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USB
|
||||
* \defgroup Group_EndpointManagement Endpoint Management
|
||||
* \brief Endpoint management definitions.
|
||||
*
|
||||
* Functions, macros and enums related to endpoint management when in USB Device mode. This
|
||||
* module contains the endpoint management macros, as well as endpoint interrupt and data
|
||||
* send/receive functions for various data types.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __ENDPOINT_H__
|
||||
#define __ENDPOINT_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's
|
||||
* numerical address in the device.
|
||||
*/
|
||||
#define ENDPOINT_EPNUM_MASK 0x07
|
||||
|
||||
/** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's
|
||||
* direction for comparing with the \c ENDPOINT_DESCRIPTOR_DIR_* masks.
|
||||
*/
|
||||
#define ENDPOINT_EPDIR_MASK 0x80
|
||||
|
||||
/** Endpoint address for the default control endpoint, which always resides in address 0. This is
|
||||
* defined for convenience to give more readable code when used with the endpoint macros.
|
||||
*/
|
||||
#define ENDPOINT_CONTROLEP 0
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/Endpoint_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/Endpoint_UC3.h"
|
||||
#elif (ARCH == ARCH_XMEGA)
|
||||
#include "XMEGA/Endpoint_XMEGA.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,124 +1,124 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Endpoint data stream transmission and reception management.
|
||||
* \copydetails Group_EndpointStreamRW
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_EndpointRW
|
||||
* \defgroup Group_EndpointStreamRW Read/Write of Multi-Byte Streams
|
||||
* \brief Endpoint data stream transmission and reception management.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
||||
* and to endpoints.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __ENDPOINT_STREAM_H__
|
||||
#define __ENDPOINT_STREAM_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Enums: */
|
||||
/** Enum for the possible error return codes of the \c Endpoint_*_Stream_* functions. */
|
||||
enum Endpoint_Stream_RW_ErrorCodes_t
|
||||
{
|
||||
ENDPOINT_RWSTREAM_NoError = 0, /**< Command completed successfully, no error. */
|
||||
ENDPOINT_RWSTREAM_EndpointStalled = 1, /**< The endpoint was stalled during the stream
|
||||
* transfer by the host or device.
|
||||
*/
|
||||
ENDPOINT_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during
|
||||
* the transfer.
|
||||
*/
|
||||
ENDPOINT_RWSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and
|
||||
* no USB endpoint traffic can occur until the bus
|
||||
* has resumed.
|
||||
*/
|
||||
ENDPOINT_RWSTREAM_Timeout = 4, /**< The host failed to accept or send the next packet
|
||||
* within the software timeout period set by the
|
||||
* \ref USB_STREAM_TIMEOUT_MS macro.
|
||||
*/
|
||||
ENDPOINT_RWSTREAM_IncompleteTransfer = 5, /**< Indicates that the endpoint bank became full or empty before
|
||||
* the complete contents of the current stream could be
|
||||
* transferred. The endpoint stream function should be called
|
||||
* again to process the next chunk of data in the transfer.
|
||||
*/
|
||||
};
|
||||
|
||||
/** Enum for the possible error return codes of the \c Endpoint_*_Control_Stream_* functions. */
|
||||
enum Endpoint_ControlStream_RW_ErrorCodes_t
|
||||
{
|
||||
ENDPOINT_RWCSTREAM_NoError = 0, /**< Command completed successfully, no error. */
|
||||
ENDPOINT_RWCSTREAM_HostAborted = 1, /**< The aborted the transfer prematurely. */
|
||||
ENDPOINT_RWCSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during
|
||||
* the transfer.
|
||||
*/
|
||||
ENDPOINT_RWCSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and
|
||||
* no USB endpoint traffic can occur until the bus
|
||||
* has resumed.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/EndpointStream_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/EndpointStream_UC3.h"
|
||||
#elif (ARCH == ARCH_XMEGA)
|
||||
#include "XMEGA/EndpointStream_XMEGA.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Endpoint data stream transmission and reception management.
|
||||
* \copydetails Group_EndpointStreamRW
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_EndpointRW
|
||||
* \defgroup Group_EndpointStreamRW Read/Write of Multi-Byte Streams
|
||||
* \brief Endpoint data stream transmission and reception management.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
||||
* and to endpoints.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __ENDPOINT_STREAM_H__
|
||||
#define __ENDPOINT_STREAM_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Enums: */
|
||||
/** Enum for the possible error return codes of the \c Endpoint_*_Stream_* functions. */
|
||||
enum Endpoint_Stream_RW_ErrorCodes_t
|
||||
{
|
||||
ENDPOINT_RWSTREAM_NoError = 0, /**< Command completed successfully, no error. */
|
||||
ENDPOINT_RWSTREAM_EndpointStalled = 1, /**< The endpoint was stalled during the stream
|
||||
* transfer by the host or device.
|
||||
*/
|
||||
ENDPOINT_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during
|
||||
* the transfer.
|
||||
*/
|
||||
ENDPOINT_RWSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and
|
||||
* no USB endpoint traffic can occur until the bus
|
||||
* has resumed.
|
||||
*/
|
||||
ENDPOINT_RWSTREAM_Timeout = 4, /**< The host failed to accept or send the next packet
|
||||
* within the software timeout period set by the
|
||||
* \ref USB_STREAM_TIMEOUT_MS macro.
|
||||
*/
|
||||
ENDPOINT_RWSTREAM_IncompleteTransfer = 5, /**< Indicates that the endpoint bank became full or empty before
|
||||
* the complete contents of the current stream could be
|
||||
* transferred. The endpoint stream function should be called
|
||||
* again to process the next chunk of data in the transfer.
|
||||
*/
|
||||
};
|
||||
|
||||
/** Enum for the possible error return codes of the \c Endpoint_*_Control_Stream_* functions. */
|
||||
enum Endpoint_ControlStream_RW_ErrorCodes_t
|
||||
{
|
||||
ENDPOINT_RWCSTREAM_NoError = 0, /**< Command completed successfully, no error. */
|
||||
ENDPOINT_RWCSTREAM_HostAborted = 1, /**< The aborted the transfer prematurely. */
|
||||
ENDPOINT_RWCSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during
|
||||
* the transfer.
|
||||
*/
|
||||
ENDPOINT_RWCSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and
|
||||
* no USB endpoint traffic can occur until the bus
|
||||
* has resumed.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/EndpointStream_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/EndpointStream_UC3.h"
|
||||
#elif (ARCH == ARCH_XMEGA)
|
||||
#include "XMEGA/EndpointStream_XMEGA.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,139 +1,139 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Common USB Host definitions for all architectures.
|
||||
* \copydetails Group_Host
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USB
|
||||
* \defgroup Group_Host Host Management
|
||||
* \brief USB Host management definitions for USB host mode.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBHOST_H__
|
||||
#define __USBHOST_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Enums: */
|
||||
/** Enum for the various states of the USB Host state machine.
|
||||
*
|
||||
* For information on each possible USB host state, refer to the USB 2.0 specification.
|
||||
* Several of the USB host states are broken up further into multiple smaller sub-states,
|
||||
* so that they can be internally implemented inside the library in an efficient manner.
|
||||
*
|
||||
* \see \ref USB_HostState, which stores the current host state machine state.
|
||||
*/
|
||||
enum USB_Host_States_t
|
||||
{
|
||||
HOST_STATE_WaitForDevice = 0, /**< This state indicates that the stack is waiting for an interval
|
||||
* to elapse before continuing with the next step of the device
|
||||
* enumeration process.
|
||||
*/
|
||||
HOST_STATE_Unattached = 1, /**< This state indicates that the host state machine is waiting for
|
||||
* a device to be attached so that it can start the enumeration process.
|
||||
*/
|
||||
HOST_STATE_Powered = 2, /**< This state indicates that a device has been attached, and the
|
||||
* library's internals are being configured to begin the enumeration
|
||||
* process.
|
||||
*/
|
||||
HOST_STATE_Powered_WaitForDeviceSettle = 3, /**< This state indicates that the stack is waiting for the initial
|
||||
* settling period to elapse before beginning the enumeration process.
|
||||
*/
|
||||
HOST_STATE_Powered_WaitForConnect = 4, /**< This state indicates that the stack is waiting for a connection event
|
||||
* from the USB controller to indicate a valid USB device has been attached
|
||||
* to the bus and is ready to be enumerated.
|
||||
*/
|
||||
HOST_STATE_Powered_DoReset = 5, /**< This state indicates that a valid USB device has been attached, and that
|
||||
* it will now be reset to ensure it is ready for enumeration.
|
||||
*/
|
||||
HOST_STATE_Powered_ConfigPipe = 6, /**< This state indicates that the attached device is currently powered and
|
||||
* reset, and that the control pipe is now being configured by the stack.
|
||||
*/
|
||||
HOST_STATE_Default = 7, /**< This state indicates that the stack is currently retrieving the control
|
||||
* endpoint's size from the device, so that the control pipe can be altered
|
||||
* to match.
|
||||
*/
|
||||
HOST_STATE_Default_PostReset = 8, /**< This state indicates that the control pipe is being reconfigured to match
|
||||
* the retrieved control endpoint size from the device, and the device's USB
|
||||
* bus address is being set.
|
||||
*/
|
||||
HOST_STATE_Default_PostAddressSet = 9, /**< This state indicates that the device's address has now been set, and the
|
||||
* stack is has now completed the device enumeration process. This state causes
|
||||
* the stack to change the current USB device address to that set for the
|
||||
* connected device, before progressing to the \ref HOST_STATE_Addressed state
|
||||
* ready for use in the user application.
|
||||
*/
|
||||
HOST_STATE_Addressed = 10, /**< Indicates that the device has been enumerated and addressed, and is now waiting
|
||||
* for the user application to configure the device ready for use.
|
||||
*/
|
||||
HOST_STATE_Configured = 11, /**< Indicates that the device has been configured into a valid device configuration,
|
||||
* ready for general use by the user application.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/Host_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/Host_UC3.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Common USB Host definitions for all architectures.
|
||||
* \copydetails Group_Host
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USB
|
||||
* \defgroup Group_Host Host Management
|
||||
* \brief USB Host management definitions for USB host mode.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBHOST_H__
|
||||
#define __USBHOST_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Enums: */
|
||||
/** Enum for the various states of the USB Host state machine.
|
||||
*
|
||||
* For information on each possible USB host state, refer to the USB 2.0 specification.
|
||||
* Several of the USB host states are broken up further into multiple smaller sub-states,
|
||||
* so that they can be internally implemented inside the library in an efficient manner.
|
||||
*
|
||||
* \see \ref USB_HostState, which stores the current host state machine state.
|
||||
*/
|
||||
enum USB_Host_States_t
|
||||
{
|
||||
HOST_STATE_WaitForDevice = 0, /**< This state indicates that the stack is waiting for an interval
|
||||
* to elapse before continuing with the next step of the device
|
||||
* enumeration process.
|
||||
*/
|
||||
HOST_STATE_Unattached = 1, /**< This state indicates that the host state machine is waiting for
|
||||
* a device to be attached so that it can start the enumeration process.
|
||||
*/
|
||||
HOST_STATE_Powered = 2, /**< This state indicates that a device has been attached, and the
|
||||
* library's internals are being configured to begin the enumeration
|
||||
* process.
|
||||
*/
|
||||
HOST_STATE_Powered_WaitForDeviceSettle = 3, /**< This state indicates that the stack is waiting for the initial
|
||||
* settling period to elapse before beginning the enumeration process.
|
||||
*/
|
||||
HOST_STATE_Powered_WaitForConnect = 4, /**< This state indicates that the stack is waiting for a connection event
|
||||
* from the USB controller to indicate a valid USB device has been attached
|
||||
* to the bus and is ready to be enumerated.
|
||||
*/
|
||||
HOST_STATE_Powered_DoReset = 5, /**< This state indicates that a valid USB device has been attached, and that
|
||||
* it will now be reset to ensure it is ready for enumeration.
|
||||
*/
|
||||
HOST_STATE_Powered_ConfigPipe = 6, /**< This state indicates that the attached device is currently powered and
|
||||
* reset, and that the control pipe is now being configured by the stack.
|
||||
*/
|
||||
HOST_STATE_Default = 7, /**< This state indicates that the stack is currently retrieving the control
|
||||
* endpoint's size from the device, so that the control pipe can be altered
|
||||
* to match.
|
||||
*/
|
||||
HOST_STATE_Default_PostReset = 8, /**< This state indicates that the control pipe is being reconfigured to match
|
||||
* the retrieved control endpoint size from the device, and the device's USB
|
||||
* bus address is being set.
|
||||
*/
|
||||
HOST_STATE_Default_PostAddressSet = 9, /**< This state indicates that the device's address has now been set, and the
|
||||
* stack is has now completed the device enumeration process. This state causes
|
||||
* the stack to change the current USB device address to that set for the
|
||||
* connected device, before progressing to the \ref HOST_STATE_Addressed state
|
||||
* ready for use in the user application.
|
||||
*/
|
||||
HOST_STATE_Addressed = 10, /**< Indicates that the device has been enumerated and addressed, and is now waiting
|
||||
* for the user application to configure the device ready for use.
|
||||
*/
|
||||
HOST_STATE_Configured = 11, /**< Indicates that the device has been configured into a valid device configuration,
|
||||
* ready for general use by the user application.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/Host_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/Host_UC3.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,80 +1,80 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Common USB OTG definitions for all architectures.
|
||||
* \copydetails Group_OTG
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USB
|
||||
* \defgroup Group_OTG USB On The Go (OTG) Management
|
||||
* \brief USB OTG management definitions.
|
||||
*
|
||||
* 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
|
||||
* roles.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBOTG_H__
|
||||
#define __USBOTG_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/OTG_AVR8.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Common USB OTG definitions for all architectures.
|
||||
* \copydetails Group_OTG
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USB
|
||||
* \defgroup Group_OTG USB On The Go (OTG) Management
|
||||
* \brief USB OTG management definitions.
|
||||
*
|
||||
* 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
|
||||
* roles.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBOTG_H__
|
||||
#define __USBOTG_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/OTG_AVR8.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,136 +1,136 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Common USB Pipe definitions for all architectures.
|
||||
* \copydetails Group_PipeManagement
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_PipeManagement
|
||||
* \defgroup Group_PipeRW Pipe Data Reading and Writing
|
||||
* \brief Pipe data read/write definitions.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to data reading and writing from and to pipes.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_PipeRW
|
||||
* \defgroup Group_PipePrimitiveRW Read/Write of Primitive Data Types
|
||||
* \brief Pipe data primitive read/write definitions.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to data reading and writing of primitive data types
|
||||
* from and to pipes.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_PipeManagement
|
||||
* \defgroup Group_PipePacketManagement Pipe Packet Management
|
||||
* \brief Pipe packet management definitions.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to packet management of pipes.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_PipeManagement
|
||||
* \defgroup Group_PipeControlReq Pipe Control Request Management
|
||||
* \brief Pipe control request definitions.
|
||||
*
|
||||
* Module for host mode request processing. This module allows for the transmission of standard, class and
|
||||
* vendor control requests to the default control endpoint of an attached device while in host mode.
|
||||
*
|
||||
* \see Chapter 9 of the USB 2.0 specification.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USB
|
||||
* \defgroup Group_PipeManagement Pipe Management
|
||||
* \brief Pipe management definitions.
|
||||
*
|
||||
* This module contains functions, macros and enums related to pipe management when in USB Host mode. This
|
||||
* module contains the pipe management macros, as well as pipe interrupt and data send/receive functions
|
||||
* for various data types.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __PIPE_H__
|
||||
#define __PIPE_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Pipe address for the default control pipe, which always resides in address 0. This is
|
||||
* defined for convenience to give more readable code when used with the pipe macros.
|
||||
*/
|
||||
#define PIPE_CONTROLPIPE 0
|
||||
|
||||
/** Pipe number mask, for masking against pipe addresses to retrieve the pipe's numerical address
|
||||
* in the device.
|
||||
*/
|
||||
#define PIPE_PIPENUM_MASK 0x07
|
||||
|
||||
/** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's
|
||||
* numerical address in the attached device.
|
||||
*/
|
||||
#define PIPE_EPNUM_MASK 0x0F
|
||||
|
||||
/** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's
|
||||
* direction for comparing with the \c ENDPOINT_DESCRIPTOR_DIR_* masks.
|
||||
*/
|
||||
#define PIPE_EPDIR_MASK 0x80
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/Pipe_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/Pipe_UC3.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Common USB Pipe definitions for all architectures.
|
||||
* \copydetails Group_PipeManagement
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_PipeManagement
|
||||
* \defgroup Group_PipeRW Pipe Data Reading and Writing
|
||||
* \brief Pipe data read/write definitions.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to data reading and writing from and to pipes.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_PipeRW
|
||||
* \defgroup Group_PipePrimitiveRW Read/Write of Primitive Data Types
|
||||
* \brief Pipe data primitive read/write definitions.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to data reading and writing of primitive data types
|
||||
* from and to pipes.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_PipeManagement
|
||||
* \defgroup Group_PipePacketManagement Pipe Packet Management
|
||||
* \brief Pipe packet management definitions.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to packet management of pipes.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_PipeManagement
|
||||
* \defgroup Group_PipeControlReq Pipe Control Request Management
|
||||
* \brief Pipe control request definitions.
|
||||
*
|
||||
* Module for host mode request processing. This module allows for the transmission of standard, class and
|
||||
* vendor control requests to the default control endpoint of an attached device while in host mode.
|
||||
*
|
||||
* \see Chapter 9 of the USB 2.0 specification.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USB
|
||||
* \defgroup Group_PipeManagement Pipe Management
|
||||
* \brief Pipe management definitions.
|
||||
*
|
||||
* This module contains functions, macros and enums related to pipe management when in USB Host mode. This
|
||||
* module contains the pipe management macros, as well as pipe interrupt and data send/receive functions
|
||||
* for various data types.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __PIPE_H__
|
||||
#define __PIPE_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Pipe address for the default control pipe, which always resides in address 0. This is
|
||||
* defined for convenience to give more readable code when used with the pipe macros.
|
||||
*/
|
||||
#define PIPE_CONTROLPIPE 0
|
||||
|
||||
/** Pipe number mask, for masking against pipe addresses to retrieve the pipe's numerical address
|
||||
* in the device.
|
||||
*/
|
||||
#define PIPE_PIPENUM_MASK 0x07
|
||||
|
||||
/** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's
|
||||
* numerical address in the attached device.
|
||||
*/
|
||||
#define PIPE_EPNUM_MASK 0x0F
|
||||
|
||||
/** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's
|
||||
* direction for comparing with the \c ENDPOINT_DESCRIPTOR_DIR_* masks.
|
||||
*/
|
||||
#define PIPE_EPDIR_MASK 0x80
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/Pipe_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/Pipe_UC3.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,100 +1,100 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Pipe data stream transmission and reception management.
|
||||
* \copydetails Group_PipeStreamRW
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_PipeRW
|
||||
* \defgroup Group_PipeStreamRW Read/Write of Multi-Byte Streams
|
||||
* \brief Pipe data stream transmission and reception management.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
||||
* and to pipes.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __PIPE_STREAM_H__
|
||||
#define __PIPE_STREAM_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Enums: */
|
||||
/** Enum for the possible error return codes of the Pipe_*_Stream_* functions. */
|
||||
enum Pipe_Stream_RW_ErrorCodes_t
|
||||
{
|
||||
PIPE_RWSTREAM_NoError = 0, /**< Command completed successfully, no error. */
|
||||
PIPE_RWSTREAM_PipeStalled = 1, /**< The device stalled the pipe during the transfer. */
|
||||
PIPE_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during
|
||||
* the transfer.
|
||||
*/
|
||||
PIPE_RWSTREAM_Timeout = 3, /**< The device failed to accept or send the next packet
|
||||
* within the software timeout period set by the
|
||||
* \ref USB_STREAM_TIMEOUT_MS macro.
|
||||
*/
|
||||
PIPE_RWSTREAM_IncompleteTransfer = 4, /**< Indicates that the pipe bank became full/empty before the
|
||||
* complete contents of the stream could be transferred.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/PipeStream_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/PipeStream_UC3.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Pipe data stream transmission and reception management.
|
||||
* \copydetails Group_PipeStreamRW
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_PipeRW
|
||||
* \defgroup Group_PipeStreamRW Read/Write of Multi-Byte Streams
|
||||
* \brief Pipe data stream transmission and reception management.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
||||
* and to pipes.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __PIPE_STREAM_H__
|
||||
#define __PIPE_STREAM_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Enums: */
|
||||
/** Enum for the possible error return codes of the Pipe_*_Stream_* functions. */
|
||||
enum Pipe_Stream_RW_ErrorCodes_t
|
||||
{
|
||||
PIPE_RWSTREAM_NoError = 0, /**< Command completed successfully, no error. */
|
||||
PIPE_RWSTREAM_PipeStalled = 1, /**< The device stalled the pipe during the transfer. */
|
||||
PIPE_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during
|
||||
* the transfer.
|
||||
*/
|
||||
PIPE_RWSTREAM_Timeout = 3, /**< The device failed to accept or send the next packet
|
||||
* within the software timeout period set by the
|
||||
* \ref USB_STREAM_TIMEOUT_MS macro.
|
||||
*/
|
||||
PIPE_RWSTREAM_IncompleteTransfer = 4, /**< Indicates that the pipe bank became full/empty before the
|
||||
* complete contents of the stream could be transferred.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/PipeStream_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/PipeStream_UC3.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,47 +1,47 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
|
||||
#include "../Device.h"
|
||||
|
||||
void USB_Device_SendRemoteWakeup(void)
|
||||
{
|
||||
USB_CLK_Unfreeze();
|
||||
|
||||
AVR32_USBB.UDCON.rmwkup = true;
|
||||
while (AVR32_USBB.UDCON.rmwkup);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
|
||||
#include "../Device.h"
|
||||
|
||||
void USB_Device_SendRemoteWakeup(void)
|
||||
{
|
||||
USB_CLK_Unfreeze();
|
||||
|
||||
AVR32_USBB.UDCON.rmwkup = true;
|
||||
while (AVR32_USBB.UDCON.rmwkup);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,259 +1,259 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Device definitions for the AVR32 UC3 microcontrollers.
|
||||
* \copydetails Group_Device_UC3
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Device
|
||||
* \defgroup Group_Device_UC3 Device Management (UC3)
|
||||
* \brief USB Device definitions for the AVR32 UC3 microcontrollers.
|
||||
*
|
||||
* Architecture specific USB Device definitions for the Atmel 32-bit UC3 AVR microcontrollers.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBDEVICE_UC3_H__
|
||||
#define __USBDEVICE_UC3_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../../Common/Common.h"
|
||||
#include "../USBController.h"
|
||||
#include "../StdDescriptors.h"
|
||||
#include "../USBInterrupt.h"
|
||||
#include "../Endpoint.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** \name USB Device Mode Option Masks */
|
||||
//@{
|
||||
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
|
||||
* USB interface should be initialized in low speed (1.5Mb/s) mode.
|
||||
*
|
||||
* \note Restrictions apply on the number, size and type of endpoints which can be used
|
||||
* when running in low speed mode - refer to the USB 2.0 specification.
|
||||
*/
|
||||
#define USB_DEVICE_OPT_LOWSPEED (1 << 0)
|
||||
|
||||
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
|
||||
* USB interface should be initialized in full speed (12Mb/s) mode.
|
||||
*/
|
||||
#define USB_DEVICE_OPT_FULLSPEED (0 << 0)
|
||||
|
||||
#if defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32) || defined(__DOXYGEN__)
|
||||
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
|
||||
* USB interface should be initialized in high speed (480Mb/s) mode.
|
||||
*/
|
||||
#define USB_DEVICE_OPT_HIGHSPEED (1 << 1)
|
||||
#endif
|
||||
//@}
|
||||
|
||||
#if (!defined(NO_INTERNAL_SERIAL) && \
|
||||
(defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32) || \
|
||||
defined(__DOXYGEN__)))
|
||||
/** 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 microcontrollers 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 \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial
|
||||
* number for the device.
|
||||
*/
|
||||
#define USE_INTERNAL_SERIAL 0xDC
|
||||
|
||||
/** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller
|
||||
* model.
|
||||
*/
|
||||
#define INTERNAL_SERIAL_LENGTH_BITS 120
|
||||
|
||||
/** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller
|
||||
* model.
|
||||
*/
|
||||
#define INTERNAL_SERIAL_START_ADDRESS 0x80800204
|
||||
#else
|
||||
#define USE_INTERNAL_SERIAL NO_DESCRIPTOR
|
||||
|
||||
#define INTERNAL_SERIAL_LENGTH_BITS 0
|
||||
#define INTERNAL_SERIAL_START_ADDRESS 0
|
||||
#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.
|
||||
*
|
||||
* Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the
|
||||
* host computer when the host has suspended all USB devices to enter a low power state.
|
||||
*
|
||||
* \note This macro should only be used if the device has indicated to the host that it
|
||||
* supports the Remote Wakeup feature in the device descriptors, and should only be
|
||||
* issued if the host is currently allowing remote wakeup events from the device (i.e.,
|
||||
* the \ref USB_Device_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP
|
||||
* compile time option is used, this macro is unavailable.
|
||||
* \n\n
|
||||
*
|
||||
* \note The USB clock must be running for this function to operate. If the stack is initialized with
|
||||
* the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running
|
||||
* before attempting to call this function.
|
||||
*
|
||||
* \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors.
|
||||
*/
|
||||
void USB_Device_SendRemoteWakeup(void);
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host)
|
||||
* the frame number is incremented by one.
|
||||
*/
|
||||
static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint16_t USB_Device_GetFrameNumber(void)
|
||||
{
|
||||
return AVR32_USBB.UDFNUM.fnum;
|
||||
}
|
||||
|
||||
#if !defined(NO_SOF_EVENTS)
|
||||
/** Enables the device mode Start Of Frame events. When enabled, this causes the
|
||||
* \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,
|
||||
* at the start of each USB frame when enumerated in device mode.
|
||||
*
|
||||
* \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
|
||||
*/
|
||||
static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_EnableSOFEvents(void)
|
||||
{
|
||||
USB_INT_Enable(USB_INT_SOFI);
|
||||
}
|
||||
|
||||
/** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the
|
||||
* \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.
|
||||
*
|
||||
* \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
|
||||
*/
|
||||
static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_DisableSOFEvents(void)
|
||||
{
|
||||
USB_INT_Disable(USB_INT_SOFI);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Inline Functions: */
|
||||
static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetLowSpeed(void)
|
||||
{
|
||||
AVR32_USBB.UDCON.ls = true;
|
||||
}
|
||||
|
||||
static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetFullSpeed(void)
|
||||
{
|
||||
AVR32_USBB.UDCON.ls = false;
|
||||
#if defined(USB_DEVICE_OPT_HIGHSPEED)
|
||||
AVR32_USBB.UDCON.spdconf = 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(USB_DEVICE_OPT_HIGHSPEED)
|
||||
static inline void USB_Device_SetHighSpeed(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetHighSpeed(void)
|
||||
{
|
||||
AVR32_USBB.UDCON.ls = false;
|
||||
AVR32_USBB.UDCON.spdconf = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetDeviceAddress(const uint8_t Address)
|
||||
{
|
||||
AVR32_USBB.UDCON.uadd = Address;
|
||||
AVR32_USBB.UDCON.adden = true;
|
||||
}
|
||||
|
||||
static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool USB_Device_IsAddressSet(void)
|
||||
{
|
||||
return AVR32_USBB.UDCON.adden;
|
||||
}
|
||||
|
||||
#if (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)
|
||||
static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) ATTR_NON_NULL_PTR_ARG(1);
|
||||
static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString)
|
||||
{
|
||||
uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();
|
||||
GlobalInterruptDisable();
|
||||
|
||||
uint8_t* SigReadAddress = (uint8_t*)INTERNAL_SERIAL_START_ADDRESS;
|
||||
|
||||
for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)
|
||||
{
|
||||
uint8_t SerialByte = *SigReadAddress;
|
||||
|
||||
if (SerialCharNum & 0x01)
|
||||
{
|
||||
SerialByte >>= 4;
|
||||
SigReadAddress++;
|
||||
}
|
||||
|
||||
SerialByte &= 0x0F;
|
||||
|
||||
UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?
|
||||
(('A' - 10) + SerialByte) : ('0' + SerialByte));
|
||||
}
|
||||
|
||||
SetGlobalInterruptMask(CurrentGlobalInt);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Device definitions for the AVR32 UC3 microcontrollers.
|
||||
* \copydetails Group_Device_UC3
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Device
|
||||
* \defgroup Group_Device_UC3 Device Management (UC3)
|
||||
* \brief USB Device definitions for the AVR32 UC3 microcontrollers.
|
||||
*
|
||||
* Architecture specific USB Device definitions for the Atmel 32-bit UC3 AVR microcontrollers.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBDEVICE_UC3_H__
|
||||
#define __USBDEVICE_UC3_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../../Common/Common.h"
|
||||
#include "../USBController.h"
|
||||
#include "../StdDescriptors.h"
|
||||
#include "../USBInterrupt.h"
|
||||
#include "../Endpoint.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** \name USB Device Mode Option Masks */
|
||||
//@{
|
||||
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
|
||||
* USB interface should be initialized in low speed (1.5Mb/s) mode.
|
||||
*
|
||||
* \note Restrictions apply on the number, size and type of endpoints which can be used
|
||||
* when running in low speed mode - refer to the USB 2.0 specification.
|
||||
*/
|
||||
#define USB_DEVICE_OPT_LOWSPEED (1 << 0)
|
||||
|
||||
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
|
||||
* USB interface should be initialized in full speed (12Mb/s) mode.
|
||||
*/
|
||||
#define USB_DEVICE_OPT_FULLSPEED (0 << 0)
|
||||
|
||||
#if defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32) || defined(__DOXYGEN__)
|
||||
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
|
||||
* USB interface should be initialized in high speed (480Mb/s) mode.
|
||||
*/
|
||||
#define USB_DEVICE_OPT_HIGHSPEED (1 << 1)
|
||||
#endif
|
||||
//@}
|
||||
|
||||
#if (!defined(NO_INTERNAL_SERIAL) && \
|
||||
(defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32) || \
|
||||
defined(__DOXYGEN__)))
|
||||
/** 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 microcontrollers 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 \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial
|
||||
* number for the device.
|
||||
*/
|
||||
#define USE_INTERNAL_SERIAL 0xDC
|
||||
|
||||
/** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller
|
||||
* model.
|
||||
*/
|
||||
#define INTERNAL_SERIAL_LENGTH_BITS 120
|
||||
|
||||
/** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller
|
||||
* model.
|
||||
*/
|
||||
#define INTERNAL_SERIAL_START_ADDRESS 0x80800204
|
||||
#else
|
||||
#define USE_INTERNAL_SERIAL NO_DESCRIPTOR
|
||||
|
||||
#define INTERNAL_SERIAL_LENGTH_BITS 0
|
||||
#define INTERNAL_SERIAL_START_ADDRESS 0
|
||||
#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.
|
||||
*
|
||||
* Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the
|
||||
* host computer when the host has suspended all USB devices to enter a low power state.
|
||||
*
|
||||
* \note This macro should only be used if the device has indicated to the host that it
|
||||
* supports the Remote Wakeup feature in the device descriptors, and should only be
|
||||
* issued if the host is currently allowing remote wakeup events from the device (i.e.,
|
||||
* the \ref USB_Device_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP
|
||||
* compile time option is used, this macro is unavailable.
|
||||
* \n\n
|
||||
*
|
||||
* \note The USB clock must be running for this function to operate. If the stack is initialized with
|
||||
* the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running
|
||||
* before attempting to call this function.
|
||||
*
|
||||
* \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors.
|
||||
*/
|
||||
void USB_Device_SendRemoteWakeup(void);
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host)
|
||||
* the frame number is incremented by one.
|
||||
*/
|
||||
static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint16_t USB_Device_GetFrameNumber(void)
|
||||
{
|
||||
return AVR32_USBB.UDFNUM.fnum;
|
||||
}
|
||||
|
||||
#if !defined(NO_SOF_EVENTS)
|
||||
/** Enables the device mode Start Of Frame events. When enabled, this causes the
|
||||
* \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,
|
||||
* at the start of each USB frame when enumerated in device mode.
|
||||
*
|
||||
* \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
|
||||
*/
|
||||
static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_EnableSOFEvents(void)
|
||||
{
|
||||
USB_INT_Enable(USB_INT_SOFI);
|
||||
}
|
||||
|
||||
/** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the
|
||||
* \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.
|
||||
*
|
||||
* \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
|
||||
*/
|
||||
static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_DisableSOFEvents(void)
|
||||
{
|
||||
USB_INT_Disable(USB_INT_SOFI);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Inline Functions: */
|
||||
static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetLowSpeed(void)
|
||||
{
|
||||
AVR32_USBB.UDCON.ls = true;
|
||||
}
|
||||
|
||||
static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetFullSpeed(void)
|
||||
{
|
||||
AVR32_USBB.UDCON.ls = false;
|
||||
#if defined(USB_DEVICE_OPT_HIGHSPEED)
|
||||
AVR32_USBB.UDCON.spdconf = 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(USB_DEVICE_OPT_HIGHSPEED)
|
||||
static inline void USB_Device_SetHighSpeed(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetHighSpeed(void)
|
||||
{
|
||||
AVR32_USBB.UDCON.ls = false;
|
||||
AVR32_USBB.UDCON.spdconf = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetDeviceAddress(const uint8_t Address)
|
||||
{
|
||||
AVR32_USBB.UDCON.uadd = Address;
|
||||
AVR32_USBB.UDCON.adden = true;
|
||||
}
|
||||
|
||||
static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool USB_Device_IsAddressSet(void)
|
||||
{
|
||||
return AVR32_USBB.UDCON.adden;
|
||||
}
|
||||
|
||||
#if (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)
|
||||
static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) ATTR_NON_NULL_PTR_ARG(1);
|
||||
static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString)
|
||||
{
|
||||
uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();
|
||||
GlobalInterruptDisable();
|
||||
|
||||
uint8_t* SigReadAddress = (uint8_t*)INTERNAL_SERIAL_START_ADDRESS;
|
||||
|
||||
for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)
|
||||
{
|
||||
uint8_t SerialByte = *SigReadAddress;
|
||||
|
||||
if (SerialCharNum & 0x01)
|
||||
{
|
||||
SerialByte >>= 4;
|
||||
SigReadAddress++;
|
||||
}
|
||||
|
||||
SerialByte &= 0x0F;
|
||||
|
||||
UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?
|
||||
(('A' - 10) + SerialByte) : ('0' + SerialByte));
|
||||
}
|
||||
|
||||
SetGlobalInterruptMask(CurrentGlobalInt);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,141 +1,141 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
|
||||
#include "../Endpoint.h"
|
||||
|
||||
#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)
|
||||
uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;
|
||||
#endif
|
||||
|
||||
volatile uint32_t USB_SelectedEndpoint = ENDPOINT_CONTROLEP;
|
||||
volatile uint8_t* USB_EndpointFIFOPos[ENDPOINT_TOTAL_ENDPOINTS];
|
||||
|
||||
bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
|
||||
const uint32_t UECFG0Data)
|
||||
{
|
||||
Endpoint_SelectEndpoint(Number);
|
||||
Endpoint_EnableEndpoint();
|
||||
|
||||
(&AVR32_USBB.uecfg0)[Number] = 0;
|
||||
(&AVR32_USBB.uecfg0)[Number] = UECFG0Data;
|
||||
USB_EndpointFIFOPos[Number] = &AVR32_USBB_SLAVE[Number * 0x10000];
|
||||
|
||||
return Endpoint_IsConfigured();
|
||||
}
|
||||
|
||||
void Endpoint_ClearEndpoints(void)
|
||||
{
|
||||
for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)
|
||||
{
|
||||
Endpoint_SelectEndpoint(EPNum);
|
||||
(&AVR32_USBB.uecfg0)[EPNum] = 0;
|
||||
(&AVR32_USBB.uecon0clr)[EPNum] = -1;
|
||||
USB_EndpointFIFOPos[EPNum] = &AVR32_USBB_SLAVE[EPNum * 0x10000];
|
||||
Endpoint_DisableEndpoint();
|
||||
}
|
||||
}
|
||||
|
||||
void Endpoint_ClearStatusStage(void)
|
||||
{
|
||||
if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST)
|
||||
{
|
||||
while (!(Endpoint_IsOUTReceived()))
|
||||
{
|
||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||
return;
|
||||
}
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (!(Endpoint_IsINReady()))
|
||||
{
|
||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||
return;
|
||||
}
|
||||
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
uint8_t Endpoint_WaitUntilReady(void)
|
||||
{
|
||||
#if (USB_STREAM_TIMEOUT_MS < 0xFF)
|
||||
uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
|
||||
#else
|
||||
uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
|
||||
#endif
|
||||
|
||||
uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN)
|
||||
{
|
||||
if (Endpoint_IsINReady())
|
||||
return ENDPOINT_READYWAIT_NoError;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Endpoint_IsOUTReceived())
|
||||
return ENDPOINT_READYWAIT_NoError;
|
||||
}
|
||||
|
||||
uint8_t USB_DeviceState_LCL = USB_DeviceState;
|
||||
|
||||
if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
|
||||
return ENDPOINT_READYWAIT_DeviceDisconnected;
|
||||
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
|
||||
return ENDPOINT_READYWAIT_BusSuspended;
|
||||
else if (Endpoint_IsStalled())
|
||||
return ENDPOINT_READYWAIT_EndpointStalled;
|
||||
|
||||
uint16_t CurrentFrameNumber = USB_Device_GetFrameNumber();
|
||||
|
||||
if (CurrentFrameNumber != PreviousFrameNumber)
|
||||
{
|
||||
PreviousFrameNumber = CurrentFrameNumber;
|
||||
|
||||
if (!(TimeoutMSRem--))
|
||||
return ENDPOINT_READYWAIT_Timeout;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
|
||||
#include "../Endpoint.h"
|
||||
|
||||
#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)
|
||||
uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;
|
||||
#endif
|
||||
|
||||
volatile uint32_t USB_SelectedEndpoint = ENDPOINT_CONTROLEP;
|
||||
volatile uint8_t* USB_EndpointFIFOPos[ENDPOINT_TOTAL_ENDPOINTS];
|
||||
|
||||
bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
|
||||
const uint32_t UECFG0Data)
|
||||
{
|
||||
Endpoint_SelectEndpoint(Number);
|
||||
Endpoint_EnableEndpoint();
|
||||
|
||||
(&AVR32_USBB.uecfg0)[Number] = 0;
|
||||
(&AVR32_USBB.uecfg0)[Number] = UECFG0Data;
|
||||
USB_EndpointFIFOPos[Number] = &AVR32_USBB_SLAVE[Number * 0x10000];
|
||||
|
||||
return Endpoint_IsConfigured();
|
||||
}
|
||||
|
||||
void Endpoint_ClearEndpoints(void)
|
||||
{
|
||||
for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)
|
||||
{
|
||||
Endpoint_SelectEndpoint(EPNum);
|
||||
(&AVR32_USBB.uecfg0)[EPNum] = 0;
|
||||
(&AVR32_USBB.uecon0clr)[EPNum] = -1;
|
||||
USB_EndpointFIFOPos[EPNum] = &AVR32_USBB_SLAVE[EPNum * 0x10000];
|
||||
Endpoint_DisableEndpoint();
|
||||
}
|
||||
}
|
||||
|
||||
void Endpoint_ClearStatusStage(void)
|
||||
{
|
||||
if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST)
|
||||
{
|
||||
while (!(Endpoint_IsOUTReceived()))
|
||||
{
|
||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||
return;
|
||||
}
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (!(Endpoint_IsINReady()))
|
||||
{
|
||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||
return;
|
||||
}
|
||||
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
uint8_t Endpoint_WaitUntilReady(void)
|
||||
{
|
||||
#if (USB_STREAM_TIMEOUT_MS < 0xFF)
|
||||
uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
|
||||
#else
|
||||
uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
|
||||
#endif
|
||||
|
||||
uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN)
|
||||
{
|
||||
if (Endpoint_IsINReady())
|
||||
return ENDPOINT_READYWAIT_NoError;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Endpoint_IsOUTReceived())
|
||||
return ENDPOINT_READYWAIT_NoError;
|
||||
}
|
||||
|
||||
uint8_t USB_DeviceState_LCL = USB_DeviceState;
|
||||
|
||||
if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
|
||||
return ENDPOINT_READYWAIT_DeviceDisconnected;
|
||||
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
|
||||
return ENDPOINT_READYWAIT_BusSuspended;
|
||||
else if (Endpoint_IsStalled())
|
||||
return ENDPOINT_READYWAIT_EndpointStalled;
|
||||
|
||||
uint16_t CurrentFrameNumber = USB_Device_GetFrameNumber();
|
||||
|
||||
if (CurrentFrameNumber != PreviousFrameNumber)
|
||||
{
|
||||
PreviousFrameNumber = CurrentFrameNumber;
|
||||
|
||||
if (!(TimeoutMSRem--))
|
||||
return ENDPOINT_READYWAIT_Timeout;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,292 +1,292 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
|
||||
#define __INCLUDE_FROM_HOST_C
|
||||
#include "../Host.h"
|
||||
|
||||
void USB_Host_ProcessNextHostState(void)
|
||||
{
|
||||
uint8_t ErrorCode = HOST_ENUMERROR_NoError;
|
||||
uint8_t SubErrorCode = HOST_ENUMERROR_NoError;
|
||||
|
||||
static uint16_t WaitMSRemaining;
|
||||
static uint8_t PostWaitState;
|
||||
|
||||
switch (USB_HostState)
|
||||
{
|
||||
case HOST_STATE_WaitForDevice:
|
||||
if (WaitMSRemaining)
|
||||
{
|
||||
if ((SubErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)
|
||||
{
|
||||
USB_HostState = PostWaitState;
|
||||
ErrorCode = HOST_ENUMERROR_WaitStage;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(--WaitMSRemaining))
|
||||
USB_HostState = PostWaitState;
|
||||
}
|
||||
|
||||
break;
|
||||
case HOST_STATE_Powered:
|
||||
WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS;
|
||||
|
||||
USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle;
|
||||
break;
|
||||
case HOST_STATE_Powered_WaitForDeviceSettle:
|
||||
if (WaitMSRemaining--)
|
||||
{
|
||||
Delay_MS(1);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
USB_Host_VBUS_Manual_Off();
|
||||
|
||||
USB_OTGPAD_On();
|
||||
USB_Host_VBUS_Auto_Enable();
|
||||
USB_Host_VBUS_Auto_On();
|
||||
|
||||
USB_HostState = HOST_STATE_Powered_WaitForConnect;
|
||||
}
|
||||
|
||||
break;
|
||||
case HOST_STATE_Powered_WaitForConnect:
|
||||
if (USB_INT_HasOccurred(USB_INT_DCONNI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_DCONNI);
|
||||
USB_INT_Clear(USB_INT_DDISCI);
|
||||
|
||||
USB_INT_Clear(USB_INT_VBERRI);
|
||||
USB_INT_Enable(USB_INT_VBERRI);
|
||||
|
||||
USB_Host_ResumeBus();
|
||||
Pipe_ClearPipes();
|
||||
|
||||
HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset);
|
||||
}
|
||||
|
||||
break;
|
||||
case HOST_STATE_Powered_DoReset:
|
||||
USB_Host_ResetDevice();
|
||||
|
||||
HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered_ConfigPipe);
|
||||
break;
|
||||
case HOST_STATE_Powered_ConfigPipe:
|
||||
Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,
|
||||
PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,
|
||||
PIPE_CONTROLPIPE_DEFAULT_SIZE, PIPE_BANK_SINGLE);
|
||||
|
||||
if (!(Pipe_IsConfigured()))
|
||||
{
|
||||
ErrorCode = HOST_ENUMERROR_PipeConfigError;
|
||||
SubErrorCode = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
USB_HostState = HOST_STATE_Default;
|
||||
break;
|
||||
case HOST_STATE_Default:
|
||||
USB_ControlRequest = (USB_Request_Header_t)
|
||||
{
|
||||
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
|
||||
.bRequest = REQ_GetDescriptor,
|
||||
.wValue = (DTYPE_Device << 8),
|
||||
.wIndex = 0,
|
||||
.wLength = 8,
|
||||
};
|
||||
|
||||
uint8_t DataBuffer[8];
|
||||
|
||||
if ((SubErrorCode = USB_Host_SendControlRequest(DataBuffer)) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
ErrorCode = HOST_ENUMERROR_ControlError;
|
||||
break;
|
||||
}
|
||||
|
||||
USB_Host_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)];
|
||||
|
||||
USB_Host_ResetDevice();
|
||||
|
||||
HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Default_PostReset);
|
||||
break;
|
||||
case HOST_STATE_Default_PostReset:
|
||||
Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,
|
||||
PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,
|
||||
USB_Host_ControlPipeSize, PIPE_BANK_SINGLE);
|
||||
|
||||
if (!(Pipe_IsConfigured()))
|
||||
{
|
||||
ErrorCode = HOST_ENUMERROR_PipeConfigError;
|
||||
SubErrorCode = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
USB_ControlRequest = (USB_Request_Header_t)
|
||||
{
|
||||
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),
|
||||
.bRequest = REQ_SetAddress,
|
||||
.wValue = USB_HOST_DEVICEADDRESS,
|
||||
.wIndex = 0,
|
||||
.wLength = 0,
|
||||
};
|
||||
|
||||
if ((SubErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
ErrorCode = HOST_ENUMERROR_ControlError;
|
||||
break;
|
||||
}
|
||||
|
||||
HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Default_PostAddressSet);
|
||||
break;
|
||||
case HOST_STATE_Default_PostAddressSet:
|
||||
USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS);
|
||||
|
||||
USB_HostState = HOST_STATE_Addressed;
|
||||
|
||||
EVENT_USB_Host_DeviceEnumerationComplete();
|
||||
break;
|
||||
}
|
||||
|
||||
if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached))
|
||||
{
|
||||
EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode);
|
||||
|
||||
USB_Host_VBUS_Auto_Off();
|
||||
|
||||
EVENT_USB_Host_DeviceUnattached();
|
||||
|
||||
USB_ResetInterface();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t USB_Host_WaitMS(uint8_t MS)
|
||||
{
|
||||
bool BusSuspended = USB_Host_IsBusSuspended();
|
||||
uint8_t ErrorCode = HOST_WAITERROR_Successful;
|
||||
bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
|
||||
|
||||
USB_INT_Disable(USB_INT_HSOFI);
|
||||
USB_INT_Clear(USB_INT_HSOFI);
|
||||
|
||||
USB_Host_ResumeBus();
|
||||
|
||||
while (MS)
|
||||
{
|
||||
if (USB_INT_HasOccurred(USB_INT_HSOFI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_HSOFI);
|
||||
MS--;
|
||||
}
|
||||
|
||||
if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host))
|
||||
{
|
||||
ErrorCode = HOST_WAITERROR_DeviceDisconnect;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (Pipe_IsError() == true)
|
||||
{
|
||||
Pipe_ClearError();
|
||||
ErrorCode = HOST_WAITERROR_PipeError;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (Pipe_IsStalled() == true)
|
||||
{
|
||||
Pipe_ClearStall();
|
||||
ErrorCode = HOST_WAITERROR_SetupStalled;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (BusSuspended)
|
||||
USB_Host_SuspendBus();
|
||||
|
||||
if (HSOFIEnabled)
|
||||
USB_INT_Enable(USB_INT_HSOFI);
|
||||
|
||||
return ErrorCode;
|
||||
}
|
||||
|
||||
static void USB_Host_ResetDevice(void)
|
||||
{
|
||||
bool BusSuspended = USB_Host_IsBusSuspended();
|
||||
|
||||
USB_INT_Disable(USB_INT_DDISCI);
|
||||
|
||||
USB_Host_ResetBus();
|
||||
while (!(USB_Host_IsBusResetComplete()));
|
||||
USB_Host_ResumeBus();
|
||||
|
||||
USB_Host_ConfigurationNumber = 0;
|
||||
|
||||
bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
|
||||
|
||||
USB_INT_Disable(USB_INT_HSOFI);
|
||||
USB_INT_Clear(USB_INT_HSOFI);
|
||||
|
||||
for (uint8_t MSRem = 10; MSRem != 0; MSRem--)
|
||||
{
|
||||
/* Workaround for powerless-pull-up devices. After a USB bus reset,
|
||||
all disconnection interrupts are suppressed while a USB frame is
|
||||
looked for - if it is found within 10ms, the device is still
|
||||
present. */
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_HSOFI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_HSOFI);
|
||||
USB_INT_Clear(USB_INT_DDISCI);
|
||||
break;
|
||||
}
|
||||
|
||||
Delay_MS(1);
|
||||
}
|
||||
|
||||
if (HSOFIEnabled)
|
||||
USB_INT_Enable(USB_INT_HSOFI);
|
||||
|
||||
if (BusSuspended)
|
||||
USB_Host_SuspendBus();
|
||||
|
||||
USB_INT_Enable(USB_INT_DDISCI);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
|
||||
#define __INCLUDE_FROM_HOST_C
|
||||
#include "../Host.h"
|
||||
|
||||
void USB_Host_ProcessNextHostState(void)
|
||||
{
|
||||
uint8_t ErrorCode = HOST_ENUMERROR_NoError;
|
||||
uint8_t SubErrorCode = HOST_ENUMERROR_NoError;
|
||||
|
||||
static uint16_t WaitMSRemaining;
|
||||
static uint8_t PostWaitState;
|
||||
|
||||
switch (USB_HostState)
|
||||
{
|
||||
case HOST_STATE_WaitForDevice:
|
||||
if (WaitMSRemaining)
|
||||
{
|
||||
if ((SubErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)
|
||||
{
|
||||
USB_HostState = PostWaitState;
|
||||
ErrorCode = HOST_ENUMERROR_WaitStage;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(--WaitMSRemaining))
|
||||
USB_HostState = PostWaitState;
|
||||
}
|
||||
|
||||
break;
|
||||
case HOST_STATE_Powered:
|
||||
WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS;
|
||||
|
||||
USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle;
|
||||
break;
|
||||
case HOST_STATE_Powered_WaitForDeviceSettle:
|
||||
if (WaitMSRemaining--)
|
||||
{
|
||||
Delay_MS(1);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
USB_Host_VBUS_Manual_Off();
|
||||
|
||||
USB_OTGPAD_On();
|
||||
USB_Host_VBUS_Auto_Enable();
|
||||
USB_Host_VBUS_Auto_On();
|
||||
|
||||
USB_HostState = HOST_STATE_Powered_WaitForConnect;
|
||||
}
|
||||
|
||||
break;
|
||||
case HOST_STATE_Powered_WaitForConnect:
|
||||
if (USB_INT_HasOccurred(USB_INT_DCONNI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_DCONNI);
|
||||
USB_INT_Clear(USB_INT_DDISCI);
|
||||
|
||||
USB_INT_Clear(USB_INT_VBERRI);
|
||||
USB_INT_Enable(USB_INT_VBERRI);
|
||||
|
||||
USB_Host_ResumeBus();
|
||||
Pipe_ClearPipes();
|
||||
|
||||
HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset);
|
||||
}
|
||||
|
||||
break;
|
||||
case HOST_STATE_Powered_DoReset:
|
||||
USB_Host_ResetDevice();
|
||||
|
||||
HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered_ConfigPipe);
|
||||
break;
|
||||
case HOST_STATE_Powered_ConfigPipe:
|
||||
Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,
|
||||
PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,
|
||||
PIPE_CONTROLPIPE_DEFAULT_SIZE, PIPE_BANK_SINGLE);
|
||||
|
||||
if (!(Pipe_IsConfigured()))
|
||||
{
|
||||
ErrorCode = HOST_ENUMERROR_PipeConfigError;
|
||||
SubErrorCode = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
USB_HostState = HOST_STATE_Default;
|
||||
break;
|
||||
case HOST_STATE_Default:
|
||||
USB_ControlRequest = (USB_Request_Header_t)
|
||||
{
|
||||
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
|
||||
.bRequest = REQ_GetDescriptor,
|
||||
.wValue = (DTYPE_Device << 8),
|
||||
.wIndex = 0,
|
||||
.wLength = 8,
|
||||
};
|
||||
|
||||
uint8_t DataBuffer[8];
|
||||
|
||||
if ((SubErrorCode = USB_Host_SendControlRequest(DataBuffer)) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
ErrorCode = HOST_ENUMERROR_ControlError;
|
||||
break;
|
||||
}
|
||||
|
||||
USB_Host_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)];
|
||||
|
||||
USB_Host_ResetDevice();
|
||||
|
||||
HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Default_PostReset);
|
||||
break;
|
||||
case HOST_STATE_Default_PostReset:
|
||||
Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,
|
||||
PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,
|
||||
USB_Host_ControlPipeSize, PIPE_BANK_SINGLE);
|
||||
|
||||
if (!(Pipe_IsConfigured()))
|
||||
{
|
||||
ErrorCode = HOST_ENUMERROR_PipeConfigError;
|
||||
SubErrorCode = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
USB_ControlRequest = (USB_Request_Header_t)
|
||||
{
|
||||
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),
|
||||
.bRequest = REQ_SetAddress,
|
||||
.wValue = USB_HOST_DEVICEADDRESS,
|
||||
.wIndex = 0,
|
||||
.wLength = 0,
|
||||
};
|
||||
|
||||
if ((SubErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
ErrorCode = HOST_ENUMERROR_ControlError;
|
||||
break;
|
||||
}
|
||||
|
||||
HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Default_PostAddressSet);
|
||||
break;
|
||||
case HOST_STATE_Default_PostAddressSet:
|
||||
USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS);
|
||||
|
||||
USB_HostState = HOST_STATE_Addressed;
|
||||
|
||||
EVENT_USB_Host_DeviceEnumerationComplete();
|
||||
break;
|
||||
}
|
||||
|
||||
if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached))
|
||||
{
|
||||
EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode);
|
||||
|
||||
USB_Host_VBUS_Auto_Off();
|
||||
|
||||
EVENT_USB_Host_DeviceUnattached();
|
||||
|
||||
USB_ResetInterface();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t USB_Host_WaitMS(uint8_t MS)
|
||||
{
|
||||
bool BusSuspended = USB_Host_IsBusSuspended();
|
||||
uint8_t ErrorCode = HOST_WAITERROR_Successful;
|
||||
bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
|
||||
|
||||
USB_INT_Disable(USB_INT_HSOFI);
|
||||
USB_INT_Clear(USB_INT_HSOFI);
|
||||
|
||||
USB_Host_ResumeBus();
|
||||
|
||||
while (MS)
|
||||
{
|
||||
if (USB_INT_HasOccurred(USB_INT_HSOFI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_HSOFI);
|
||||
MS--;
|
||||
}
|
||||
|
||||
if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host))
|
||||
{
|
||||
ErrorCode = HOST_WAITERROR_DeviceDisconnect;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (Pipe_IsError() == true)
|
||||
{
|
||||
Pipe_ClearError();
|
||||
ErrorCode = HOST_WAITERROR_PipeError;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (Pipe_IsStalled() == true)
|
||||
{
|
||||
Pipe_ClearStall();
|
||||
ErrorCode = HOST_WAITERROR_SetupStalled;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (BusSuspended)
|
||||
USB_Host_SuspendBus();
|
||||
|
||||
if (HSOFIEnabled)
|
||||
USB_INT_Enable(USB_INT_HSOFI);
|
||||
|
||||
return ErrorCode;
|
||||
}
|
||||
|
||||
static void USB_Host_ResetDevice(void)
|
||||
{
|
||||
bool BusSuspended = USB_Host_IsBusSuspended();
|
||||
|
||||
USB_INT_Disable(USB_INT_DDISCI);
|
||||
|
||||
USB_Host_ResetBus();
|
||||
while (!(USB_Host_IsBusResetComplete()));
|
||||
USB_Host_ResumeBus();
|
||||
|
||||
USB_Host_ConfigurationNumber = 0;
|
||||
|
||||
bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
|
||||
|
||||
USB_INT_Disable(USB_INT_HSOFI);
|
||||
USB_INT_Clear(USB_INT_HSOFI);
|
||||
|
||||
for (uint8_t MSRem = 10; MSRem != 0; MSRem--)
|
||||
{
|
||||
/* Workaround for powerless-pull-up devices. After a USB bus reset,
|
||||
all disconnection interrupts are suppressed while a USB frame is
|
||||
looked for - if it is found within 10ms, the device is still
|
||||
present. */
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_HSOFI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_HSOFI);
|
||||
USB_INT_Clear(USB_INT_DDISCI);
|
||||
break;
|
||||
}
|
||||
|
||||
Delay_MS(1);
|
||||
}
|
||||
|
||||
if (HSOFIEnabled)
|
||||
USB_INT_Enable(USB_INT_HSOFI);
|
||||
|
||||
if (BusSuspended)
|
||||
USB_Host_SuspendBus();
|
||||
|
||||
USB_INT_Enable(USB_INT_DDISCI);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,372 +1,372 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Host definitions for the AVR32 UC3B microcontrollers.
|
||||
* \copydetails Group_Host_UC3B
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Host
|
||||
* \defgroup Group_Host_UC3B Host Management (UC3B)
|
||||
* \brief USB Host definitions for the AVR32 UC3B microcontrollers.
|
||||
*
|
||||
* Architecture specific USB Host definitions for the Atmel 32-bit AVR UC3B microcontrollers.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBHOST_UC3B_H__
|
||||
#define __USBHOST_UC3B_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../../Common/Common.h"
|
||||
#include "../StdDescriptors.h"
|
||||
#include "../Pipe.h"
|
||||
#include "../USBInterrupt.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Indicates the fixed USB device address which any attached device is enumerated to when in
|
||||
* host mode. As only one USB device may be attached to the AVR in host mode at any one time
|
||||
* and that the address used is not important (other than the fact that it is non-zero), a
|
||||
* fixed value is specified by the library.
|
||||
*/
|
||||
#define USB_HOST_DEVICEADDRESS 1
|
||||
|
||||
#if !defined(USB_HOST_TIMEOUT_MS) || defined(__DOXYGEN__)
|
||||
/** Constant for the maximum software timeout period of sent USB control transactions to an attached
|
||||
* device. If a device fails to respond to a sent control request within this period, the
|
||||
* library will return a timeout error code.
|
||||
*
|
||||
* This value may be overridden in the user project makefile as the value of the
|
||||
* \ref USB_HOST_TIMEOUT_MS token, and passed to the compiler using the -D switch.
|
||||
*/
|
||||
#define USB_HOST_TIMEOUT_MS 1000
|
||||
#endif
|
||||
|
||||
#if !defined(HOST_DEVICE_SETTLE_DELAY_MS) || defined(__DOXYGEN__)
|
||||
/** Constant for the delay in milliseconds after a device is connected before the library
|
||||
* will start the enumeration process. Some devices require a delay of up to 5 seconds
|
||||
* after connection before the enumeration process can start or incorrect operation will
|
||||
* occur.
|
||||
*
|
||||
* The default delay value may be overridden in the user project makefile by defining the
|
||||
* \c HOST_DEVICE_SETTLE_DELAY_MS token to the required delay in milliseconds, and passed to the
|
||||
* compiler using the -D switch.
|
||||
*/
|
||||
#define HOST_DEVICE_SETTLE_DELAY_MS 1000
|
||||
#endif
|
||||
|
||||
/* Enums: */
|
||||
/** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event.
|
||||
*
|
||||
* \see \ref Group_Events for more information on this event.
|
||||
*/
|
||||
enum USB_Host_ErrorCodes_t
|
||||
{
|
||||
HOST_ERROR_VBusVoltageDip = 0, /**< VBUS voltage dipped to an unacceptable level. This
|
||||
* error may be the result of an attached device drawing
|
||||
* too much current from the VBUS line, or due to the
|
||||
* AVR's power source being unable to supply sufficient
|
||||
* current.
|
||||
*/
|
||||
};
|
||||
|
||||
/** Enum for the error codes for the \ref EVENT_USB_Host_DeviceEnumerationFailed() event.
|
||||
*
|
||||
* \see \ref Group_Events for more information on this event.
|
||||
*/
|
||||
enum USB_Host_EnumerationErrorCodes_t
|
||||
{
|
||||
HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid
|
||||
* ErrorCode parameter value for the \ref EVENT_USB_Host_DeviceEnumerationFailed()
|
||||
* event.
|
||||
*/
|
||||
HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed
|
||||
* to complete successfully, due to a timeout or other
|
||||
* error.
|
||||
*/
|
||||
HOST_ENUMERROR_NoDeviceDetected = 2, /**< No device was detected, despite the USB data lines
|
||||
* indicating the attachment of a device.
|
||||
*/
|
||||
HOST_ENUMERROR_ControlError = 3, /**< One of the enumeration control requests failed to
|
||||
* complete successfully.
|
||||
*/
|
||||
HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to
|
||||
* configure correctly.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended)
|
||||
* the frame number is incremented by one.
|
||||
*/
|
||||
static inline uint16_t USB_Host_GetFrameNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline uint16_t USB_Host_GetFrameNumber(void)
|
||||
{
|
||||
return AVR32_USBB_UHFNUM;
|
||||
}
|
||||
|
||||
#if !defined(NO_SOF_EVENTS)
|
||||
/** Enables the host mode Start Of Frame events. When enabled, this causes the
|
||||
* \ref EVENT_USB_Host_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,
|
||||
* at the start of each USB frame when a device is enumerated while in host mode.
|
||||
*
|
||||
* \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
|
||||
*/
|
||||
static inline void USB_Host_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_EnableSOFEvents(void)
|
||||
{
|
||||
USB_INT_Enable(USB_INT_HSOFI);
|
||||
}
|
||||
|
||||
/** Disables the host mode Start Of Frame events. When disabled, this stops the firing of the
|
||||
* \ref EVENT_USB_Host_StartOfFrame() event when enumerated in host mode.
|
||||
*
|
||||
* \note Not available when the NO_SOF_EVENTS compile time token is defined.
|
||||
*/
|
||||
static inline void USB_Host_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_DisableSOFEvents(void)
|
||||
{
|
||||
USB_INT_Disable(USB_INT_HSOFI);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host.
|
||||
* USB bus resets leave the default control pipe configured (if already configured).
|
||||
*
|
||||
* If the USB bus has been suspended prior to issuing a bus reset, the attached device will be
|
||||
* woken up automatically and the bus resumed after the reset has been correctly issued.
|
||||
*/
|
||||
static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_ResetBus(void)
|
||||
{
|
||||
AVR32_USBB.UHCON.reset = true;
|
||||
}
|
||||
|
||||
/** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has
|
||||
* completed.
|
||||
*
|
||||
* \return Boolean \c true if no bus reset is currently being sent, \c false otherwise.
|
||||
*/
|
||||
static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline bool USB_Host_IsBusResetComplete(void)
|
||||
{
|
||||
return AVR32_USBB.UHCON.reset;
|
||||
}
|
||||
|
||||
/** Resumes USB communications with an attached and enumerated device, by resuming the transmission
|
||||
* of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the
|
||||
* host and attached device may occur.
|
||||
*/
|
||||
static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_ResumeBus(void)
|
||||
{
|
||||
AVR32_USBB.UHCON.sofe = true;
|
||||
}
|
||||
|
||||
/** Suspends the USB bus, preventing any communications from occurring between the host and attached
|
||||
* device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame
|
||||
* messages to the device.
|
||||
*
|
||||
* \note While the USB bus is suspended, all USB interrupt sources are also disabled; this means that
|
||||
* some events (such as device disconnections) will not fire until the bus is resumed.
|
||||
*/
|
||||
static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_SuspendBus(void)
|
||||
{
|
||||
AVR32_USBB.UHCON.sofe = false;
|
||||
}
|
||||
|
||||
/** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro,
|
||||
* false otherwise. While suspended, no USB communications can occur until the bus is resumed,
|
||||
* except for the Remote Wakeup event from the device if supported.
|
||||
*
|
||||
* \return Boolean \c true if the bus is currently suspended, \c false otherwise.
|
||||
*/
|
||||
static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline bool USB_Host_IsBusSuspended(void)
|
||||
{
|
||||
return AVR32_USBB.UHCON.sofe;
|
||||
}
|
||||
|
||||
/** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or
|
||||
* false if the attached device is enumerated in Low Speed mode (1.5Mb/s).
|
||||
*
|
||||
* \return Boolean \c true if the attached device is enumerated in Full Speed mode, \c false otherwise.
|
||||
*/
|
||||
static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline bool USB_Host_IsDeviceFullSpeed(void)
|
||||
{
|
||||
return (AVR32_USBB.USBSTA.speed == AVR32_USBB_SPEED_FULL);
|
||||
}
|
||||
|
||||
/** Determines if the attached device is currently issuing a Remote Wakeup request, requesting
|
||||
* that the host resume the USB bus and wake up the device, false otherwise.
|
||||
*
|
||||
* \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise.
|
||||
*/
|
||||
static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline bool USB_Host_IsRemoteWakeupSent(void)
|
||||
{
|
||||
return AVR32_USBB.UHINT.rxrsmi;
|
||||
}
|
||||
|
||||
/** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */
|
||||
static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_ClearRemoteWakeupSent(void)
|
||||
{
|
||||
AVR32_USBB.UHINTCLR.rxrsmic = true;
|
||||
}
|
||||
|
||||
/** Accepts a Remote Wakeup request from an attached device. This must be issued in response to
|
||||
* a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to
|
||||
* be resumed.
|
||||
*/
|
||||
static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_ResumeFromWakeupRequest(void)
|
||||
{
|
||||
AVR32_USBB.UHCON.resume = true;
|
||||
}
|
||||
|
||||
/** Determines if a resume from Remote Wakeup request is currently being sent to an attached
|
||||
* device.
|
||||
*
|
||||
* \return Boolean \c true if no resume request is currently being sent, \c false otherwise.
|
||||
*/
|
||||
static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline bool USB_Host_IsResumeFromWakeupRequestSent(void)
|
||||
{
|
||||
return AVR32_USBB.UHCON.resume;
|
||||
}
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Macros: */
|
||||
static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_HostMode_On(void)
|
||||
{
|
||||
// Not required for UC3B
|
||||
}
|
||||
|
||||
static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_HostMode_Off(void)
|
||||
{
|
||||
// Not required for UC3B
|
||||
}
|
||||
|
||||
static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_VBUS_Auto_Enable(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.vbushwc = false;
|
||||
}
|
||||
|
||||
static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_VBUS_Manual_Enable(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.vbushwc = true;
|
||||
}
|
||||
|
||||
static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_VBUS_Auto_On(void)
|
||||
{
|
||||
AVR32_USBB.USBSTASET.vbusrqs = true;
|
||||
}
|
||||
|
||||
static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_VBUS_Manual_On(void)
|
||||
{
|
||||
AVR32_USBB.USBSTASET.vbusrqs = true;
|
||||
}
|
||||
|
||||
static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_VBUS_Auto_Off(void)
|
||||
{
|
||||
AVR32_USBB.USBSTACLR.vbusrqc = true;
|
||||
}
|
||||
|
||||
static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_VBUS_Manual_Off(void)
|
||||
{
|
||||
AVR32_USBB.USBSTACLR.vbusrqc = true;
|
||||
}
|
||||
|
||||
static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_SetDeviceAddress(const uint8_t Address)
|
||||
{
|
||||
AVR32_USBB.UHADDR1.uhaddr_p0 = Address;
|
||||
AVR32_USBB.UHADDR1.uhaddr_p1 = Address;
|
||||
AVR32_USBB.UHADDR1.uhaddr_p2 = Address;
|
||||
AVR32_USBB.UHADDR1.uhaddr_p3 = Address;
|
||||
AVR32_USBB.UHADDR2.uhaddr_p4 = Address;
|
||||
AVR32_USBB.UHADDR2.uhaddr_p5 = Address;
|
||||
AVR32_USBB.UHADDR2.uhaddr_p6 = Address;
|
||||
}
|
||||
|
||||
/* Enums: */
|
||||
enum USB_Host_WaitMSErrorCodes_t
|
||||
{
|
||||
HOST_WAITERROR_Successful = 0,
|
||||
HOST_WAITERROR_DeviceDisconnect = 1,
|
||||
HOST_WAITERROR_PipeError = 2,
|
||||
HOST_WAITERROR_SetupStalled = 3,
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
void USB_Host_ProcessNextHostState(void);
|
||||
uint8_t USB_Host_WaitMS(uint8_t MS);
|
||||
|
||||
#if defined(__INCLUDE_FROM_HOST_C)
|
||||
static void USB_Host_ResetDevice(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Host definitions for the AVR32 UC3B microcontrollers.
|
||||
* \copydetails Group_Host_UC3B
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Host
|
||||
* \defgroup Group_Host_UC3B Host Management (UC3B)
|
||||
* \brief USB Host definitions for the AVR32 UC3B microcontrollers.
|
||||
*
|
||||
* Architecture specific USB Host definitions for the Atmel 32-bit AVR UC3B microcontrollers.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBHOST_UC3B_H__
|
||||
#define __USBHOST_UC3B_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../../Common/Common.h"
|
||||
#include "../StdDescriptors.h"
|
||||
#include "../Pipe.h"
|
||||
#include "../USBInterrupt.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Indicates the fixed USB device address which any attached device is enumerated to when in
|
||||
* host mode. As only one USB device may be attached to the AVR in host mode at any one time
|
||||
* and that the address used is not important (other than the fact that it is non-zero), a
|
||||
* fixed value is specified by the library.
|
||||
*/
|
||||
#define USB_HOST_DEVICEADDRESS 1
|
||||
|
||||
#if !defined(USB_HOST_TIMEOUT_MS) || defined(__DOXYGEN__)
|
||||
/** Constant for the maximum software timeout period of sent USB control transactions to an attached
|
||||
* device. If a device fails to respond to a sent control request within this period, the
|
||||
* library will return a timeout error code.
|
||||
*
|
||||
* This value may be overridden in the user project makefile as the value of the
|
||||
* \ref USB_HOST_TIMEOUT_MS token, and passed to the compiler using the -D switch.
|
||||
*/
|
||||
#define USB_HOST_TIMEOUT_MS 1000
|
||||
#endif
|
||||
|
||||
#if !defined(HOST_DEVICE_SETTLE_DELAY_MS) || defined(__DOXYGEN__)
|
||||
/** Constant for the delay in milliseconds after a device is connected before the library
|
||||
* will start the enumeration process. Some devices require a delay of up to 5 seconds
|
||||
* after connection before the enumeration process can start or incorrect operation will
|
||||
* occur.
|
||||
*
|
||||
* The default delay value may be overridden in the user project makefile by defining the
|
||||
* \c HOST_DEVICE_SETTLE_DELAY_MS token to the required delay in milliseconds, and passed to the
|
||||
* compiler using the -D switch.
|
||||
*/
|
||||
#define HOST_DEVICE_SETTLE_DELAY_MS 1000
|
||||
#endif
|
||||
|
||||
/* Enums: */
|
||||
/** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event.
|
||||
*
|
||||
* \see \ref Group_Events for more information on this event.
|
||||
*/
|
||||
enum USB_Host_ErrorCodes_t
|
||||
{
|
||||
HOST_ERROR_VBusVoltageDip = 0, /**< VBUS voltage dipped to an unacceptable level. This
|
||||
* error may be the result of an attached device drawing
|
||||
* too much current from the VBUS line, or due to the
|
||||
* AVR's power source being unable to supply sufficient
|
||||
* current.
|
||||
*/
|
||||
};
|
||||
|
||||
/** Enum for the error codes for the \ref EVENT_USB_Host_DeviceEnumerationFailed() event.
|
||||
*
|
||||
* \see \ref Group_Events for more information on this event.
|
||||
*/
|
||||
enum USB_Host_EnumerationErrorCodes_t
|
||||
{
|
||||
HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid
|
||||
* ErrorCode parameter value for the \ref EVENT_USB_Host_DeviceEnumerationFailed()
|
||||
* event.
|
||||
*/
|
||||
HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed
|
||||
* to complete successfully, due to a timeout or other
|
||||
* error.
|
||||
*/
|
||||
HOST_ENUMERROR_NoDeviceDetected = 2, /**< No device was detected, despite the USB data lines
|
||||
* indicating the attachment of a device.
|
||||
*/
|
||||
HOST_ENUMERROR_ControlError = 3, /**< One of the enumeration control requests failed to
|
||||
* complete successfully.
|
||||
*/
|
||||
HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to
|
||||
* configure correctly.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended)
|
||||
* the frame number is incremented by one.
|
||||
*/
|
||||
static inline uint16_t USB_Host_GetFrameNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline uint16_t USB_Host_GetFrameNumber(void)
|
||||
{
|
||||
return AVR32_USBB_UHFNUM;
|
||||
}
|
||||
|
||||
#if !defined(NO_SOF_EVENTS)
|
||||
/** Enables the host mode Start Of Frame events. When enabled, this causes the
|
||||
* \ref EVENT_USB_Host_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,
|
||||
* at the start of each USB frame when a device is enumerated while in host mode.
|
||||
*
|
||||
* \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
|
||||
*/
|
||||
static inline void USB_Host_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_EnableSOFEvents(void)
|
||||
{
|
||||
USB_INT_Enable(USB_INT_HSOFI);
|
||||
}
|
||||
|
||||
/** Disables the host mode Start Of Frame events. When disabled, this stops the firing of the
|
||||
* \ref EVENT_USB_Host_StartOfFrame() event when enumerated in host mode.
|
||||
*
|
||||
* \note Not available when the NO_SOF_EVENTS compile time token is defined.
|
||||
*/
|
||||
static inline void USB_Host_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_DisableSOFEvents(void)
|
||||
{
|
||||
USB_INT_Disable(USB_INT_HSOFI);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host.
|
||||
* USB bus resets leave the default control pipe configured (if already configured).
|
||||
*
|
||||
* If the USB bus has been suspended prior to issuing a bus reset, the attached device will be
|
||||
* woken up automatically and the bus resumed after the reset has been correctly issued.
|
||||
*/
|
||||
static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_ResetBus(void)
|
||||
{
|
||||
AVR32_USBB.UHCON.reset = true;
|
||||
}
|
||||
|
||||
/** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has
|
||||
* completed.
|
||||
*
|
||||
* \return Boolean \c true if no bus reset is currently being sent, \c false otherwise.
|
||||
*/
|
||||
static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline bool USB_Host_IsBusResetComplete(void)
|
||||
{
|
||||
return AVR32_USBB.UHCON.reset;
|
||||
}
|
||||
|
||||
/** Resumes USB communications with an attached and enumerated device, by resuming the transmission
|
||||
* of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the
|
||||
* host and attached device may occur.
|
||||
*/
|
||||
static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_ResumeBus(void)
|
||||
{
|
||||
AVR32_USBB.UHCON.sofe = true;
|
||||
}
|
||||
|
||||
/** Suspends the USB bus, preventing any communications from occurring between the host and attached
|
||||
* device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame
|
||||
* messages to the device.
|
||||
*
|
||||
* \note While the USB bus is suspended, all USB interrupt sources are also disabled; this means that
|
||||
* some events (such as device disconnections) will not fire until the bus is resumed.
|
||||
*/
|
||||
static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_SuspendBus(void)
|
||||
{
|
||||
AVR32_USBB.UHCON.sofe = false;
|
||||
}
|
||||
|
||||
/** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro,
|
||||
* false otherwise. While suspended, no USB communications can occur until the bus is resumed,
|
||||
* except for the Remote Wakeup event from the device if supported.
|
||||
*
|
||||
* \return Boolean \c true if the bus is currently suspended, \c false otherwise.
|
||||
*/
|
||||
static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline bool USB_Host_IsBusSuspended(void)
|
||||
{
|
||||
return AVR32_USBB.UHCON.sofe;
|
||||
}
|
||||
|
||||
/** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or
|
||||
* false if the attached device is enumerated in Low Speed mode (1.5Mb/s).
|
||||
*
|
||||
* \return Boolean \c true if the attached device is enumerated in Full Speed mode, \c false otherwise.
|
||||
*/
|
||||
static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline bool USB_Host_IsDeviceFullSpeed(void)
|
||||
{
|
||||
return (AVR32_USBB.USBSTA.speed == AVR32_USBB_SPEED_FULL);
|
||||
}
|
||||
|
||||
/** Determines if the attached device is currently issuing a Remote Wakeup request, requesting
|
||||
* that the host resume the USB bus and wake up the device, false otherwise.
|
||||
*
|
||||
* \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise.
|
||||
*/
|
||||
static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline bool USB_Host_IsRemoteWakeupSent(void)
|
||||
{
|
||||
return AVR32_USBB.UHINT.rxrsmi;
|
||||
}
|
||||
|
||||
/** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */
|
||||
static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_ClearRemoteWakeupSent(void)
|
||||
{
|
||||
AVR32_USBB.UHINTCLR.rxrsmic = true;
|
||||
}
|
||||
|
||||
/** Accepts a Remote Wakeup request from an attached device. This must be issued in response to
|
||||
* a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to
|
||||
* be resumed.
|
||||
*/
|
||||
static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_ResumeFromWakeupRequest(void)
|
||||
{
|
||||
AVR32_USBB.UHCON.resume = true;
|
||||
}
|
||||
|
||||
/** Determines if a resume from Remote Wakeup request is currently being sent to an attached
|
||||
* device.
|
||||
*
|
||||
* \return Boolean \c true if no resume request is currently being sent, \c false otherwise.
|
||||
*/
|
||||
static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline bool USB_Host_IsResumeFromWakeupRequestSent(void)
|
||||
{
|
||||
return AVR32_USBB.UHCON.resume;
|
||||
}
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Macros: */
|
||||
static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_HostMode_On(void)
|
||||
{
|
||||
// Not required for UC3B
|
||||
}
|
||||
|
||||
static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_HostMode_Off(void)
|
||||
{
|
||||
// Not required for UC3B
|
||||
}
|
||||
|
||||
static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_VBUS_Auto_Enable(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.vbushwc = false;
|
||||
}
|
||||
|
||||
static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_VBUS_Manual_Enable(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.vbushwc = true;
|
||||
}
|
||||
|
||||
static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_VBUS_Auto_On(void)
|
||||
{
|
||||
AVR32_USBB.USBSTASET.vbusrqs = true;
|
||||
}
|
||||
|
||||
static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_VBUS_Manual_On(void)
|
||||
{
|
||||
AVR32_USBB.USBSTASET.vbusrqs = true;
|
||||
}
|
||||
|
||||
static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_VBUS_Auto_Off(void)
|
||||
{
|
||||
AVR32_USBB.USBSTACLR.vbusrqc = true;
|
||||
}
|
||||
|
||||
static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_VBUS_Manual_Off(void)
|
||||
{
|
||||
AVR32_USBB.USBSTACLR.vbusrqc = true;
|
||||
}
|
||||
|
||||
static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Host_SetDeviceAddress(const uint8_t Address)
|
||||
{
|
||||
AVR32_USBB.UHADDR1.uhaddr_p0 = Address;
|
||||
AVR32_USBB.UHADDR1.uhaddr_p1 = Address;
|
||||
AVR32_USBB.UHADDR1.uhaddr_p2 = Address;
|
||||
AVR32_USBB.UHADDR1.uhaddr_p3 = Address;
|
||||
AVR32_USBB.UHADDR2.uhaddr_p4 = Address;
|
||||
AVR32_USBB.UHADDR2.uhaddr_p5 = Address;
|
||||
AVR32_USBB.UHADDR2.uhaddr_p6 = Address;
|
||||
}
|
||||
|
||||
/* Enums: */
|
||||
enum USB_Host_WaitMSErrorCodes_t
|
||||
{
|
||||
HOST_WAITERROR_Successful = 0,
|
||||
HOST_WAITERROR_DeviceDisconnect = 1,
|
||||
HOST_WAITERROR_PipeError = 2,
|
||||
HOST_WAITERROR_SetupStalled = 3,
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
void USB_Host_ProcessNextHostState(void);
|
||||
uint8_t USB_Host_WaitMS(uint8_t MS);
|
||||
|
||||
#if defined(__INCLUDE_FROM_HOST_C)
|
||||
static void USB_Host_ResetDevice(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,138 +1,138 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
|
||||
#include "../Pipe.h"
|
||||
|
||||
uint8_t USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;
|
||||
|
||||
volatile uint32_t USB_SelectedPipe = PIPE_CONTROLPIPE;
|
||||
volatile uint8_t* USB_PipeFIFOPos[PIPE_TOTAL_PIPES];
|
||||
|
||||
bool Pipe_ConfigurePipe(const uint8_t Number,
|
||||
const uint8_t Type,
|
||||
const uint8_t Token,
|
||||
const uint8_t EndpointNumber,
|
||||
const uint16_t Size,
|
||||
const uint8_t Banks)
|
||||
{
|
||||
Pipe_SelectPipe(Number);
|
||||
Pipe_EnablePipe();
|
||||
|
||||
(&AVR32_USBB.upcfg0)[Number] = 0;
|
||||
(&AVR32_USBB.upcfg0)[Number] = (AVR32_USBB_ALLOC_MASK |
|
||||
((uint32_t)Type << AVR32_USBB_PTYPE_OFFSET) |
|
||||
((uint32_t)Token << AVR32_USBB_PTOKEN_OFFSET) |
|
||||
((uint32_t)Banks << AVR32_USBB_PBK_OFFSET) |
|
||||
((EndpointNumber & PIPE_EPNUM_MASK) << AVR32_USBB_PEPNUM_OFFSET));
|
||||
USB_PipeFIFOPos[Number] = &AVR32_USBB_SLAVE[Number * 0x10000];
|
||||
|
||||
Pipe_SetInfiniteINRequests();
|
||||
|
||||
return Pipe_IsConfigured();
|
||||
}
|
||||
|
||||
void Pipe_ClearPipes(void)
|
||||
{
|
||||
for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
|
||||
{
|
||||
Pipe_SelectPipe(PNum);
|
||||
(&AVR32_USBB.upcfg0)[PNum] = 0;
|
||||
(&AVR32_USBB.upcon0clr)[PNum] = -1;
|
||||
USB_PipeFIFOPos[PNum] = &AVR32_USBB_SLAVE[PNum * 0x10000];
|
||||
Pipe_DisablePipe();
|
||||
}
|
||||
}
|
||||
|
||||
bool Pipe_IsEndpointBound(const uint8_t EndpointAddress)
|
||||
{
|
||||
uint8_t PrevPipeNumber = Pipe_GetCurrentPipe();
|
||||
|
||||
for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
|
||||
{
|
||||
Pipe_SelectPipe(PNum);
|
||||
|
||||
if (!(Pipe_IsConfigured()))
|
||||
continue;
|
||||
|
||||
if (Pipe_GetBoundEndpointAddress() == EndpointAddress)
|
||||
return true;
|
||||
}
|
||||
|
||||
Pipe_SelectPipe(PrevPipeNumber);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t Pipe_WaitUntilReady(void)
|
||||
{
|
||||
#if (USB_STREAM_TIMEOUT_MS < 0xFF)
|
||||
uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
|
||||
#else
|
||||
uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
|
||||
#endif
|
||||
|
||||
uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)
|
||||
{
|
||||
if (Pipe_IsINReceived())
|
||||
return PIPE_READYWAIT_NoError;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Pipe_IsOUTReady())
|
||||
return PIPE_READYWAIT_NoError;
|
||||
}
|
||||
|
||||
if (Pipe_IsStalled())
|
||||
return PIPE_READYWAIT_PipeStalled;
|
||||
else if (USB_HostState == HOST_STATE_Unattached)
|
||||
return PIPE_READYWAIT_DeviceDisconnected;
|
||||
|
||||
uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
|
||||
|
||||
if (CurrentFrameNumber != PreviousFrameNumber)
|
||||
{
|
||||
PreviousFrameNumber = CurrentFrameNumber;
|
||||
|
||||
if (!(TimeoutMSRem--))
|
||||
return PIPE_READYWAIT_Timeout;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
|
||||
#include "../Pipe.h"
|
||||
|
||||
uint8_t USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;
|
||||
|
||||
volatile uint32_t USB_SelectedPipe = PIPE_CONTROLPIPE;
|
||||
volatile uint8_t* USB_PipeFIFOPos[PIPE_TOTAL_PIPES];
|
||||
|
||||
bool Pipe_ConfigurePipe(const uint8_t Number,
|
||||
const uint8_t Type,
|
||||
const uint8_t Token,
|
||||
const uint8_t EndpointNumber,
|
||||
const uint16_t Size,
|
||||
const uint8_t Banks)
|
||||
{
|
||||
Pipe_SelectPipe(Number);
|
||||
Pipe_EnablePipe();
|
||||
|
||||
(&AVR32_USBB.upcfg0)[Number] = 0;
|
||||
(&AVR32_USBB.upcfg0)[Number] = (AVR32_USBB_ALLOC_MASK |
|
||||
((uint32_t)Type << AVR32_USBB_PTYPE_OFFSET) |
|
||||
((uint32_t)Token << AVR32_USBB_PTOKEN_OFFSET) |
|
||||
((uint32_t)Banks << AVR32_USBB_PBK_OFFSET) |
|
||||
((EndpointNumber & PIPE_EPNUM_MASK) << AVR32_USBB_PEPNUM_OFFSET));
|
||||
USB_PipeFIFOPos[Number] = &AVR32_USBB_SLAVE[Number * 0x10000];
|
||||
|
||||
Pipe_SetInfiniteINRequests();
|
||||
|
||||
return Pipe_IsConfigured();
|
||||
}
|
||||
|
||||
void Pipe_ClearPipes(void)
|
||||
{
|
||||
for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
|
||||
{
|
||||
Pipe_SelectPipe(PNum);
|
||||
(&AVR32_USBB.upcfg0)[PNum] = 0;
|
||||
(&AVR32_USBB.upcon0clr)[PNum] = -1;
|
||||
USB_PipeFIFOPos[PNum] = &AVR32_USBB_SLAVE[PNum * 0x10000];
|
||||
Pipe_DisablePipe();
|
||||
}
|
||||
}
|
||||
|
||||
bool Pipe_IsEndpointBound(const uint8_t EndpointAddress)
|
||||
{
|
||||
uint8_t PrevPipeNumber = Pipe_GetCurrentPipe();
|
||||
|
||||
for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
|
||||
{
|
||||
Pipe_SelectPipe(PNum);
|
||||
|
||||
if (!(Pipe_IsConfigured()))
|
||||
continue;
|
||||
|
||||
if (Pipe_GetBoundEndpointAddress() == EndpointAddress)
|
||||
return true;
|
||||
}
|
||||
|
||||
Pipe_SelectPipe(PrevPipeNumber);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t Pipe_WaitUntilReady(void)
|
||||
{
|
||||
#if (USB_STREAM_TIMEOUT_MS < 0xFF)
|
||||
uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
|
||||
#else
|
||||
uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
|
||||
#endif
|
||||
|
||||
uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)
|
||||
{
|
||||
if (Pipe_IsINReceived())
|
||||
return PIPE_READYWAIT_NoError;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Pipe_IsOUTReady())
|
||||
return PIPE_READYWAIT_NoError;
|
||||
}
|
||||
|
||||
if (Pipe_IsStalled())
|
||||
return PIPE_READYWAIT_PipeStalled;
|
||||
else if (USB_HostState == HOST_STATE_Unattached)
|
||||
return PIPE_READYWAIT_DeviceDisconnected;
|
||||
|
||||
uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
|
||||
|
||||
if (CurrentFrameNumber != PreviousFrameNumber)
|
||||
{
|
||||
PreviousFrameNumber = CurrentFrameNumber;
|
||||
|
||||
if (!(TimeoutMSRem--))
|
||||
return PIPE_READYWAIT_Timeout;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,215 +1,215 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#define __INCLUDE_FROM_USB_CONTROLLER_C
|
||||
#include "../USBController.h"
|
||||
|
||||
#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY))
|
||||
volatile uint8_t USB_CurrentMode = USB_MODE_None;
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS)
|
||||
volatile uint8_t USB_Options;
|
||||
#endif
|
||||
|
||||
void USB_Init(
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
const uint8_t Mode
|
||||
#endif
|
||||
|
||||
#if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS))
|
||||
,
|
||||
#elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))
|
||||
void
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS)
|
||||
const uint8_t Options
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#if !defined(USE_STATIC_OPTIONS)
|
||||
USB_Options = Options;
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
if (Mode == USB_MODE_UID)
|
||||
{
|
||||
AVR32_USBB.USBCON.uide = true;
|
||||
USB_INT_Enable(USB_INT_IDTI);
|
||||
USB_CurrentMode = USB_GetUSBModeFromUID();
|
||||
}
|
||||
else
|
||||
{
|
||||
AVR32_USBB.USBCON.uide = false;
|
||||
USB_CurrentMode = Mode;
|
||||
}
|
||||
#else
|
||||
AVR32_USBB.USBCON.uide = false;
|
||||
#endif
|
||||
|
||||
USB_IsInitialized = true;
|
||||
|
||||
USB_ResetInterface();
|
||||
}
|
||||
|
||||
void USB_Disable(void)
|
||||
{
|
||||
USB_INT_DisableAllInterrupts();
|
||||
USB_INT_ClearAllInterrupts();
|
||||
|
||||
USB_Detach();
|
||||
USB_Controller_Disable();
|
||||
|
||||
USB_OTGPAD_Off();
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
USB_CurrentMode = USB_MODE_None;
|
||||
#endif
|
||||
|
||||
AVR32_PM.GCCTRL[3].cen = false;
|
||||
|
||||
USB_IsInitialized = false;
|
||||
}
|
||||
|
||||
void USB_ResetInterface(void)
|
||||
{
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
bool UIDModeSelectEnabled = AVR32_USBB.USBCON.uide;
|
||||
#endif
|
||||
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].pllsel = !(USB_Options & USB_OPT_GCLK_SRC_OSC);
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].oscsel = !(USB_Options & USB_OPT_GCLK_CHANNEL_0);
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].diven = (F_USB != USB_CLOCK_REQUIRED_FREQ);
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].div = (F_USB == USB_CLOCK_REQUIRED_FREQ) ? 0 : (uint32_t)(((F_USB / USB_CLOCK_REQUIRED_FREQ) - 1) / 2);
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].cen = true;
|
||||
|
||||
USB_INT_DisableAllInterrupts();
|
||||
USB_INT_ClearAllInterrupts();
|
||||
|
||||
USB_Controller_Reset();
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
if (UIDModeSelectEnabled)
|
||||
USB_INT_Enable(USB_INT_IDTI);
|
||||
#endif
|
||||
|
||||
USB_CLK_Unfreeze();
|
||||
|
||||
if (USB_CurrentMode == USB_MODE_Device)
|
||||
{
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
AVR32_USBB.USBCON.uimod = true;
|
||||
|
||||
USB_Init_Device();
|
||||
#endif
|
||||
}
|
||||
else if (USB_CurrentMode == USB_MODE_Host)
|
||||
{
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
AVR32_USBB.USBCON.uimod = false;
|
||||
|
||||
USB_Init_Host();
|
||||
#endif
|
||||
}
|
||||
|
||||
USB_OTGPAD_On();
|
||||
}
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
static void USB_Init_Device(void)
|
||||
{
|
||||
USB_DeviceState = DEVICE_STATE_Unattached;
|
||||
USB_Device_ConfigurationNumber = 0;
|
||||
|
||||
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
|
||||
USB_Device_RemoteWakeupEnabled = false;
|
||||
#endif
|
||||
|
||||
#if !defined(NO_DEVICE_SELF_POWER)
|
||||
USB_Device_CurrentlySelfPowered = false;
|
||||
#endif
|
||||
|
||||
#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)
|
||||
USB_Descriptor_Device_t* DeviceDescriptorPtr;
|
||||
|
||||
if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR)
|
||||
USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
|
||||
#endif
|
||||
|
||||
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
|
||||
{
|
||||
USB_Device_SetLowSpeed();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(USB_DEVICE_OPT_HIGHSPEED)
|
||||
if (USB_Options & USB_DEVICE_OPT_HIGHSPEED)
|
||||
USB_Device_SetHighSpeed();
|
||||
else
|
||||
USB_Device_SetFullSpeed();
|
||||
#else
|
||||
USB_Device_SetFullSpeed();
|
||||
#endif
|
||||
}
|
||||
|
||||
USB_INT_Enable(USB_INT_VBUSTI);
|
||||
|
||||
Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
|
||||
ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize,
|
||||
ENDPOINT_BANK_SINGLE);
|
||||
|
||||
USB_INT_Clear(USB_INT_SUSPI);
|
||||
USB_INT_Enable(USB_INT_SUSPI);
|
||||
USB_INT_Enable(USB_INT_EORSTI);
|
||||
|
||||
USB_Attach();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
static void USB_Init_Host(void)
|
||||
{
|
||||
USB_HostState = HOST_STATE_Unattached;
|
||||
USB_Host_ConfigurationNumber = 0;
|
||||
USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;
|
||||
|
||||
USB_Host_HostMode_On();
|
||||
|
||||
USB_Host_VBUS_Auto_On();
|
||||
|
||||
USB_INT_Enable(USB_INT_DCONNI);
|
||||
USB_INT_Enable(USB_INT_BCERRI);
|
||||
|
||||
USB_Attach();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#define __INCLUDE_FROM_USB_CONTROLLER_C
|
||||
#include "../USBController.h"
|
||||
|
||||
#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY))
|
||||
volatile uint8_t USB_CurrentMode = USB_MODE_None;
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS)
|
||||
volatile uint8_t USB_Options;
|
||||
#endif
|
||||
|
||||
void USB_Init(
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
const uint8_t Mode
|
||||
#endif
|
||||
|
||||
#if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS))
|
||||
,
|
||||
#elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))
|
||||
void
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS)
|
||||
const uint8_t Options
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#if !defined(USE_STATIC_OPTIONS)
|
||||
USB_Options = Options;
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
if (Mode == USB_MODE_UID)
|
||||
{
|
||||
AVR32_USBB.USBCON.uide = true;
|
||||
USB_INT_Enable(USB_INT_IDTI);
|
||||
USB_CurrentMode = USB_GetUSBModeFromUID();
|
||||
}
|
||||
else
|
||||
{
|
||||
AVR32_USBB.USBCON.uide = false;
|
||||
USB_CurrentMode = Mode;
|
||||
}
|
||||
#else
|
||||
AVR32_USBB.USBCON.uide = false;
|
||||
#endif
|
||||
|
||||
USB_IsInitialized = true;
|
||||
|
||||
USB_ResetInterface();
|
||||
}
|
||||
|
||||
void USB_Disable(void)
|
||||
{
|
||||
USB_INT_DisableAllInterrupts();
|
||||
USB_INT_ClearAllInterrupts();
|
||||
|
||||
USB_Detach();
|
||||
USB_Controller_Disable();
|
||||
|
||||
USB_OTGPAD_Off();
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
USB_CurrentMode = USB_MODE_None;
|
||||
#endif
|
||||
|
||||
AVR32_PM.GCCTRL[3].cen = false;
|
||||
|
||||
USB_IsInitialized = false;
|
||||
}
|
||||
|
||||
void USB_ResetInterface(void)
|
||||
{
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
bool UIDModeSelectEnabled = AVR32_USBB.USBCON.uide;
|
||||
#endif
|
||||
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].pllsel = !(USB_Options & USB_OPT_GCLK_SRC_OSC);
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].oscsel = !(USB_Options & USB_OPT_GCLK_CHANNEL_0);
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].diven = (F_USB != USB_CLOCK_REQUIRED_FREQ);
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].div = (F_USB == USB_CLOCK_REQUIRED_FREQ) ? 0 : (uint32_t)(((F_USB / USB_CLOCK_REQUIRED_FREQ) - 1) / 2);
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].cen = true;
|
||||
|
||||
USB_INT_DisableAllInterrupts();
|
||||
USB_INT_ClearAllInterrupts();
|
||||
|
||||
USB_Controller_Reset();
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
if (UIDModeSelectEnabled)
|
||||
USB_INT_Enable(USB_INT_IDTI);
|
||||
#endif
|
||||
|
||||
USB_CLK_Unfreeze();
|
||||
|
||||
if (USB_CurrentMode == USB_MODE_Device)
|
||||
{
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
AVR32_USBB.USBCON.uimod = true;
|
||||
|
||||
USB_Init_Device();
|
||||
#endif
|
||||
}
|
||||
else if (USB_CurrentMode == USB_MODE_Host)
|
||||
{
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
AVR32_USBB.USBCON.uimod = false;
|
||||
|
||||
USB_Init_Host();
|
||||
#endif
|
||||
}
|
||||
|
||||
USB_OTGPAD_On();
|
||||
}
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
static void USB_Init_Device(void)
|
||||
{
|
||||
USB_DeviceState = DEVICE_STATE_Unattached;
|
||||
USB_Device_ConfigurationNumber = 0;
|
||||
|
||||
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
|
||||
USB_Device_RemoteWakeupEnabled = false;
|
||||
#endif
|
||||
|
||||
#if !defined(NO_DEVICE_SELF_POWER)
|
||||
USB_Device_CurrentlySelfPowered = false;
|
||||
#endif
|
||||
|
||||
#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)
|
||||
USB_Descriptor_Device_t* DeviceDescriptorPtr;
|
||||
|
||||
if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR)
|
||||
USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
|
||||
#endif
|
||||
|
||||
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
|
||||
{
|
||||
USB_Device_SetLowSpeed();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(USB_DEVICE_OPT_HIGHSPEED)
|
||||
if (USB_Options & USB_DEVICE_OPT_HIGHSPEED)
|
||||
USB_Device_SetHighSpeed();
|
||||
else
|
||||
USB_Device_SetFullSpeed();
|
||||
#else
|
||||
USB_Device_SetFullSpeed();
|
||||
#endif
|
||||
}
|
||||
|
||||
USB_INT_Enable(USB_INT_VBUSTI);
|
||||
|
||||
Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
|
||||
ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize,
|
||||
ENDPOINT_BANK_SINGLE);
|
||||
|
||||
USB_INT_Clear(USB_INT_SUSPI);
|
||||
USB_INT_Enable(USB_INT_SUSPI);
|
||||
USB_INT_Enable(USB_INT_EORSTI);
|
||||
|
||||
USB_Attach();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
static void USB_Init_Host(void)
|
||||
{
|
||||
USB_HostState = HOST_STATE_Unattached;
|
||||
USB_Host_ConfigurationNumber = 0;
|
||||
USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;
|
||||
|
||||
USB_Host_HostMode_On();
|
||||
|
||||
USB_Host_VBUS_Auto_On();
|
||||
|
||||
USB_INT_Enable(USB_INT_DCONNI);
|
||||
USB_INT_Enable(USB_INT_BCERRI);
|
||||
|
||||
USB_Attach();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,383 +1,383 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Controller definitions for the AVR32 UC3 microcontrollers.
|
||||
* \copydetails Group_USBManagement_UC3
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USBManagement
|
||||
* \defgroup Group_USBManagement_UC3 USB Interface Management (UC3)
|
||||
* \brief USB Controller definitions for the AVR32 UC3 microcontrollers.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to the setup and management of the USB interface.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBCONTROLLER_UC3_H__
|
||||
#define __USBCONTROLLER_UC3_H__
|
||||
|
||||
/* Includes: */
|
||||
#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 "../HostStandardReq.h"
|
||||
#include "../PipeStream.h"
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
|
||||
#include "../Device.h"
|
||||
#include "../Endpoint.h"
|
||||
#include "../DeviceStandardReq.h"
|
||||
#include "../EndpointStream.h"
|
||||
#endif
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks and Defines: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
#if !defined(F_USB)
|
||||
#error F_USB is not defined. You must define F_USB to the frequency of the clock input to the USB module.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** \name USB Controller Option Masks */
|
||||
//@{
|
||||
/** Selects one of the system's main clock oscillators as the input clock to the USB Generic Clock source
|
||||
* generation module. This indicates that an external oscillator should be used directly instead of an
|
||||
* internal PLL clock source.
|
||||
*/
|
||||
#define USB_OPT_GCLK_SRC_OSC (1 << 2)
|
||||
|
||||
/** Selects one of the system's PLL oscillators as the input clock to the USB Generic Clock source
|
||||
* generation module. This indicates that one of the device's PLL outputs should be used instead of an
|
||||
* external oscillator source.
|
||||
*/
|
||||
#define USB_OPT_GCLK_SRC_PLL (0 << 2)
|
||||
|
||||
/** Selects PLL or External Oscillator 0 as the USB Generic Clock source module input clock. */
|
||||
#define USB_OPT_GCLK_CHANNEL_0 (1 << 3)
|
||||
|
||||
/** Selects PLL or External Oscillator 1 as the USB Generic Clock source module input clock. */
|
||||
#define USB_OPT_GCLK_CHANNEL_1 (0 << 3)
|
||||
//@}
|
||||
|
||||
/** \name Endpoint/Pipe Type Masks */
|
||||
//@{
|
||||
/** Mask for a CONTROL type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_CONTROL 0x00
|
||||
|
||||
/** Mask for an ISOCHRONOUS type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_ISOCHRONOUS 0x01
|
||||
|
||||
/** Mask for a BULK type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_BULK 0x02
|
||||
|
||||
/** Mask for an INTERRUPT type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_INTERRUPT 0x03
|
||||
//@}
|
||||
|
||||
#if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)
|
||||
/** Constant for the maximum software timeout period of the USB data stream transfer functions
|
||||
* (both control and standard) when in either device or host mode. If the next packet of a stream
|
||||
* is not received or acknowledged within this time period, the stream function will fail.
|
||||
*
|
||||
* This value may be overridden in the user project makefile as the value of the
|
||||
* \ref USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch.
|
||||
*/
|
||||
#define USB_STREAM_TIMEOUT_MS 100
|
||||
#endif
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Determines if the VBUS line is currently high (i.e. the USB host is supplying power).
|
||||
*
|
||||
* \return Boolean \c true if the VBUS line is currently detecting power from a host, \c false otherwise.
|
||||
*/
|
||||
static inline bool USB_VBUS_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline bool USB_VBUS_GetStatus(void)
|
||||
{
|
||||
return AVR32_USBB.USBSTA.vbus;
|
||||
}
|
||||
|
||||
/** Detaches the device from the USB bus. This has the effect of removing the device from any
|
||||
* attached host, ceasing USB communications. If no host is present, this prevents any host from
|
||||
* enumerating the device once attached until \ref USB_Attach() is called.
|
||||
*/
|
||||
static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Detach(void)
|
||||
{
|
||||
AVR32_USBB.UDCON.detach = true;
|
||||
}
|
||||
|
||||
/** Attaches the device to the USB bus. This announces the device's presence to any attached
|
||||
* USB host, starting the enumeration process. If no host is present, attaching the device
|
||||
* will allow for enumeration once a host is connected to the device.
|
||||
*
|
||||
* This is inexplicably also required for proper operation while in host mode, to enable the
|
||||
* attachment of a device to the host. This is despite the bit being located in the device-mode
|
||||
* register and despite the datasheet making no mention of its requirement in host mode.
|
||||
*/
|
||||
static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Attach(void)
|
||||
{
|
||||
AVR32_USBB.UDCON.detach = false;
|
||||
}
|
||||
|
||||
/* Function Prototypes: */
|
||||
/** Main function to initialize and start the USB interface. Once active, the USB interface will
|
||||
* allow for device connection to a host when in device mode, or for device enumeration while in
|
||||
* host mode.
|
||||
*
|
||||
* As the USB library relies on interrupts for the device and host mode enumeration processes,
|
||||
* the user must enable global interrupts before or shortly after this function is called. In
|
||||
* device mode, interrupts must be enabled within 500ms of this function being called to ensure
|
||||
* that the host does not time out whilst enumerating the device. In host mode, interrupts may be
|
||||
* enabled at the application's leisure however enumeration will not begin of an attached device
|
||||
* until after this has occurred.
|
||||
*
|
||||
* Calling this function when the USB interface is already initialized will cause a complete USB
|
||||
* interface reset and re-enumeration.
|
||||
*
|
||||
* \param[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value
|
||||
* from the \ref USB_Modes_t enum.
|
||||
*
|
||||
* \param[in] Options Mask indicating the options which should be used when initializing the USB
|
||||
* interface to control the USB interface's behaviour. This should be comprised of
|
||||
* a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the
|
||||
* PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device
|
||||
* mode speed.
|
||||
*
|
||||
* \note To reduce the FLASH requirements of the library if only device or host mode is required,
|
||||
* the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY
|
||||
* (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler
|
||||
* via the -D switch. If the mode is statically set, this parameter does not exist in the
|
||||
* function prototype.
|
||||
* \n\n
|
||||
*
|
||||
* \note To reduce the FLASH requirements of the library if only fixed settings are are required,
|
||||
* the options may be set statically in the same manner as the mode (see the Mode parameter of
|
||||
* this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token,
|
||||
* defined to the appropriate options masks. When the options are statically set, this
|
||||
* parameter does not exist in the function prototype.
|
||||
*
|
||||
* \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks.
|
||||
*/
|
||||
void USB_Init(
|
||||
#if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)
|
||||
const uint8_t Mode
|
||||
#endif
|
||||
|
||||
#if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__)
|
||||
,
|
||||
#elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))
|
||||
void
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
|
||||
const uint8_t Options
|
||||
#endif
|
||||
);
|
||||
|
||||
/** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO
|
||||
* memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface
|
||||
* is restarted with the \ref USB_Init() function.
|
||||
*/
|
||||
void USB_Disable(void);
|
||||
|
||||
/** Resets the interface, when already initialized. This will re-enumerate the device if already connected
|
||||
* to a host, or re-enumerate an already attached device when in host mode.
|
||||
*/
|
||||
void USB_ResetInterface(void);
|
||||
|
||||
/* Global Variables: */
|
||||
#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__)
|
||||
/** Indicates the mode that the USB interface is currently initialized to, a value from the
|
||||
* \ref USB_Modes_t enum.
|
||||
*
|
||||
* \note This variable should be treated as read-only in the user application, and never manually
|
||||
* changed in value.
|
||||
* \n\n
|
||||
*
|
||||
* \note When the controller is initialized into UID auto-detection mode, this variable will hold the
|
||||
* currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller
|
||||
* is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time
|
||||
* options, or a limitation of the USB controller in the chosen device model) this will evaluate to
|
||||
* a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the
|
||||
* USB interface is not initialized.
|
||||
*/
|
||||
extern volatile uint8_t USB_CurrentMode;
|
||||
#elif defined(USB_HOST_ONLY)
|
||||
#define USB_CurrentMode USB_MODE_Host
|
||||
#elif defined(USB_DEVICE_ONLY)
|
||||
#define USB_CurrentMode USB_MODE_Device
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
|
||||
/** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init()
|
||||
* was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module.
|
||||
*
|
||||
* \note This variable should be treated as read-only in the user application, and never manually
|
||||
* changed in value.
|
||||
*/
|
||||
extern volatile uint8_t USB_Options;
|
||||
#elif defined(USE_STATIC_OPTIONS)
|
||||
#define USB_Options USE_STATIC_OPTIONS
|
||||
#endif
|
||||
|
||||
/* Enums: */
|
||||
/** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the
|
||||
* user application via \ref USB_CurrentMode.
|
||||
*/
|
||||
enum USB_Modes_t
|
||||
{
|
||||
USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */
|
||||
USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */
|
||||
USB_MODE_Host = 2, /**< Indicates that the controller is currently initialized in USB Host mode. */
|
||||
USB_MODE_UID = 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the
|
||||
* USB connector.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Macros: */
|
||||
#if defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32)
|
||||
#define USB_CLOCK_REQUIRED_FREQ 12000000UL
|
||||
#else
|
||||
#define USB_CLOCK_REQUIRED_FREQ 48000000UL
|
||||
#endif
|
||||
|
||||
/* Function Prototypes: */
|
||||
#if defined(__INCLUDE_FROM_USB_CONTROLLER_C)
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
static void USB_Init_Device(void);
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
static void USB_Init_Host(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Inline Functions: */
|
||||
static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_OTGPAD_On(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.otgpade = true;
|
||||
}
|
||||
|
||||
static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_OTGPAD_Off(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.otgpade = false;
|
||||
}
|
||||
|
||||
static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_CLK_Freeze(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.frzclk = true;
|
||||
}
|
||||
|
||||
static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_CLK_Unfreeze(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.frzclk = false;
|
||||
}
|
||||
|
||||
static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Controller_Enable(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.usbe = true;
|
||||
}
|
||||
|
||||
static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Controller_Disable(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.usbe = false;
|
||||
}
|
||||
|
||||
static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Controller_Reset(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.usbe = false;
|
||||
AVR32_USBB.USBCON.usbe = true;
|
||||
}
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline uint8_t USB_GetUSBModeFromUID(void)
|
||||
{
|
||||
if (AVR32_USBB.USBSTA.id)
|
||||
return USB_MODE_Device;
|
||||
else
|
||||
return USB_MODE_Host;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Controller definitions for the AVR32 UC3 microcontrollers.
|
||||
* \copydetails Group_USBManagement_UC3
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USBManagement
|
||||
* \defgroup Group_USBManagement_UC3 USB Interface Management (UC3)
|
||||
* \brief USB Controller definitions for the AVR32 UC3 microcontrollers.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to the setup and management of the USB interface.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBCONTROLLER_UC3_H__
|
||||
#define __USBCONTROLLER_UC3_H__
|
||||
|
||||
/* Includes: */
|
||||
#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 "../HostStandardReq.h"
|
||||
#include "../PipeStream.h"
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
|
||||
#include "../Device.h"
|
||||
#include "../Endpoint.h"
|
||||
#include "../DeviceStandardReq.h"
|
||||
#include "../EndpointStream.h"
|
||||
#endif
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks and Defines: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
#if !defined(F_USB)
|
||||
#error F_USB is not defined. You must define F_USB to the frequency of the clock input to the USB module.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** \name USB Controller Option Masks */
|
||||
//@{
|
||||
/** Selects one of the system's main clock oscillators as the input clock to the USB Generic Clock source
|
||||
* generation module. This indicates that an external oscillator should be used directly instead of an
|
||||
* internal PLL clock source.
|
||||
*/
|
||||
#define USB_OPT_GCLK_SRC_OSC (1 << 2)
|
||||
|
||||
/** Selects one of the system's PLL oscillators as the input clock to the USB Generic Clock source
|
||||
* generation module. This indicates that one of the device's PLL outputs should be used instead of an
|
||||
* external oscillator source.
|
||||
*/
|
||||
#define USB_OPT_GCLK_SRC_PLL (0 << 2)
|
||||
|
||||
/** Selects PLL or External Oscillator 0 as the USB Generic Clock source module input clock. */
|
||||
#define USB_OPT_GCLK_CHANNEL_0 (1 << 3)
|
||||
|
||||
/** Selects PLL or External Oscillator 1 as the USB Generic Clock source module input clock. */
|
||||
#define USB_OPT_GCLK_CHANNEL_1 (0 << 3)
|
||||
//@}
|
||||
|
||||
/** \name Endpoint/Pipe Type Masks */
|
||||
//@{
|
||||
/** Mask for a CONTROL type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_CONTROL 0x00
|
||||
|
||||
/** Mask for an ISOCHRONOUS type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_ISOCHRONOUS 0x01
|
||||
|
||||
/** Mask for a BULK type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_BULK 0x02
|
||||
|
||||
/** Mask for an INTERRUPT type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_INTERRUPT 0x03
|
||||
//@}
|
||||
|
||||
#if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)
|
||||
/** Constant for the maximum software timeout period of the USB data stream transfer functions
|
||||
* (both control and standard) when in either device or host mode. If the next packet of a stream
|
||||
* is not received or acknowledged within this time period, the stream function will fail.
|
||||
*
|
||||
* This value may be overridden in the user project makefile as the value of the
|
||||
* \ref USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch.
|
||||
*/
|
||||
#define USB_STREAM_TIMEOUT_MS 100
|
||||
#endif
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Determines if the VBUS line is currently high (i.e. the USB host is supplying power).
|
||||
*
|
||||
* \return Boolean \c true if the VBUS line is currently detecting power from a host, \c false otherwise.
|
||||
*/
|
||||
static inline bool USB_VBUS_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline bool USB_VBUS_GetStatus(void)
|
||||
{
|
||||
return AVR32_USBB.USBSTA.vbus;
|
||||
}
|
||||
|
||||
/** Detaches the device from the USB bus. This has the effect of removing the device from any
|
||||
* attached host, ceasing USB communications. If no host is present, this prevents any host from
|
||||
* enumerating the device once attached until \ref USB_Attach() is called.
|
||||
*/
|
||||
static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Detach(void)
|
||||
{
|
||||
AVR32_USBB.UDCON.detach = true;
|
||||
}
|
||||
|
||||
/** Attaches the device to the USB bus. This announces the device's presence to any attached
|
||||
* USB host, starting the enumeration process. If no host is present, attaching the device
|
||||
* will allow for enumeration once a host is connected to the device.
|
||||
*
|
||||
* This is inexplicably also required for proper operation while in host mode, to enable the
|
||||
* attachment of a device to the host. This is despite the bit being located in the device-mode
|
||||
* register and despite the datasheet making no mention of its requirement in host mode.
|
||||
*/
|
||||
static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Attach(void)
|
||||
{
|
||||
AVR32_USBB.UDCON.detach = false;
|
||||
}
|
||||
|
||||
/* Function Prototypes: */
|
||||
/** Main function to initialize and start the USB interface. Once active, the USB interface will
|
||||
* allow for device connection to a host when in device mode, or for device enumeration while in
|
||||
* host mode.
|
||||
*
|
||||
* As the USB library relies on interrupts for the device and host mode enumeration processes,
|
||||
* the user must enable global interrupts before or shortly after this function is called. In
|
||||
* device mode, interrupts must be enabled within 500ms of this function being called to ensure
|
||||
* that the host does not time out whilst enumerating the device. In host mode, interrupts may be
|
||||
* enabled at the application's leisure however enumeration will not begin of an attached device
|
||||
* until after this has occurred.
|
||||
*
|
||||
* Calling this function when the USB interface is already initialized will cause a complete USB
|
||||
* interface reset and re-enumeration.
|
||||
*
|
||||
* \param[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value
|
||||
* from the \ref USB_Modes_t enum.
|
||||
*
|
||||
* \param[in] Options Mask indicating the options which should be used when initializing the USB
|
||||
* interface to control the USB interface's behaviour. This should be comprised of
|
||||
* a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the
|
||||
* PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device
|
||||
* mode speed.
|
||||
*
|
||||
* \note To reduce the FLASH requirements of the library if only device or host mode is required,
|
||||
* the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY
|
||||
* (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler
|
||||
* via the -D switch. If the mode is statically set, this parameter does not exist in the
|
||||
* function prototype.
|
||||
* \n\n
|
||||
*
|
||||
* \note To reduce the FLASH requirements of the library if only fixed settings are are required,
|
||||
* the options may be set statically in the same manner as the mode (see the Mode parameter of
|
||||
* this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token,
|
||||
* defined to the appropriate options masks. When the options are statically set, this
|
||||
* parameter does not exist in the function prototype.
|
||||
*
|
||||
* \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks.
|
||||
*/
|
||||
void USB_Init(
|
||||
#if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)
|
||||
const uint8_t Mode
|
||||
#endif
|
||||
|
||||
#if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__)
|
||||
,
|
||||
#elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))
|
||||
void
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
|
||||
const uint8_t Options
|
||||
#endif
|
||||
);
|
||||
|
||||
/** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO
|
||||
* memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface
|
||||
* is restarted with the \ref USB_Init() function.
|
||||
*/
|
||||
void USB_Disable(void);
|
||||
|
||||
/** Resets the interface, when already initialized. This will re-enumerate the device if already connected
|
||||
* to a host, or re-enumerate an already attached device when in host mode.
|
||||
*/
|
||||
void USB_ResetInterface(void);
|
||||
|
||||
/* Global Variables: */
|
||||
#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__)
|
||||
/** Indicates the mode that the USB interface is currently initialized to, a value from the
|
||||
* \ref USB_Modes_t enum.
|
||||
*
|
||||
* \note This variable should be treated as read-only in the user application, and never manually
|
||||
* changed in value.
|
||||
* \n\n
|
||||
*
|
||||
* \note When the controller is initialized into UID auto-detection mode, this variable will hold the
|
||||
* currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller
|
||||
* is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time
|
||||
* options, or a limitation of the USB controller in the chosen device model) this will evaluate to
|
||||
* a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the
|
||||
* USB interface is not initialized.
|
||||
*/
|
||||
extern volatile uint8_t USB_CurrentMode;
|
||||
#elif defined(USB_HOST_ONLY)
|
||||
#define USB_CurrentMode USB_MODE_Host
|
||||
#elif defined(USB_DEVICE_ONLY)
|
||||
#define USB_CurrentMode USB_MODE_Device
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
|
||||
/** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init()
|
||||
* was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module.
|
||||
*
|
||||
* \note This variable should be treated as read-only in the user application, and never manually
|
||||
* changed in value.
|
||||
*/
|
||||
extern volatile uint8_t USB_Options;
|
||||
#elif defined(USE_STATIC_OPTIONS)
|
||||
#define USB_Options USE_STATIC_OPTIONS
|
||||
#endif
|
||||
|
||||
/* Enums: */
|
||||
/** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the
|
||||
* user application via \ref USB_CurrentMode.
|
||||
*/
|
||||
enum USB_Modes_t
|
||||
{
|
||||
USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */
|
||||
USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */
|
||||
USB_MODE_Host = 2, /**< Indicates that the controller is currently initialized in USB Host mode. */
|
||||
USB_MODE_UID = 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the
|
||||
* USB connector.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Macros: */
|
||||
#if defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32)
|
||||
#define USB_CLOCK_REQUIRED_FREQ 12000000UL
|
||||
#else
|
||||
#define USB_CLOCK_REQUIRED_FREQ 48000000UL
|
||||
#endif
|
||||
|
||||
/* Function Prototypes: */
|
||||
#if defined(__INCLUDE_FROM_USB_CONTROLLER_C)
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
static void USB_Init_Device(void);
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
static void USB_Init_Host(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Inline Functions: */
|
||||
static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_OTGPAD_On(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.otgpade = true;
|
||||
}
|
||||
|
||||
static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_OTGPAD_Off(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.otgpade = false;
|
||||
}
|
||||
|
||||
static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_CLK_Freeze(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.frzclk = true;
|
||||
}
|
||||
|
||||
static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_CLK_Unfreeze(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.frzclk = false;
|
||||
}
|
||||
|
||||
static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Controller_Enable(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.usbe = true;
|
||||
}
|
||||
|
||||
static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Controller_Disable(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.usbe = false;
|
||||
}
|
||||
|
||||
static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Controller_Reset(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.usbe = false;
|
||||
AVR32_USBB.USBCON.usbe = true;
|
||||
}
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline uint8_t USB_GetUSBModeFromUID(void)
|
||||
{
|
||||
if (AVR32_USBB.USBSTA.id)
|
||||
return USB_MODE_Device;
|
||||
else
|
||||
return USB_MODE_Host;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,202 +1,202 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBInterrupt.h"
|
||||
|
||||
void USB_INT_DisableAllInterrupts(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.vbuste = false;
|
||||
AVR32_USBB.USBCON.idte = false;
|
||||
|
||||
AVR32_USBB.uhinteclr = -1;
|
||||
AVR32_USBB.udinteclr = -1;
|
||||
}
|
||||
|
||||
void USB_INT_ClearAllInterrupts(void)
|
||||
{
|
||||
AVR32_USBB.USBSTACLR.vbustic = true;
|
||||
AVR32_USBB.USBSTACLR.idtic = true;
|
||||
|
||||
AVR32_USBB.uhintclr = -1;
|
||||
AVR32_USBB.udintclr = -1;
|
||||
}
|
||||
|
||||
ISR(USB_GEN_vect)
|
||||
{
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
#if !defined(NO_SOF_EVENTS)
|
||||
if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_SOFI);
|
||||
|
||||
EVENT_USB_Device_StartOfFrame();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_VBUSTI) && USB_INT_IsEnabled(USB_INT_VBUSTI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_VBUSTI);
|
||||
|
||||
if (USB_VBUS_GetStatus())
|
||||
{
|
||||
USB_DeviceState = DEVICE_STATE_Powered;
|
||||
EVENT_USB_Device_Connect();
|
||||
}
|
||||
else
|
||||
{
|
||||
USB_DeviceState = DEVICE_STATE_Unattached;
|
||||
EVENT_USB_Device_Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI))
|
||||
{
|
||||
USB_INT_Disable(USB_INT_SUSPI);
|
||||
USB_INT_Enable(USB_INT_WAKEUPI);
|
||||
|
||||
USB_CLK_Freeze();
|
||||
|
||||
USB_DeviceState = DEVICE_STATE_Suspended;
|
||||
EVENT_USB_Device_Suspend();
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI))
|
||||
{
|
||||
USB_CLK_Unfreeze();
|
||||
|
||||
USB_INT_Clear(USB_INT_WAKEUPI);
|
||||
|
||||
USB_INT_Disable(USB_INT_WAKEUPI);
|
||||
USB_INT_Enable(USB_INT_SUSPI);
|
||||
|
||||
if (USB_Device_ConfigurationNumber)
|
||||
USB_DeviceState = DEVICE_STATE_Configured;
|
||||
else
|
||||
USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;
|
||||
|
||||
EVENT_USB_Device_WakeUp();
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_EORSTI);
|
||||
|
||||
USB_DeviceState = DEVICE_STATE_Default;
|
||||
USB_Device_ConfigurationNumber = 0;
|
||||
|
||||
USB_INT_Clear(USB_INT_SUSPI);
|
||||
USB_INT_Disable(USB_INT_SUSPI);
|
||||
USB_INT_Enable(USB_INT_WAKEUPI);
|
||||
|
||||
USB_Device_SetDeviceAddress(0);
|
||||
Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
|
||||
ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize,
|
||||
ENDPOINT_BANK_SINGLE);
|
||||
|
||||
EVENT_USB_Device_Reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
#if !defined(NO_SOF_EVENTS)
|
||||
if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_HSOFI);
|
||||
|
||||
EVENT_USB_Host_StartOfFrame();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_DDISCI) && USB_INT_IsEnabled(USB_INT_DDISCI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_DDISCI);
|
||||
USB_INT_Clear(USB_INT_DCONNI);
|
||||
USB_INT_Disable(USB_INT_DDISCI);
|
||||
|
||||
EVENT_USB_Host_DeviceUnattached();
|
||||
|
||||
USB_ResetInterface();
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_VBERRI) && USB_INT_IsEnabled(USB_INT_VBERRI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_VBERRI);
|
||||
|
||||
USB_Host_VBUS_Manual_Off();
|
||||
USB_Host_VBUS_Auto_Off();
|
||||
|
||||
EVENT_USB_Host_HostError(HOST_ERROR_VBusVoltageDip);
|
||||
EVENT_USB_Host_DeviceUnattached();
|
||||
|
||||
USB_HostState = HOST_STATE_Unattached;
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_DCONNI) && USB_INT_IsEnabled(USB_INT_DCONNI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_DCONNI);
|
||||
USB_INT_Disable(USB_INT_DCONNI);
|
||||
|
||||
EVENT_USB_Host_DeviceAttached();
|
||||
|
||||
USB_INT_Enable(USB_INT_DDISCI);
|
||||
|
||||
USB_HostState = HOST_STATE_Powered;
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_BCERRI) && USB_INT_IsEnabled(USB_INT_BCERRI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_BCERRI);
|
||||
|
||||
EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0);
|
||||
EVENT_USB_Host_DeviceUnattached();
|
||||
|
||||
USB_ResetInterface();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
if (USB_INT_HasOccurred(USB_INT_IDTI) && USB_INT_IsEnabled(USB_INT_IDTI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_IDTI);
|
||||
|
||||
if (USB_DeviceState != DEVICE_STATE_Unattached)
|
||||
EVENT_USB_Device_Disconnect();
|
||||
|
||||
if (USB_HostState != HOST_STATE_Unattached)
|
||||
EVENT_USB_Host_DeviceUnattached();
|
||||
|
||||
USB_CurrentMode = USB_GetUSBModeFromUID();
|
||||
USB_ResetInterface();
|
||||
|
||||
EVENT_USB_UIDChange();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBInterrupt.h"
|
||||
|
||||
void USB_INT_DisableAllInterrupts(void)
|
||||
{
|
||||
AVR32_USBB.USBCON.vbuste = false;
|
||||
AVR32_USBB.USBCON.idte = false;
|
||||
|
||||
AVR32_USBB.uhinteclr = -1;
|
||||
AVR32_USBB.udinteclr = -1;
|
||||
}
|
||||
|
||||
void USB_INT_ClearAllInterrupts(void)
|
||||
{
|
||||
AVR32_USBB.USBSTACLR.vbustic = true;
|
||||
AVR32_USBB.USBSTACLR.idtic = true;
|
||||
|
||||
AVR32_USBB.uhintclr = -1;
|
||||
AVR32_USBB.udintclr = -1;
|
||||
}
|
||||
|
||||
ISR(USB_GEN_vect)
|
||||
{
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
#if !defined(NO_SOF_EVENTS)
|
||||
if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_SOFI);
|
||||
|
||||
EVENT_USB_Device_StartOfFrame();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_VBUSTI) && USB_INT_IsEnabled(USB_INT_VBUSTI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_VBUSTI);
|
||||
|
||||
if (USB_VBUS_GetStatus())
|
||||
{
|
||||
USB_DeviceState = DEVICE_STATE_Powered;
|
||||
EVENT_USB_Device_Connect();
|
||||
}
|
||||
else
|
||||
{
|
||||
USB_DeviceState = DEVICE_STATE_Unattached;
|
||||
EVENT_USB_Device_Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI))
|
||||
{
|
||||
USB_INT_Disable(USB_INT_SUSPI);
|
||||
USB_INT_Enable(USB_INT_WAKEUPI);
|
||||
|
||||
USB_CLK_Freeze();
|
||||
|
||||
USB_DeviceState = DEVICE_STATE_Suspended;
|
||||
EVENT_USB_Device_Suspend();
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI))
|
||||
{
|
||||
USB_CLK_Unfreeze();
|
||||
|
||||
USB_INT_Clear(USB_INT_WAKEUPI);
|
||||
|
||||
USB_INT_Disable(USB_INT_WAKEUPI);
|
||||
USB_INT_Enable(USB_INT_SUSPI);
|
||||
|
||||
if (USB_Device_ConfigurationNumber)
|
||||
USB_DeviceState = DEVICE_STATE_Configured;
|
||||
else
|
||||
USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;
|
||||
|
||||
EVENT_USB_Device_WakeUp();
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_EORSTI);
|
||||
|
||||
USB_DeviceState = DEVICE_STATE_Default;
|
||||
USB_Device_ConfigurationNumber = 0;
|
||||
|
||||
USB_INT_Clear(USB_INT_SUSPI);
|
||||
USB_INT_Disable(USB_INT_SUSPI);
|
||||
USB_INT_Enable(USB_INT_WAKEUPI);
|
||||
|
||||
USB_Device_SetDeviceAddress(0);
|
||||
Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
|
||||
ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize,
|
||||
ENDPOINT_BANK_SINGLE);
|
||||
|
||||
EVENT_USB_Device_Reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
#if !defined(NO_SOF_EVENTS)
|
||||
if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_HSOFI);
|
||||
|
||||
EVENT_USB_Host_StartOfFrame();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_DDISCI) && USB_INT_IsEnabled(USB_INT_DDISCI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_DDISCI);
|
||||
USB_INT_Clear(USB_INT_DCONNI);
|
||||
USB_INT_Disable(USB_INT_DDISCI);
|
||||
|
||||
EVENT_USB_Host_DeviceUnattached();
|
||||
|
||||
USB_ResetInterface();
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_VBERRI) && USB_INT_IsEnabled(USB_INT_VBERRI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_VBERRI);
|
||||
|
||||
USB_Host_VBUS_Manual_Off();
|
||||
USB_Host_VBUS_Auto_Off();
|
||||
|
||||
EVENT_USB_Host_HostError(HOST_ERROR_VBusVoltageDip);
|
||||
EVENT_USB_Host_DeviceUnattached();
|
||||
|
||||
USB_HostState = HOST_STATE_Unattached;
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_DCONNI) && USB_INT_IsEnabled(USB_INT_DCONNI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_DCONNI);
|
||||
USB_INT_Disable(USB_INT_DCONNI);
|
||||
|
||||
EVENT_USB_Host_DeviceAttached();
|
||||
|
||||
USB_INT_Enable(USB_INT_DDISCI);
|
||||
|
||||
USB_HostState = HOST_STATE_Powered;
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_BCERRI) && USB_INT_IsEnabled(USB_INT_BCERRI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_BCERRI);
|
||||
|
||||
EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0);
|
||||
EVENT_USB_Host_DeviceUnattached();
|
||||
|
||||
USB_ResetInterface();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
if (USB_INT_HasOccurred(USB_INT_IDTI) && USB_INT_IsEnabled(USB_INT_IDTI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_IDTI);
|
||||
|
||||
if (USB_DeviceState != DEVICE_STATE_Unattached)
|
||||
EVENT_USB_Device_Disconnect();
|
||||
|
||||
if (USB_HostState != HOST_STATE_Unattached)
|
||||
EVENT_USB_Host_DeviceUnattached();
|
||||
|
||||
USB_CurrentMode = USB_GetUSBModeFromUID();
|
||||
USB_ResetInterface();
|
||||
|
||||
EVENT_USB_UIDChange();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,353 +1,353 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Controller Interrupt definitions for the AVR32 UC3 microcontrollers.
|
||||
*
|
||||
* This file contains definitions required for the correct handling of low level USB service routine interrupts
|
||||
* from the USB controller.
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
#ifndef __USBINTERRUPT_UC3_H__
|
||||
#define __USBINTERRUPT_UC3_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../../Common/Common.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Enums: */
|
||||
enum USB_Interrupts_t
|
||||
{
|
||||
USB_INT_VBUSTI = 0,
|
||||
#if (defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__))
|
||||
USB_INT_IDTI = 1,
|
||||
#endif
|
||||
#if (defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__))
|
||||
USB_INT_WAKEUPI = 2,
|
||||
USB_INT_SUSPI = 3,
|
||||
USB_INT_EORSTI = 4,
|
||||
USB_INT_SOFI = 5,
|
||||
#endif
|
||||
#if (defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__))
|
||||
USB_INT_HSOFI = 6,
|
||||
USB_INT_DCONNI = 7,
|
||||
USB_INT_DDISCI = 8,
|
||||
USB_INT_RSTI = 9,
|
||||
USB_INT_BCERRI = 10,
|
||||
USB_INT_VBERRI = 11,
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Inline Functions: */
|
||||
static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_INT_Enable(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_VBUSTI:
|
||||
AVR32_USBB.USBCON.vbuste = true;
|
||||
break;
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
case USB_INT_IDTI:
|
||||
AVR32_USBB.USBCON.idte = true;
|
||||
break;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
case USB_INT_WAKEUPI:
|
||||
AVR32_USBB.UDINTESET.wakeupes = true;
|
||||
break;
|
||||
case USB_INT_SUSPI:
|
||||
AVR32_USBB.UDINTESET.suspes = true;
|
||||
break;
|
||||
case USB_INT_EORSTI:
|
||||
AVR32_USBB.UDINTESET.eorstes = true;
|
||||
break;
|
||||
case USB_INT_SOFI:
|
||||
AVR32_USBB.UDINTESET.sofes = true;
|
||||
break;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
case USB_INT_HSOFI:
|
||||
AVR32_USBB.UHINTESET.hsofies = true;
|
||||
break;
|
||||
case USB_INT_DCONNI:
|
||||
AVR32_USBB.UHINTESET.dconnies = true;
|
||||
break;
|
||||
case USB_INT_DDISCI:
|
||||
AVR32_USBB.UHINTESET.ddiscies = true;
|
||||
break;
|
||||
case USB_INT_RSTI:
|
||||
AVR32_USBB.UHINTESET.rsties = true;
|
||||
break;
|
||||
case USB_INT_BCERRI:
|
||||
AVR32_USBB.USBCON.bcerre = true;
|
||||
break;
|
||||
case USB_INT_VBERRI:
|
||||
AVR32_USBB.USBCON.vberre = true;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_INT_Disable(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_VBUSTI:
|
||||
AVR32_USBB.USBCON.vbuste = false;
|
||||
break;
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
case USB_INT_IDTI:
|
||||
AVR32_USBB.USBCON.idte = false;
|
||||
break;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
case USB_INT_WAKEUPI:
|
||||
AVR32_USBB.UDINTECLR.wakeupec = true;
|
||||
break;
|
||||
case USB_INT_SUSPI:
|
||||
AVR32_USBB.UDINTECLR.suspec = true;
|
||||
break;
|
||||
case USB_INT_EORSTI:
|
||||
AVR32_USBB.UDINTECLR.eorstec = true;
|
||||
break;
|
||||
case USB_INT_SOFI:
|
||||
AVR32_USBB.UDINTECLR.sofec = true;
|
||||
break;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
case USB_INT_HSOFI:
|
||||
AVR32_USBB.UHINTECLR.hsofiec = true;
|
||||
break;
|
||||
case USB_INT_DCONNI:
|
||||
AVR32_USBB.UHINTECLR.dconniec = true;
|
||||
break;
|
||||
case USB_INT_DDISCI:
|
||||
AVR32_USBB.UHINTECLR.ddisciec = true;
|
||||
break;
|
||||
case USB_INT_RSTI:
|
||||
AVR32_USBB.UHINTECLR.rstiec = true;
|
||||
break;
|
||||
case USB_INT_BCERRI:
|
||||
AVR32_USBB.USBCON.bcerre = false;
|
||||
break;
|
||||
case USB_INT_VBERRI:
|
||||
AVR32_USBB.USBCON.vberre = false;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_INT_Clear(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_VBUSTI:
|
||||
AVR32_USBB.USBSTACLR.vbustic = true;
|
||||
(void)AVR32_USBB.USBSTACLR;
|
||||
break;
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
case USB_INT_IDTI:
|
||||
AVR32_USBB.USBSTACLR.idtic = true;
|
||||
(void)AVR32_USBB.USBSTACLR;
|
||||
break;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
case USB_INT_WAKEUPI:
|
||||
AVR32_USBB.UDINTCLR.wakeupc = true;
|
||||
(void)AVR32_USBB.UDINTCLR;
|
||||
break;
|
||||
case USB_INT_SUSPI:
|
||||
AVR32_USBB.UDINTCLR.suspc = true;
|
||||
(void)AVR32_USBB.UDINTCLR;
|
||||
break;
|
||||
case USB_INT_EORSTI:
|
||||
AVR32_USBB.UDINTCLR.eorstc = true;
|
||||
(void)AVR32_USBB.UDINTCLR;
|
||||
break;
|
||||
case USB_INT_SOFI:
|
||||
AVR32_USBB.UDINTCLR.sofc = true;
|
||||
(void)AVR32_USBB.UDINTCLR;
|
||||
break;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
case USB_INT_HSOFI:
|
||||
AVR32_USBB.UHINTCLR.hsofic = true;
|
||||
(void)AVR32_USBB.UHINTCLR;
|
||||
break;
|
||||
case USB_INT_DCONNI:
|
||||
AVR32_USBB.UHINTCLR.dconnic = true;
|
||||
(void)AVR32_USBB.UHINTCLR;
|
||||
break;
|
||||
case USB_INT_DDISCI:
|
||||
AVR32_USBB.UHINTCLR.ddiscic = true;
|
||||
(void)AVR32_USBB.UHINTCLR;
|
||||
break;
|
||||
case USB_INT_RSTI:
|
||||
AVR32_USBB.UHINTCLR.rstic = true;
|
||||
(void)AVR32_USBB.UHINTCLR;
|
||||
break;
|
||||
case USB_INT_BCERRI:
|
||||
AVR32_USBB.USBSTACLR.bcerric = true;
|
||||
(void)AVR32_USBB.USBSTACLR;
|
||||
break;
|
||||
case USB_INT_VBERRI:
|
||||
AVR32_USBB.USBSTACLR.vberric = true;
|
||||
(void)AVR32_USBB.USBSTACLR;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool USB_INT_IsEnabled(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_VBUSTI:
|
||||
return AVR32_USBB.USBCON.vbuste;
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
case USB_INT_IDTI:
|
||||
return AVR32_USBB.USBCON.idte;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
case USB_INT_WAKEUPI:
|
||||
return AVR32_USBB.UDINTE.wakeupe;
|
||||
case USB_INT_SUSPI:
|
||||
return AVR32_USBB.UDINTE.suspe;
|
||||
case USB_INT_EORSTI:
|
||||
return AVR32_USBB.UDINTE.eorste;
|
||||
case USB_INT_SOFI:
|
||||
return AVR32_USBB.UDINTE.sofe;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
case USB_INT_HSOFI:
|
||||
return AVR32_USBB.UHINTE.hsofie;
|
||||
case USB_INT_DCONNI:
|
||||
return AVR32_USBB.UHINTE.dconnie;
|
||||
case USB_INT_DDISCI:
|
||||
return AVR32_USBB.UHINTE.ddiscie;
|
||||
case USB_INT_RSTI:
|
||||
return AVR32_USBB.UHINTE.rstie;
|
||||
case USB_INT_BCERRI:
|
||||
return AVR32_USBB.USBCON.bcerre;
|
||||
case USB_INT_VBERRI:
|
||||
return AVR32_USBB.USBCON.vberre;
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool USB_INT_HasOccurred(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_VBUSTI:
|
||||
return AVR32_USBB.USBSTA.vbusti;
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
case USB_INT_IDTI:
|
||||
return AVR32_USBB.USBSTA.idti;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
case USB_INT_WAKEUPI:
|
||||
return AVR32_USBB.UDINT.wakeup;
|
||||
case USB_INT_SUSPI:
|
||||
return AVR32_USBB.UDINT.susp;
|
||||
case USB_INT_EORSTI:
|
||||
return AVR32_USBB.UDINT.eorst;
|
||||
case USB_INT_SOFI:
|
||||
return AVR32_USBB.UDINT.sof;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
case USB_INT_HSOFI:
|
||||
return AVR32_USBB.UHINT.hsofi;
|
||||
case USB_INT_DCONNI:
|
||||
return AVR32_USBB.UHINT.dconni;
|
||||
case USB_INT_DDISCI:
|
||||
return AVR32_USBB.UHINT.ddisci;
|
||||
case USB_INT_RSTI:
|
||||
return AVR32_USBB.UHINT.rsti;
|
||||
case USB_INT_BCERRI:
|
||||
return AVR32_USBB.USBSTA.bcerri;
|
||||
case USB_INT_VBERRI:
|
||||
return AVR32_USBB.USBSTA.vberri;
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Includes: */
|
||||
#include "../USBMode.h"
|
||||
#include "../Events.h"
|
||||
#include "../USBController.h"
|
||||
|
||||
/* Function Prototypes: */
|
||||
void USB_INT_ClearAllInterrupts(void);
|
||||
void USB_INT_DisableAllInterrupts(void);
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* ISR Prototypes: */
|
||||
#if defined(__DOXYGEN__)
|
||||
/** Interrupt service routine handler for the USB controller ISR group. This interrupt routine <b>must</b> be
|
||||
* linked to the entire USB controller ISR vector group inside the AVR32's interrupt controller peripheral,
|
||||
* using the user application's preferred USB controller driver.
|
||||
*/
|
||||
void USB_GEN_vect(void);
|
||||
#else
|
||||
ISR(USB_GEN_vect);
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Controller Interrupt definitions for the AVR32 UC3 microcontrollers.
|
||||
*
|
||||
* This file contains definitions required for the correct handling of low level USB service routine interrupts
|
||||
* from the USB controller.
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
#ifndef __USBINTERRUPT_UC3_H__
|
||||
#define __USBINTERRUPT_UC3_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../../Common/Common.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Enums: */
|
||||
enum USB_Interrupts_t
|
||||
{
|
||||
USB_INT_VBUSTI = 0,
|
||||
#if (defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__))
|
||||
USB_INT_IDTI = 1,
|
||||
#endif
|
||||
#if (defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__))
|
||||
USB_INT_WAKEUPI = 2,
|
||||
USB_INT_SUSPI = 3,
|
||||
USB_INT_EORSTI = 4,
|
||||
USB_INT_SOFI = 5,
|
||||
#endif
|
||||
#if (defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__))
|
||||
USB_INT_HSOFI = 6,
|
||||
USB_INT_DCONNI = 7,
|
||||
USB_INT_DDISCI = 8,
|
||||
USB_INT_RSTI = 9,
|
||||
USB_INT_BCERRI = 10,
|
||||
USB_INT_VBERRI = 11,
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Inline Functions: */
|
||||
static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_INT_Enable(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_VBUSTI:
|
||||
AVR32_USBB.USBCON.vbuste = true;
|
||||
break;
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
case USB_INT_IDTI:
|
||||
AVR32_USBB.USBCON.idte = true;
|
||||
break;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
case USB_INT_WAKEUPI:
|
||||
AVR32_USBB.UDINTESET.wakeupes = true;
|
||||
break;
|
||||
case USB_INT_SUSPI:
|
||||
AVR32_USBB.UDINTESET.suspes = true;
|
||||
break;
|
||||
case USB_INT_EORSTI:
|
||||
AVR32_USBB.UDINTESET.eorstes = true;
|
||||
break;
|
||||
case USB_INT_SOFI:
|
||||
AVR32_USBB.UDINTESET.sofes = true;
|
||||
break;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
case USB_INT_HSOFI:
|
||||
AVR32_USBB.UHINTESET.hsofies = true;
|
||||
break;
|
||||
case USB_INT_DCONNI:
|
||||
AVR32_USBB.UHINTESET.dconnies = true;
|
||||
break;
|
||||
case USB_INT_DDISCI:
|
||||
AVR32_USBB.UHINTESET.ddiscies = true;
|
||||
break;
|
||||
case USB_INT_RSTI:
|
||||
AVR32_USBB.UHINTESET.rsties = true;
|
||||
break;
|
||||
case USB_INT_BCERRI:
|
||||
AVR32_USBB.USBCON.bcerre = true;
|
||||
break;
|
||||
case USB_INT_VBERRI:
|
||||
AVR32_USBB.USBCON.vberre = true;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_INT_Disable(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_VBUSTI:
|
||||
AVR32_USBB.USBCON.vbuste = false;
|
||||
break;
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
case USB_INT_IDTI:
|
||||
AVR32_USBB.USBCON.idte = false;
|
||||
break;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
case USB_INT_WAKEUPI:
|
||||
AVR32_USBB.UDINTECLR.wakeupec = true;
|
||||
break;
|
||||
case USB_INT_SUSPI:
|
||||
AVR32_USBB.UDINTECLR.suspec = true;
|
||||
break;
|
||||
case USB_INT_EORSTI:
|
||||
AVR32_USBB.UDINTECLR.eorstec = true;
|
||||
break;
|
||||
case USB_INT_SOFI:
|
||||
AVR32_USBB.UDINTECLR.sofec = true;
|
||||
break;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
case USB_INT_HSOFI:
|
||||
AVR32_USBB.UHINTECLR.hsofiec = true;
|
||||
break;
|
||||
case USB_INT_DCONNI:
|
||||
AVR32_USBB.UHINTECLR.dconniec = true;
|
||||
break;
|
||||
case USB_INT_DDISCI:
|
||||
AVR32_USBB.UHINTECLR.ddisciec = true;
|
||||
break;
|
||||
case USB_INT_RSTI:
|
||||
AVR32_USBB.UHINTECLR.rstiec = true;
|
||||
break;
|
||||
case USB_INT_BCERRI:
|
||||
AVR32_USBB.USBCON.bcerre = false;
|
||||
break;
|
||||
case USB_INT_VBERRI:
|
||||
AVR32_USBB.USBCON.vberre = false;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_INT_Clear(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_VBUSTI:
|
||||
AVR32_USBB.USBSTACLR.vbustic = true;
|
||||
(void)AVR32_USBB.USBSTACLR;
|
||||
break;
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
case USB_INT_IDTI:
|
||||
AVR32_USBB.USBSTACLR.idtic = true;
|
||||
(void)AVR32_USBB.USBSTACLR;
|
||||
break;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
case USB_INT_WAKEUPI:
|
||||
AVR32_USBB.UDINTCLR.wakeupc = true;
|
||||
(void)AVR32_USBB.UDINTCLR;
|
||||
break;
|
||||
case USB_INT_SUSPI:
|
||||
AVR32_USBB.UDINTCLR.suspc = true;
|
||||
(void)AVR32_USBB.UDINTCLR;
|
||||
break;
|
||||
case USB_INT_EORSTI:
|
||||
AVR32_USBB.UDINTCLR.eorstc = true;
|
||||
(void)AVR32_USBB.UDINTCLR;
|
||||
break;
|
||||
case USB_INT_SOFI:
|
||||
AVR32_USBB.UDINTCLR.sofc = true;
|
||||
(void)AVR32_USBB.UDINTCLR;
|
||||
break;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
case USB_INT_HSOFI:
|
||||
AVR32_USBB.UHINTCLR.hsofic = true;
|
||||
(void)AVR32_USBB.UHINTCLR;
|
||||
break;
|
||||
case USB_INT_DCONNI:
|
||||
AVR32_USBB.UHINTCLR.dconnic = true;
|
||||
(void)AVR32_USBB.UHINTCLR;
|
||||
break;
|
||||
case USB_INT_DDISCI:
|
||||
AVR32_USBB.UHINTCLR.ddiscic = true;
|
||||
(void)AVR32_USBB.UHINTCLR;
|
||||
break;
|
||||
case USB_INT_RSTI:
|
||||
AVR32_USBB.UHINTCLR.rstic = true;
|
||||
(void)AVR32_USBB.UHINTCLR;
|
||||
break;
|
||||
case USB_INT_BCERRI:
|
||||
AVR32_USBB.USBSTACLR.bcerric = true;
|
||||
(void)AVR32_USBB.USBSTACLR;
|
||||
break;
|
||||
case USB_INT_VBERRI:
|
||||
AVR32_USBB.USBSTACLR.vberric = true;
|
||||
(void)AVR32_USBB.USBSTACLR;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool USB_INT_IsEnabled(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_VBUSTI:
|
||||
return AVR32_USBB.USBCON.vbuste;
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
case USB_INT_IDTI:
|
||||
return AVR32_USBB.USBCON.idte;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
case USB_INT_WAKEUPI:
|
||||
return AVR32_USBB.UDINTE.wakeupe;
|
||||
case USB_INT_SUSPI:
|
||||
return AVR32_USBB.UDINTE.suspe;
|
||||
case USB_INT_EORSTI:
|
||||
return AVR32_USBB.UDINTE.eorste;
|
||||
case USB_INT_SOFI:
|
||||
return AVR32_USBB.UDINTE.sofe;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
case USB_INT_HSOFI:
|
||||
return AVR32_USBB.UHINTE.hsofie;
|
||||
case USB_INT_DCONNI:
|
||||
return AVR32_USBB.UHINTE.dconnie;
|
||||
case USB_INT_DDISCI:
|
||||
return AVR32_USBB.UHINTE.ddiscie;
|
||||
case USB_INT_RSTI:
|
||||
return AVR32_USBB.UHINTE.rstie;
|
||||
case USB_INT_BCERRI:
|
||||
return AVR32_USBB.USBCON.bcerre;
|
||||
case USB_INT_VBERRI:
|
||||
return AVR32_USBB.USBCON.vberre;
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool USB_INT_HasOccurred(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_VBUSTI:
|
||||
return AVR32_USBB.USBSTA.vbusti;
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
case USB_INT_IDTI:
|
||||
return AVR32_USBB.USBSTA.idti;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
case USB_INT_WAKEUPI:
|
||||
return AVR32_USBB.UDINT.wakeup;
|
||||
case USB_INT_SUSPI:
|
||||
return AVR32_USBB.UDINT.susp;
|
||||
case USB_INT_EORSTI:
|
||||
return AVR32_USBB.UDINT.eorst;
|
||||
case USB_INT_SOFI:
|
||||
return AVR32_USBB.UDINT.sof;
|
||||
#endif
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
case USB_INT_HSOFI:
|
||||
return AVR32_USBB.UHINT.hsofi;
|
||||
case USB_INT_DCONNI:
|
||||
return AVR32_USBB.UHINT.dconni;
|
||||
case USB_INT_DDISCI:
|
||||
return AVR32_USBB.UHINT.ddisci;
|
||||
case USB_INT_RSTI:
|
||||
return AVR32_USBB.UHINT.rsti;
|
||||
case USB_INT_BCERRI:
|
||||
return AVR32_USBB.USBSTA.bcerri;
|
||||
case USB_INT_VBERRI:
|
||||
return AVR32_USBB.USBSTA.vberri;
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Includes: */
|
||||
#include "../USBMode.h"
|
||||
#include "../Events.h"
|
||||
#include "../USBController.h"
|
||||
|
||||
/* Function Prototypes: */
|
||||
void USB_INT_ClearAllInterrupts(void);
|
||||
void USB_INT_DisableAllInterrupts(void);
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* ISR Prototypes: */
|
||||
#if defined(__DOXYGEN__)
|
||||
/** Interrupt service routine handler for the USB controller ISR group. This interrupt routine <b>must</b> be
|
||||
* linked to the entire USB controller ISR vector group inside the AVR32's interrupt controller peripheral,
|
||||
* using the user application's preferred USB controller driver.
|
||||
*/
|
||||
void USB_GEN_vect(void);
|
||||
#else
|
||||
ISR(USB_GEN_vect);
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,82 +1,82 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Common USB Controller definitions for all architectures.
|
||||
* \copydetails Group_USBManagement
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USB
|
||||
* \defgroup Group_USBManagement USB Interface Management
|
||||
* \brief USB Controller definitions for general USB controller management.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to the setup and management of the USB interface.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBCONTROLLER_H__
|
||||
#define __USBCONTROLLER_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks and Defines: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/USBController_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/USBController_UC3.h"
|
||||
#elif (ARCH == ARCH_XMEGA)
|
||||
#include "XMEGA/USBController_XMEGA.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Common USB Controller definitions for all architectures.
|
||||
* \copydetails Group_USBManagement
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USB
|
||||
* \defgroup Group_USBManagement USB Interface Management
|
||||
* \brief USB Controller definitions for general USB controller management.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to the setup and management of the USB interface.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBCONTROLLER_H__
|
||||
#define __USBCONTROLLER_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks and Defines: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/USBController_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/USBController_UC3.h"
|
||||
#elif (ARCH == ARCH_XMEGA)
|
||||
#include "XMEGA/USBController_XMEGA.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,73 +1,73 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB controller interrupt service routine management.
|
||||
*
|
||||
* This file contains definitions required for the correct handling of low level USB service routine interrupts
|
||||
* from the USB controller.
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
#ifndef __USBINTERRUPT_H__
|
||||
#define __USBINTERRUPT_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/USBInterrupt_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/USBInterrupt_UC3.h"
|
||||
#elif (ARCH == ARCH_XMEGA)
|
||||
#include "XMEGA/USBInterrupt_XMEGA.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB controller interrupt service routine management.
|
||||
*
|
||||
* This file contains definitions required for the correct handling of low level USB service routine interrupts
|
||||
* from the USB controller.
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
#ifndef __USBINTERRUPT_H__
|
||||
#define __USBINTERRUPT_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../Common/Common.h"
|
||||
#include "USBMode.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Architecture Includes: */
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
#include "AVR8/USBInterrupt_AVR8.h"
|
||||
#elif (ARCH == ARCH_UC3)
|
||||
#include "UC3/USBInterrupt_UC3.h"
|
||||
#elif (ARCH == ARCH_XMEGA)
|
||||
#include "XMEGA/USBInterrupt_XMEGA.h"
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,44 +1,44 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
|
||||
#include "../Device.h"
|
||||
|
||||
void USB_Device_SendRemoteWakeup(void)
|
||||
{
|
||||
USB.CTRLB |= USB_RWAKEUP_bm;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
|
||||
#include "../Device.h"
|
||||
|
||||
void USB_Device_SendRemoteWakeup(void)
|
||||
{
|
||||
USB.CTRLB |= USB_RWAKEUP_bm;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,238 +1,238 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Device definitions for the AVR XMEGA microcontrollers.
|
||||
* \copydetails Group_Device_XMEGA
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Device
|
||||
* \defgroup Group_Device_XMEGA Device Management (XMEGA)
|
||||
* \brief USB Device definitions for the AVR XMEGA microcontrollers.
|
||||
*
|
||||
* Architecture specific USB Device definitions for the Atmel AVR XMEGA microcontrollers.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBDEVICE_XMEGA_H__
|
||||
#define __USBDEVICE_XMEGA_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../../Common/Common.h"
|
||||
#include "../USBController.h"
|
||||
#include "../StdDescriptors.h"
|
||||
#include "../USBInterrupt.h"
|
||||
#include "../Endpoint.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
#if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))
|
||||
#error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** \name USB Device Mode Option Masks */
|
||||
//@{
|
||||
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
|
||||
* USB interface should be initialized in low speed (1.5Mb/s) mode.
|
||||
*
|
||||
* \note Low Speed mode is not available on all USB AVR models.
|
||||
* \n
|
||||
*
|
||||
* \note Restrictions apply on the number, size and type of endpoints which can be used
|
||||
* when running in low speed mode - refer to the USB 2.0 specification.
|
||||
*/
|
||||
#define USB_DEVICE_OPT_LOWSPEED (1 << 0)
|
||||
|
||||
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
|
||||
* USB interface should be initialized in full speed (12Mb/s) mode.
|
||||
*/
|
||||
#define USB_DEVICE_OPT_FULLSPEED (0 << 0)
|
||||
//@}
|
||||
|
||||
/** 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 microcontrollers 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 \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial
|
||||
* number for the device.
|
||||
*/
|
||||
#define USE_INTERNAL_SERIAL 0xDC
|
||||
|
||||
/** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller
|
||||
* model.
|
||||
*/
|
||||
#define INTERNAL_SERIAL_LENGTH_BITS (8 * (1 + (offsetof(NVM_PROD_SIGNATURES_t, COORDY1) - offsetof(NVM_PROD_SIGNATURES_t, LOTNUM0))))
|
||||
|
||||
/** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller
|
||||
* model.
|
||||
*/
|
||||
#define INTERNAL_SERIAL_START_ADDRESS offsetof(NVM_PROD_SIGNATURES_t, LOTNUM0)
|
||||
|
||||
/* 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.
|
||||
*
|
||||
* Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the
|
||||
* host computer when the host has suspended all USB devices to enter a low power state.
|
||||
*
|
||||
* \note This macro should only be used if the device has indicated to the host that it
|
||||
* supports the Remote Wakeup feature in the device descriptors, and should only be
|
||||
* issued if the host is currently allowing remote wakeup events from the device (i.e.,
|
||||
* the \ref USB_Device_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP
|
||||
* compile time option is used, this macro is unavailable.
|
||||
* \n\n
|
||||
*
|
||||
* \note The USB clock must be running for this function to operate. If the stack is initialized with
|
||||
* the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running
|
||||
* before attempting to call this function.
|
||||
*
|
||||
* \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors.
|
||||
*/
|
||||
void USB_Device_SendRemoteWakeup(void);
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host)
|
||||
* the frame number is incremented by one.
|
||||
*/
|
||||
static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint16_t USB_Device_GetFrameNumber(void)
|
||||
{
|
||||
return (((uint16_t)USB_EndpointTable.FRAMENUMH << 8) | USB_EndpointTable.FRAMENUML);
|
||||
}
|
||||
|
||||
#if !defined(NO_SOF_EVENTS)
|
||||
/** Enables the device mode Start Of Frame events. When enabled, this causes the
|
||||
* \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,
|
||||
* at the start of each USB frame when enumerated in device mode.
|
||||
*
|
||||
* \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
|
||||
*/
|
||||
static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_EnableSOFEvents(void)
|
||||
{
|
||||
USB.INTCTRLA |= USB_SOFIE_bm;
|
||||
}
|
||||
|
||||
/** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the
|
||||
* \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.
|
||||
*
|
||||
* \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
|
||||
*/
|
||||
static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_DisableSOFEvents(void)
|
||||
{
|
||||
USB.INTCTRLA &= ~USB_SOFIE_bm;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Inline Functions: */
|
||||
static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetLowSpeed(void)
|
||||
{
|
||||
USB.CTRLA &= ~USB_SPEED_bm;
|
||||
}
|
||||
|
||||
static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetFullSpeed(void)
|
||||
{
|
||||
USB.CTRLA |= USB_SPEED_bm;
|
||||
}
|
||||
|
||||
static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetDeviceAddress(const uint8_t Address)
|
||||
{
|
||||
USB.ADDR = Address;
|
||||
}
|
||||
|
||||
static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool USB_Device_IsAddressSet(void)
|
||||
{
|
||||
return ((USB.ADDR != 0) ? true : false);
|
||||
}
|
||||
|
||||
static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) ATTR_NON_NULL_PTR_ARG(1);
|
||||
static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString)
|
||||
{
|
||||
uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();
|
||||
GlobalInterruptDisable();
|
||||
|
||||
uint8_t SigReadAddress = INTERNAL_SERIAL_START_ADDRESS;
|
||||
|
||||
for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)
|
||||
{
|
||||
uint8_t SerialByte;
|
||||
|
||||
NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc;
|
||||
SerialByte = pgm_read_byte(SigReadAddress);
|
||||
|
||||
if (SerialCharNum & 0x01)
|
||||
{
|
||||
SerialByte >>= 4;
|
||||
SigReadAddress++;
|
||||
}
|
||||
|
||||
SerialByte &= 0x0F;
|
||||
|
||||
UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?
|
||||
(('A' - 10) + SerialByte) : ('0' + SerialByte));
|
||||
}
|
||||
|
||||
SetGlobalInterruptMask(CurrentGlobalInt);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Device definitions for the AVR XMEGA microcontrollers.
|
||||
* \copydetails Group_Device_XMEGA
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Device
|
||||
* \defgroup Group_Device_XMEGA Device Management (XMEGA)
|
||||
* \brief USB Device definitions for the AVR XMEGA microcontrollers.
|
||||
*
|
||||
* Architecture specific USB Device definitions for the Atmel AVR XMEGA microcontrollers.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBDEVICE_XMEGA_H__
|
||||
#define __USBDEVICE_XMEGA_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../../Common/Common.h"
|
||||
#include "../USBController.h"
|
||||
#include "../StdDescriptors.h"
|
||||
#include "../USBInterrupt.h"
|
||||
#include "../Endpoint.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
#if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))
|
||||
#error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** \name USB Device Mode Option Masks */
|
||||
//@{
|
||||
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
|
||||
* USB interface should be initialized in low speed (1.5Mb/s) mode.
|
||||
*
|
||||
* \note Low Speed mode is not available on all USB AVR models.
|
||||
* \n
|
||||
*
|
||||
* \note Restrictions apply on the number, size and type of endpoints which can be used
|
||||
* when running in low speed mode - refer to the USB 2.0 specification.
|
||||
*/
|
||||
#define USB_DEVICE_OPT_LOWSPEED (1 << 0)
|
||||
|
||||
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
|
||||
* USB interface should be initialized in full speed (12Mb/s) mode.
|
||||
*/
|
||||
#define USB_DEVICE_OPT_FULLSPEED (0 << 0)
|
||||
//@}
|
||||
|
||||
/** 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 microcontrollers 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 \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial
|
||||
* number for the device.
|
||||
*/
|
||||
#define USE_INTERNAL_SERIAL 0xDC
|
||||
|
||||
/** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller
|
||||
* model.
|
||||
*/
|
||||
#define INTERNAL_SERIAL_LENGTH_BITS (8 * (1 + (offsetof(NVM_PROD_SIGNATURES_t, COORDY1) - offsetof(NVM_PROD_SIGNATURES_t, LOTNUM0))))
|
||||
|
||||
/** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller
|
||||
* model.
|
||||
*/
|
||||
#define INTERNAL_SERIAL_START_ADDRESS offsetof(NVM_PROD_SIGNATURES_t, LOTNUM0)
|
||||
|
||||
/* 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.
|
||||
*
|
||||
* Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the
|
||||
* host computer when the host has suspended all USB devices to enter a low power state.
|
||||
*
|
||||
* \note This macro should only be used if the device has indicated to the host that it
|
||||
* supports the Remote Wakeup feature in the device descriptors, and should only be
|
||||
* issued if the host is currently allowing remote wakeup events from the device (i.e.,
|
||||
* the \ref USB_Device_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP
|
||||
* compile time option is used, this macro is unavailable.
|
||||
* \n\n
|
||||
*
|
||||
* \note The USB clock must be running for this function to operate. If the stack is initialized with
|
||||
* the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running
|
||||
* before attempting to call this function.
|
||||
*
|
||||
* \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors.
|
||||
*/
|
||||
void USB_Device_SendRemoteWakeup(void);
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host)
|
||||
* the frame number is incremented by one.
|
||||
*/
|
||||
static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint16_t USB_Device_GetFrameNumber(void)
|
||||
{
|
||||
return (((uint16_t)USB_EndpointTable.FRAMENUMH << 8) | USB_EndpointTable.FRAMENUML);
|
||||
}
|
||||
|
||||
#if !defined(NO_SOF_EVENTS)
|
||||
/** Enables the device mode Start Of Frame events. When enabled, this causes the
|
||||
* \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,
|
||||
* at the start of each USB frame when enumerated in device mode.
|
||||
*
|
||||
* \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
|
||||
*/
|
||||
static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_EnableSOFEvents(void)
|
||||
{
|
||||
USB.INTCTRLA |= USB_SOFIE_bm;
|
||||
}
|
||||
|
||||
/** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the
|
||||
* \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.
|
||||
*
|
||||
* \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
|
||||
*/
|
||||
static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_DisableSOFEvents(void)
|
||||
{
|
||||
USB.INTCTRLA &= ~USB_SOFIE_bm;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Inline Functions: */
|
||||
static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetLowSpeed(void)
|
||||
{
|
||||
USB.CTRLA &= ~USB_SPEED_bm;
|
||||
}
|
||||
|
||||
static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetFullSpeed(void)
|
||||
{
|
||||
USB.CTRLA |= USB_SPEED_bm;
|
||||
}
|
||||
|
||||
static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetDeviceAddress(const uint8_t Address)
|
||||
{
|
||||
USB.ADDR = Address;
|
||||
}
|
||||
|
||||
static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool USB_Device_IsAddressSet(void)
|
||||
{
|
||||
return ((USB.ADDR != 0) ? true : false);
|
||||
}
|
||||
|
||||
static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) ATTR_NON_NULL_PTR_ARG(1);
|
||||
static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString)
|
||||
{
|
||||
uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();
|
||||
GlobalInterruptDisable();
|
||||
|
||||
uint8_t SigReadAddress = INTERNAL_SERIAL_START_ADDRESS;
|
||||
|
||||
for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)
|
||||
{
|
||||
uint8_t SerialByte;
|
||||
|
||||
NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc;
|
||||
SerialByte = pgm_read_byte(SigReadAddress);
|
||||
|
||||
if (SerialCharNum & 0x01)
|
||||
{
|
||||
SerialByte >>= 4;
|
||||
SigReadAddress++;
|
||||
}
|
||||
|
||||
SerialByte &= 0x0F;
|
||||
|
||||
UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?
|
||||
(('A' - 10) + SerialByte) : ('0' + SerialByte));
|
||||
}
|
||||
|
||||
SetGlobalInterruptMask(CurrentGlobalInt);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,67 +1,67 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
|
||||
#include "../Endpoint.h"
|
||||
|
||||
#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)
|
||||
uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;
|
||||
#endif
|
||||
|
||||
bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
|
||||
const uint8_t UECFG0XData,
|
||||
const uint8_t UECFG1XData)
|
||||
{
|
||||
return false; // TODO
|
||||
}
|
||||
|
||||
void Endpoint_ClearEndpoints(void)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Endpoint_ClearStatusStage(void)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
uint8_t Endpoint_WaitUntilReady(void)
|
||||
{
|
||||
return 0; // TODO
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
|
||||
#include "../Endpoint.h"
|
||||
|
||||
#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)
|
||||
uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;
|
||||
#endif
|
||||
|
||||
bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
|
||||
const uint8_t UECFG0XData,
|
||||
const uint8_t UECFG1XData)
|
||||
{
|
||||
return false; // TODO
|
||||
}
|
||||
|
||||
void Endpoint_ClearEndpoints(void)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Endpoint_ClearStatusStage(void)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
uint8_t Endpoint_WaitUntilReady(void)
|
||||
{
|
||||
return 0; // TODO
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,37 +1,37 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,37 +1,37 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,37 +1,37 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBMode.h"
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,83 +1,83 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#if defined(TEMPLATE_FUNC_NAME)
|
||||
|
||||
uint8_t TEMPLATE_FUNC_NAME (void* const Buffer,
|
||||
uint16_t Length)
|
||||
{
|
||||
uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
|
||||
|
||||
if (!(Length))
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
while (Length)
|
||||
{
|
||||
uint8_t USB_DeviceState_LCL = USB_DeviceState;
|
||||
|
||||
if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
|
||||
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
|
||||
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
|
||||
return ENDPOINT_RWCSTREAM_BusSuspended;
|
||||
else if (Endpoint_IsSETUPReceived())
|
||||
return ENDPOINT_RWCSTREAM_HostAborted;
|
||||
|
||||
if (Endpoint_IsOUTReceived())
|
||||
{
|
||||
while (Length && Endpoint_BytesInEndpoint())
|
||||
{
|
||||
TEMPLATE_TRANSFER_BYTE(DataStream);
|
||||
TEMPLATE_BUFFER_MOVE(DataStream, 1);
|
||||
Length--;
|
||||
}
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
}
|
||||
|
||||
while (!(Endpoint_IsINReady()))
|
||||
{
|
||||
uint8_t USB_DeviceState_LCL = USB_DeviceState;
|
||||
|
||||
if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
|
||||
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
|
||||
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
|
||||
return ENDPOINT_RWCSTREAM_BusSuspended;
|
||||
}
|
||||
|
||||
return ENDPOINT_RWCSTREAM_NoError;
|
||||
}
|
||||
|
||||
#undef TEMPLATE_BUFFER_OFFSET
|
||||
#undef TEMPLATE_BUFFER_MOVE
|
||||
#undef TEMPLATE_FUNC_NAME
|
||||
#undef TEMPLATE_TRANSFER_BYTE
|
||||
|
||||
#endif
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#if defined(TEMPLATE_FUNC_NAME)
|
||||
|
||||
uint8_t TEMPLATE_FUNC_NAME (void* const Buffer,
|
||||
uint16_t Length)
|
||||
{
|
||||
uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
|
||||
|
||||
if (!(Length))
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
while (Length)
|
||||
{
|
||||
uint8_t USB_DeviceState_LCL = USB_DeviceState;
|
||||
|
||||
if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
|
||||
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
|
||||
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
|
||||
return ENDPOINT_RWCSTREAM_BusSuspended;
|
||||
else if (Endpoint_IsSETUPReceived())
|
||||
return ENDPOINT_RWCSTREAM_HostAborted;
|
||||
|
||||
if (Endpoint_IsOUTReceived())
|
||||
{
|
||||
while (Length && Endpoint_BytesInEndpoint())
|
||||
{
|
||||
TEMPLATE_TRANSFER_BYTE(DataStream);
|
||||
TEMPLATE_BUFFER_MOVE(DataStream, 1);
|
||||
Length--;
|
||||
}
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
}
|
||||
|
||||
while (!(Endpoint_IsINReady()))
|
||||
{
|
||||
uint8_t USB_DeviceState_LCL = USB_DeviceState;
|
||||
|
||||
if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
|
||||
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
|
||||
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
|
||||
return ENDPOINT_RWCSTREAM_BusSuspended;
|
||||
}
|
||||
|
||||
return ENDPOINT_RWCSTREAM_NoError;
|
||||
}
|
||||
|
||||
#undef TEMPLATE_BUFFER_OFFSET
|
||||
#undef TEMPLATE_BUFFER_MOVE
|
||||
#undef TEMPLATE_FUNC_NAME
|
||||
#undef TEMPLATE_TRANSFER_BYTE
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,92 +1,92 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#if defined(TEMPLATE_FUNC_NAME)
|
||||
|
||||
uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer,
|
||||
uint16_t Length)
|
||||
{
|
||||
uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
|
||||
bool LastPacketFull = false;
|
||||
|
||||
if (Length > USB_ControlRequest.wLength)
|
||||
Length = USB_ControlRequest.wLength;
|
||||
else if (!(Length))
|
||||
Endpoint_ClearIN();
|
||||
|
||||
while (Length || LastPacketFull)
|
||||
{
|
||||
uint8_t USB_DeviceState_LCL = USB_DeviceState;
|
||||
|
||||
if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
|
||||
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
|
||||
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
|
||||
return ENDPOINT_RWCSTREAM_BusSuspended;
|
||||
else if (Endpoint_IsSETUPReceived())
|
||||
return ENDPOINT_RWCSTREAM_HostAborted;
|
||||
else if (Endpoint_IsOUTReceived())
|
||||
break;
|
||||
|
||||
if (Endpoint_IsINReady())
|
||||
{
|
||||
uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint();
|
||||
|
||||
while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize))
|
||||
{
|
||||
TEMPLATE_TRANSFER_BYTE(DataStream);
|
||||
TEMPLATE_BUFFER_MOVE(DataStream, 1);
|
||||
Length--;
|
||||
BytesInEndpoint++;
|
||||
}
|
||||
|
||||
LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
}
|
||||
|
||||
while (!(Endpoint_IsOUTReceived()))
|
||||
{
|
||||
uint8_t USB_DeviceState_LCL = USB_DeviceState;
|
||||
|
||||
if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
|
||||
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
|
||||
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
|
||||
return ENDPOINT_RWCSTREAM_BusSuspended;
|
||||
}
|
||||
|
||||
return ENDPOINT_RWCSTREAM_NoError;
|
||||
}
|
||||
|
||||
#undef TEMPLATE_BUFFER_OFFSET
|
||||
#undef TEMPLATE_BUFFER_MOVE
|
||||
#undef TEMPLATE_FUNC_NAME
|
||||
#undef TEMPLATE_TRANSFER_BYTE
|
||||
|
||||
#endif
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#if defined(TEMPLATE_FUNC_NAME)
|
||||
|
||||
uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer,
|
||||
uint16_t Length)
|
||||
{
|
||||
uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
|
||||
bool LastPacketFull = false;
|
||||
|
||||
if (Length > USB_ControlRequest.wLength)
|
||||
Length = USB_ControlRequest.wLength;
|
||||
else if (!(Length))
|
||||
Endpoint_ClearIN();
|
||||
|
||||
while (Length || LastPacketFull)
|
||||
{
|
||||
uint8_t USB_DeviceState_LCL = USB_DeviceState;
|
||||
|
||||
if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
|
||||
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
|
||||
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
|
||||
return ENDPOINT_RWCSTREAM_BusSuspended;
|
||||
else if (Endpoint_IsSETUPReceived())
|
||||
return ENDPOINT_RWCSTREAM_HostAborted;
|
||||
else if (Endpoint_IsOUTReceived())
|
||||
break;
|
||||
|
||||
if (Endpoint_IsINReady())
|
||||
{
|
||||
uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint();
|
||||
|
||||
while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize))
|
||||
{
|
||||
TEMPLATE_TRANSFER_BYTE(DataStream);
|
||||
TEMPLATE_BUFFER_MOVE(DataStream, 1);
|
||||
Length--;
|
||||
BytesInEndpoint++;
|
||||
}
|
||||
|
||||
LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
}
|
||||
|
||||
while (!(Endpoint_IsOUTReceived()))
|
||||
{
|
||||
uint8_t USB_DeviceState_LCL = USB_DeviceState;
|
||||
|
||||
if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
|
||||
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
|
||||
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
|
||||
return ENDPOINT_RWCSTREAM_BusSuspended;
|
||||
}
|
||||
|
||||
return ENDPOINT_RWCSTREAM_NoError;
|
||||
}
|
||||
|
||||
#undef TEMPLATE_BUFFER_OFFSET
|
||||
#undef TEMPLATE_BUFFER_MOVE
|
||||
#undef TEMPLATE_FUNC_NAME
|
||||
#undef TEMPLATE_TRANSFER_BYTE
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,88 +1,88 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#if defined(TEMPLATE_FUNC_NAME)
|
||||
|
||||
uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer,
|
||||
uint16_t Length,
|
||||
uint16_t* const BytesProcessed)
|
||||
{
|
||||
uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
|
||||
uint16_t BytesInTransfer = 0;
|
||||
uint8_t ErrorCode;
|
||||
|
||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||
return ErrorCode;
|
||||
|
||||
if (BytesProcessed != NULL)
|
||||
{
|
||||
Length -= *BytesProcessed;
|
||||
TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed);
|
||||
}
|
||||
|
||||
while (Length)
|
||||
{
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
{
|
||||
TEMPLATE_CLEAR_ENDPOINT();
|
||||
|
||||
if (BytesProcessed != NULL)
|
||||
{
|
||||
*BytesProcessed += BytesInTransfer;
|
||||
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
||||
}
|
||||
|
||||
#if !defined(INTERRUPT_CONTROL_ENDPOINT)
|
||||
USB_USBTask();
|
||||
#endif
|
||||
|
||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||
return ErrorCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
TEMPLATE_TRANSFER_BYTE(DataStream);
|
||||
TEMPLATE_BUFFER_MOVE(DataStream, 1);
|
||||
Length--;
|
||||
BytesInTransfer++;
|
||||
}
|
||||
}
|
||||
|
||||
return ENDPOINT_RWSTREAM_NoError;
|
||||
}
|
||||
|
||||
#undef TEMPLATE_FUNC_NAME
|
||||
#undef TEMPLATE_BUFFER_TYPE
|
||||
#undef TEMPLATE_TRANSFER_BYTE
|
||||
#undef TEMPLATE_CLEAR_ENDPOINT
|
||||
#undef TEMPLATE_BUFFER_OFFSET
|
||||
#undef TEMPLATE_BUFFER_MOVE
|
||||
|
||||
#endif
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#if defined(TEMPLATE_FUNC_NAME)
|
||||
|
||||
uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer,
|
||||
uint16_t Length,
|
||||
uint16_t* const BytesProcessed)
|
||||
{
|
||||
uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
|
||||
uint16_t BytesInTransfer = 0;
|
||||
uint8_t ErrorCode;
|
||||
|
||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||
return ErrorCode;
|
||||
|
||||
if (BytesProcessed != NULL)
|
||||
{
|
||||
Length -= *BytesProcessed;
|
||||
TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed);
|
||||
}
|
||||
|
||||
while (Length)
|
||||
{
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
{
|
||||
TEMPLATE_CLEAR_ENDPOINT();
|
||||
|
||||
if (BytesProcessed != NULL)
|
||||
{
|
||||
*BytesProcessed += BytesInTransfer;
|
||||
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
||||
}
|
||||
|
||||
#if !defined(INTERRUPT_CONTROL_ENDPOINT)
|
||||
USB_USBTask();
|
||||
#endif
|
||||
|
||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||
return ErrorCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
TEMPLATE_TRANSFER_BYTE(DataStream);
|
||||
TEMPLATE_BUFFER_MOVE(DataStream, 1);
|
||||
Length--;
|
||||
BytesInTransfer++;
|
||||
}
|
||||
}
|
||||
|
||||
return ENDPOINT_RWSTREAM_NoError;
|
||||
}
|
||||
|
||||
#undef TEMPLATE_FUNC_NAME
|
||||
#undef TEMPLATE_BUFFER_TYPE
|
||||
#undef TEMPLATE_TRANSFER_BYTE
|
||||
#undef TEMPLATE_CLEAR_ENDPOINT
|
||||
#undef TEMPLATE_BUFFER_OFFSET
|
||||
#undef TEMPLATE_BUFFER_MOVE
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,169 +1,169 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#define __INCLUDE_FROM_USB_CONTROLLER_C
|
||||
#include "../USBController.h"
|
||||
|
||||
#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY))
|
||||
volatile uint8_t USB_CurrentMode = USB_MODE_None;
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS)
|
||||
volatile uint8_t USB_Options;
|
||||
#endif
|
||||
|
||||
USB_EP_TABLE_t USB_EndpointTable ATTR_ALIGNED(2);
|
||||
|
||||
void USB_Init(
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
const uint8_t Mode
|
||||
#endif
|
||||
|
||||
#if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS))
|
||||
,
|
||||
#elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))
|
||||
void
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS)
|
||||
const uint8_t Options
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#if !defined(USE_STATIC_OPTIONS)
|
||||
USB_Options = Options;
|
||||
#endif
|
||||
|
||||
USB_IsInitialized = true;
|
||||
|
||||
uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();
|
||||
GlobalInterruptDisable();
|
||||
|
||||
NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc;
|
||||
USB.CAL0 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL0));
|
||||
NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc;
|
||||
USB.CAL1 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL1));
|
||||
|
||||
if ((USB_Options & USB_OPT_BUSEVENT_PRIHIGH) == USB_OPT_BUSEVENT_PRIHIGH)
|
||||
USB.INTCTRLA = (3 << USB_INTLVL_gp);
|
||||
else if ((USB_Options & USB_OPT_BUSEVENT_PRIMED) == USB_OPT_BUSEVENT_PRIMED)
|
||||
USB.INTCTRLA = (2 << USB_INTLVL_gp);
|
||||
else
|
||||
USB.INTCTRLA = (1 << USB_INTLVL_gp);
|
||||
|
||||
SetGlobalInterruptMask(CurrentGlobalInt);
|
||||
|
||||
USB_ResetInterface();
|
||||
}
|
||||
|
||||
void USB_Disable(void)
|
||||
{
|
||||
USB_INT_DisableAllInterrupts();
|
||||
USB_INT_ClearAllInterrupts();
|
||||
|
||||
USB_Detach();
|
||||
USB_Controller_Disable();
|
||||
|
||||
USB_IsInitialized = false;
|
||||
}
|
||||
|
||||
void USB_ResetInterface(void)
|
||||
{
|
||||
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
|
||||
CLK.USBCTRL = ((((F_USB / 6000000) - 1) << CLK_USBPSDIV_gp) | CLK_USBSRC_PLL_gc | CLK_USBSEN_bm);
|
||||
else
|
||||
CLK.USBCTRL = ((((F_USB / 48000000) - 1) << CLK_USBPSDIV_gp) | CLK_USBSRC_PLL_gc | CLK_USBSEN_bm);
|
||||
|
||||
USB_INT_DisableAllInterrupts();
|
||||
USB_INT_ClearAllInterrupts();
|
||||
|
||||
USB_Controller_Reset();
|
||||
USB_Init_Device();
|
||||
}
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
static void USB_Init_Device(void)
|
||||
{
|
||||
USB_DeviceState = DEVICE_STATE_Unattached;
|
||||
USB_Device_ConfigurationNumber = 0;
|
||||
|
||||
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
|
||||
USB_Device_RemoteWakeupEnabled = false;
|
||||
#endif
|
||||
|
||||
#if !defined(NO_DEVICE_SELF_POWER)
|
||||
USB_Device_CurrentlySelfPowered = false;
|
||||
#endif
|
||||
|
||||
#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)
|
||||
USB_Descriptor_Device_t* DeviceDescriptorPtr;
|
||||
|
||||
#if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \
|
||||
!(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS))
|
||||
uint8_t DescriptorAddressSpace;
|
||||
|
||||
if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr, &DescriptorAddressSpace) != NO_DESCRIPTOR)
|
||||
{
|
||||
if (DescriptorAddressSpace == MEMSPACE_FLASH)
|
||||
USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
|
||||
else if (DescriptorAddressSpace == MEMSPACE_EEPROM)
|
||||
USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
|
||||
else
|
||||
USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
|
||||
}
|
||||
#else
|
||||
if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR)
|
||||
{
|
||||
#if defined(USE_RAM_DESCRIPTORS)
|
||||
USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
|
||||
#elif defined(USE_EEPROM_DESCRIPTORS)
|
||||
USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
|
||||
#else
|
||||
USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
|
||||
USB_Device_SetLowSpeed();
|
||||
else
|
||||
USB_Device_SetFullSpeed();
|
||||
|
||||
Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
|
||||
ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize,
|
||||
ENDPOINT_BANK_SINGLE);
|
||||
|
||||
USB_INT_Enable(USB_INT_BUSEVENTI);
|
||||
|
||||
USB_Attach();
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#define __INCLUDE_FROM_USB_CONTROLLER_C
|
||||
#include "../USBController.h"
|
||||
|
||||
#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY))
|
||||
volatile uint8_t USB_CurrentMode = USB_MODE_None;
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS)
|
||||
volatile uint8_t USB_Options;
|
||||
#endif
|
||||
|
||||
USB_EP_TABLE_t USB_EndpointTable ATTR_ALIGNED(2);
|
||||
|
||||
void USB_Init(
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
const uint8_t Mode
|
||||
#endif
|
||||
|
||||
#if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS))
|
||||
,
|
||||
#elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))
|
||||
void
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS)
|
||||
const uint8_t Options
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#if !defined(USE_STATIC_OPTIONS)
|
||||
USB_Options = Options;
|
||||
#endif
|
||||
|
||||
USB_IsInitialized = true;
|
||||
|
||||
uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();
|
||||
GlobalInterruptDisable();
|
||||
|
||||
NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc;
|
||||
USB.CAL0 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL0));
|
||||
NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc;
|
||||
USB.CAL1 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL1));
|
||||
|
||||
if ((USB_Options & USB_OPT_BUSEVENT_PRIHIGH) == USB_OPT_BUSEVENT_PRIHIGH)
|
||||
USB.INTCTRLA = (3 << USB_INTLVL_gp);
|
||||
else if ((USB_Options & USB_OPT_BUSEVENT_PRIMED) == USB_OPT_BUSEVENT_PRIMED)
|
||||
USB.INTCTRLA = (2 << USB_INTLVL_gp);
|
||||
else
|
||||
USB.INTCTRLA = (1 << USB_INTLVL_gp);
|
||||
|
||||
SetGlobalInterruptMask(CurrentGlobalInt);
|
||||
|
||||
USB_ResetInterface();
|
||||
}
|
||||
|
||||
void USB_Disable(void)
|
||||
{
|
||||
USB_INT_DisableAllInterrupts();
|
||||
USB_INT_ClearAllInterrupts();
|
||||
|
||||
USB_Detach();
|
||||
USB_Controller_Disable();
|
||||
|
||||
USB_IsInitialized = false;
|
||||
}
|
||||
|
||||
void USB_ResetInterface(void)
|
||||
{
|
||||
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
|
||||
CLK.USBCTRL = ((((F_USB / 6000000) - 1) << CLK_USBPSDIV_gp) | CLK_USBSRC_PLL_gc | CLK_USBSEN_bm);
|
||||
else
|
||||
CLK.USBCTRL = ((((F_USB / 48000000) - 1) << CLK_USBPSDIV_gp) | CLK_USBSRC_PLL_gc | CLK_USBSEN_bm);
|
||||
|
||||
USB_INT_DisableAllInterrupts();
|
||||
USB_INT_ClearAllInterrupts();
|
||||
|
||||
USB_Controller_Reset();
|
||||
USB_Init_Device();
|
||||
}
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
static void USB_Init_Device(void)
|
||||
{
|
||||
USB_DeviceState = DEVICE_STATE_Unattached;
|
||||
USB_Device_ConfigurationNumber = 0;
|
||||
|
||||
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
|
||||
USB_Device_RemoteWakeupEnabled = false;
|
||||
#endif
|
||||
|
||||
#if !defined(NO_DEVICE_SELF_POWER)
|
||||
USB_Device_CurrentlySelfPowered = false;
|
||||
#endif
|
||||
|
||||
#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)
|
||||
USB_Descriptor_Device_t* DeviceDescriptorPtr;
|
||||
|
||||
#if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \
|
||||
!(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS))
|
||||
uint8_t DescriptorAddressSpace;
|
||||
|
||||
if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr, &DescriptorAddressSpace) != NO_DESCRIPTOR)
|
||||
{
|
||||
if (DescriptorAddressSpace == MEMSPACE_FLASH)
|
||||
USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
|
||||
else if (DescriptorAddressSpace == MEMSPACE_EEPROM)
|
||||
USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
|
||||
else
|
||||
USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
|
||||
}
|
||||
#else
|
||||
if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR)
|
||||
{
|
||||
#if defined(USE_RAM_DESCRIPTORS)
|
||||
USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
|
||||
#elif defined(USE_EEPROM_DESCRIPTORS)
|
||||
USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
|
||||
#else
|
||||
USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
|
||||
USB_Device_SetLowSpeed();
|
||||
else
|
||||
USB_Device_SetFullSpeed();
|
||||
|
||||
Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
|
||||
ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize,
|
||||
ENDPOINT_BANK_SINGLE);
|
||||
|
||||
USB_INT_Enable(USB_INT_BUSEVENTI);
|
||||
|
||||
USB_Attach();
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,319 +1,319 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Controller definitions for the AVR XMEGA microcontrollers.
|
||||
* \copydetails Group_USBManagement_XMEGA
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USBManagement
|
||||
* \defgroup Group_USBManagement_XMEGA USB Interface Management (XMEGA)
|
||||
* \brief USB Controller definitions for the AVR XMEGA microcontrollers.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to the setup and management of the USB interface.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBCONTROLLER_XMEGA_H__
|
||||
#define __USBCONTROLLER_XMEGA_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../../Common/Common.h"
|
||||
#include "../USBMode.h"
|
||||
#include "../Events.h"
|
||||
#include "../USBTask.h"
|
||||
#include "../USBInterrupt.h"
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* External Variables: */
|
||||
extern USB_EP_TABLE_t USB_EndpointTable;
|
||||
#endif
|
||||
|
||||
/* Includes: */
|
||||
#if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
|
||||
#include "../Device.h"
|
||||
#include "../Endpoint.h"
|
||||
#include "../DeviceStandardReq.h"
|
||||
#include "../EndpointStream.h"
|
||||
#endif
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks and Defines: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
#if !defined(F_USB)
|
||||
#error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** \name USB Controller Option Masks */
|
||||
//@{
|
||||
/** Sets the USB bus interrupt priority level to be low priority. The USB bus interrupt is used for Start of Frame events, bus suspend
|
||||
* and resume events, bus reset events and other events related to the management of the USB bus.
|
||||
*/
|
||||
#define USB_OPT_BUSEVENT_PRILOW ((0 << 1) | (0 << 1))
|
||||
|
||||
/** Sets the USB bus interrupt priority level to be medium priority. The USB bus interrupt is used for Start of Frame events, bus suspend
|
||||
* and resume events, bus reset events and other events related to the management of the USB bus.
|
||||
*/
|
||||
#define USB_OPT_BUSEVENT_PRIMED ((0 << 1) | (1 << 1))
|
||||
|
||||
/** Sets the USB bus interrupt priority level to be high priority. The USB bus interrupt is used for Start of Frame events, bus suspend
|
||||
* and resume events, bus reset events and other events related to the management of the USB bus.
|
||||
*/
|
||||
#define USB_OPT_BUSEVENT_PRIHIGH ((1 << 1) | (0 << 1))
|
||||
//@}
|
||||
|
||||
/** \name Endpoint/Pipe Type Masks */
|
||||
//@{
|
||||
/** Mask for a CONTROL type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_CONTROL 0x00
|
||||
|
||||
/** Mask for an ISOCHRONOUS type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_ISOCHRONOUS 0x01
|
||||
|
||||
/** Mask for a BULK type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_BULK 0x02
|
||||
|
||||
/** Mask for an INTERRUPT type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_INTERRUPT 0x03
|
||||
//@}
|
||||
|
||||
#if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)
|
||||
/** Constant for the maximum software timeout period of the USB data stream transfer functions
|
||||
* (both control and standard) when in either device or host mode. If the next packet of a stream
|
||||
* is not received or acknowledged within this time period, the stream function will fail.
|
||||
*
|
||||
* This value may be overridden in the user project makefile as the value of the
|
||||
* \ref USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch.
|
||||
*/
|
||||
#define USB_STREAM_TIMEOUT_MS 100
|
||||
#endif
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Detaches the device from the USB bus. This has the effect of removing the device from any
|
||||
* attached host, ceasing USB communications. If no host is present, this prevents any host from
|
||||
* enumerating the device once attached until \ref USB_Attach() is called.
|
||||
*/
|
||||
static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Detach(void)
|
||||
{
|
||||
USB.CTRLB &= ~USB_ATTACH_bm;
|
||||
}
|
||||
|
||||
/** Attaches the device to the USB bus. This announces the device's presence to any attached
|
||||
* USB host, starting the enumeration process. If no host is present, attaching the device
|
||||
* will allow for enumeration once a host is connected to the device.
|
||||
*
|
||||
* This is inexplicably also required for proper operation while in host mode, to enable the
|
||||
* attachment of a device to the host. This is despite the bit being located in the device-mode
|
||||
* register and despite the datasheet making no mention of its requirement in host mode.
|
||||
*/
|
||||
static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Attach(void)
|
||||
{
|
||||
USB.CTRLB |= USB_ATTACH_bm;
|
||||
}
|
||||
|
||||
/* Function Prototypes: */
|
||||
/** Main function to initialize and start the USB interface. Once active, the USB interface will
|
||||
* allow for device connection to a host when in device mode, or for device enumeration while in
|
||||
* host mode.
|
||||
*
|
||||
* As the USB library relies on interrupts for the device and host mode enumeration processes,
|
||||
* the user must enable global interrupts before or shortly after this function is called. In
|
||||
* device mode, interrupts must be enabled within 500ms of this function being called to ensure
|
||||
* that the host does not time out whilst enumerating the device. In host mode, interrupts may be
|
||||
* enabled at the application's leisure however enumeration will not begin of an attached device
|
||||
* until after this has occurred.
|
||||
*
|
||||
* Calling this function when the USB interface is already initialized will cause a complete USB
|
||||
* interface reset and re-enumeration.
|
||||
*
|
||||
* \param[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value
|
||||
* from the \ref USB_Modes_t enum.
|
||||
*
|
||||
* \param[in] Options Mask indicating the options which should be used when initializing the USB
|
||||
* interface to control the USB interface's behaviour. This should be comprised of
|
||||
* a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the
|
||||
* PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device
|
||||
* mode speed.
|
||||
*
|
||||
* \note To reduce the FLASH requirements of the library if only device or host mode is required,
|
||||
* the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY
|
||||
* (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler
|
||||
* via the -D switch. If the mode is statically set, this parameter does not exist in the
|
||||
* function prototype.
|
||||
* \n\n
|
||||
*
|
||||
* \note To reduce the FLASH requirements of the library if only fixed settings are are required,
|
||||
* the options may be set statically in the same manner as the mode (see the Mode parameter of
|
||||
* this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token,
|
||||
* defined to the appropriate options masks. When the options are statically set, this
|
||||
* parameter does not exist in the function prototype.
|
||||
* \n\n
|
||||
*
|
||||
* \note The mode parameter does not exist on devices where only one mode is possible, such as USB
|
||||
* AVR models which only implement the USB device mode in hardware.
|
||||
*
|
||||
* \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks.
|
||||
*/
|
||||
void USB_Init(
|
||||
#if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)
|
||||
const uint8_t Mode
|
||||
#endif
|
||||
|
||||
#if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__)
|
||||
,
|
||||
#elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))
|
||||
void
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
|
||||
const uint8_t Options
|
||||
#endif
|
||||
);
|
||||
|
||||
/** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO
|
||||
* memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface
|
||||
* is restarted with the \ref USB_Init() function.
|
||||
*/
|
||||
void USB_Disable(void);
|
||||
|
||||
/** Resets the interface, when already initialized. This will re-enumerate the device if already connected
|
||||
* to a host, or re-enumerate an already attached device when in host mode.
|
||||
*/
|
||||
void USB_ResetInterface(void);
|
||||
|
||||
/* Global Variables: */
|
||||
#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__)
|
||||
/** Indicates the mode that the USB interface is currently initialized to, a value from the
|
||||
* \ref USB_Modes_t enum.
|
||||
*
|
||||
* \note This variable should be treated as read-only in the user application, and never manually
|
||||
* changed in value.
|
||||
* \n\n
|
||||
*
|
||||
* \note When the controller is initialized into UID auto-detection mode, this variable will hold the
|
||||
* currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller
|
||||
* is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time
|
||||
* options, or a limitation of the USB controller in the chosen device model) this will evaluate to
|
||||
* a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the
|
||||
* USB interface is not initialized.
|
||||
*/
|
||||
extern volatile uint8_t USB_CurrentMode;
|
||||
#elif defined(USB_DEVICE_ONLY)
|
||||
#define USB_CurrentMode USB_MODE_Device
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
|
||||
/** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init()
|
||||
* was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module.
|
||||
*
|
||||
* \note This variable should be treated as read-only in the user application, and never manually
|
||||
* changed in value.
|
||||
*/
|
||||
extern volatile uint8_t USB_Options;
|
||||
#elif defined(USE_STATIC_OPTIONS)
|
||||
#define USB_Options USE_STATIC_OPTIONS
|
||||
#endif
|
||||
|
||||
/* Enums: */
|
||||
/** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the
|
||||
* user application via \ref USB_CurrentMode.
|
||||
*/
|
||||
enum USB_Modes_t
|
||||
{
|
||||
USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */
|
||||
USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */
|
||||
};
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Function Prototypes: */
|
||||
#if defined(__INCLUDE_FROM_USB_CONTROLLER_C)
|
||||
static void USB_Init_Device(void);
|
||||
#endif
|
||||
|
||||
/* Inline Functions: */
|
||||
static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Controller_Enable(void)
|
||||
{
|
||||
USB.CTRLA |= (USB_ENABLE_bm | USB_STFRNUM_bm | USB_MAXEP_gm);
|
||||
}
|
||||
|
||||
static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Controller_Disable(void)
|
||||
{
|
||||
USB.CTRLA &= ~USB_ENABLE_bm;
|
||||
}
|
||||
|
||||
static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Controller_Reset(void)
|
||||
{
|
||||
USB.CTRLA &= ~USB_ENABLE_bm;
|
||||
USB.CTRLA |= USB_ENABLE_bm;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Controller definitions for the AVR XMEGA microcontrollers.
|
||||
* \copydetails Group_USBManagement_XMEGA
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
/** \ingroup Group_USBManagement
|
||||
* \defgroup Group_USBManagement_XMEGA USB Interface Management (XMEGA)
|
||||
* \brief USB Controller definitions for the AVR XMEGA microcontrollers.
|
||||
*
|
||||
* Functions, macros, variables, enums and types related to the setup and management of the USB interface.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __USBCONTROLLER_XMEGA_H__
|
||||
#define __USBCONTROLLER_XMEGA_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../../Common/Common.h"
|
||||
#include "../USBMode.h"
|
||||
#include "../Events.h"
|
||||
#include "../USBTask.h"
|
||||
#include "../USBInterrupt.h"
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* External Variables: */
|
||||
extern USB_EP_TABLE_t USB_EndpointTable;
|
||||
#endif
|
||||
|
||||
/* Includes: */
|
||||
#if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
|
||||
#include "../Device.h"
|
||||
#include "../Endpoint.h"
|
||||
#include "../DeviceStandardReq.h"
|
||||
#include "../EndpointStream.h"
|
||||
#endif
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks and Defines: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
#if !defined(F_USB)
|
||||
#error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** \name USB Controller Option Masks */
|
||||
//@{
|
||||
/** Sets the USB bus interrupt priority level to be low priority. The USB bus interrupt is used for Start of Frame events, bus suspend
|
||||
* and resume events, bus reset events and other events related to the management of the USB bus.
|
||||
*/
|
||||
#define USB_OPT_BUSEVENT_PRILOW ((0 << 1) | (0 << 1))
|
||||
|
||||
/** Sets the USB bus interrupt priority level to be medium priority. The USB bus interrupt is used for Start of Frame events, bus suspend
|
||||
* and resume events, bus reset events and other events related to the management of the USB bus.
|
||||
*/
|
||||
#define USB_OPT_BUSEVENT_PRIMED ((0 << 1) | (1 << 1))
|
||||
|
||||
/** Sets the USB bus interrupt priority level to be high priority. The USB bus interrupt is used for Start of Frame events, bus suspend
|
||||
* and resume events, bus reset events and other events related to the management of the USB bus.
|
||||
*/
|
||||
#define USB_OPT_BUSEVENT_PRIHIGH ((1 << 1) | (0 << 1))
|
||||
//@}
|
||||
|
||||
/** \name Endpoint/Pipe Type Masks */
|
||||
//@{
|
||||
/** Mask for a CONTROL type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_CONTROL 0x00
|
||||
|
||||
/** Mask for an ISOCHRONOUS type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_ISOCHRONOUS 0x01
|
||||
|
||||
/** Mask for a BULK type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_BULK 0x02
|
||||
|
||||
/** Mask for an INTERRUPT type endpoint or pipe.
|
||||
*
|
||||
* \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
|
||||
*/
|
||||
#define EP_TYPE_INTERRUPT 0x03
|
||||
//@}
|
||||
|
||||
#if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)
|
||||
/** Constant for the maximum software timeout period of the USB data stream transfer functions
|
||||
* (both control and standard) when in either device or host mode. If the next packet of a stream
|
||||
* is not received or acknowledged within this time period, the stream function will fail.
|
||||
*
|
||||
* This value may be overridden in the user project makefile as the value of the
|
||||
* \ref USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch.
|
||||
*/
|
||||
#define USB_STREAM_TIMEOUT_MS 100
|
||||
#endif
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Detaches the device from the USB bus. This has the effect of removing the device from any
|
||||
* attached host, ceasing USB communications. If no host is present, this prevents any host from
|
||||
* enumerating the device once attached until \ref USB_Attach() is called.
|
||||
*/
|
||||
static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Detach(void)
|
||||
{
|
||||
USB.CTRLB &= ~USB_ATTACH_bm;
|
||||
}
|
||||
|
||||
/** Attaches the device to the USB bus. This announces the device's presence to any attached
|
||||
* USB host, starting the enumeration process. If no host is present, attaching the device
|
||||
* will allow for enumeration once a host is connected to the device.
|
||||
*
|
||||
* This is inexplicably also required for proper operation while in host mode, to enable the
|
||||
* attachment of a device to the host. This is despite the bit being located in the device-mode
|
||||
* register and despite the datasheet making no mention of its requirement in host mode.
|
||||
*/
|
||||
static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Attach(void)
|
||||
{
|
||||
USB.CTRLB |= USB_ATTACH_bm;
|
||||
}
|
||||
|
||||
/* Function Prototypes: */
|
||||
/** Main function to initialize and start the USB interface. Once active, the USB interface will
|
||||
* allow for device connection to a host when in device mode, or for device enumeration while in
|
||||
* host mode.
|
||||
*
|
||||
* As the USB library relies on interrupts for the device and host mode enumeration processes,
|
||||
* the user must enable global interrupts before or shortly after this function is called. In
|
||||
* device mode, interrupts must be enabled within 500ms of this function being called to ensure
|
||||
* that the host does not time out whilst enumerating the device. In host mode, interrupts may be
|
||||
* enabled at the application's leisure however enumeration will not begin of an attached device
|
||||
* until after this has occurred.
|
||||
*
|
||||
* Calling this function when the USB interface is already initialized will cause a complete USB
|
||||
* interface reset and re-enumeration.
|
||||
*
|
||||
* \param[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value
|
||||
* from the \ref USB_Modes_t enum.
|
||||
*
|
||||
* \param[in] Options Mask indicating the options which should be used when initializing the USB
|
||||
* interface to control the USB interface's behaviour. This should be comprised of
|
||||
* a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the
|
||||
* PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device
|
||||
* mode speed.
|
||||
*
|
||||
* \note To reduce the FLASH requirements of the library if only device or host mode is required,
|
||||
* the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY
|
||||
* (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler
|
||||
* via the -D switch. If the mode is statically set, this parameter does not exist in the
|
||||
* function prototype.
|
||||
* \n\n
|
||||
*
|
||||
* \note To reduce the FLASH requirements of the library if only fixed settings are are required,
|
||||
* the options may be set statically in the same manner as the mode (see the Mode parameter of
|
||||
* this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token,
|
||||
* defined to the appropriate options masks. When the options are statically set, this
|
||||
* parameter does not exist in the function prototype.
|
||||
* \n\n
|
||||
*
|
||||
* \note The mode parameter does not exist on devices where only one mode is possible, such as USB
|
||||
* AVR models which only implement the USB device mode in hardware.
|
||||
*
|
||||
* \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks.
|
||||
*/
|
||||
void USB_Init(
|
||||
#if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)
|
||||
const uint8_t Mode
|
||||
#endif
|
||||
|
||||
#if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__)
|
||||
,
|
||||
#elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))
|
||||
void
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
|
||||
const uint8_t Options
|
||||
#endif
|
||||
);
|
||||
|
||||
/** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO
|
||||
* memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface
|
||||
* is restarted with the \ref USB_Init() function.
|
||||
*/
|
||||
void USB_Disable(void);
|
||||
|
||||
/** Resets the interface, when already initialized. This will re-enumerate the device if already connected
|
||||
* to a host, or re-enumerate an already attached device when in host mode.
|
||||
*/
|
||||
void USB_ResetInterface(void);
|
||||
|
||||
/* Global Variables: */
|
||||
#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__)
|
||||
/** Indicates the mode that the USB interface is currently initialized to, a value from the
|
||||
* \ref USB_Modes_t enum.
|
||||
*
|
||||
* \note This variable should be treated as read-only in the user application, and never manually
|
||||
* changed in value.
|
||||
* \n\n
|
||||
*
|
||||
* \note When the controller is initialized into UID auto-detection mode, this variable will hold the
|
||||
* currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller
|
||||
* is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time
|
||||
* options, or a limitation of the USB controller in the chosen device model) this will evaluate to
|
||||
* a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the
|
||||
* USB interface is not initialized.
|
||||
*/
|
||||
extern volatile uint8_t USB_CurrentMode;
|
||||
#elif defined(USB_DEVICE_ONLY)
|
||||
#define USB_CurrentMode USB_MODE_Device
|
||||
#endif
|
||||
|
||||
#if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
|
||||
/** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init()
|
||||
* was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module.
|
||||
*
|
||||
* \note This variable should be treated as read-only in the user application, and never manually
|
||||
* changed in value.
|
||||
*/
|
||||
extern volatile uint8_t USB_Options;
|
||||
#elif defined(USE_STATIC_OPTIONS)
|
||||
#define USB_Options USE_STATIC_OPTIONS
|
||||
#endif
|
||||
|
||||
/* Enums: */
|
||||
/** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the
|
||||
* user application via \ref USB_CurrentMode.
|
||||
*/
|
||||
enum USB_Modes_t
|
||||
{
|
||||
USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */
|
||||
USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */
|
||||
};
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Function Prototypes: */
|
||||
#if defined(__INCLUDE_FROM_USB_CONTROLLER_C)
|
||||
static void USB_Init_Device(void);
|
||||
#endif
|
||||
|
||||
/* Inline Functions: */
|
||||
static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Controller_Enable(void)
|
||||
{
|
||||
USB.CTRLA |= (USB_ENABLE_bm | USB_STFRNUM_bm | USB_MAXEP_gm);
|
||||
}
|
||||
|
||||
static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Controller_Disable(void)
|
||||
{
|
||||
USB.CTRLA &= ~USB_ENABLE_bm;
|
||||
}
|
||||
|
||||
static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Controller_Reset(void)
|
||||
{
|
||||
USB.CTRLA &= ~USB_ENABLE_bm;
|
||||
USB.CTRLA |= USB_ENABLE_bm;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,100 +1,100 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBInterrupt.h"
|
||||
|
||||
void USB_INT_DisableAllInterrupts(void)
|
||||
{
|
||||
USB.INTCTRLA = 0;
|
||||
USB.INTCTRLB = 0;
|
||||
}
|
||||
|
||||
void USB_INT_ClearAllInterrupts(void)
|
||||
{
|
||||
USB.INTFLAGSACLR = 0xFF;
|
||||
USB.INTFLAGSBCLR = 0xFF;
|
||||
}
|
||||
|
||||
ISR(USB_BUSEVENT_vect)
|
||||
{
|
||||
#if !defined(NO_SOF_EVENTS)
|
||||
if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_SOFI);
|
||||
|
||||
EVENT_USB_Device_StartOfFrame();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Suspend))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_BUSEVENTI_Suspend);
|
||||
|
||||
#if !defined(NO_LIMITED_CONTROLLER_CONNECT)
|
||||
USB_DeviceState = DEVICE_STATE_Unattached;
|
||||
EVENT_USB_Device_Disconnect();
|
||||
#else
|
||||
USB_DeviceState = DEVICE_STATE_Suspended;
|
||||
EVENT_USB_Device_Suspend();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Resume))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_BUSEVENTI_Resume);
|
||||
|
||||
if (USB_Device_ConfigurationNumber)
|
||||
USB_DeviceState = DEVICE_STATE_Configured;
|
||||
else
|
||||
USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;
|
||||
|
||||
#if !defined(NO_LIMITED_CONTROLLER_CONNECT)
|
||||
EVENT_USB_Device_Connect();
|
||||
#else
|
||||
EVENT_USB_Device_WakeUp();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Reset))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_BUSEVENTI_Reset);
|
||||
|
||||
USB_DeviceState = DEVICE_STATE_Default;
|
||||
USB_Device_ConfigurationNumber = 0;
|
||||
|
||||
Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
|
||||
ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize,
|
||||
ENDPOINT_BANK_SINGLE);
|
||||
|
||||
EVENT_USB_Device_Reset();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define __INCLUDE_FROM_USB_DRIVER
|
||||
#include "../USBInterrupt.h"
|
||||
|
||||
void USB_INT_DisableAllInterrupts(void)
|
||||
{
|
||||
USB.INTCTRLA = 0;
|
||||
USB.INTCTRLB = 0;
|
||||
}
|
||||
|
||||
void USB_INT_ClearAllInterrupts(void)
|
||||
{
|
||||
USB.INTFLAGSACLR = 0xFF;
|
||||
USB.INTFLAGSBCLR = 0xFF;
|
||||
}
|
||||
|
||||
ISR(USB_BUSEVENT_vect)
|
||||
{
|
||||
#if !defined(NO_SOF_EVENTS)
|
||||
if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_SOFI);
|
||||
|
||||
EVENT_USB_Device_StartOfFrame();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Suspend))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_BUSEVENTI_Suspend);
|
||||
|
||||
#if !defined(NO_LIMITED_CONTROLLER_CONNECT)
|
||||
USB_DeviceState = DEVICE_STATE_Unattached;
|
||||
EVENT_USB_Device_Disconnect();
|
||||
#else
|
||||
USB_DeviceState = DEVICE_STATE_Suspended;
|
||||
EVENT_USB_Device_Suspend();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Resume))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_BUSEVENTI_Resume);
|
||||
|
||||
if (USB_Device_ConfigurationNumber)
|
||||
USB_DeviceState = DEVICE_STATE_Configured;
|
||||
else
|
||||
USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;
|
||||
|
||||
#if !defined(NO_LIMITED_CONTROLLER_CONNECT)
|
||||
EVENT_USB_Device_Connect();
|
||||
#else
|
||||
EVENT_USB_Device_WakeUp();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Reset))
|
||||
{
|
||||
USB_INT_Clear(USB_INT_BUSEVENTI_Reset);
|
||||
|
||||
USB_DeviceState = DEVICE_STATE_Default;
|
||||
USB_Device_ConfigurationNumber = 0;
|
||||
|
||||
Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
|
||||
ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize,
|
||||
ENDPOINT_BANK_SINGLE);
|
||||
|
||||
EVENT_USB_Device_Reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,166 +1,166 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Controller Interrupt definitions for the AVR XMEGA microcontrollers.
|
||||
*
|
||||
* This file contains definitions required for the correct handling of low level USB service routine interrupts
|
||||
* from the USB controller.
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
#ifndef __USBINTERRUPT_XMEGA_H__
|
||||
#define __USBINTERRUPT_XMEGA_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../../Common/Common.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Enums: */
|
||||
enum USB_Interrupts_t
|
||||
{
|
||||
USB_INT_BUSEVENTI = 1,
|
||||
USB_INT_BUSEVENTI_Suspend = 2,
|
||||
USB_INT_BUSEVENTI_Resume = 3,
|
||||
USB_INT_BUSEVENTI_Reset = 4,
|
||||
USB_INT_SOFI = 5,
|
||||
};
|
||||
|
||||
/* Inline Functions: */
|
||||
static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_INT_Enable(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_BUSEVENTI:
|
||||
USB.INTCTRLA |= USB_BUSEVIE_bm;
|
||||
return;
|
||||
case USB_INT_SOFI:
|
||||
USB.INTCTRLA |= USB_SOFIE_bm;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_INT_Disable(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_BUSEVENTI:
|
||||
USB.INTCTRLA &= ~USB_BUSEVIE_bm;
|
||||
return;
|
||||
case USB_INT_SOFI:
|
||||
USB.INTCTRLA &= ~USB_SOFIE_bm;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_INT_Clear(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_BUSEVENTI_Suspend:
|
||||
USB.INTFLAGSACLR = USB_SUSPENDIF_bm;
|
||||
return;
|
||||
case USB_INT_BUSEVENTI_Resume:
|
||||
USB.INTFLAGSACLR = USB_RESUMEIF_bm;
|
||||
return;
|
||||
case USB_INT_BUSEVENTI_Reset:
|
||||
USB.INTFLAGSACLR = USB_RSTIF_bm;
|
||||
return;
|
||||
case USB_INT_SOFI:
|
||||
USB.INTFLAGSACLR = USB_SOFIF_bm;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool USB_INT_IsEnabled(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_BUSEVENTI:
|
||||
return (USB.INTCTRLA & USB_BUSEVIE_bm);
|
||||
case USB_INT_SOFI:
|
||||
return (USB.INTCTRLA & USB_SOFIE_bm);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool USB_INT_HasOccurred(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_BUSEVENTI_Suspend:
|
||||
return (USB.INTFLAGSACLR & USB_SUSPENDIF_bm);
|
||||
case USB_INT_BUSEVENTI_Resume:
|
||||
return (USB.INTFLAGSACLR & USB_RESUMEIF_bm);
|
||||
case USB_INT_BUSEVENTI_Reset:
|
||||
return (USB.INTFLAGSACLR & USB_RSTIF_bm);
|
||||
case USB_INT_SOFI:
|
||||
return (USB.INTFLAGSACLR & USB_SOFIF_bm);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Includes: */
|
||||
#include "../USBMode.h"
|
||||
#include "../Events.h"
|
||||
#include "../USBController.h"
|
||||
|
||||
/* Function Prototypes: */
|
||||
void USB_INT_ClearAllInterrupts(void);
|
||||
void USB_INT_DisableAllInterrupts(void);
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief USB Controller Interrupt definitions for the AVR XMEGA microcontrollers.
|
||||
*
|
||||
* This file contains definitions required for the correct handling of low level USB service routine interrupts
|
||||
* from the USB controller.
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||
*/
|
||||
|
||||
#ifndef __USBINTERRUPT_XMEGA_H__
|
||||
#define __USBINTERRUPT_XMEGA_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "../../../../Common/Common.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Enums: */
|
||||
enum USB_Interrupts_t
|
||||
{
|
||||
USB_INT_BUSEVENTI = 1,
|
||||
USB_INT_BUSEVENTI_Suspend = 2,
|
||||
USB_INT_BUSEVENTI_Resume = 3,
|
||||
USB_INT_BUSEVENTI_Reset = 4,
|
||||
USB_INT_SOFI = 5,
|
||||
};
|
||||
|
||||
/* Inline Functions: */
|
||||
static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_INT_Enable(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_BUSEVENTI:
|
||||
USB.INTCTRLA |= USB_BUSEVIE_bm;
|
||||
return;
|
||||
case USB_INT_SOFI:
|
||||
USB.INTCTRLA |= USB_SOFIE_bm;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_INT_Disable(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_BUSEVENTI:
|
||||
USB.INTCTRLA &= ~USB_BUSEVIE_bm;
|
||||
return;
|
||||
case USB_INT_SOFI:
|
||||
USB.INTCTRLA &= ~USB_SOFIE_bm;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_INT_Clear(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_BUSEVENTI_Suspend:
|
||||
USB.INTFLAGSACLR = USB_SUSPENDIF_bm;
|
||||
return;
|
||||
case USB_INT_BUSEVENTI_Resume:
|
||||
USB.INTFLAGSACLR = USB_RESUMEIF_bm;
|
||||
return;
|
||||
case USB_INT_BUSEVENTI_Reset:
|
||||
USB.INTFLAGSACLR = USB_RSTIF_bm;
|
||||
return;
|
||||
case USB_INT_SOFI:
|
||||
USB.INTFLAGSACLR = USB_SOFIF_bm;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool USB_INT_IsEnabled(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_BUSEVENTI:
|
||||
return (USB.INTCTRLA & USB_BUSEVIE_bm);
|
||||
case USB_INT_SOFI:
|
||||
return (USB.INTCTRLA & USB_SOFIE_bm);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool USB_INT_HasOccurred(const uint8_t Interrupt)
|
||||
{
|
||||
switch (Interrupt)
|
||||
{
|
||||
case USB_INT_BUSEVENTI_Suspend:
|
||||
return (USB.INTFLAGSACLR & USB_SUSPENDIF_bm);
|
||||
case USB_INT_BUSEVENTI_Resume:
|
||||
return (USB.INTFLAGSACLR & USB_RESUMEIF_bm);
|
||||
case USB_INT_BUSEVENTI_Reset:
|
||||
return (USB.INTFLAGSACLR & USB_RSTIF_bm);
|
||||
case USB_INT_SOFI:
|
||||
return (USB.INTFLAGSACLR & USB_SOFIF_bm);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Includes: */
|
||||
#include "../USBMode.h"
|
||||
#include "../Events.h"
|
||||
#include "../USBController.h"
|
||||
|
||||
/* Function Prototypes: */
|
||||
void USB_INT_ClearAllInterrupts(void);
|
||||
void USB_INT_DisableAllInterrupts(void);
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue