Clean up excessive whitespace at the end of each line using the wspurify tool made by Laszlo Monda

This commit is contained in:
Dean Camera 2010-10-13 14:05:35 +00:00
parent a8871c7fba
commit 5a4def7478
760 changed files with 12883 additions and 12164 deletions

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -46,7 +46,7 @@ uint8_t USB_Host_GetDeviceConfigDescriptor(uint8_t ConfigNumber, uint16_t* const
.wIndex = 0,
.wLength = sizeof(USB_Descriptor_Configuration_Header_t),
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
if ((ErrorCode = USB_Host_SendControlRequest(ConfigHeader)) != HOST_SENDCONTROL_Successful)
@ -56,15 +56,15 @@ uint8_t USB_Host_GetDeviceConfigDescriptor(uint8_t ConfigNumber, uint16_t* const
if (*ConfigSizePtr > BufferSize)
return HOST_GETCONFIG_BuffOverflow;
USB_ControlRequest.wLength = *ConfigSizePtr;
if ((ErrorCode = USB_Host_SendControlRequest(BufferPtr)) != HOST_SENDCONTROL_Successful)
return ErrorCode;
if (DESCRIPTOR_TYPE(BufferPtr) != DTYPE_Configuration)
return HOST_GETCONFIG_InvalidData;
return HOST_GETCONFIG_Successful;
}
#endif
@ -75,7 +75,7 @@ void USB_GetNextDescriptorOfType(uint16_t* const BytesRem,
{
while (*BytesRem)
{
USB_GetNextDescriptor(BytesRem, CurrConfigLoc);
USB_GetNextDescriptor(BytesRem, CurrConfigLoc);
if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type)
return;
@ -109,22 +109,22 @@ void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
const uint8_t AfterType)
{
USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, AfterType);
if (*BytesRem)
USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type);
}
uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem, void** const CurrConfigLoc, ConfigComparatorPtr_t const ComparatorRoutine)
{
uint8_t ErrorCode;
while (*BytesRem)
{
uint8_t* PrevDescLoc = *CurrConfigLoc;
uint16_t PrevBytesRem = *BytesRem;
USB_GetNextDescriptor(BytesRem, CurrConfigLoc);
if ((ErrorCode = ComparatorRoutine(*CurrConfigLoc)) != DESCRIPTOR_SEARCH_NotFound)
{
if (ErrorCode == DESCRIPTOR_SEARCH_Fail)
@ -132,10 +132,11 @@ uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem, void** const CurrCon
*CurrConfigLoc = PrevDescLoc;
*BytesRem = PrevBytesRem;
}
return ErrorCode;
}
}
return DESCRIPTOR_SEARCH_COMP_EndOfDescriptor;
}

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -52,12 +52,12 @@
/* Includes: */
#include <stdint.h>
#include "../../../Common/Common.h"
#include "HostStandardReq.h"
#include "USBMode.h"
#include "StdDescriptors.h"
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
@ -67,8 +67,8 @@
#if !defined(__INCLUDE_FROM_USB_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#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.
@ -108,7 +108,7 @@
* values can be accessed in the \ref USB_DescriptorTypes_t enum.
*/
#define DESCRIPTOR_TYPE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).Type
/** Returns the descriptor's size, expressed as the 8-bit value indicating the number of bytes. */
#define DESCRIPTOR_SIZE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).Size
@ -119,7 +119,7 @@
* \see \ref USB_GetNextDescriptorComp function for more details.
*/
typedef uint8_t (* ConfigComparatorPtr_t)(void*);
/* Enums: */
/** Enum for the possible return codes of the \ref USB_Host_GetDeviceConfigDescriptor() function. */
enum USB_Host_GetConfigDescriptor_ErrorCodes_t
@ -138,7 +138,7 @@
*/
HOST_GETCONFIG_InvalidData = 6, /**< The device returned invalid configuration descriptor data. */
};
/** Enum for return values of a descriptor comparator function. */
enum DSearch_Return_ErrorCodes_t
{
@ -155,7 +155,7 @@
DESCRIPTOR_SEARCH_COMP_Fail = 1, /**< Comparator function returned Descriptor_Search_Fail. */
DESCRIPTOR_SEARCH_COMP_EndOfDescriptor = 2, /**< End of configuration descriptor reached before match found. */
};
/* Function Prototypes: */
/** Retrieves the configuration descriptor data from an attached device via a standard request into a buffer,
* including validity and size checking to prevent a buffer overflow.
@ -266,16 +266,16 @@
* \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor.
*/
static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,
void** CurrConfigLoc) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
void** CurrConfigLoc) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,
void** CurrConfigLoc)
{
uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size;
*CurrConfigLoc = ((uint8_t*)*CurrConfigLoc) + CurrDescriptorSize;
*BytesRem -= CurrDescriptorSize;
}
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
@ -284,3 +284,4 @@
#endif
/** @} */

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -50,12 +50,12 @@ void USB_Device_ProcessControlRequest(void)
{
bool RequestHandled = false;
uint8_t* RequestHeader = (uint8_t*)&USB_ControlRequest;
for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++)
*(RequestHeader++) = Endpoint_Read_Byte();
uint8_t bmRequestType = USB_ControlRequest.bmRequestType;
switch (USB_ControlRequest.bRequest)
{
case REQ_GetStatus:
@ -92,7 +92,7 @@ void USB_Device_ProcessControlRequest(void)
USB_Device_GetDescriptor();
RequestHandled = true;
}
break;
case REQ_GetConfiguration:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE))
@ -114,11 +114,11 @@ void USB_Device_ProcessControlRequest(void)
if (!(RequestHandled))
EVENT_USB_Device_UnhandledControlRequest();
if (Endpoint_IsSETUPReceived())
{
Endpoint_StallTransaction();
Endpoint_ClearSETUP();
Endpoint_ClearSETUP();
}
}
@ -129,9 +129,9 @@ static void USB_Device_SetAddress(void)
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
Endpoint_ClearSETUP();
Endpoint_ClearStatusStage();
while (!(Endpoint_IsINReady()));
USB_DeviceState = (DeviceAddress) ? DEVICE_STATE_Addressed : DEVICE_STATE_Default;
@ -157,7 +157,7 @@ static void USB_Device_SetConfiguration(void)
#else
uint8_t MemoryAddressSpace;
#endif
if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr
#if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS)
, &MemoryAddressSpace
@ -166,7 +166,7 @@ static void USB_Device_SetConfiguration(void)
{
return;
}
if (MemoryAddressSpace == MEMSPACE_FLASH)
{
if (((uint8_t)USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))
@ -183,7 +183,7 @@ static void USB_Device_SetConfiguration(void)
return;
}
#endif
Endpoint_ClearSETUP();
USB_ConfigurationNumber = (uint8_t)USB_ControlRequest.wValue;
@ -225,7 +225,7 @@ static void USB_Device_GetInternalSerialDescriptor(void)
SignatureDescriptor.Header.Type = DTYPE_String;
SignatureDescriptor.Header.Size = sizeof(SignatureDescriptor);
uint8_t SigReadAddress = 0x0E;
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
@ -233,17 +233,17 @@ static void USB_Device_GetInternalSerialDescriptor(void)
for (uint8_t SerialCharNum = 0; SerialCharNum < 20; SerialCharNum++)
{
uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
if (SerialCharNum & 0x01)
{
SerialByte >>= 4;
SigReadAddress++;
}
SignatureDescriptor.UnicodeString[SerialCharNum] = USB_Device_NibbleToASCII(SerialByte);
}
}
Endpoint_ClearSETUP();
Endpoint_Write_Control_Stream_LE(&SignatureDescriptor, sizeof(SignatureDescriptor));
@ -256,11 +256,11 @@ static void USB_Device_GetDescriptor(void)
{
const void* DescriptorPointer;
uint16_t DescriptorSize;
#if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS)
uint8_t DescriptorAddressSpace;
#endif
#if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)
if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL))
{
@ -268,7 +268,7 @@ static void USB_Device_GetDescriptor(void)
return;
}
#endif
if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex,
&DescriptorPointer
#if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS)
@ -278,7 +278,7 @@ static void USB_Device_GetDescriptor(void)
{
return;
}
Endpoint_ClearSETUP();
#if defined(USE_RAM_DESCRIPTORS)
@ -286,14 +286,14 @@ static void USB_Device_GetDescriptor(void)
#elif defined(USE_EEPROM_DESCRIPTORS)
Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize);
#elif defined(USE_FLASH_DESCRIPTORS)
Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize);
Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize);
#else
if (DescriptorAddressSpace == MEMSPACE_FLASH)
Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize);
Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize);
else if (DescriptorAddressSpace == MEMSPACE_EEPROM)
Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize);
else
Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize);
Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize);
#endif
Endpoint_ClearOUT();
@ -305,14 +305,14 @@ static void USB_Device_GetStatus(void)
switch (USB_ControlRequest.bmRequestType)
{
#if !defined(NO_DEVICE_SELF_POWER) || !defined(NO_DEVICE_REMOTE_WAKEUP)
#if !defined(NO_DEVICE_SELF_POWER) || !defined(NO_DEVICE_REMOTE_WAKEUP)
case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE):
#if !defined(NO_DEVICE_SELF_POWER)
if (USB_CurrentlySelfPowered)
CurrentStatus |= FEATURE_SELFPOWERED_ENABLED;
#endif
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
if (USB_RemoteWakeupEnabled)
CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED;
#endif
@ -324,7 +324,7 @@ static void USB_Device_GetStatus(void)
CurrentStatus = Endpoint_IsStalled();
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
break;
#endif
@ -336,7 +336,7 @@ static void USB_Device_GetStatus(void)
Endpoint_Write_Word_LE(CurrentStatus);
Endpoint_ClearIN();
Endpoint_ClearStatusStage();
}
@ -344,28 +344,28 @@ static void USB_Device_ClearSetFeature(void)
{
switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT)
{
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
case REQREC_DEVICE:
if ((uint8_t)USB_ControlRequest.wValue == FEATURE_REMOTE_WAKEUP)
USB_RemoteWakeupEnabled = (USB_ControlRequest.bRequest == REQ_SetFeature);
else
return;
break;
break;
#endif
#if !defined(CONTROL_ONLY_DEVICE)
case REQREC_ENDPOINT:
if ((uint8_t)USB_ControlRequest.wValue == FEATURE_ENDPOINT_HALT)
{
uint8_t EndpointIndex = ((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK);
if (EndpointIndex == ENDPOINT_CONTROLEP)
return;
Endpoint_SelectEndpoint(EndpointIndex);
if (Endpoint_IsEnabled())
{
{
if (USB_ControlRequest.bRequest == REQ_SetFeature)
{
Endpoint_StallTransaction();
@ -375,10 +375,10 @@ static void USB_Device_ClearSetFeature(void)
Endpoint_ClearStall();
Endpoint_ResetFIFO(EndpointIndex);
Endpoint_ResetDataToggle();
}
}
}
}
break;
#endif
default:
@ -393,3 +393,4 @@ static void USB_Device_ClearSetFeature(void)
}
#endif

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -48,7 +48,7 @@
#include <util/atomic.h>
#include <stdint.h>
#include <stdbool.h>
#include "StdDescriptors.h"
#include "Events.h"
#include "StdRequestType.h"
@ -64,13 +64,13 @@
#if !defined(__INCLUDE_FROM_USB_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Macros: */
#if defined(USE_SINGLE_DEVICE_CONFIGURATION)
#define FIXED_NUM_CONFIGURATIONS 1
#endif
/* Enums: */
#if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS)
/** Enum for the possible descriptor memory spaces, for the MemoryAddressSpace of the
@ -86,7 +86,7 @@
MEMSPACE_RAM = 2, /**< Indicates the requested descriptor is located in RAM memory. */
};
#endif
/* Global Variables: */
/** Indicates the currently set configuration number of the device. USB devices may have several
* different configurations which the host can select between; this indicates the currently selected
@ -98,7 +98,7 @@
* \ingroup Group_Device
*/
extern uint8_t USB_ConfigurationNumber;
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
/** Indicates if the host is currently allowing the device to issue remote wakeup events. If this
* flag is cleared, the device should not issue remote wakeup events to the host.
@ -108,7 +108,7 @@
* \n\n
*
* \note To reduce FLASH usage of the compiled applications where Remote Wakeup is not supported,
* this global and the underlying management code can be disabled by defining the
* this global and the underlying management code can be disabled by defining the
* NO_DEVICE_REMOTE_WAKEUP token in the project makefile and passing it to the compiler via
* the -D switch.
*
@ -116,7 +116,7 @@
*/
extern bool USB_RemoteWakeupEnabled;
#endif
#if !defined(NO_DEVICE_SELF_POWER)
/** Indicates if the device is currently being powered by its own power supply, rather than being
* powered by the host's USB supply. This flag should remain cleared if the device does not
@ -126,7 +126,7 @@
*/
extern bool USB_CurrentlySelfPowered;
#endif
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
#if defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)
@ -138,10 +138,10 @@
#elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS)
#error Only one of the USE_*_DESCRIPTORS modes should be selected.
#endif
/* Function Prototypes: */
void USB_Device_ProcessControlRequest(void);
#if defined(__INCLUDE_FROM_DEVICESTDREQ_C)
static void USB_Device_SetAddress(void);
static void USB_Device_SetConfiguration(void);
@ -149,11 +149,11 @@
static void USB_Device_GetDescriptor(void);
static void USB_Device_GetStatus(void);
static void USB_Device_ClearSetFeature(void);
#if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)
static char USB_Device_NibbleToASCII(uint8_t Nibble) ATTR_ALWAYS_INLINE;
static void USB_Device_GetInternalSerialDescriptor(void);
#endif
#endif
#endif
#endif
@ -161,5 +161,6 @@
#if defined(__cplusplus)
}
#endif
#endif

