Commit 381dd0d4 authored by Dean Camera's avatar Dean Camera

Move out common architecture-independent core definitions into the appropriate...

Move out common architecture-independent core definitions into the appropriate core dispatch header files.
parent f3f48118
This diff is collapsed.
......@@ -92,6 +92,7 @@
typedef uint32_t uint_reg_t;
// TODO
#define EEMEM
#define PROGMEM const
#define ISR(Name) void Name (void)
......
......@@ -126,35 +126,6 @@
*/
void USB_Device_SendRemoteWakeup(void);
/* Type Defines: */
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.
*/
};
/* 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.
......
......@@ -174,11 +174,6 @@
*/
#define ENDPOINT_BANK_DOUBLE (1 << EPBK0)
//@}
/** 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
#if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))
/** Default size of the default control endpoint's bank, until altered by the control endpoint bank size
......@@ -187,16 +182,6 @@
#define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8
#endif
/** 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
/** Retrives the maximum bank size in bytes of a given endpoint.
*
* \note This macro will only work correctly on endpoint indexes that are compile-time constants
......
......@@ -97,109 +97,6 @@
#define HOST_DEVICE_SETTLE_DELAY_MS 1000
#endif
/* Enums: */
/** Enum for the various states of the USB Host 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 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_WaitForDeviceRemoval = 0, /**< Internally implemented by the library. This state can be
* used by the library to wait until the attached device is
* removed by the user - useful for when an error occurs or
* further communication with the device is not needed. This
* allows for other code to run while the state machine is
* effectively disabled.
*/
HOST_STATE_WaitForDevice = 1, /**< Internally implemented by the library. This state indicates
* that the stack is waiting for an interval to elapse before
* continuing with the next step of the device enumeration
* process.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Unattached = 2, /**< Internally implemented by the library. This state indicates
* that the host state machine is waiting for a device to be
* attached so that it can start the enumeration process.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Powered = 3, /**< Internally implemented by the library. This state indicates
* that a device has been attached, and the library's internals
* are being configured to begin the enumeration process.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Powered_WaitForDeviceSettle = 4, /**< Internally implemented by the library. This state indicates
* that the stack is waiting for the initial settling period to
* elapse before beginning the enumeration process.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Powered_WaitForConnect = 5, /**< Internally implemented by the library. 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.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Powered_DoReset = 6, /**< Internally implemented by the library. This state indicates
* that a valid USB device has been attached, and that it is
* will now be reset to ensure it is ready for enumeration.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Powered_ConfigPipe = 7, /**< Internally implemented by the library. This state indicates
* that the attached device is currently powered and reset, and
* that the control pipe is now being configured by the stack.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Default = 8, /**< Internally implemented by the library. 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.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Default_PostReset = 9, /**< Internally implemented by the library. 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.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Default_PostAddressSet = 10, /**< Internally implemented by the library. 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 user-implemented
* \ref HOST_STATE_Addressed state for further communications.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Addressed = 11, /**< May be implemented by the user project. This state should
* set the device configuration before progressing to the
* \ref HOST_STATE_Configured state. Other processing (such as the
* retrieval and processing of the device descriptor) should also
* be placed in this state.
*/
HOST_STATE_Configured = 12, /**< May be implemented by the user project. This state should implement the
* actual work performed on the attached device and changed to the
* \ref HOST_STATE_Suspended or \ref HOST_STATE_WaitForDeviceRemoval states as needed.
*/
HOST_STATE_Suspended = 15, /**< May be implemented by the user project. This state should be maintained
* while the bus is suspended, and changed to either the \ref HOST_STATE_Configured
* (after resuming the bus with the USB_Host_ResumeBus() macro) or the
* \ref HOST_STATE_WaitForDeviceRemoval states as needed.
*/
};
/** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event.
*
* \see \ref Group_Events for more information on this event.
......
......@@ -155,22 +155,12 @@
*/
#define PIPE_BANK_DOUBLE (1 << EPBK0)
//@}
/** 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
/** Default size of the default control pipe's bank, until altered by the Endpoint0Size value
* in the device descriptor of the attached device.
*/
#define PIPE_CONTROLPIPE_DEFAULT_SIZE 64
/** Pipe number mask, for masking against pipe addresses to retrieve the pipe's numerical address
* in the device.
*/
#define PIPE_PIPENUM_MASK 0x07
/** Total number of pipes (including the default control pipe at address 0) which may be used in
* the device. Different USB AVR models support different amounts of pipes, this value reflects
* the maximum number of pipes for the currently selected AVR model.
......@@ -184,16 +174,6 @@
*/
#define PIPE_MAX_SIZE 256
/** 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
/* Enums: */
/** Enum for the possible error return codes of the \ref Pipe_WaitUntilReady() function.
*
......
......@@ -54,12 +54,6 @@
#include "StdDescriptors.h"
#include "USBInterrupt.h"
#include "Endpoint.h"
#if (ARCH == ARCH_AVR8)
#include "AVR8/Device_AVR8.h"
#elif (ARCH == ARCH_UC3B)
#include "UC3B/Device_UC3B.h"
#endif
/* Preprocessor Checks: */
#if !defined(__INCLUDE_FROM_USB_DRIVER)
......@@ -67,6 +61,35 @@
#endif
/* Public Interface - May be used in end-application: */
/* Enums: */
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
......@@ -101,6 +124,13 @@
#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_UC3B)
#include "UC3B/Device_UC3B.h"
#endif
#endif
/** @} */
......
......@@ -75,17 +75,35 @@
/* Includes: */
#include "../../../Common/Common.h"
/* 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_UC3B)
#include "UC3B/Endpoint_UC3B.h"
#endif
/* Preprocessor Checks: */
#if !defined(__INCLUDE_FROM_USB_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
#endif
/** @} */
......
......@@ -52,17 +52,122 @@
/* Includes: */
#include "../../../Common/Common.h"
/* 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. Only some states are
* implemented in the LUFA library - other states are left to the user to implement.
*
* 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_WaitForDeviceRemoval = 0, /**< Internally implemented by the library. This state can be
* used by the library to wait until the attached device is
* removed by the user - useful for when an error occurs or
* further communication with the device is not needed. This
* allows for other code to run while the state machine is
* effectively disabled.
*/
HOST_STATE_WaitForDevice = 1, /**< Internally implemented by the library. This state indicates
* that the stack is waiting for an interval to elapse before
* continuing with the next step of the device enumeration
* process.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Unattached = 2, /**< Internally implemented by the library. This state indicates
* that the host state machine is waiting for a device to be
* attached so that it can start the enumeration process.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Powered = 3, /**< Internally implemented by the library. This state indicates
* that a device has been attached, and the library's internals
* are being configured to begin the enumeration process.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Powered_WaitForDeviceSettle = 4, /**< Internally implemented by the library. This state indicates
* that the stack is waiting for the initial settling period to
* elapse before beginning the enumeration process.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Powered_WaitForConnect = 5, /**< Internally implemented by the library. 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.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Powered_DoReset = 6, /**< Internally implemented by the library. This state indicates
* that a valid USB device has been attached, and that it is
* will now be reset to ensure it is ready for enumeration.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Powered_ConfigPipe = 7, /**< Internally implemented by the library. This state indicates
* that the attached device is currently powered and reset, and
* that the control pipe is now being configured by the stack.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Default = 8, /**< Internally implemented by the library. 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.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Default_PostReset = 9, /**< Internally implemented by the library. 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.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Default_PostAddressSet = 10, /**< Internally implemented by the library. 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 user-implemented
* \ref HOST_STATE_Addressed state for further communications.
*
* \note Do not manually change to this state in the user code.
*/
HOST_STATE_Addressed = 11, /**< May be implemented by the user project. This state should
* set the device configuration before progressing to the
* \ref HOST_STATE_Configured state. Other processing (such as the
* retrieval and processing of the device descriptor) should also
* be placed in this state.
*/
HOST_STATE_Configured = 12, /**< May be implemented by the user project. This state should implement the
* actual work performed on the attached device and changed to the
* \ref HOST_STATE_Suspended or \ref HOST_STATE_WaitForDeviceRemoval states as needed.
*/
HOST_STATE_Suspended = 15, /**< May be implemented by the user project. This state should be maintained
* while the bus is suspended, and changed to either the \ref HOST_STATE_Configured
* (after resuming the bus with the USB_Host_ResumeBus() macro) or the
* \ref HOST_STATE_WaitForDeviceRemoval states as needed.
*/
};
/* Architecture Includes: */
#if (ARCH == ARCH_AVR8)
#include "AVR8/Host_AVR8.h"
#elif (ARCH == ARCH_UC3B)
#include "UC3B/Host_UC3B.h"
#endif
/* Preprocessor Checks: */
#if !defined(__INCLUDE_FROM_USB_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
#endif
/** @} */
......
......@@ -52,16 +52,17 @@
/* Includes: */
#include "../../../Common/Common.h"
#if (ARCH == ARCH_AVR8)
#include "AVR8/OTG_AVR8.h"
#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
#endif
/** @} */
......
......@@ -85,17 +85,40 @@
/* Includes: */
#include "../../../Common/Common.h"
/* 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_UC3B)
#include "UC3B/Pipe_UC3B.h"
#endif
/* Preprocessor Checks: */
#if !defined(__INCLUDE_FROM_USB_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
#endif
/** @} */
......
......@@ -115,35 +115,6 @@
*/
void USB_Device_SendRemoteWakeup(void);
/* Type Defines: */
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.
*/
};
/* 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.
......
......@@ -120,7 +120,7 @@
/* Inline Functions: */
static inline uint32_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST
ATTR_ALWAYS_INLINE;
ATTR_ALWAYS_INLINE;
static inline uint32_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)
{
uint8_t MaskVal = 0;
......@@ -182,11 +182,6 @@
*/
#define ENDPOINT_BANK_TRIPLE AVR32_USBB_UECFG0_EPBK_TRIPLE
//@}
/** 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
#if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))
/** Default size of the default control endpoint's bank, until altered by the control endpoint bank size
......@@ -195,16 +190,6 @@
#define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8
#endif
/** 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
/** Retrives the maximum bank size in bytes of a given endpoint.
*
* \note This macro will only work correctly on endpoint indexes that are compile-time constants
......
......@@ -98,108 +98,6 @@
#endif
/* Enums: */
/** Enum for the various states of the USB Host 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 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_WaitForDeviceRemoval = 0, /**< Internally implemented by the library. This state can be
* used by the library to wait until the attached device is