aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-04-17 08:33:53 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-04-17 08:33:53 +0000
commit32e735b2b2eefb74e0415a5826692f7ba8c0a984 (patch)
tree09bb85a81dfe3c2e5e2137b2ad1b2547063aee58 /LUFA/Drivers
parentd38fa49cb6cb3804c9bb17601688a62ba466b535 (diff)
downloadlufa-32e735b2b2eefb74e0415a5826692f7ba8c0a984.tar.gz
lufa-32e735b2b2eefb74e0415a5826692f7ba8c0a984.tar.bz2
lufa-32e735b2b2eefb74e0415a5826692f7ba8c0a984.zip
Removed "Host_" section of the function names in ConfigDescriptor.h, as most of the routines can now be used in device mode on the device descriptor.
Renamed functions in the HID parser to have a "USB_" prefix and the acronym "HID" in the name. Further module-level documentation updates.
Diffstat (limited to 'LUFA/Drivers')
-rw-r--r--LUFA/Drivers/USB/Class/ConfigDescriptor.c45
-rw-r--r--LUFA/Drivers/USB/Class/ConfigDescriptor.h168
-rw-r--r--LUFA/Drivers/USB/Class/HIDParser.h12
-rw-r--r--LUFA/Drivers/USB/HighLevel/USBInterrupt.h6
4 files changed, 118 insertions, 113 deletions
diff --git a/LUFA/Drivers/USB/Class/ConfigDescriptor.c b/LUFA/Drivers/USB/Class/ConfigDescriptor.c
index ecd58791c..61a5c445c 100644
--- a/LUFA/Drivers/USB/Class/ConfigDescriptor.c
+++ b/LUFA/Drivers/USB/Class/ConfigDescriptor.c
@@ -28,13 +28,10 @@
this software.
*/
-#include "../HighLevel/USBMode.h"
-
-#if defined(USB_CAN_BE_HOST)
-
#include "ConfigDescriptor.h"
-uint8_t USB_Host_GetDeviceConfigDescriptor(uint16_t* const ConfigSizePtr, void* BufferPtr)
+#if defined(USB_CAN_BE_HOST)
+uint8_t USB_GetDeviceConfigDescriptor(uint16_t* const ConfigSizePtr, void* BufferPtr)
{
uint8_t ErrorCode;
@@ -70,28 +67,29 @@ uint8_t USB_Host_GetDeviceConfigDescriptor(uint16_t* const ConfigSizePtr, void*
return ErrorCode;
}
+#endif
-void USB_Host_GetNextDescriptorOfType(uint16_t* const BytesRem,
- uint8_t** const CurrConfigLoc,
- const uint8_t Type)
+void USB_GetNextDescriptorOfType(uint16_t* const BytesRem,
+ uint8_t** const CurrConfigLoc,
+ const uint8_t Type)
{
while (*BytesRem)
{
- USB_Host_GetNextDescriptor(BytesRem, CurrConfigLoc);
+ USB_GetNextDescriptor(BytesRem, CurrConfigLoc);
if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type)
return;
}
}
-void USB_Host_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,
- uint8_t** const CurrConfigLoc,
- const uint8_t Type,
- const uint8_t BeforeType)
+void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,
+ uint8_t** const CurrConfigLoc,
+ const uint8_t Type,
+ const uint8_t BeforeType)
{
while (*BytesRem)
{
- USB_Host_GetNextDescriptor(BytesRem, CurrConfigLoc);
+ USB_GetNextDescriptor(BytesRem, CurrConfigLoc);
if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type)
{
@@ -105,19 +103,18 @@ void USB_Host_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,
}
}
-void USB_Host_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
- uint8_t** const CurrConfigLoc,
- const uint8_t Type,
- const uint8_t AfterType)
+void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
+ uint8_t** const CurrConfigLoc,
+ const uint8_t Type,
+ const uint8_t AfterType)
{
- USB_Host_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, AfterType);
+ USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, AfterType);
if (*BytesRem)
- USB_Host_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type);
+ USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type);
}
-uint8_t USB_Host_GetNextDescriptorComp_P(uint16_t* BytesRem, uint8_t** CurrConfigLoc,
- uint8_t (* const ComparatorRoutine)(void*))
+uint8_t USB_GetNextDescriptorComp_P(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ComparatorPtr_t ComparatorRoutine)
{
uint8_t ErrorCode;
@@ -126,7 +123,7 @@ uint8_t USB_Host_GetNextDescriptorComp_P(uint16_t* BytesRem, uint8_t** CurrConfi
uint8_t* PrevDescLoc = *CurrConfigLoc;
uint16_t PrevBytesRem = *BytesRem;
- USB_Host_GetNextDescriptor(BytesRem, CurrConfigLoc);
+ USB_GetNextDescriptor(BytesRem, CurrConfigLoc);
if ((ErrorCode = ComparatorRoutine(*CurrConfigLoc)) != Descriptor_Search_NotFound)
{
@@ -142,5 +139,3 @@ uint8_t USB_Host_GetNextDescriptorComp_P(uint16_t* BytesRem, uint8_t** CurrConfi
return Descriptor_Search_Comp_EndOfDescriptor;
}
-
-#endif
diff --git a/LUFA/Drivers/USB/Class/ConfigDescriptor.h b/LUFA/Drivers/USB/Class/ConfigDescriptor.h
index d5fcbb0bb..7a1d53118 100644
--- a/LUFA/Drivers/USB/Class/ConfigDescriptor.h
+++ b/LUFA/Drivers/USB/Class/ConfigDescriptor.h
@@ -50,6 +50,7 @@
#include <avr/io.h>
#include "../../../Common/Common.h"
+ #include "../HighLevel/USBMode.h"
#include "../LowLevel/HostChapter9.h"
#include "../HighLevel/StdDescriptors.h"
@@ -58,7 +59,7 @@
extern "C" {
#endif
- /* Public Interface - May be used in end-application: */
+ /* Public Interface - May be used in end-application: */
/* Macros: */
/** Mask for determining the type of an endpoint from an endpoint descriptor. This should then be compared
* with the EP_TYPE_* masks to determine the exact type of the endpoint.
@@ -121,42 +122,49 @@
*/
#define DESCRIPTOR_COMPARATOR(name) uint8_t DCOMP_##name (void* const CurrentDescriptor)
- /** Searches for the next descriptor in the given configuration descriptor using a premade comparator
- * function. The routine updates the position and remaining configuration descriptor bytes values
- * automatically. If a comparator routine fails a search, the descriptor pointer is retreated back
- * so that the next descriptor search invocation will start from the descriptor which first caused the
- * original search to fail. This behaviour allows for one comparator to be used immediately after another
- * has failed, starting the second search from the descriptor which failed the first.
- *
- * \param DSize Pointer to an int storing the remaining bytes in the configuration descriptor
- * \param DPos Pointer to the current position in the configuration descriptor
- * \param DSearch Name of the comparator search function to use on the configuration descriptor
- *
- * \return Value of one of the members of the DSearch_Comp_Return_ErrorCodes_t enum
- *
- * Usage Example:
- * \code
- * DESCRIPTOR_COMPARATOR(EndpointSearcher); // Comparator Prototype
- *
- * DESCRIPTOR_COMPARATOR(EndpointSearcher)
- * {
- * if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
- * return Descriptor_Search_Found;
- * else
- * return Descriptor_Search_NotFound;
- * }
- *
- * //...
- * // After retrieving configuration descriptor:
- * if (USB_Host_GetNextDescriptorComp(&BytesRemaining, &ConfigDescriptorData, EndpointSearcher) ==
- * Descriptor_Search_Comp_Found)
- * {
- * // Do something with the endpoint descriptor
- * }
- * \endcode
- */
- #define USB_Host_GetNextDescriptorComp(DSize, DPos, DSearch) \
- USB_Host_GetNextDescriptorComp_P(DSize, DPos, DCOMP_##DSearch)
+ /* Psuedo-Functions: */
+ #if defined(__DOXYGEN__)
+ /** Searches for the next descriptor in the given configuration descriptor using a premade comparator
+ * function. The routine updates the position and remaining configuration descriptor bytes values
+ * automatically. If a comparator routine fails a search, the descriptor pointer is retreated back
+ * so that the next descriptor search invocation will start from the descriptor which first caused the
+ * original search to fail. This behaviour allows for one comparator to be used immediately after another
+ * has failed, starting the second search from the descriptor which failed the first.
+ *
+ * \note This function is available in USB Host mode only.
+ *
+ * \param BytesRem Pointer to an int storing the remaining bytes in the configuration descriptor
+ * \param CurrConfigLoc Pointer to the current position in the configuration descriptor
+ * \param ComparatorRoutine Name of the comparator search function to use on the configuration descriptor
+ *
+ * \return Value of one of the members of the DSearch_Comp_Return_ErrorCodes_t enum
+ *
+ * Usage Example:
+ * \code
+ * DESCRIPTOR_COMPARATOR(EndpointSearcher); // Comparator Prototype
+ *
+ * DESCRIPTOR_COMPARATOR(EndpointSearcher)
+ * {
+ * if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+ * return Descriptor_Search_Found;
+ * else
+ * return Descriptor_Search_NotFound;
+ * }
+ *
+ * //...
+ * // After retrieving configuration descriptor:
+ * if (USB_Host_GetNextDescriptorComp(&BytesRemaining, &ConfigDescriptorData, EndpointSearcher) ==
+ * Descriptor_Search_Comp_Found)
+ * {
+ * // Do something with the endpoint descriptor
+ * }
+ * \endcode
+ */
+ uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ComparatorPtr_t ComparatorRoutine);
+ #else
+ #define USB_GetNextDescriptorComp(DSize, DPos, DSearch) USB_GetNextDescriptorComp_P(DSize, DPos, DCOMP_##DSearch)
+ #endif
+
/* Enums: */
/** Enum for return values of a descriptor comparator made with DESCRIPTOR_COMPARATOR. */
enum DSearch_Return_ErrorCodes_t
@@ -166,7 +174,7 @@
Descriptor_Search_NotFound = 2, /**< Current descriptor does not match comparator criteria. */
};
- /** Enum for return values of USB_Host_GetNextDescriptorComp() */
+ /** Enum for return values of USB_GetNextDescriptorComp(). */
enum DSearch_Comp_Return_ErrorCodes_t
{
Descriptor_Search_Comp_Found = 0, /**< Configuration descriptor now points to descriptor which matches
@@ -187,31 +195,8 @@
* of bytes indicated by ConfigSizePtr of the configuration descriptor will be loaded
* into the buffer
*/
- uint8_t USB_Host_GetDeviceConfigDescriptor(uint16_t* const ConfigSizePtr, void* BufferPtr)
- ATTR_NON_NULL_PTR_ARG(1);
-
- /* Inline Functions: */
- /** Skips over the current sub-descriptor inside the configuration descriptor, so that the pointer then
- points to the next sub-descriptor. The bytes remaining value is automatically decremented.
- *
- * \param BytesRem Pointer to the number of bytes remaining of the configuration descriptor
- * \param CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor
- */
- static inline void USB_Host_GetNextDescriptor(uint16_t* const BytesRem,
- uint8_t** const CurrConfigLoc)
- ATTR_NON_NULL_PTR_ARG(1, 2);
- static inline void USB_Host_GetNextDescriptor(uint16_t* const BytesRem,
- uint8_t** const CurrConfigLoc)
- {
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
- uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size;
- #else
- uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).bLength;
- #endif
-
- *CurrConfigLoc += CurrDescriptorSize;
- *BytesRem -= CurrDescriptorSize;
- }
+ uint8_t USB_GetDeviceConfigDescriptor(uint16_t* const ConfigSizePtr, void* BufferPtr)
+ ATTR_NON_NULL_PTR_ARG(1);
/** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value.
* The bytes remaining value is automatically decremented.
@@ -220,10 +205,10 @@
* \param CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor
* \param Type Descriptor type value to search for
*/
- void USB_Host_GetNextDescriptorOfType(uint16_t* const BytesRem,
- uint8_t** const CurrConfigLoc,
- const uint8_t Type)
- ATTR_NON_NULL_PTR_ARG(1, 2);
+ void USB_GetNextDescriptorOfType(uint16_t* const BytesRem,
+ uint8_t** const CurrConfigLoc,
+ const uint8_t Type)
+ ATTR_NON_NULL_PTR_ARG(1, 2);
/** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value,
* which must come before a descriptor of the second given type value. If the BeforeType type
@@ -235,11 +220,11 @@
* \param Type Descriptor type value to search for
* \param BeforeType Descriptor type value which must not be reached before the given Type descriptor
*/
- void USB_Host_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,
- uint8_t** const CurrConfigLoc,
- const uint8_t Type,
- const uint8_t BeforeType)
- ATTR_NON_NULL_PTR_ARG(1, 2);
+ void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,
+ uint8_t** const CurrConfigLoc,
+ const uint8_t Type,
+ const uint8_t BeforeType)
+ ATTR_NON_NULL_PTR_ARG(1, 2);
/** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value,
* which must come after a descriptor of the second given type value. The bytes remaining value is
@@ -250,17 +235,42 @@
* \param Type Descriptor type value to search for
* \param AfterType Descriptor type value which must be reached before the given Type descriptor
*/
- void USB_Host_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
- uint8_t** const CurrConfigLoc,
- const uint8_t Type,
- const uint8_t AfterType)
- ATTR_NON_NULL_PTR_ARG(1, 2);
+ void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
+ uint8_t** const CurrConfigLoc,
+ const uint8_t Type,
+ const uint8_t AfterType)
+ ATTR_NON_NULL_PTR_ARG(1, 2);
+
+ /* Inline Functions: */
+ /** Skips over the current sub-descriptor inside the configuration descriptor, so that the pointer then
+ points to the next sub-descriptor. The bytes remaining value is automatically decremented.
+ *
+ * \param BytesRem Pointer to the number of bytes remaining of the configuration descriptor
+ * \param CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor
+ */
+ static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,
+ uint8_t** const CurrConfigLoc)
+ ATTR_NON_NULL_PTR_ARG(1, 2);
+ static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,
+ uint8_t** const CurrConfigLoc)
+ {
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
+ uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size;
+ #else
+ uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).bLength;
+ #endif
+
+ *CurrConfigLoc += CurrDescriptorSize;
+ *BytesRem -= CurrDescriptorSize;
+ }
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
+ /* Type Defines: */
+ typedef uint8_t (* const ComparatorPtr_t)(void* const);
+
/* Function Prototypes: */
- uint8_t USB_Host_GetNextDescriptorComp_P(uint16_t* BytesRem, uint8_t** CurrConfigLoc,
- uint8_t (* const ComparatorRoutine)(void* const));
+ uint8_t USB_GetNextDescriptorComp_P(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ComparatorPtr_t ComparatorRoutine);
#endif
/* Disable C linkage for C++ Compilers: */
diff --git a/LUFA/Drivers/USB/Class/HIDParser.h b/LUFA/Drivers/USB/Class/HIDParser.h
index 4d9f9db7a..f02f1fd09 100644
--- a/LUFA/Drivers/USB/Class/HIDParser.h
+++ b/LUFA/Drivers/USB/Class/HIDParser.h
@@ -215,8 +215,8 @@
*
* \return A value in the HID_Parse_ErrorCodes_t enum
*/
- uint8_t ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID_ReportInfo_t* const ParserData)
- ATTR_NON_NULL_PTR_ARG(1, 3);
+ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID_ReportInfo_t* const ParserData)
+ ATTR_NON_NULL_PTR_ARG(1, 3);
/** Extracts the given report item's value out of the given HID report and places it into the Value
* member of the report item's HID_ReportItem_t structure.
@@ -226,8 +226,8 @@
*
* \returns Boolean true if the item to retrieve was located in the given report, false otherwise
*/
- bool GetReportItemInfo(const uint8_t* ReportData, HID_ReportItem_t* const ReportItem)
- ATTR_NON_NULL_PTR_ARG(1, 2);
+ bool USB_GetHIDReportItemInfo(const uint8_t* ReportData, HID_ReportItem_t* const ReportItem)
+ ATTR_NON_NULL_PTR_ARG(1, 2);
/** Retrieves the given report item's value out of the Value member of the report item's
* HID_ReportItem_t structure and places it into the correct position in the HID report
@@ -239,8 +239,8 @@
* \param ReportData Buffer holding the current OUT report data
* \param ReportItem Pointer to the report item of interest in a HID_ReportInfo_t ReportItem array
*/
- void SetReportItemInfo(uint8_t* ReportData, const HID_ReportItem_t* ReportItem)
- ATTR_NON_NULL_PTR_ARG(1, 2);
+ void USB_SetHIDReportItemInfo(uint8_t* ReportData, const HID_ReportItem_t* ReportItem)
+ ATTR_NON_NULL_PTR_ARG(1, 2);
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
diff --git a/LUFA/Drivers/USB/HighLevel/USBInterrupt.h b/LUFA/Drivers/USB/HighLevel/USBInterrupt.h
index 56297e3d4..c5b0a8358 100644
--- a/LUFA/Drivers/USB/HighLevel/USBInterrupt.h
+++ b/LUFA/Drivers/USB/HighLevel/USBInterrupt.h
@@ -31,9 +31,9 @@
/** \ingroup Group_USB
* @defgroup Group_USBInterrupt Endpoint and Pipe Interrupts
*
- * Main USB interrupt vector handler. This file manages the main USB interrupt vector, for handling such
- * events as VBUS interrupts (on supported USB AVR models), device connections and disconnections, etc.
- * as well as providing easy to use macros for the management of the Endpoint/Pipe interrupt vector.
+ * This module manages the main USB interrupt vector, for handling such events as VBUS interrupts
+ * (on supported USB AVR models), device connections and disconnections, etc. as well as providing
+ * easy to use macros for the management of the unified Endpoint/Pipe interrupt vector.
*
* @{
*/