View file

@ -230,4 +230,4 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte())
#include "Template/Template_Endpoint_Control_R.c"
#endif
#endif

View file

@ -522,3 +522,4 @@
#endif
/** @} */

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -36,3 +36,4 @@ void USB_Event_Stub(void)
{
}

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -64,13 +64,13 @@
*
* @{
*/
#ifndef __USBEVENTS_H__
#define __USBEVENTS_H__
/* Includes: */
#include <stdint.h>
#include "../../../Common/Common.h"
#include "USBMode.h"
@ -83,8 +83,8 @@
#if !defined(__INCLUDE_FROM_USB_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Public Interface - May be used in end-application: */
/* Pseudo-Functions for Doxygen: */
#if !defined(__INCLUDE_FROM_EVENTS_C) || defined(__DOXYGEN__)
/** Event for USB mode pin level change. This event fires when the USB interface is set to dual role
@ -112,7 +112,7 @@
* \ref Group_USBManagement documentation).
*/
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
/** Event for USB device attachment. This event fires when a the USB interface is in host mode, and
* a USB device has been connected to the USB interface. This is interrupt driven, thus fires before
* the standard \ref EVENT_USB_Device_Connect() event and so can be used to programmatically start the USB
@ -141,11 +141,11 @@
* \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage.
*/
void EVENT_USB_Host_DeviceUnattached(void);
/** Event for USB device enumeration failure. This event fires when a the USB interface is
* in host mode, and an attached USB device has failed to enumerate completely.
*
* \param[in] ErrorCode Error code indicating the failure reason, a value in
* \param[in] ErrorCode Error code indicating the failure reason, a value in
* \ref USB_Host_EnumerationErrorCodes_t.
*
* \param[in] SubErrorCode Sub error code indicating the reason for failure - for example, if the
@ -327,17 +327,17 @@
*/
void EVENT_USB_Device_StartOfFrame(void);
#endif
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_EVENTS_C)
void USB_Event_Stub(void) ATTR_CONST;
#if defined(USB_CAN_BE_BOTH)
void EVENT_USB_UIDChange(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
#endif
#if defined(USB_CAN_BE_HOST)
void EVENT_USB_Host_HostError(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
void EVENT_USB_Host_DeviceAttached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
@ -366,7 +366,8 @@
#if defined(__cplusplus)
}
#endif
#endif
/** @} */

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -45,7 +45,7 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
uint16_t DataLen = USB_ControlRequest.wLength;
USB_Host_ResumeBus();
if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)
goto End_Of_Control_Send;
@ -58,7 +58,7 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
Pipe_Write_Byte(*(HeaderStream++));
Pipe_ClearSETUP();
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_SetupSent)) != HOST_SENDCONTROL_Successful)
goto End_Of_Control_Send;
@ -70,7 +70,7 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_DIRECTION) == REQDIR_DEVICETOHOST)
{
Pipe_SetPipeToken(PIPE_TOKEN_IN);
if (DataStream != NULL)
{
while (DataLen)
@ -79,10 +79,10 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_InReceived)) != HOST_SENDCONTROL_Successful)
goto End_Of_Control_Send;
if (!(Pipe_BytesInPipe()))
DataLen = 0;
while (Pipe_BytesInPipe() && DataLen)
{
*(DataStream++) = Pipe_Read_Byte();
@ -96,7 +96,7 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
Pipe_SetPipeToken(PIPE_TOKEN_OUT);
Pipe_Unfreeze();
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful)
goto End_Of_Control_Send;
@ -110,7 +110,7 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
if (DataStream != NULL)
{
Pipe_SetPipeToken(PIPE_TOKEN_OUT);
Pipe_Unfreeze();
Pipe_Unfreeze();
while (DataLen)
{
@ -118,11 +118,11 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
goto End_Of_Control_Send;
while (DataLen && (Pipe_BytesInPipe() < USB_ControlPipeSize))
{
{
Pipe_Write_Byte(*(DataStream++));
DataLen--;
}
Pipe_ClearOUT();
}
@ -131,7 +131,7 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
Pipe_Freeze();
}
Pipe_SetPipeToken(PIPE_TOKEN_IN);
Pipe_Unfreeze();
@ -143,7 +143,7 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
End_Of_Control_Send:
Pipe_Freeze();
if (BusSuspended)
USB_Host_SuspendBus();
@ -155,11 +155,11 @@ End_Of_Control_Send:
static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType)
{
#if (USB_HOST_TIMEOUT_MS < 0xFF)
uint8_t TimeoutCounter = USB_HOST_TIMEOUT_MS;
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()) ||
((WaitType == USB_HOST_WAITFOR_OutReady) && Pipe_IsOUTReady())))
@ -168,7 +168,7 @@ static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType)
if ((ErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)
return ErrorCode;
if (!(TimeoutCounter--))
return HOST_SENDCONTROL_SoftwareTimeOut;
}
@ -177,3 +177,4 @@ static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType)
}
#endif

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -44,11 +44,11 @@
/* Includes: */
#include <stdint.h>
#include <stdbool.h>
#include "USBMode.h"
#include "StdRequestType.h"
#include "../LowLevel/USBController.h"
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
@ -58,7 +58,7 @@
#if !defined(__INCLUDE_FROM_USB_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Enums: */
/** Enum for the \ref USB_Host_SendControlRequest() return code, indicating the reason for the error
@ -78,7 +78,7 @@
*/
HOST_SENDCONTROL_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */
};
/* Function Prototypes: */
/** Sends the request stored in the \ref USB_ControlRequest global structure to the attached device,
* and transfers the data stored in the buffer to the device, or from the device to the buffer
@ -92,7 +92,7 @@
* \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
*/
uint8_t USB_Host_SendControlRequest(void* const BufferPtr);
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Enums: */
@ -102,7 +102,7 @@
USB_HOST_WAITFOR_InReceived,
USB_HOST_WAITFOR_OutReady,
};
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_HOSTSTDREQ_C)
static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType);
@ -113,5 +113,6 @@
#if defined(__cplusplus)
}
#endif
#endif

