aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-05-15 12:27:32 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-05-15 12:27:32 +0000
commiteeba38e343a299e12964aec15fd43108d3dc9130 (patch)
tree4ad58eb59a275db1102be49aba13a775617f1fa9 /LUFA/Drivers/USB
parent76d5e99bb8765030a7f99e7b5adf9bae7f92e0ba (diff)
downloadlufa-eeba38e343a299e12964aec15fd43108d3dc9130.tar.gz
lufa-eeba38e343a299e12964aec15fd43108d3dc9130.tar.bz2
lufa-eeba38e343a299e12964aec15fd43108d3dc9130.zip
Create a new function pointer type in StreamCallbacks.h for endpoint/pipe stream callbacks, to make stream function prototypes clearer.
Diffstat (limited to 'LUFA/Drivers/USB')
-rw-r--r--LUFA/Drivers/USB/Class/ConfigDescriptor.c4
-rw-r--r--LUFA/Drivers/USB/Class/ConfigDescriptor.h13
-rw-r--r--LUFA/Drivers/USB/HighLevel/StreamCallbacks.h10
-rw-r--r--LUFA/Drivers/USB/LowLevel/Endpoint.c14
-rw-r--r--LUFA/Drivers/USB/LowLevel/Endpoint.h10
-rw-r--r--LUFA/Drivers/USB/LowLevel/HostChapter9.c4
-rw-r--r--LUFA/Drivers/USB/LowLevel/Pipe.c14
-rw-r--r--LUFA/Drivers/USB/LowLevel/Pipe.h10
8 files changed, 52 insertions, 27 deletions
diff --git a/LUFA/Drivers/USB/Class/ConfigDescriptor.c b/LUFA/Drivers/USB/Class/ConfigDescriptor.c
index 78838305a..59e3a4b89 100644
--- a/LUFA/Drivers/USB/Class/ConfigDescriptor.c
+++ b/LUFA/Drivers/USB/Class/ConfigDescriptor.c
@@ -114,13 +114,13 @@ void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type);
}
-uint8_t USB_GetNextDescriptorComp_Prv(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ComparatorPtr_t ComparatorRoutine)
+uint8_t USB_GetNextDescriptorComp_Prv(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine)
{
uint8_t ErrorCode;
while (*BytesRem)
{
- uint8_t* PrevDescLoc = *CurrConfigLoc;
+ uint8_t* PrevDescLoc = *CurrConfigLoc;
uint16_t PrevBytesRem = *BytesRem;
USB_GetNextDescriptor(BytesRem, CurrConfigLoc);
diff --git a/LUFA/Drivers/USB/Class/ConfigDescriptor.h b/LUFA/Drivers/USB/Class/ConfigDescriptor.h
index 6f5bbc448..74d6d2727 100644
--- a/LUFA/Drivers/USB/Class/ConfigDescriptor.h
+++ b/LUFA/Drivers/USB/Class/ConfigDescriptor.h
@@ -264,13 +264,18 @@
*BytesRem -= CurrDescriptorSize;
}
- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
/* Type Defines: */
- typedef uint8_t (* const ComparatorPtr_t)(void* const);
+ /** Type define for a Configuration Descriptor comparator function (function taking a pointer to an array
+ * of type void, returning a uint8_t value).
+ *
+ * \see \ref USB_GetNextDescriptorComp function for more details
+ */
+ typedef uint8_t (* const ConfigComparatorPtr_t)(void* const);
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
/* Function Prototypes: */
- uint8_t USB_GetNextDescriptorComp_Prv(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ComparatorPtr_t ComparatorRoutine);
+ uint8_t USB_GetNextDescriptorComp_Prv(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine);
#endif
/* Disable C linkage for C++ Compilers: */
diff --git a/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h b/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h
index 6a18920c3..e739d8438 100644
--- a/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h
+++ b/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h
@@ -85,7 +85,15 @@
STREAMCALLBACK_Continue = 0, /**< Continue sending or receiving the stream. */
STREAMCALLBACK_Abort = 1, /**< Abort the stream send or receiving process. */
};
-
+
+ /* Type Defines: */
+ /** Type define for a Stream Callback function (function taking no arguments and retuning a
+ * uint8_t value).
+ *
+ * \see \ref STREAM_CALLBACK macro for more details
+ */
+ typedef uint8_t (* const StreamCallbackPtr_t)(void);
+
#endif
/** @} */
diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.c b/LUFA/Drivers/USB/LowLevel/Endpoint.c
index bd264b17f..099022c1c 100644
--- a/LUFA/Drivers/USB/LowLevel/Endpoint.c
+++ b/LUFA/Drivers/USB/LowLevel/Endpoint.c
@@ -74,7 +74,11 @@ void Endpoint_ClearEndpoints(void)
#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
USB_INT_Clear(USB_INT_SOFI);
@@ -108,7 +112,7 @@ uint8_t Endpoint_WaitUntilReady(void)
uint8_t Endpoint_Discard_Stream(uint16_t Length
#if !defined(NO_STREAM_CALLBACKS)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
)
{
@@ -143,7 +147,7 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
uint8_t Endpoint_Write_Stream_LE(const void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
)
{
@@ -179,7 +183,7 @@ uint8_t Endpoint_Write_Stream_LE(const void* Buffer, uint16_t Length
uint8_t Endpoint_Write_Stream_BE(const void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
)
{
@@ -215,7 +219,7 @@ uint8_t Endpoint_Write_Stream_BE(const void* Buffer, uint16_t Length
uint8_t Endpoint_Read_Stream_LE(void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
)
{
@@ -251,7 +255,7 @@ uint8_t Endpoint_Read_Stream_LE(void* Buffer, uint16_t Length
uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
)
{
diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h
index 9a553d33f..7f2b76a2f 100644
--- a/LUFA/Drivers/USB/LowLevel/Endpoint.h
+++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h
@@ -727,7 +727,7 @@
*/
uint8_t Endpoint_Discard_Stream(uint16_t Length
#if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
);
@@ -754,7 +754,7 @@
*/
uint8_t Endpoint_Write_Stream_LE(const void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
) ATTR_NON_NULL_PTR_ARG(1);
@@ -781,7 +781,7 @@
*/
uint8_t Endpoint_Write_Stream_BE(const void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
) ATTR_NON_NULL_PTR_ARG(1);
@@ -808,7 +808,7 @@
*/
uint8_t Endpoint_Read_Stream_LE(void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
) ATTR_NON_NULL_PTR_ARG(1);
@@ -835,7 +835,7 @@
*/
uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
) ATTR_NON_NULL_PTR_ARG(1);
diff --git a/LUFA/Drivers/USB/LowLevel/HostChapter9.c b/LUFA/Drivers/USB/LowLevel/HostChapter9.c
index 4b96c691d..238e099ef 100644
--- a/LUFA/Drivers/USB/LowLevel/HostChapter9.c
+++ b/LUFA/Drivers/USB/LowLevel/HostChapter9.c
@@ -153,7 +153,11 @@ End_Of_Control_Send:
static uint8_t USB_Host_Wait_For_Setup_IOS(const uint8_t WaitType)
{
+ #if (USB_HOST_TIMEOUT_MS < 0xFF)
+ uint8_t TimeoutCounter = USB_HOST_TIMEOUT_MS;
+ #else
uint16_t TimeoutCounter = USB_HOST_TIMEOUT_MS;
+ #endif
while (!(((WaitType == USB_HOST_WAITFOR_SetupSent) && Pipe_IsSETUPSent()) ||
((WaitType == USB_HOST_WAITFOR_InReceived) && Pipe_IsINReceived()) ||
diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.c b/LUFA/Drivers/USB/LowLevel/Pipe.c
index c81ee6433..71a33d62f 100644
--- a/LUFA/Drivers/USB/LowLevel/Pipe.c
+++ b/LUFA/Drivers/USB/LowLevel/Pipe.c
@@ -70,7 +70,11 @@ void Pipe_ClearPipes(void)
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
USB_INT_Clear(USB_INT_HSOFI);
@@ -104,7 +108,7 @@ uint8_t Pipe_WaitUntilReady(void)
uint8_t Pipe_Write_Stream_LE(const void* Data, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
)
{
@@ -140,7 +144,7 @@ uint8_t Pipe_Write_Stream_LE(const void* Data, uint16_t Length
uint8_t Pipe_Write_Stream_BE(const void* Data, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
)
{
@@ -176,7 +180,7 @@ uint8_t Pipe_Write_Stream_BE(const void* Data, uint16_t Length
uint8_t Pipe_Discard_Stream(uint16_t Length
#if !defined(NO_STREAM_CALLBACKS)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
)
{
@@ -211,7 +215,7 @@ uint8_t Pipe_Discard_Stream(uint16_t Length
uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
)
{
@@ -247,7 +251,7 @@ uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length
uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
)
{
diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h
index 796b4c5a2..c96a440a0 100644
--- a/LUFA/Drivers/USB/LowLevel/Pipe.h
+++ b/LUFA/Drivers/USB/LowLevel/Pipe.h
@@ -759,7 +759,7 @@
*/
uint8_t Pipe_Write_Stream_LE(const void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
) ATTR_NON_NULL_PTR_ARG(1);
@@ -783,7 +783,7 @@
*/
uint8_t Pipe_Write_Stream_BE(const void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
) ATTR_NON_NULL_PTR_ARG(1);
@@ -806,7 +806,7 @@
*/
uint8_t Pipe_Discard_Stream(uint16_t Length
#if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
);
@@ -830,7 +830,7 @@
*/
uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
) ATTR_NON_NULL_PTR_ARG(1);
@@ -854,7 +854,7 @@
*/
uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length
#if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)
- , uint8_t (* const Callback)(void)
+ , StreamCallbackPtr_t Callback
#endif
) ATTR_NON_NULL_PTR_ARG(1);