aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/HighLevel
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-04-05 06:27:49 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-04-05 06:27:49 +0000
commit7d4cccc22d60125fac111819df48af1873d11018 (patch)
treed288ebae796fda45a59122f81c09e43d368de571 /LUFA/Drivers/USB/HighLevel
parent01d388f293ba531008122ebb4cfcf7113a228398 (diff)
downloadlufa-7d4cccc22d60125fac111819df48af1873d11018.tar.gz
lufa-7d4cccc22d60125fac111819df48af1873d11018.tar.bz2
lufa-7d4cccc22d60125fac111819df48af1873d11018.zip
Move StdRequestType.h, StreamCallbacks.h, USBMode.h from the LowLevel USB driver directory to the HighLevel USB driver directory, where they are more suited.
Diffstat (limited to 'LUFA/Drivers/USB/HighLevel')
-rw-r--r--LUFA/Drivers/USB/HighLevel/Events.c2
-rw-r--r--LUFA/Drivers/USB/HighLevel/Events.h2
-rw-r--r--LUFA/Drivers/USB/HighLevel/StdDescriptors.c3
-rw-r--r--LUFA/Drivers/USB/HighLevel/StdDescriptors.h2
-rw-r--r--LUFA/Drivers/USB/HighLevel/StdRequestType.h191
-rw-r--r--LUFA/Drivers/USB/HighLevel/StreamCallbacks.h87
-rw-r--r--LUFA/Drivers/USB/HighLevel/USBInterrupt.c1
-rw-r--r--LUFA/Drivers/USB/HighLevel/USBInterrupt.h2
-rw-r--r--LUFA/Drivers/USB/HighLevel/USBMode.h77
-rw-r--r--LUFA/Drivers/USB/HighLevel/USBTask.c2
-rw-r--r--LUFA/Drivers/USB/HighLevel/USBTask.h2
11 files changed, 363 insertions, 8 deletions
diff --git a/LUFA/Drivers/USB/HighLevel/Events.c b/LUFA/Drivers/USB/HighLevel/Events.c
index dbc428aae..12bf75dbe 100644
--- a/LUFA/Drivers/USB/HighLevel/Events.c
+++ b/LUFA/Drivers/USB/HighLevel/Events.c
@@ -28,7 +28,7 @@
this software.
*/
-#include "../LowLevel/USBMode.h"
+#include "USBMode.h"
#define INCLUDE_FROM_EVENTS_C
#include "Events.h"
diff --git a/LUFA/Drivers/USB/HighLevel/Events.h b/LUFA/Drivers/USB/HighLevel/Events.h
index d53cd8eb0..c9882cfc0 100644
--- a/LUFA/Drivers/USB/HighLevel/Events.h
+++ b/LUFA/Drivers/USB/HighLevel/Events.h
@@ -47,7 +47,7 @@
#include <avr/io.h>
#include "../../../Common/Common.h"
- #include "../LowLevel/USBMode.h"
+ #include "USBMode.h"
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
diff --git a/LUFA/Drivers/USB/HighLevel/StdDescriptors.c b/LUFA/Drivers/USB/HighLevel/StdDescriptors.c
index 5fdc72e80..82ef7a7ce 100644
--- a/LUFA/Drivers/USB/HighLevel/StdDescriptors.c
+++ b/LUFA/Drivers/USB/HighLevel/StdDescriptors.c
@@ -28,7 +28,8 @@
this software.
*/
-#include "../LowLevel/USBMode.h"
+#include "USBMode.h"
+
#if defined(USB_CAN_BE_DEVICE)
#include "StdDescriptors.h"
diff --git a/LUFA/Drivers/USB/HighLevel/StdDescriptors.h b/LUFA/Drivers/USB/HighLevel/StdDescriptors.h
index 491e817a9..7a247cbda 100644
--- a/LUFA/Drivers/USB/HighLevel/StdDescriptors.h
+++ b/LUFA/Drivers/USB/HighLevel/StdDescriptors.h
@@ -52,7 +52,7 @@
#include <stdbool.h>
#include "../../../Common/Common.h"
- #include "../LowLevel/USBMode.h"
+ #include "USBMode.h"
#include "Events.h"
#if defined(USB_CAN_BE_DEVICE)
diff --git a/LUFA/Drivers/USB/HighLevel/StdRequestType.h b/LUFA/Drivers/USB/HighLevel/StdRequestType.h
new file mode 100644
index 000000000..02d4fdc58
--- /dev/null
+++ b/LUFA/Drivers/USB/HighLevel/StdRequestType.h
@@ -0,0 +1,191 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2009.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, and distribute this software
+ and its documentation for any purpose and without fee is hereby
+ granted, 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
+ *
+ * Contains definitions for the various control request parameters, so that the request details (such as data
+ * direction, request recipient, etc.) can be extracted via masking.
+ */
+
+#ifndef __STDREQTYPE_H__
+#define __STDREQTYPE_H__
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device
+ * or Device to Host). The result of this mask should then be compared to the request direction masks.
+ *
+ * \see REQDIR_* macros for masks indicating the request data direction.
+ */
+ #define CONTROL_REQTYPE_DIRECTION 0b10000000
+
+ /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor
+ * Specific). The result of this mask should then be compared to the request type masks.
+ *
+ * \see REQTYPE_* macros for masks indicating the request type.
+ */
+ #define CONTROL_REQTYPE_TYPE 0b01100000
+
+ /** Mask for the request type parameter, to indicate the recipient of the request (Standard, Class
+ * or Vendor Specific). The result of this mask should then be compared to the request recipient
+ * masks.
+ *
+ * \see REQREC_* macros for masks indicating the request recipient.
+ */
+ #define CONTROL_REQTYPE_RECIPIENT 0b00011111
+
+ /** Request data direction mask, indicating that the request data will flow from host to device.
+ *
+ * \see CONTROL_REQTYPE_DIRECTION macro.
+ */
+ #define REQDIR_HOSTTODEVICE (0 << 7)
+
+ /** Request data direction mask, indicating that the request data will flow from device to host.
+ *
+ * \see CONTROL_REQTYPE_DIRECTION macro.
+ */
+ #define REQDIR_DEVICETOHOST (1 << 7)
+
+ /** Request type mask, indicating that the request is a standard request.
+ *
+ * \see CONTROL_REQTYPE_TYPE macro.
+ */
+ #define REQTYPE_STANDARD (0 << 5)
+
+ /** Request type mask, indicating that the request is a class-specific request.
+ *
+ * \see CONTROL_REQTYPE_TYPE macro.
+ */
+ #define REQTYPE_CLASS (1 << 5)
+
+ /** Request type mask, indicating that the request is a vendor specific request.
+ *
+ * \see CONTROL_REQTYPE_TYPE macro.
+ */
+ #define REQTYPE_VENDOR (2 << 5)
+
+ /** Request recipient mask, indicating that the request is to be issued to the device as a whole.
+ *
+ * \see CONTROL_REQTYPE_RECIPIENT macro.
+ */
+ #define REQREC_DEVICE (0 << 0)
+
+ /** Request recipient mask, indicating that the request is to be issued to an interface in the
+ * currently selected configuration.
+ *
+ * \see CONTROL_REQTYPE_RECIPIENT macro.
+ */
+ #define REQREC_INTERFACE (1 << 0)
+
+ /** Request recipient mask, indicating that the request is to be issued to an endpoint in the
+ * currently selected configuration.
+ *
+ * \see CONTROL_REQTYPE_RECIPIENT macro.
+ */
+ #define REQREC_ENDPOINT (2 << 0)
+
+ /** Request recipient mask, indicating that the request is to be issued to an unspecified element
+ * in the currently selected configuration.
+ *
+ * \see CONTROL_REQTYPE_RECIPIENT macro.
+ */
+ #define REQREC_OTHER (3 << 0)
+
+ /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
+ * request this indicates that an endpoint (whose address is given elsewhere in the request
+ * should have its stall condition cleared. If used in a similar manner inside a Set Feature
+ * request, this stalls an endpoint.
+ */
+ #define FEATURE_ENDPOINT_HALT 0x00
+
+ /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
+ * request this indicates that the remote wakeup enabled device should not issue remote
+ * wakeup requests until further notice. If used in a similar manner inside a Set Feature
+ * request, this re-enabled the remote wakeup feature on the device.
+ */
+ #define FEATURE_REMOTE_WAKEUP 0x01
+
+ /* Enums: */
+ /** Enumeration for the various standard request commands. These commands are applicable when the
+ * request type is REQTYPE_STANDARD (with the exception of REQ_GetDescriptor, which is always
+ * handled regardless of the request type value).
+ *
+ * \see Chapter 9 of the USB 2.0 Specification.
+ */
+ enum USB_Control_Request_t
+ {
+ REQ_GetStatus = 0, /**< Implemented in the library for device, endpoint and interface
+ * recipients. Passed to the user application for other recipients
+ * via the USB_UnhandledControlPacket() event when received in
+ * device mode. */
+ REQ_ClearFeature = 1, /**< Implemented in the library for device, endpoint and interface
+ * recipients. Passed to the user application for other recipients
+ * via the USB_UnhandledControlPacket() event when received in
+ * device mode. */
+ REQ_SetFeature = 3, /**< Implemented in the library for device, endpoint and interface
+ * recipients. Passed to the user application for other recipients
+ * via the USB_UnhandledControlPacket() event when received in
+ * device mode. */
+ REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed
+ * to the user application for other recipients via the
+ * USB_UnhandledControlPacket() event when received in
+ * device mode. */
+ REQ_GetDescriptor = 6, /**< Implemented in the library for all recipients and all request
+ * types. */
+ REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application
+ * via the USB_UnhandledControlPacket() event when received in
+ * device mode. */
+ REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed
+ * to the user application for other recipients via the
+ * USB_UnhandledControlPacket() event when received in
+ * device mode. */
+ REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed
+ * to the user application for other recipients via the
+ * USB_UnhandledControlPacket() event when received in
+ * device mode. */
+ REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application
+ * via the USB_UnhandledControlPacket() event when received in
+ * device mode. */
+ REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application
+ * via the USB_UnhandledControlPacket() event when received in
+ * device mode. */
+ REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application
+ * via the USB_UnhandledControlPacket() event when received in
+ * device mode. */
+ };
+
+/* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Macros: */
+ #define FEATURE_SELFPOWERED_ENABLED (1 << 0)
+ #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1)
+ #endif
+
+#endif
diff --git a/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h b/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h
new file mode 100644
index 000000000..5c2dad637
--- /dev/null
+++ b/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h
@@ -0,0 +1,87 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2009.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, and distribute this software
+ and its documentation for any purpose and without fee is hereby
+ granted, 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
+ *
+ * Macros and enums for the stream callback routines in Endpoint.h and Pipe.c. This module contains the
+ * code required to easily set up stream callback functions which can be used to force early abort of a
+ * stream read/write process.
+ */
+
+#ifndef __STREAMCALLBACK_H__
+#define __STREAMCALLBACK_H__
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** Creates a prototype for or begins a stream callback routine. Stream callback routines are small
+ * routines which are executed during stream read or writes (if the callback-enabled versions of
+ * these functions are used) which allow the user application to abort the transfer when certain
+ * arbitrary conditions are met.
+ *
+ * Stream callback functions should return a value from the StreamCallback_Return_ErrorCodes_t
+ * enum.
+ *
+ * Usage Example (Device Endpoint, but applicable for Host Pipes also):
+ * \code
+ * STREAM_CALLBACK(GlobalNotSet); // Callback Prototype
+ *
+ * STREAM_CALLBACK(GlobalNotSet)
+ * {
+ * if (MyGlobal == false)
+ * return ENDPOINT_STREAMCALLBACK_Continue;
+ * else
+ * return ENDPOINT_STREAMCALLBACK_Abort;
+ * }
+ *
+ * //...
+ * // Inside some routine:
+ * if (Endpoint_Write_Stream_LE(DataBuffer, sizeof(DataBuffer), GlobalNotSet) ==
+ * ENDPOINT_RWSTREAM_ERROR_CallbackAborted)
+ * {
+ * // Do something when the callback aborted the transfer early
+ * }
+ * \endcode
+ */
+ #define STREAM_CALLBACK(name) uint8_t name (void)
+
+ /** Used with the Endpoint and Pipe stream functions as the callback function parameter, indicating that the stream
+ * call has no callback function to be called between USB packets.
+ */
+ #define NO_STREAM_CALLBACK NULL
+
+ /* Enums: */
+ /** Enum for the possible error return codes of a stream callback function */
+ enum StreamCallback_Return_ErrorCodes_t
+ {
+ STREAMCALLBACK_Continue = 0, /**< Continue sending or receiving the stream. */
+ STREAMCALLBACK_Abort = 1, /**< Abort the stream send or receiving process. */
+ };
+
+#endif
diff --git a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c
index 58faa69de..93bd6d084 100644
--- a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c
+++ b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c
@@ -28,7 +28,6 @@
this software.
*/
-#include "../LowLevel/USBMode.h"
#include "USBInterrupt.h"
void USB_INT_DisableAllInterrupts(void)
diff --git a/LUFA/Drivers/USB/HighLevel/USBInterrupt.h b/LUFA/Drivers/USB/HighLevel/USBInterrupt.h
index 20b89eba1..d54de3920 100644
--- a/LUFA/Drivers/USB/HighLevel/USBInterrupt.h
+++ b/LUFA/Drivers/USB/HighLevel/USBInterrupt.h
@@ -43,7 +43,7 @@
#include "../../../Common/Common.h"
#include "../LowLevel/LowLevel.h"
- #include "../LowLevel/USBMode.h"
+ #include "USBMode.h"
#include "Events.h"
/* Enable C linkage for C++ Compilers: */
diff --git a/LUFA/Drivers/USB/HighLevel/USBMode.h b/LUFA/Drivers/USB/HighLevel/USBMode.h
new file mode 100644
index 000000000..138af9ed0
--- /dev/null
+++ b/LUFA/Drivers/USB/HighLevel/USBMode.h
@@ -0,0 +1,77 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2009.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, and distribute this software
+ and its documentation for any purpose and without fee is hereby
+ granted, 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.
+*/
+
+#ifndef __USBMODE_H__
+#define __USBMODE_H__
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Macros: */
+ #if ((defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
+ defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \
+ defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \
+ defined(__AVR_ATmega32U6__)) && !defined(USB_DEVICE_ONLY))
+ #define USB_DEVICE_ONLY
+ #endif
+
+ #if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__))
+ #define USB_LIMITED_CONTROLLER
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
+ #define USB_MODIFIED_FULL_CONTROLLER
+ #else
+ #define USB_FULL_CONTROLLER
+ #endif
+
+ #if (!defined(USB_DEVICE_ONLY) && !defined(USB_HOST_ONLY))
+ #define USB_CAN_BE_BOTH
+ #define USB_CAN_BE_HOST
+ #define USB_CAN_BE_DEVICE
+ #elif defined(USB_HOST_ONLY)
+ #define USB_CAN_BE_HOST
+ #define USB_CurrentMode USB_MODE_HOST
+ #elif defined(USB_DEVICE_ONLY)
+ #define USB_CAN_BE_DEVICE
+ #define USB_CurrentMode USB_MODE_DEVICE
+ #endif
+
+ #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY))
+ #error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive.
+ #endif
+
+ #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))
+ #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
+ #endif
+
+ #if defined(USE_STATIC_OPTIONS)
+ #define USB_Options USE_STATIC_OPTIONS
+ #endif
+ #endif
+
+#endif
diff --git a/LUFA/Drivers/USB/HighLevel/USBTask.c b/LUFA/Drivers/USB/HighLevel/USBTask.c
index c58e237e3..395f2d25e 100644
--- a/LUFA/Drivers/USB/HighLevel/USBTask.c
+++ b/LUFA/Drivers/USB/HighLevel/USBTask.c
@@ -28,7 +28,7 @@
this software.
*/
-#include "../LowLevel/USBMode.h"
+#include "USBMode.h"
#define INCLUDE_FROM_USBTASK_C
#include "USBTask.h"
diff --git a/LUFA/Drivers/USB/HighLevel/USBTask.h b/LUFA/Drivers/USB/HighLevel/USBTask.h
index c8180f588..e0ca8ede8 100644
--- a/LUFA/Drivers/USB/HighLevel/USBTask.h
+++ b/LUFA/Drivers/USB/HighLevel/USBTask.h
@@ -46,7 +46,7 @@
#include "../../../Scheduler/Scheduler.h"
#include "../LowLevel/LowLevel.h"
- #include "../LowLevel/USBMode.h"
+ #include "USBMode.h"
#include "Events.h"
#include "StdDescriptors.h"