View file

@ -193,3 +193,4 @@ uint8_t Pipe_Discard_Stream(uint16_t Length
#include "Template/Template_Pipe_RW.c"
#endif

View file

@ -296,3 +296,4 @@
#endif
/** @} */

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -45,7 +45,7 @@
*
* @{
*/
#ifndef __USBDESCRIPTORS_H__
#define __USBDESCRIPTORS_H__
@ -58,7 +58,7 @@
#include "../../../Common/Common.h"
#include "USBMode.h"
#include "Events.h"
#if defined(USB_CAN_BE_DEVICE)
#include "../LowLevel/Device.h"
#endif
@ -72,7 +72,7 @@
#if !defined(__INCLUDE_FROM_USB_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors
@ -98,7 +98,7 @@
#else
#define USE_INTERNAL_SERIAL NO_DESCRIPTOR
#endif
/** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes. */
#define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
@ -106,7 +106,7 @@
* Should be used in string descriptor's headers for giving the string descriptor's byte length.
*/
#define USB_STRING_LEN(str) (sizeof(USB_Descriptor_Header_t) + ((str) << 1))
/** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded
* Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the
* standard device descriptor.
@ -129,7 +129,7 @@
* EndpointAddress value to indicate to the host that the endpoint is of the OUT direction (i.e, from
* host to device).
*/
#define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00
#define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00
/** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
* descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
@ -177,7 +177,7 @@
* \see The USB specification for more details on the possible Endpoint attributes.
*/
#define ENDPOINT_ATTR_SYNC (3 << 2)
/** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
* Attributes value to indicate that the specified endpoint is used for data transfers.
*
@ -198,7 +198,7 @@
* \see The USB specification for more details on the possible Endpoint usage attributes.
*/
#define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
/* Enums: */
/** Enum for the possible standard descriptor types, as given in each descriptor's header. */
enum USB_DescriptorTypes_t
@ -231,7 +231,7 @@
* given by the specific class.
*/
} USB_Descriptor_Header_t;
/** \brief Standard USB Descriptor Header (USB-IF naming conventions).
*
* Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
@ -246,7 +246,7 @@
* given by the specific class.
*/
} USB_StdDescriptor_Header_t;
/** \brief Standard USB Device Descriptor (LUFA naming conventions).
*
* Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
@ -262,13 +262,13 @@
uint8_t Class; /**< USB device class. */
uint8_t SubClass; /**< USB device subclass. */
uint8_t Protocol; /**< USB device protocol. */
uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
uint16_t VendorID; /**< Vendor ID for the USB product. */
uint16_t ProductID; /**< Unique product ID for the USB product. */
uint16_t ReleaseNumber; /**< Product release (version) number. */
uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The
* host will request this string via a separate
* control request for the string descriptor.
@ -354,7 +354,7 @@
typedef struct
{
USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,
* and all sub descriptors inside the configuration.
*/
@ -362,17 +362,17 @@
uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */
uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */
uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of zero or
* more USB_CONFIG_ATTR_* masks.
*/
uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the
* current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
* macro.
*/
} USB_Descriptor_Configuration_Header_t;
/** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
*
* Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
@ -419,14 +419,14 @@
* selected by the host.
*/
uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */
uint8_t Class; /**< Interface class ID. */
uint8_t SubClass; /**< Interface subclass ID. */
uint8_t Protocol; /**< Interface protocol ID. */
uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the interface. */
} USB_Descriptor_Interface_t;
/** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
*
* Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
@ -471,7 +471,7 @@
typedef struct
{
USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */
uint8_t TotalInterfaces; /**< Total number of associated interfaces. */
@ -483,7 +483,7 @@
* interface association.
*/
} USB_Descriptor_Interface_Association_t;
/** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
*
* Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
@ -538,7 +538,7 @@
* or ISOCHRONOUS type.
*/
} USB_Descriptor_Endpoint_t;
/** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
*
* Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
@ -553,10 +553,10 @@
uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
* value given by the specific class.
*/
uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current
uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current
* configuration, including direction mask.
*/
uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
* and attributes (ENDPOINT_ATTR_*) masks.
*/
uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
@ -583,7 +583,7 @@
typedef struct
{
USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
wchar_t UnicodeString[]; /**< String data, as unicode characters (alternatively,
* string language IDs). If normal ASCII characters are
* to be used, they must be added as an array of characters
@ -636,12 +636,13 @@
#define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
#define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
#endif
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
#endif
#endif
/** @} */

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -36,7 +36,7 @@
* \note This file should not be included directly. It is automatically included as needed by the USB driver
* dispatch header located in LUFA/Drivers/USB/USB.h.
*/
/** \ingroup Group_USB
* @defgroup Group_StdRequest Standard USB Requests
*
@ -56,7 +56,7 @@
#if !defined(__INCLUDE_FROM_USB_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Mask for the request type parameter, to indicate the direction of the request data (Host to Device
@ -137,7 +137,7 @@
* \see \ref CONTROL_REQTYPE_RECIPIENT macro.
*/
#define REQREC_OTHER (3 << 0)
/** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature
* request this indicates that an endpoint (whose address is given elsewhere in the request
* should have its stall condition cleared. If used in a similar manner inside a Set Feature
@ -229,3 +229,4 @@
#endif
/** @} */

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -37,7 +37,7 @@
* \note This file should not be included directly. It is automatically included as needed by the USB driver
* dispatch header located in LUFA/Drivers/USB/USB.h.
*/
/** \ingroup Group_USB
* @defgroup Group_StreamCallbacks Endpoint and Pipe Stream Callbacks
*
@ -47,7 +47,7 @@
*
* @{
*/
#ifndef __STREAMCALLBACK_H__
#define __STREAMCALLBACK_H__
@ -58,14 +58,14 @@
#if !defined(__INCLUDE_FROM_USB_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Used with the Endpoint and Pipe stream functions as the callback function parameter, indicating that the stream
* call has no callback function to be called between USB packets.
*/
#define NO_STREAM_CALLBACK NULL
/* Enums: */
/** Enum for the possible error return codes of a stream callback function. */
enum StreamCallback_Return_ErrorCodes_t
@ -80,7 +80,8 @@
* are to be used as the callback parameter of the stream functions.
*/
typedef uint8_t (* const StreamCallbackPtr_t)(void);
#endif
/** @} */

View file

@ -2,10 +2,10 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer,
uint16_t Length)
{
uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
if (!(Length))
Endpoint_ClearOUT();
while (Length)
{
uint8_t USB_DeviceState_LCL = USB_DeviceState;
@ -16,7 +16,7 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer,
return ENDPOINT_RWCSTREAM_BusSuspended;
else if (Endpoint_IsSETUPReceived())
return ENDPOINT_RWCSTREAM_HostAborted;
if (Endpoint_IsOUTReceived())
{
while (Length && Endpoint_BytesInEndpoint())
@ -24,11 +24,11 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer,
TEMPLATE_TRANSFER_BYTE(DataStream);
Length--;
}
Endpoint_ClearOUT();
}
}
}
while (!(Endpoint_IsINReady()))
{
uint8_t USB_DeviceState_LCL = USB_DeviceState;
@ -38,11 +38,11 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer,
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
return ENDPOINT_RWCSTREAM_BusSuspended;
}
return ENDPOINT_RWCSTREAM_NoError;
}
#undef TEMPLATE_BUFFER_OFFSET
#undef TEMPLATE_FUNC_NAME
#undef TEMPLATE_TRANSFER_BYTE
#undef TEMPLATE_TRANSFER_BYTE

