diff --git a/Demos/Host/CDCHost/CDCHost.c b/Demos/Host/CDCHost/CDCHost.c
index b499a275e3..a4194090a3 100644
--- a/Demos/Host/CDCHost/CDCHost.c
+++ b/Demos/Host/CDCHost/CDCHost.c
@@ -246,7 +246,7 @@ TASK(USB_CDC_Host)
{
/* Get the length of the pipe data, and create a new buffer to hold it */
uint16_t BufferLength = Pipe_BytesInPipe();
- uint8_t Buffer[BufferLength];
+ uint8_t Buffer[BufferLength];
/* Read in the pipe data to the temporary buffer */
Pipe_Read_Stream_LE(Buffer, BufferLength);
@@ -267,7 +267,7 @@ TASK(USB_CDC_Host)
/* Check if a packet has been received */
if (Pipe_IsINReceived())
{
- /* Discard the event notification */
+ /* Discard the unused event notification */
Pipe_ClearIN();
}
diff --git a/LUFA/ChangeLog.txt b/LUFA/ChangeLog.txt
index d17c758e1f..303c4659ae 100644
--- a/LUFA/ChangeLog.txt
+++ b/LUFA/ChangeLog.txt
@@ -17,6 +17,8 @@
* - Moved control endpoint interrupt handling into the library itself, enable via the new INTERRUPT_CONTROL_ENDPOINT token
* - Fixed CDCHost not clearing configured pipes and resetting configured pipes mask when a partially enumerated invalid CDC
* interface is skipped
+ * - Clarified the size of library tokens which accept integer values in the Compile Time Tokens page, values now use the smallest datatype
+ * inside the library that is able to hold their defined value to save space
*
*
* \section Sec_ChangeLog090510 Version 090510
diff --git a/LUFA/CompileTimeTokens.txt b/LUFA/CompileTimeTokens.txt
index bb235e1722..718fa8f530 100644
--- a/LUFA/CompileTimeTokens.txt
+++ b/LUFA/CompileTimeTokens.txt
@@ -50,27 +50,27 @@
* HID_STATETABLE_STACK_DEPTH - ( \ref Group_HIDParser ) \n
* HID reports may contain PUSH and POP elements, to store and retrieve the current HID state table onto a stack. This
* allows for reports to save the state table before modifying it slightly for a data item, and then restore the previous
- * state table in a compact manner. This token may be defined to a non-zero value to give the maximum depth of the state
+ * state table in a compact manner. This token may be defined to a non-zero 8-bit value to give the maximum depth of the state
* table stack. If not defined, this defaults to the value indicated in the HID.h file documentation.
*
* HID_USAGE_STACK_DEPTH - ( \ref Group_HIDParser ) \n
* HID reports generally contain many USAGE elements, which are assigned to INPUT, OUTPUT and FEATURE items in succession
* when multiple items are defined at once (via REPORT COUNT elements). This allows for several items to be defined with
- * different usages in a compact manner. This token may be defined to a non-zero value to set the maximum depth of the
+ * different usages in a compact manner. This token may be defined to a non-zero 8-bit value to set the maximum depth of the
* usage stack, indicating the maximum number of USAGE items which can be stored temporarily until the next INPUT, OUTPUT
* and FEATURE item. If not defined, this defaults to the value indicated in the HID.h file documentation.
*
* HID_MAX_COLLECTIONS - ( \ref Group_HIDParser ) \n
* HID reports generally contain several COLLECTION elements, used to group related data items together. Collection information
* is stored separately in the processed usage structure (and referred to by the data elements in the structure) to save space.
- * This token may be defined to a non-zero value to set the maximum number of COLLECTION items which can be processed by the
+ * This token may be defined to a non-zero 8-bit value to set the maximum number of COLLECTION items which can be processed by the
* parser into the resultant processed report structure. If not defined, this defaults to the value indicated in the HID.h file
* documentation.
*
* HID_MAX_REPORTITEMS - ( \ref Group_HIDParser ) \n
* All HID reports contain one or more INPUT, OUTPUT and/or FEATURE items describing the data which can be sent to and from the HID
* device. Each item has associated usages, bit offsets in the item reports and other associated data indicating the manner in which
- * the report data should be interpreted by the host. This token may be defined to a non-zero value to set the maximum number of
+ * the report data should be interpreted by the host. This token may be defined to a non-zero 8-bit value to set the maximum number of
* data elements which can be stored in the processed HID report structure, including INPUT, OUTPUT and (if enabled) FEATURE items.
* If a item has a multiple count (i.e. a REPORT COUNT of more than 1), each item in the report count is placed separately in the
* processed HID report table. If not defined, this defaults to the value indicated in the HID.h file documentation.
@@ -121,14 +121,14 @@
*
* USB_HOST_TIMEOUT_MS - ( \ref Group_Host ) \n
* When a control transfer is initiated in host mode to an attached device, a timeout is used to abort the transfer if the attached
- * device fails to respond within the timeout period. This token may be defined to a non-zero value to set the timeout period for
+ * device fails to respond within the timeout period. This token may be defined to a non-zero 16-bit value to set the timeout period for
* control transfers, specified in milliseconds. If not defined, the default value specified in Host.h is used instead.
*
* HOST_DEVICE_SETTLE_DELAY_MS - ( \ref Group_Host ) \n
* Some devices require a delay of up to 5 seconds after they are connected to VBUS before the enumeration process can be started, or
* they will fail to enumerate correctly. By placing a delay before the enumeration process, it can be ensured that the bus has settled
- * back to a known idle state before communications occur with the device. This token may be defined to a non-zero value to set the
- * device settle period, specified in milliseconds. If not defined, the default value specified in Host.h is used instead.
+ * back to a known idle state before communications occur with the device. This token may be defined to a non-zero 16-bit value to set
+ * the device settle period, specified in milliseconds. If not defined, the default value specified in Host.h is used instead.
*
* USE_STATIC_OPTIONS - ( \ref Group_USBManagement ) \n
* By default, the USB_Init() function accepts dynamic options at runtime to alter the library behaviour, including whether the USB pad
@@ -148,7 +148,7 @@
*
* USB_STREAM_TIMEOUT_MS - ( \ref Group_USBManagement ) \n
* When endpoint and/or pipe stream functions are used, by default there is a timeout between each transfer which the connected device or host
- * must satisfy, or the stream function aborts the remaining data transfer. This token may be defined to a non-zero value to set the timeout
+ * must satisfy, or the stream function aborts the remaining data transfer. This token may be defined to a non-zero 16-bit value to set the timeout
* period for stream transfers, specified in milliseconds. If not defined, the default value specified in LowLevel.h is used instead.
*
* NO_LIMITED_CONTROLLER_CONNECT - ( \ref Group_Events ) \n
diff --git a/LUFA/Drivers/USB/Class/ConfigDescriptor.c b/LUFA/Drivers/USB/Class/ConfigDescriptor.c
index 78838305ad..59e3a4b897 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 6f5bbc4487..74d6d2727b 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 6a18920c35..e739d8438d 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 bd264b17ff..099022c1cf 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 9a553d33ff..7f2b76a2fe 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 4b96c691df..238e099efd 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 c81ee6433a..71a33d62f2 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 796b4c5a26..c96a440a03 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);