From 9d6a373cb61b55b94312de3809ac76fcbd0a696c Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 21 Sep 2009 06:08:39 +0000 Subject: [PATCH] Add const qualifiers to Host mode Class drivers. Fix KeyboardHost ClassDriver demo; boot protocol keyboard report structure in the Host Mode HID Class driver uses the full keycode array from the attached device. --- .../ClassDriver/KeyboardHost/KeyboardHost.c | 18 +-- LUFA/Common/FunctionAttributes.h | 104 +++++++++--------- LUFA/Drivers/USB/Class/Host/CDC.c | 16 +-- LUFA/Drivers/USB/Class/Host/CDC.h | 20 ++-- LUFA/Drivers/USB/Class/Host/HID.c | 16 +-- LUFA/Drivers/USB/Class/Host/HID.h | 18 +-- LUFA/Drivers/USB/Class/Host/HIDParser.c | 2 +- LUFA/Drivers/USB/Class/Host/HIDParser.h | 4 +- LUFA/Drivers/USB/Class/Host/MassStorage.c | 48 ++++---- LUFA/Drivers/USB/Class/Host/MassStorage.h | 38 ++++--- LUFA/Drivers/USB/Class/Host/StillImage.c | 28 ++--- LUFA/Drivers/USB/Class/Host/StillImage.h | 28 ++--- LUFA/Drivers/USB/LowLevel/Pipe.c | 2 +- LUFA/Drivers/USB/LowLevel/Pipe.h | 2 +- 14 files changed, 179 insertions(+), 165 deletions(-) diff --git a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c index a6605f00fb..effd16b010 100644 --- a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c +++ b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c @@ -115,25 +115,27 @@ int main(void) { USB_KeyboardReport_Data_t KeyboardReport; uint8_t ReportID = 0; - + HID_Host_ReceiveReport(&Keyboard_HID_Interface, false, &ReportID, &KeyboardReport); LEDs_ChangeLEDs(LEDS_LED1, (KeyboardReport.Modifier) ? LEDS_LED1 : 0); - if (KeyboardReport.KeyCode) + uint8_t PressedKeyCode = KeyboardReport.KeyCode[0]; + + if (PressedKeyCode) { char PressedKey = 0; LEDs_ToggleLEDs(LEDS_LED2); /* Retrieve pressed key character if alphanumeric */ - if ((KeyboardReport.KeyCode >= 0x04) && (KeyboardReport.KeyCode <= 0x1D)) - PressedKey = (KeyboardReport.KeyCode - 0x04) + 'A'; - else if ((KeyboardReport.KeyCode >= 0x1E) && (KeyboardReport.KeyCode <= 0x27)) - PressedKey = (KeyboardReport.KeyCode - 0x1E) + '0'; - else if (KeyboardReport.KeyCode == 0x2C) + if ((PressedKeyCode >= 0x04) && (PressedKeyCode <= 0x1D)) + PressedKey = (PressedKeyCode - 0x04) + 'A'; + else if ((PressedKeyCode >= 0x1E) && (PressedKeyCode <= 0x27)) + PressedKey = (PressedKeyCode - 0x1E) + '0'; + else if (PressedKeyCode == 0x2C) PressedKey = ' '; - else if (KeyboardReport.KeyCode == 0x28) + else if (PressedKeyCode == 0x28) PressedKey = '\n'; if (PressedKey) diff --git a/LUFA/Common/FunctionAttributes.h b/LUFA/Common/FunctionAttributes.h index 9a293b6195..f86e3d9492 100644 --- a/LUFA/Common/FunctionAttributes.h +++ b/LUFA/Common/FunctionAttributes.h @@ -34,6 +34,9 @@ * and code generation features of the compiler. Attributes may be placed in the function prototype in any * order, and multiple attributes can be specified for a single function via a space separated list. * + * On incompatible versions of GCC or on other compilers, these macros evaluate to nothing unless they are + * critical to the code's function and thus must throw a compiler error when used. + * * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's * functionality. */ @@ -56,10 +59,57 @@ /* Public Interface - May be used in end-application: */ /* Macros: */ - /** Indicates to the compiler that the function can not ever return, so that any stack restoring or - * return code may be omitted by the compiler in the resulting binary. - */ - #define ATTR_NO_RETURN __attribute__ ((noreturn)) + #if __GNUC__ >= 3 + /** Indicates to the compiler that the function can not ever return, so that any stack restoring or + * return code may be omitted by the compiler in the resulting binary. + */ + #define ATTR_NO_RETURN __attribute__ ((noreturn)) + + /** Indicates that the function returns a value which should not be ignored by the user code. When + * applied, any ignored return value from calling the function will produce a compiler warning. + */ + #define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) + + /** Indicates that the specified parameters of the function are pointers which should never be NULL. + * When applied as a 1-based comma separated list the compiler will emit a warning if the specified + * parameters are known at compiler time to be NULL at the point of calling the function. + */ + #define ATTR_NON_NULL_PTR_ARG(...) __attribute__ ((nonnull (__VA_ARGS__))) + + /** Removes any preamble or postamble from the function. When used, the function will not have any + * register or stack saving code. This should be used with caution, and when used the programmer + * is responsible for maintaining stack and register integrity. + */ + #define ATTR_NAKED __attribute__ ((naked)) + + /** Prevents the compiler from considering a specified function for inlining. When applied, the given + * function will not be inlined under any circumstances. + */ + #define ATTR_NO_INLINE __attribute__ ((noinline)) + + /** Forces the compiler to inline the specified function. When applied, the given function will be + * inlined under all circumstances. + */ + #define ATTR_ALWAYS_INLINE __attribute__ ((always_inline)) + + /** Indicates that the specified function is pure, in that it has no side-effects other than global + * or parameter variable access. + */ + #define ATTR_PURE __attribute__ ((pure)) + + /** Indicates that the specified function is constant, in that it has no side effects other than + * parameter access. + */ + #define ATTR_CONST __attribute__ ((const)) + + /** Marks a given function as deprecated, which produces a warning if the function is called. */ + #define ATTR_DEPRECATED __attribute__ ((deprecated)) + + /** Marks a function as a weak reference, which can be overridden by other functions with an + * identical name (in which case the weak reference is discarded at link time). + */ + #define ATTR_WEAK __attribute__ ((weak)) + #endif /** Places the function in one of the initialization sections, which execute before the main function * of the application. The init function number can be specified as "x", as an integer. Refer to the @@ -67,54 +117,8 @@ */ #define ATTR_INIT_SECTION(x) __attribute__ ((naked, section (".init" #x ))) - /** Indicates that the function returns a value which should not be ignored by the user code. When - * applied, any ignored return value from calling the function will produce a compiler warning. - */ - #define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) - - /** Indicates that the specified parameters of the function are pointers which should never be NULL. - * When applied as a 1-based comma separated list the compiler will emit a warning if the specified - * parameters are known at compiler time to be NULL at the point of calling the function. - */ - #define ATTR_NON_NULL_PTR_ARG(...) __attribute__ ((nonnull (__VA_ARGS__))) - - /** Removes any preamble or postamble from the function. When used, the function will not have any - * register or stack saving code. This should be used with caution, and when used the programmer - * is responsible for maintaining stack and register integrity. - */ - #define ATTR_NAKED __attribute__ ((naked)) - - /** Prevents the compiler from considering a specified function for inlining. When applied, the given - * function will not be inlined under any circumstances. - */ - #define ATTR_NO_INLINE __attribute__ ((noinline)) - - /** Forces the compiler to inline the specified function. When applied, the given function will be - * inlined under all circumstances. - */ - #define ATTR_ALWAYS_INLINE __attribute__ ((always_inline)) - - /** Indicates that the specified function is pure, in that it has no side-effects other than global - * or parameter variable access. - */ - #define ATTR_PURE __attribute__ ((pure)) - - /** Indicates that the specified function is constant, in that it has no side effects other than - * parameter access. - */ - #define ATTR_CONST __attribute__ ((const)) - - /** Marks a given function as deprecated, which produces a warning if the function is called. */ - #define ATTR_DEPRECATED __attribute__ ((deprecated)) - - /** Marks a function as a weak reference, which can be overridden by other functions with an - * identical name (in which case the weak reference is discarded at link time). - */ - #define ATTR_WEAK __attribute__ ((weak)) - /** Marks a function as an alias for another function of name "x". */ #define ATTR_ALIAS(x) __attribute__ ((alias( #x ))) - #endif /** @} */ diff --git a/LUFA/Drivers/USB/Class/Host/CDC.c b/LUFA/Drivers/USB/Class/Host/CDC.c index 8ef6242e49..fde145ac6a 100644 --- a/LUFA/Drivers/USB/Class/Host/CDC.c +++ b/LUFA/Drivers/USB/Class/Host/CDC.c @@ -34,7 +34,7 @@ #define INCLUDE_FROM_CDC_CLASS_HOST_C #include "CDC.h" -uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint16_t ConfigDescriptorSize, +uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, uint16_t ConfigDescriptorSize, uint8_t* ConfigDescriptorData) { uint8_t FoundEndpoints = 0; @@ -189,7 +189,7 @@ static uint8_t DComp_CDC_Host_NextCDCInterfaceEndpoint(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } -void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) +void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) { if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive)) return; @@ -219,7 +219,7 @@ void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) Pipe_Freeze(); } -uint8_t CDC_Host_SetLineEncoding(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) +uint8_t CDC_Host_SetLineEncoding(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) { USB_ControlRequest = (USB_Request_Header_t) { @@ -235,7 +235,7 @@ uint8_t CDC_Host_SetLineEncoding(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) return USB_Host_SendControlRequest(&CDCInterfaceInfo->State.LineEncoding); } -uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) +uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) { USB_ControlRequest = (USB_Request_Header_t) { @@ -251,7 +251,7 @@ uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* CDCInterfa return USB_Host_SendControlRequest(NULL); } -uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length) +uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, char* Data, const uint16_t Length) { if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive)) return PIPE_READYWAIT_NoError; @@ -266,7 +266,7 @@ uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Da return ErrorCode; } -uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data) +uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, const uint8_t Data) { if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive)) return PIPE_READYWAIT_NoError;; @@ -290,7 +290,7 @@ uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Da return PIPE_READYWAIT_NoError; } -uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) +uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) { uint16_t BytesInPipe = 0; @@ -309,7 +309,7 @@ uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) return BytesInPipe; } -uint8_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) +uint8_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) { uint8_t ReceivedByte = 0; diff --git a/LUFA/Drivers/USB/Class/Host/CDC.h b/LUFA/Drivers/USB/Class/Host/CDC.h index df5a41ff09..3fb04f3013 100644 --- a/LUFA/Drivers/USB/Class/Host/CDC.h +++ b/LUFA/Drivers/USB/Class/Host/CDC.h @@ -124,7 +124,7 @@ * * \param[in,out] CDCInterfaceInfo Pointer to a structure containing an CDC Class host configuration and state */ - void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Host interface configuration routine, to configure a given CDC host interface instance using the Configuration * Descriptor read from an attached USB device. This function automatically updates the given CDC Host instance's @@ -133,12 +133,12 @@ * the Addressed state. * * \param[in,out] CDCInterfaceInfo Pointer to a structure containing an CDC Class host configuration and state - * \param[in] ConfigDescriptorLength Length of the attached device's Configuration Descriptor + * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor * \param[in] DeviceConfigDescriptor Pointer to a buffer containing the attached device's Configuration Descriptor * * \return A value from the \ref CDCHost_EnumerationFailure_ErrorCodes_t enum */ - uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint16_t ConfigDescriptorLength, + uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, uint16_t ConfigDescriptorSize, uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3); /** Sets the line encoding for the attached device's virtual serial port. This should be called when the LineEncoding @@ -148,7 +148,7 @@ * * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum */ - uint8_t CDC_Host_SetLineEncoding(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + uint8_t CDC_Host_SetLineEncoding(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Sends a Serial Control Line State Change notification to the device. This should be called when the virtual serial * control lines (DTR, RTS, etc.) have changed states. Line states persist until they are cleared via a second @@ -159,7 +159,7 @@ * * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum */ - uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Sends a given string to the attached USB device, if connected. If a device is not connected when the function is called, the * string is discarded. @@ -170,7 +170,7 @@ * * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum */ - uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, char* Data, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1, 2); + uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, char* Data, const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1, 2); /** Sends a given byte to the attached USB device, if connected. If a host is not connected when the function is called, the * byte is discarded. @@ -180,7 +180,7 @@ * * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum */ - uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint8_t Data) ATTR_NON_NULL_PTR_ARG(1); + uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1); /** Determines the number of bytes received by the CDC interface from the device, waiting to be read. * @@ -188,7 +188,7 @@ * * \return Total number of buffered bytes received from the device */ - uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Reads a byte of data from the device. If no data is waiting to be read of if a USB device is not connected, the function * returns 0. The \ref CDC_Host_BytesReceived() function should be queried before data is received to ensure that no data @@ -198,7 +198,7 @@ * * \return Next received byte from the device, or 0 if no data received */ - uint8_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + uint8_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** CDC class driver event for a control line state change on a CDC host interface. This event fires each time the device notifies * the host of a control line state change (containing the virtual serial control line states, such as DCD) and may be hooked in the @@ -208,7 +208,7 @@ * * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state */ - void EVENT_CDC_Host_ControLineStateChanged(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + void EVENT_CDC_Host_ControLineStateChanged(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) diff --git a/LUFA/Drivers/USB/Class/Host/HID.c b/LUFA/Drivers/USB/Class/Host/HID.c index d01d312110..741f56a18f 100644 --- a/LUFA/Drivers/USB/Class/Host/HID.c +++ b/LUFA/Drivers/USB/Class/Host/HID.c @@ -36,7 +36,7 @@ #warning The HID Host mode Class driver is currently incomplete and is for preview purposes only. -uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint16_t ConfigDescriptorSize, +uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, uint16_t ConfigDescriptorSize, uint8_t* ConfigDescriptorData) { uint8_t FoundEndpoints = 0; @@ -149,12 +149,13 @@ static uint8_t DComp_HID_Host_NextHIDInterfaceEndpoint(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } -void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) +void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) { } -uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, bool ControlRequest, uint8_t* ReportID, void* Buffer) +uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, const bool ControlRequest, + uint8_t* ReportID, void* Buffer) { if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive)) return false; @@ -207,7 +208,8 @@ uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, bool } } -uint8_t HID_Host_SendReport(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint8_t ReportID, void* Buffer, uint16_t ReportSize) +uint8_t HID_Host_SendReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, uint8_t ReportID, void* Buffer, + const uint16_t ReportSize) { if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive)) return false; @@ -247,7 +249,7 @@ uint8_t HID_Host_SendReport(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint8_t } } -bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) +bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) { if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive)) return false; @@ -264,7 +266,7 @@ bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) return ReportReceived; } -uint8_t USB_HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) +uint8_t USB_HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) { uint8_t ErrorCode; @@ -290,7 +292,7 @@ uint8_t USB_HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) return HOST_SENDCONTROL_Successful; } -uint8_t USB_HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) +uint8_t USB_HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) { uint8_t ErrorCode; diff --git a/LUFA/Drivers/USB/Class/Host/HID.h b/LUFA/Drivers/USB/Class/Host/HID.h index 230930a5ce..a8865a5c18 100644 --- a/LUFA/Drivers/USB/Class/Host/HID.h +++ b/LUFA/Drivers/USB/Class/Host/HID.h @@ -125,7 +125,7 @@ * * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state */ - void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Host interface configuration routine, to configure a given HID host interface instance using the Configuration * Descriptor read from an attached USB device. This function automatically updates the given HID Host instance's @@ -137,12 +137,12 @@ * to either the \ref USB_HID_Host_SetBootProtocol() or \ref USB_HID_Host_SetReportProtocol() function. * * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state - * \param[in] ConfigDescriptorLength Length of the attached device's Configuration Descriptor + * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor * \param[in] DeviceConfigDescriptor Pointer to a buffer containing the attached device's Configuration Descriptor * * \return A value from the \ref HIDHost_EnumerationFailure_ErrorCodes_t enum */ - uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint16_t ConfigDescriptorLength, + uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, uint16_t ConfigDescriptorSize, uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3); @@ -158,7 +158,7 @@ * \return An error code from the \ref USB_Host_SendControlErrorCodes_t enum if the ControlRequest flag is set, * a value from the \ref Pipe_Stream_RW_ErrorCodes_t enum otherwise */ - uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, bool ControlRequest, uint8_t* ReportID, + uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, const bool ControlRequest, uint8_t* ReportID, void* Buffer) ATTR_NON_NULL_PTR_ARG(1, 3); /** Sends an OUT report to the currently attached HID device, using the device's OUT pipe if available or the device's @@ -172,8 +172,8 @@ * \return An error code from the \ref USB_Host_SendControlErrorCodes_t enum if the DeviceUsesOUTPipe flag is set in * the interface's state structure, a value from the \ref Pipe_Stream_RW_ErrorCodes_t enum otherwise */ - uint8_t HID_Host_SendReport(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint8_t ReportID, - void* Buffer, uint16_t ReportSize) ATTR_NON_NULL_PTR_ARG(1, 3); + uint8_t HID_Host_SendReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, const uint8_t ReportID, + void* Buffer, const uint16_t ReportSize) ATTR_NON_NULL_PTR_ARG(1, 3); /** Determines if a HID IN report has been received from the attached device on the data IN pipe. * @@ -181,7 +181,7 @@ * * \return Boolean true if a report has been received, false otherwise */ - bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Switches the attached HID device's reporting protocol over to the Boot Report protocol mode, on supported devices. * @@ -190,7 +190,7 @@ * \return \ref HID_ERROR_LOGICAL if the device does not support Boot Protocol mode, a value from the * \ref USB_Host_SendControlErrorCodes_t enum otherwise */ - uint8_t USB_HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + uint8_t USB_HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Switches the attached HID device's reporting protocol over to the standard Report protocol mode. This also retrieves * and parses the device's HID report descriptor, so that the size of each report can be determined in advance. @@ -205,7 +205,7 @@ * not have a valid \ref HID_ReportInfo_t structure set in its configuration, a mask of \ref HID_ERROR_LOGICAL * and a value from the \ref HID_Parse_ErrorCodes_t otherwise */ - uint8_t USB_HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + uint8_t USB_HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) diff --git a/LUFA/Drivers/USB/Class/Host/HIDParser.c b/LUFA/Drivers/USB/Class/Host/HIDParser.c index 6c315da7a4..b302a94b47 100644 --- a/LUFA/Drivers/USB/Class/Host/HIDParser.c +++ b/LUFA/Drivers/USB/Class/Host/HIDParser.c @@ -342,7 +342,7 @@ void USB_SetHIDReportItemInfo(uint8_t* ReportData, const HID_ReportItem_t* Repor } } -uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData, uint8_t ReportID, uint8_t ReportType) +uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData, const uint8_t ReportID, const uint8_t ReportType) { for (uint8_t i = 0; i < HID_MAX_REPORT_IDS; i++) { diff --git a/LUFA/Drivers/USB/Class/Host/HIDParser.h b/LUFA/Drivers/USB/Class/Host/HIDParser.h index 74916dbb6b..a2830dd30e 100644 --- a/LUFA/Drivers/USB/Class/Host/HIDParser.h +++ b/LUFA/Drivers/USB/Class/Host/HIDParser.h @@ -278,8 +278,8 @@ * * \return Size of the report in bytes, or 0 if the report does not exist */ - uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData, uint8_t ReportID, - uint8_t ReportType) ATTR_NON_NULL_PTR_ARG(1); + uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData, const uint8_t ReportID, + const uint8_t ReportType) ATTR_NON_NULL_PTR_ARG(1); /** Callback routine for the HID Report Parser. This callback must be implemented by the user code when * the parser is used, to determine what report IN, OUT and FEATURE item's information is stored into the user diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.c b/LUFA/Drivers/USB/Class/Host/MassStorage.c index ead7768d6f..047685cced 100644 --- a/LUFA/Drivers/USB/Class/Host/MassStorage.c +++ b/LUFA/Drivers/USB/Class/Host/MassStorage.c @@ -34,7 +34,7 @@ #define INCLUDE_FROM_MS_CLASS_HOST_C #include "MassStorage.h" -uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint16_t ConfigDescriptorLength, +uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, uint16_t ConfigDescriptorSize, uint8_t* DeviceConfigDescriptor) { uint8_t FoundEndpoints = 0; @@ -44,7 +44,7 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint16_ if (DESCRIPTOR_TYPE(DeviceConfigDescriptor) != DTYPE_Configuration) return MS_ENUMERROR_InvalidConfigDescriptor; - if (USB_GetNextDescriptorComp(&ConfigDescriptorLength, &DeviceConfigDescriptor, + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &DeviceConfigDescriptor, DComp_NextMSInterface) != DESCRIPTOR_SEARCH_COMP_Found) { return MS_ENUMERROR_NoMSInterfaceFound; @@ -54,7 +54,7 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint16_ while (FoundEndpoints != (MS_FOUND_DATAPIPE_IN | MS_FOUND_DATAPIPE_OUT)) { - if (USB_GetNextDescriptorComp(&ConfigDescriptorLength, &DeviceConfigDescriptor, + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &DeviceConfigDescriptor, DComp_NextMSInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { return MS_ENUMERROR_EndpointsNotFound; @@ -127,12 +127,12 @@ static uint8_t DComp_NextMSInterfaceEndpoint(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } -void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* MSInterfaceInfo) +void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) { } -static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, MS_CommandBlockWrapper_t* SCSICommandBlock, +static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, MS_CommandBlockWrapper_t* const SCSICommandBlock, void* BufferPtr) { uint8_t ErrorCode = PIPE_RWSTREAM_NoError; @@ -164,7 +164,7 @@ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, MS_ return ErrorCode; } -static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* MSInterfaceInfo) +static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) { uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS; @@ -217,8 +217,8 @@ static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* MSInterfaceI return PIPE_RWSTREAM_NoError; } -static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, - MS_CommandBlockWrapper_t* SCSICommandBlock, void* BufferPtr) +static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + MS_CommandBlockWrapper_t* const SCSICommandBlock, void* BufferPtr) { uint8_t ErrorCode = PIPE_RWSTREAM_NoError; uint16_t BytesRem = SCSICommandBlock->DataTransferLength; @@ -261,8 +261,8 @@ static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, return ErrorCode; } -static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, - MS_CommandStatusWrapper_t* SCSICommandStatus) +static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + MS_CommandStatusWrapper_t* const SCSICommandStatus) { uint8_t ErrorCode = PIPE_RWSTREAM_NoError; @@ -287,7 +287,7 @@ static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* MSInterfaceInf return ErrorCode; } -uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* MSInterfaceInfo) +uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) { if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnect; @@ -306,7 +306,7 @@ uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* MSInterfaceInfo) return USB_Host_SendControlRequest(NULL); } -uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t* MaxLUNIndex) +uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, uint8_t* const MaxLUNIndex) { if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnect; @@ -330,7 +330,8 @@ uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t* Max return ErrorCode; } -uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, SCSI_Inquiry_Response_t* InquiryData) +uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, + SCSI_Inquiry_Response_t* const InquiryData) { if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnect; @@ -366,7 +367,7 @@ uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t return PIPE_RWSTREAM_NoError; } -uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex) +uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex) { if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnect; @@ -402,8 +403,8 @@ uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t return PIPE_RWSTREAM_NoError; } -uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, - SCSI_Capacity_t* DeviceCapacity) +uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, + SCSI_Capacity_t* const DeviceCapacity) { if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnect; @@ -446,8 +447,8 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uin return PIPE_RWSTREAM_NoError; } -uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, - SCSI_Request_Sense_Response_t* SenseData) +uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, + SCSI_Request_Sense_Response_t* const SenseData) { if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnect; @@ -483,7 +484,8 @@ uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t L return PIPE_RWSTREAM_NoError; } -uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, bool PreventRemoval) +uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, + const bool PreventRemoval) { if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnect; @@ -519,8 +521,8 @@ uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* MSInterfaceIn return PIPE_RWSTREAM_NoError; } -uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddress, - uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer) +uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, const uint32_t BlockAddress, + const uint8_t Blocks, const uint16_t BlockSize, void* BlockBuffer) { if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnect; @@ -560,8 +562,8 @@ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8 return PIPE_RWSTREAM_NoError; } -uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddress, - uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer) +uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, const uint32_t BlockAddress, + const uint8_t Blocks, const uint16_t BlockSize, void* BlockBuffer) { if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnect; diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.h b/LUFA/Drivers/USB/Class/Host/MassStorage.h index 2395fcf1fe..a65a352c1c 100644 --- a/LUFA/Drivers/USB/Class/Host/MassStorage.h +++ b/LUFA/Drivers/USB/Class/Host/MassStorage.h @@ -179,7 +179,7 @@ * * \param[in,out] MSInterfaceInfo Pointer to a structure containing an MS Class host configuration and state */ - void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Host interface configuration routine, to configure a given Mass Storage host interface instance using the * Configuration Descriptor read from an attached USB device. This function automatically updates the given Mass @@ -188,12 +188,12 @@ * the host state machine is in the Addressed state. * * \param[in,out] MSInterfaceInfo Pointer to a structure containing an MS Class host configuration and state - * \param[in] ConfigDescriptorLength Length of the attached device's Configuration Descriptor + * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor * \param[in] DeviceConfigDescriptor Pointer to a buffer containing the attached device's Configuration Descriptor * * \return A value from the \ref MSHost_EnumerationFailure_ErrorCodes_t enum */ - uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint16_t ConfigDescriptorLength, + uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, uint16_t ConfigDescriptorSize, uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3); /** Sends a MASS STORAGE RESET control request to the attached device, resetting the Mass Storage Interface @@ -203,7 +203,7 @@ * * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum */ - uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Sends a GET MAX LUN control request to the attached device, retrieving the index of the highest LUN (Logical * UNit, a logical drive) in the device. This value can then be used in the other functions of the Mass Storage @@ -214,7 +214,7 @@ * * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum */ - uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t* MaxLUNIndex) ATTR_NON_NULL_PTR_ARG(1, 2); + uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, uint8_t* const MaxLUNIndex) ATTR_NON_NULL_PTR_ARG(1, 2); /** Retrieves the Mass Storage device's inquiry data for the specified LUN, indicating the device characteristics and * properties. @@ -225,8 +225,8 @@ * * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED */ - uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, - SCSI_Inquiry_Response_t* InquiryData) ATTR_NON_NULL_PTR_ARG(1, 3); + uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, + SCSI_Inquiry_Response_t* const InquiryData) ATTR_NON_NULL_PTR_ARG(1, 3); /** Sends a TEST UNIT READY command to the device, to determine if it is ready to accept other SCSI commands. * @@ -235,7 +235,7 @@ * * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready */ - uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex) ATTR_NON_NULL_PTR_ARG(1); + uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex) ATTR_NON_NULL_PTR_ARG(1); /** Retrieves the total capacity of the attached USB Mass Storage device, in blocks, and block size. * @@ -245,8 +245,8 @@ * * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready */ - uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, - SCSI_Capacity_t* DeviceCapacity) ATTR_NON_NULL_PTR_ARG(1, 3); + uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, + SCSI_Capacity_t* const DeviceCapacity) ATTR_NON_NULL_PTR_ARG(1, 3); /** Retrieves the device sense data, indicating the current device state and error codes for the previously * issued command. @@ -257,8 +257,8 @@ * * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready */ - uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, - SCSI_Request_Sense_Response_t* SenseData) ATTR_NON_NULL_PTR_ARG(1, 3); + uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, + SCSI_Request_Sense_Response_t* const SenseData) ATTR_NON_NULL_PTR_ARG(1, 3); /** Issues a PREVENT MEDIUM REMOVAL command, to logically (or, depending on the type of device, physically) lock * the device from removal so that blocks of data on the medium can be read or altered. @@ -269,8 +269,8 @@ * * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready */ - uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, - bool PreventRemoval) ATTR_NON_NULL_PTR_ARG(1); + uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, + const bool PreventRemoval) ATTR_NON_NULL_PTR_ARG(1); /** Reads blocks of data from the attached Mass Storage device's medium. * @@ -283,8 +283,9 @@ * * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready */ - uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddress, - uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1, 6); + uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, + const uint32_t BlockAddress, const uint8_t Blocks, const uint16_t BlockSize, + void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1, 6); /** Writes blocks of data to the attached Mass Storage device's medium. * @@ -297,8 +298,9 @@ * * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready */ - uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddress, - uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1, 6); + uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, + const uint32_t BlockAddress, const uint8_t Blocks, const uint16_t BlockSize, + void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1, 6); /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) diff --git a/LUFA/Drivers/USB/Class/Host/StillImage.c b/LUFA/Drivers/USB/Class/Host/StillImage.c index 7e3be8a81c..c176310b2c 100644 --- a/LUFA/Drivers/USB/Class/Host/StillImage.c +++ b/LUFA/Drivers/USB/Class/Host/StillImage.c @@ -34,7 +34,7 @@ #define INCLUDE_FROM_SI_CLASS_HOST_C #include "StillImage.h" -uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, uint16_t ConfigDescriptorLength, +uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, uint16_t ConfigDescriptorSize, uint8_t* DeviceConfigDescriptor) { uint8_t FoundEndpoints = 0; @@ -44,7 +44,7 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, uint16_ if (DESCRIPTOR_TYPE(DeviceConfigDescriptor) != DTYPE_Configuration) return SI_ENUMERROR_InvalidConfigDescriptor; - if (USB_GetNextDescriptorComp(&ConfigDescriptorLength, &DeviceConfigDescriptor, + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &DeviceConfigDescriptor, DComp_SI_Host_NextSIInterface) != DESCRIPTOR_SEARCH_COMP_Found) { return SI_ENUMERROR_NoSIInterfaceFound; @@ -52,7 +52,7 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, uint16_ while (FoundEndpoints != (SI_FOUND_EVENTS_IN | SI_FOUND_DATAPIPE_IN | SI_FOUND_DATAPIPE_OUT)) { - if (USB_GetNextDescriptorComp(&ConfigDescriptorLength, &DeviceConfigDescriptor, + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &DeviceConfigDescriptor, DComp_SI_Host_NextSIInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { return SI_ENUMERROR_EndpointsNotFound; @@ -142,12 +142,12 @@ uint8_t DComp_SI_Host_NextSIInterfaceEndpoint(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } -void SI_Host_USBTask(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) +void SI_Host_USBTask(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) { } -static uint8_t SImage_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader) +static uint8_t SImage_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, SI_PIMA_Container_t* const PIMAHeader) { uint8_t ErrorCode; @@ -173,7 +173,7 @@ static uint8_t SImage_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceI return PIPE_RWSTREAM_NoError; } -static uint8_t SImage_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader) +static uint8_t SImage_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, SI_PIMA_Container_t* const PIMAHeader) { uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS; @@ -236,7 +236,7 @@ static uint8_t SImage_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* SIInterfa return PIPE_RWSTREAM_NoError; } -uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes) +uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, void* Buffer, const uint16_t Bytes) { uint8_t ErrorCode; @@ -251,7 +251,7 @@ uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buf return ErrorCode; } -uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes) +uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, void* Buffer, const uint16_t Bytes) { uint8_t ErrorCode; @@ -280,7 +280,7 @@ bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) return IsEventReceived; } -uint8_t SImage_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, SI_PIMA_Container_t* PIMAHeader) +uint8_t SImage_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, SI_PIMA_Container_t* const PIMAHeader) { uint8_t ErrorCode; @@ -295,7 +295,7 @@ uint8_t SImage_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, return ErrorCode; } -uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) +uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) { if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnect; @@ -325,7 +325,7 @@ uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) return PIPE_RWSTREAM_NoError; } -uint8_t SImage_Host_CloseSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) +uint8_t SImage_Host_CloseSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) { if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnect; @@ -354,8 +354,8 @@ uint8_t SImage_Host_CloseSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) return PIPE_RWSTREAM_NoError; } -uint8_t SImage_Host_SendCommand(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, uint16_t Operation, - uint8_t TotalParams, uint32_t* Params) +uint8_t SImage_Host_SendCommand(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, const uint16_t Operation, + const uint8_t TotalParams, uint32_t* Params) { if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnect; @@ -377,7 +377,7 @@ uint8_t SImage_Host_SendCommand(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, uint16 return PIPE_RWSTREAM_NoError; } -uint8_t SImage_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) +uint8_t SImage_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) { uint8_t ErrorCode; SI_PIMA_Container_t PIMABlock; diff --git a/LUFA/Drivers/USB/Class/Host/StillImage.h b/LUFA/Drivers/USB/Class/Host/StillImage.h index 037ae6c019..9ba10e9b92 100644 --- a/LUFA/Drivers/USB/Class/Host/StillImage.h +++ b/LUFA/Drivers/USB/Class/Host/StillImage.h @@ -109,7 +109,7 @@ * * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state */ - void SI_Host_USBTask(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + void SI_Host_USBTask(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Host interface configuration routine, to configure a given Still Image host interface instance using the @@ -119,12 +119,12 @@ * the host state machine is in the Addressed state. * * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state - * \param[in] ConfigDescriptorLength Length of the attached device's Configuration Descriptor + * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor * \param[in] DeviceConfigDescriptor Pointer to a buffer containing the attached device's Configuration Descriptor * * \return A value from the \ref SIHost_EnumerationFailure_ErrorCodes_t enum */ - uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, uint16_t ConfigDescriptorLength, + uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, uint16_t ConfigDescriptorSize, uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3); /** Opens a new PIMA session with the attached device. This should be used before any session-orientated PIMA commands @@ -135,7 +135,7 @@ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device * returned a logical command failure */ - uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Closes an already opened PIMA session with the attached device. This should be used after all session-orientated * PIMA commands have been issued to the device. @@ -145,7 +145,7 @@ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device * returned a logical command failure */ - uint8_t SImage_Host_CloseSession(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + uint8_t SImage_Host_CloseSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Sends a given PIMA command to the attached device, filling out the PIMA command header automatically as required. * @@ -157,8 +157,8 @@ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device * returned a logical command failure */ - uint8_t SImage_Host_SendCommand(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, uint16_t Operation, uint8_t TotalParams, - uint32_t* Params) ATTR_NON_NULL_PTR_ARG(1); + uint8_t SImage_Host_SendCommand(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, const uint16_t Operation, + const uint8_t TotalParams, uint32_t* Params) ATTR_NON_NULL_PTR_ARG(1); /** Receives and checks a response block from the attached PIMA device, once a command has been issued and all data * associated with the command has been transferred. @@ -168,7 +168,7 @@ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device * returned a logical command failure */ - uint8_t SImage_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + uint8_t SImage_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Indicates if the device has issued a PIMA event block to the host via the asynchronous events pipe. * @@ -176,7 +176,7 @@ * * \return Boolean true if an event is waiting to be read, false otherwise */ - bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + bool SImage_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Receives an asynchronous event block from the device via the asynchronous events pipe. * @@ -186,8 +186,8 @@ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device * returned a logical command failure */ - uint8_t SImage_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, - SI_PIMA_Container_t* PIMAHeader) ATTR_NON_NULL_PTR_ARG(1, 2); + uint8_t SImage_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + SI_PIMA_Container_t* const PIMAHeader) ATTR_NON_NULL_PTR_ARG(1, 2); /** Sends arbitrary data to the attached device, for use in the data phase of PIMA commands which require data * transfer beyond the regular PIMA command block parameters. @@ -198,7 +198,8 @@ * * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum */ - uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes) ATTR_NON_NULL_PTR_ARG(1, 2); + uint8_t SImage_Host_SendData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, void* Buffer, + const uint16_t Bytes) ATTR_NON_NULL_PTR_ARG(1, 2); /** Receives arbitrary data from the attached device, for use in the data phase of PIMA commands which require data * transfer beyond the regular PIMA command block parameters. @@ -209,7 +210,8 @@ * * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum */ - uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* SIInterfaceInfo, void* Buffer, uint16_t Bytes) ATTR_NON_NULL_PTR_ARG(1, 2); + uint8_t SImage_Host_ReadData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, void* Buffer, + const uint16_t Bytes) ATTR_NON_NULL_PTR_ARG(1, 2); /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.c b/LUFA/Drivers/USB/LowLevel/Pipe.c index 58d7343b05..400cc5f028 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.c +++ b/LUFA/Drivers/USB/LowLevel/Pipe.c @@ -70,7 +70,7 @@ void Pipe_ClearPipes(void) } } -bool Pipe_IsEndpointBound(uint8_t EndpointAddress) +bool Pipe_IsEndpointBound(const uint8_t EndpointAddress) { uint8_t PrevPipeNumber = Pipe_GetCurrentPipe(); diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h index fd01b5c58c..25ca94b820 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.h +++ b/LUFA/Drivers/USB/LowLevel/Pipe.h @@ -809,7 +809,7 @@ * * \return Boolean true if a pipe bound to the given endpoint address is found, false otherwise */ - bool Pipe_IsEndpointBound(uint8_t EndpointAddress); + bool Pipe_IsEndpointBound(const uint8_t EndpointAddress); /** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host * as needed. The last packet is not automatically discarded once the remaining bytes has been read; the