View file

@ -3,7 +3,7 @@ uint8_t TEMPLATE_FUNC_NAME (const void* Buffer,
{
uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
bool LastPacketFull = false;
if (Length > USB_ControlRequest.wLength)
Length = USB_ControlRequest.wLength;
else if (!(Length))
@ -12,7 +12,7 @@ uint8_t TEMPLATE_FUNC_NAME (const void* Buffer,
while (Length || LastPacketFull)
{
uint8_t USB_DeviceState_LCL = USB_DeviceState;
if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
@ -25,19 +25,19 @@ uint8_t TEMPLATE_FUNC_NAME (const void* Buffer,
if (Endpoint_IsINReady())
{
uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint();
while (Length && (BytesInEndpoint < USB_ControlEndpointSize))
{
TEMPLATE_TRANSFER_BYTE(DataStream);
Length--;
BytesInEndpoint++;
}
LastPacketFull = (BytesInEndpoint == USB_ControlEndpointSize);
Endpoint_ClearIN();
}
}
while (!(Endpoint_IsOUTReceived()))
{
uint8_t USB_DeviceState_LCL = USB_DeviceState;
@ -53,4 +53,4 @@ uint8_t TEMPLATE_FUNC_NAME (const void* Buffer,
#undef TEMPLATE_BUFFER_OFFSET
#undef TEMPLATE_FUNC_NAME
#undef TEMPLATE_TRANSFER_BYTE
#undef TEMPLATE_TRANSFER_BYTE

View file

@ -4,7 +4,7 @@ uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer,
{
uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
uint8_t ErrorCode;
if ((ErrorCode = Endpoint_WaitUntilReady()))
return ErrorCode;
@ -34,7 +34,7 @@ uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer,
}
Length -= 8;
TEMPLATE_TRANSFER_BYTE(DataStream);
case 7: TEMPLATE_TRANSFER_BYTE(DataStream);
case 6: TEMPLATE_TRANSFER_BYTE(DataStream);
@ -43,7 +43,7 @@ uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer,
case 3: TEMPLATE_TRANSFER_BYTE(DataStream);
case 2: TEMPLATE_TRANSFER_BYTE(DataStream);
case 1: TEMPLATE_TRANSFER_BYTE(DataStream);
} while (Length >= 8);
} while (Length >= 8);
}
}
#endif
@ -76,4 +76,4 @@ uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer,
#undef TEMPLATE_BUFFER_TYPE
#undef TEMPLATE_TRANSFER_BYTE
#undef TEMPLATE_CLEAR_ENDPOINT
#undef TEMPLATE_BUFFER_OFFSET
#undef TEMPLATE_BUFFER_OFFSET

View file

@ -4,7 +4,7 @@ uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer,
{
uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
uint8_t ErrorCode;
Pipe_SetPipeToken(TEMPLATE_TOKEN);
if ((ErrorCode = Pipe_WaitUntilReady()))
@ -36,7 +36,7 @@ uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer,
}
Length -= 8;
TEMPLATE_TRANSFER_BYTE(DataStream);
case 7: TEMPLATE_TRANSFER_BYTE(DataStream);
case 6: TEMPLATE_TRANSFER_BYTE(DataStream);
@ -45,7 +45,7 @@ uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer,
case 3: TEMPLATE_TRANSFER_BYTE(DataStream);
case 2: TEMPLATE_TRANSFER_BYTE(DataStream);
case 1: TEMPLATE_TRANSFER_BYTE(DataStream);
} while (Length >= 8);
} while (Length >= 8);
}
}
#endif
@ -70,7 +70,7 @@ uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer,
Length--;
}
}
return PIPE_RWSTREAM_NoError;
}
@ -80,3 +80,4 @@ uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer,
#undef TEMPLATE_TRANSFER_BYTE
#undef TEMPLATE_CLEAR_PIPE
#undef TEMPLATE_BUFFER_OFFSET

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -58,7 +58,7 @@
#if !defined(__INCLUDE_FROM_USB_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
/* Public Interface - May be used in end-application: */
#if defined(__DOXYGEN__)
/** Indicates that the target AVR microcontroller belongs to the Series 2 USB controller
@ -96,7 +96,7 @@
*/
#define USB_CAN_BE_BOTH
#else
/* Macros: */
/* Macros: */
#if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \
defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__))
#define USB_SERIES_2_AVR
@ -106,13 +106,13 @@
#define USB_SERIES_6_AVR
#elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))
#define USB_SERIES_7_AVR
#endif
#endif
#if !defined(USB_SERIES_7_AVR)
#if !defined(USB_SERIES_7_AVR)
#if defined(USB_HOST_ONLY)
#error USB_HOST_ONLY is not available for the currently selected USB AVR model.
#endif
#if !defined(USB_DEVICE_ONLY)
#define USB_DEVICE_ONLY
#endif
@ -127,12 +127,12 @@
#elif defined(USB_DEVICE_ONLY)
#define USB_CAN_BE_DEVICE
#endif
#if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY))
#error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive.
#endif
#endif
#endif
/** @} */
/** @} */

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -63,12 +63,12 @@ static void USB_DeviceTask(void)
if (USB_DeviceState != DEVICE_STATE_Unattached)
{
uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint();
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
if (Endpoint_IsSETUPReceived())
USB_Device_ProcessControlRequest();
Endpoint_SelectEndpoint(PrevEndpoint);
}
}
@ -78,11 +78,12 @@ static void USB_DeviceTask(void)
static void USB_HostTask(void)
{
uint8_t PrevPipe = Pipe_GetCurrentPipe();
Pipe_SelectPipe(PIPE_CONTROLPIPE);
USB_Host_ProcessNextHostState();
Pipe_SelectPipe(PrevPipe);
}
#endif

View file

@ -1,7 +1,7 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
@ -9,13 +9,13 @@
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
@ -45,7 +45,7 @@
#include <avr/interrupt.h>
#include <stdint.h>
#include <stdbool.h>
#include "../LowLevel/USBController.h"
#include "Events.h"
#include "StdRequestType.h"
@ -59,7 +59,7 @@
#if defined(USB_CAN_BE_HOST)
#include "HostStandardReq.h"
#endif
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
@ -69,7 +69,7 @@
#if !defined(__INCLUDE_FROM_USB_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Global Variables: */
/** Indicates if the USB interface is currently initialized but not necessarily connected to a host
@ -90,7 +90,7 @@
* \ingroup Group_USBManagement
*/
extern USB_Request_Header_t USB_ControlRequest;
#if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)
#if !defined(HOST_STATE_AS_GPIOR) || defined(__DOXYGEN__)
/** Indicates the current host state machine state. When in host mode, this indicates the state
@ -101,7 +101,7 @@
* the library internally.
*
* To reduce program size and speed up checks of this global, it can be placed into one of the AVR's
* GPIOR hardware registers instead of RAM by defining the HOST_STATE_AS_GPIOR token to a value
* GPIOR hardware registers instead of RAM by defining the HOST_STATE_AS_GPIOR token to a value
* between 0 and 2 in the project makefile and passing it to the compiler via the -D switch. When
* defined, the corresponding GPIOR register should not be used in the user application except
* implicitly via the library APIs.
@ -130,7 +130,7 @@
* (see \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events).
*
* To reduce program size and speed up checks of this global, it can be placed into one of the AVR's
* GPIOR hardware registers instead of RAM by defining the DEVICE_STATE_AS_GPIOR token to a value
* GPIOR hardware registers instead of RAM by defining the DEVICE_STATE_AS_GPIOR token to a value
* between 0 and 2 in the project makefile and passing it to the compiler via the -D switch. When
* defined, the corresponding GPIOR register should not be used in the user application except
* implicitly via the library APIs.
@ -162,7 +162,7 @@
* The USB task must be serviced within 30ms while in device mode, or within 1ms while in host mode.
* The task may be serviced at all times, or (for minimum CPU consumption):
*
* - In device mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Device_Connect()
* - In device mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Device_Connect()
* event and disabled again on the firing of the \ref EVENT_USB_Device_Disconnect() event.
*
* - In host mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Host_DeviceAttached()
@ -185,21 +185,22 @@
#if defined(USB_CAN_BE_HOST)
static void USB_HostTask(void);
#endif
#if defined(USB_CAN_BE_DEVICE)
static void USB_DeviceTask(void);
#endif
#endif
/* Macros: */
#define HOST_TASK_NONBLOCK_WAIT(Duration, NextState) MACROS{ USB_HostState = HOST_STATE_WaitForDevice; \
WaitMSRemaining = (Duration); \
PostWaitState = (NextState); }MACROE
#endif
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
#endif
#endif