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 @@
*
* \section Module Description
* Audio Class Driver module. This module contains an internal implementation of the USB Audio 1.0 Class, for Device
* USB mode only. User applications can use this class driver instead of implementing the Audio class manually via
* USB mode only. User applications can use this class driver instead of implementing the Audio class manually via
* the low-level LUFA APIs.
*
* This module is designed to simplify the user code by exposing only the required interface needed to interface with
@ -64,7 +64,7 @@
/* Includes: */
#include "../HighLevel/USBMode.h"
#if defined(NO_STREAM_CALLBACKS)
#error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers.
#endif
@ -72,7 +72,8 @@
#if defined(USB_CAN_BE_DEVICE)
#include "Device/Audio.h"
#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
@ -55,7 +55,7 @@
*
* @{
*/
#ifndef _CDC_CLASS_H_
#define _CDC_CLASS_H_
@ -73,11 +73,12 @@
#if defined(USB_CAN_BE_DEVICE)
#include "Device/CDC.h"
#endif
#if defined(USB_CAN_BE_HOST)
#include "Host/CDC.h"
#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
@ -52,7 +52,7 @@
/* Includes: */
#include "../../USB.h"
#include <string.h>
/* Enable C linkage for C++ Compilers: */
@ -72,7 +72,7 @@
*/
#define AUDIO_TOTAL_SAMPLE_RATES 1
#endif
/** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_CHANNEL_LEFT_FRONT (1 << 0)
@ -139,58 +139,58 @@
/** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
#define AUDIO_FEATURE_BASS_LOUDNESS (1 << 9)
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_UNDEFINED 0x0100
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_STREAMING 0x0101
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_VENDOR 0x01FF
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_IN_UNDEFINED 0x0200
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_IN_MIC 0x0201
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_IN_DESKTOP_MIC 0x0202
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_IN_PERSONAL_MIC 0x0203
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_IN_OMNIDIR_MIC 0x0204
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_IN_MIC_ARRAY 0x0205
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_IN_PROCESSING_MIC 0x0206
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_IN_OUT_UNDEFINED 0x0300
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_OUT_SPEAKER 0x0301
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_OUT_HEADPHONES 0x0302
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_OUT_HEAD_MOUNTED 0x0303
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_OUT_DESKTOP 0x0304
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_OUT_ROOM 0x0305
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_OUT_COMMUNICATION 0x0306
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
/** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
#define AUDIO_TERMINAL_OUT_LOWFREQ 0x0307
/** Convenience macro to fill a 24-bit \ref USB_Audio_SampleFreq_t structure with the given sample rate as a 24-bit number.
@ -198,7 +198,7 @@
* \param[in] freq Required audio sampling frequency in HZ
*/
#define AUDIO_SAMPLE_FREQ(freq) {((uint32_t)freq & 0x00FFFF), (((uint32_t)freq >> 16) & 0x0000FF)}
/** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint
* accepts only filled endpoint packets of audio samples.
*/
@ -208,7 +208,7 @@
* will accept partially filled endpoint packets of audio samples.
*/
#define AUDIO_EP_ACCEPTS_SMALL_PACKETS (0 << 7)
/* Enums: */
/** Audio class specific interface description subtypes, for the Audio Control interface. */
enum Audio_CSInterface_AC_SubTypes_t
@ -236,7 +236,7 @@
{
AUDIO_DSUBTYPE_CSEndpoint_General = 0x01, /**< Audio class specific endpoint general descriptor. */
};
/* Type Defines: */
/** \brief Audio class-specific Input Terminal Descriptor (LUFA naming conventions).
*
@ -252,7 +252,7 @@
uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
* must be \ref AUDIO_DSUBTYPE_CSInterface_InputTerminal.
*/
uint8_t TerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */
uint16_t TerminalType; /**< Type of terminal, a TERMINAL_* mask. */
uint8_t AssociatedOutputTerminal; /**< ID of associated output terminal, for physically grouped terminals
@ -260,7 +260,7 @@
*/
uint8_t TotalChannels; /**< Total number of separate audio channels within this interface (right, left, etc.) */
uint16_t ChannelConfig; /**< CHANNEL_* masks indicating what channel layout is supported by this terminal. */
uint8_t ChannelStrIndex; /**< Index of a string descriptor describing this channel within the device. */
uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */
} USB_Audio_Descriptor_InputTerminal_t;
@ -291,7 +291,7 @@
*/
uint8_t bNrChannels; /**< Total number of separate audio channels within this interface (right, left, etc.) */
uint16_t wChannelConfig; /**< CHANNEL_* masks indicating what channel layout is supported by this terminal. */
uint8_t iChannelNames; /**< Index of a string descriptor describing this channel within the device. */
uint8_t iTerminal; /**< Index of a string descriptor describing this descriptor within the device. */
} USB_Audio_StdDescriptor_InputTerminal_t;
@ -310,14 +310,14 @@
uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
* must be \ref AUDIO_DSUBTYPE_CSInterface_OutputTerminal.
*/
uint8_t TerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */
uint16_t TerminalType; /**< Type of terminal, a TERMINAL_* mask. */
uint8_t AssociatedInputTerminal; /**< ID of associated input terminal, for physically grouped terminals
* such as the speaker and microphone of a phone handset.
*/
uint8_t SourceID; /**< ID value of the unit this terminal's audio is sourced from. */
uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */
} USB_Audio_Descriptor_OutputTerminal_t;
@ -346,7 +346,7 @@
* such as the speaker and microphone of a phone handset.
*/
uint8_t bSourceID; /**< ID value of the unit this terminal's audio is sourced from. */
uint8_t iTerminal; /**< Index of a string descriptor describing this descriptor within the device. */
} USB_Audio_StdDescriptor_OutputTerminal_t;
@ -367,7 +367,7 @@
uint16_t ACSpecification; /**< Binary coded decimal value, indicating the supported Audio Class specification version. */
uint16_t TotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */
uint8_t InCollection; /**< Total number of Audio Streaming interfaces linked to this Audio Control interface (must be 1). */
uint8_t InterfaceNumber; /**< Interface number of the associated Audio Streaming interface. */
} USB_Audio_Descriptor_Interface_AC_t;
@ -394,11 +394,11 @@
uint16_t bcdADC; /**< Binary coded decimal value, indicating the supported Audio Class specification version. */
uint16_t wTotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */
uint8_t bInCollection; /**< Total number of Audio Streaming interfaces linked to this Audio Control interface (must be 1). */
uint8_t bInterfaceNumbers; /**< Interface number of the associated Audio Streaming interface. */
} USB_Audio_StdDescriptor_Interface_AC_t;
/** \brief Audio class-specific Feature Unit Descriptor (LUFA naming conventions).
*
* Type define for an Audio class-specific Feature Unit descriptor. This indicates to the host what features
@ -413,13 +413,13 @@
uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
* must be \ref AUDIO_DSUBTYPE_CSInterface_Feature.
*/
uint8_t UnitID; /**< ID value of this feature unit - must be a unique value within the device. */
uint8_t SourceID; /**< Source ID value of the audio source input into this feature unit. */
uint8_t ControlSize; /**< Size of each element in the ChanelControlls array. */
uint8_t ChannelControls[3]; /**< Feature masks for the control channel, and each separate audio channel. */
uint8_t FeatureUnitStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */
} USB_Audio_Descriptor_FeatureUnit_t;
@ -442,16 +442,16 @@
uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
* must be \ref AUDIO_DSUBTYPE_CSInterface_Feature.
*/
uint8_t bUnitID; /**< ID value of this feature unit - must be a unique value within the device. */
uint8_t bSourceID; /**< Source ID value of the audio source input into this feature unit. */
uint8_t bControlSize; /**< Size of each element in the ChanelControlls array. */
uint8_t bmaControls[3]; /**< Feature masks for the control channel, and each separate audio channel. */
uint8_t iFeature; /**< Index of a string descriptor describing this descriptor within the device. */
} USB_Audio_StdDescriptor_FeatureUnit_t;
/** \brief Audio class-specific Streaming Audio Interface Descriptor (LUFA naming conventions).
*
* Type define for an Audio class-specific streaming interface descriptor. This indicates to the host
@ -465,9 +465,9 @@
uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
* a value from the \ref Audio_CSInterface_AS_SubTypes_t enum.
*/
uint8_t TerminalLink; /**< ID value of the output terminal this descriptor is describing. */
uint8_t FrameDelay; /**< Delay in frames resulting from the complete sample processing from input to output. */
uint16_t AudioFormat; /**< Format of the audio stream, see Audio Device Formats specification. */
} USB_Audio_Descriptor_Interface_AS_t;
@ -490,13 +490,13 @@
uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
* a value from the \ref Audio_CSInterface_AS_SubTypes_t enum.
*/
uint8_t bTerminalLink; /**< ID value of the output terminal this descriptor is describing. */
uint8_t bDelay; /**< Delay in frames resulting from the complete sample processing from input to output. */
uint16_t wFormatTag; /**< Format of the audio stream, see Audio Device Formats specification. */
} USB_Audio_StdDescriptor_Interface_AS_t;
/** \brief 24-Bit Audio Frequency Structure.
*
* Type define for a 24bit audio sample frequency structure. GCC does not contain a built in 24bit datatype,
@ -522,14 +522,14 @@
uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
* must be \ref AUDIO_DSUBTYPE_CSInterface_FormatType.
*/
uint8_t FormatType; /**< Format of the audio stream, see Audio Device Formats specification. */
uint8_t Channels; /**< Total number of discrete channels in the stream. */
uint8_t SubFrameSize; /**< Size in bytes of each channel's sample data in the stream. */
uint8_t BitResolution; /**< Bits of resolution of each channel's samples in the stream. */
uint8_t SampleFrequencyType; /**< Total number of sample frequencies supported by the device. */
uint8_t SampleFrequencyType; /**< Total number of sample frequencies supported by the device. */
USB_Audio_SampleFreq_t SampleFrequencies[AUDIO_TOTAL_SAMPLE_RATES]; /**< Sample frequencies supported by the device (must be 24-bit). */
} USB_Audio_Descriptor_Format_t;
@ -555,17 +555,17 @@
uint8_t bFormatType; /**< Format of the audio stream, see Audio Device Formats specification. */
uint8_t bNrChannels; /**< Total number of discrete channels in the stream. */
uint8_t bSubFrameSize; /**< Size in bytes of each channel's sample data in the stream. */
uint8_t bBitResolution; /**< Bits of resolution of each channel's samples in the stream. */
uint8_t bSampleFrequencyType; /**< Total number of sample frequencies supported by the device. */
uint8_t bSampleFrequencyType; /**< Total number of sample frequencies supported by the device. */
uint8_t SampleFrequencies[AUDIO_TOTAL_SAMPLE_RATES * 3]; /**< Sample frequencies supported by the device (must be 24-bit). */
} USB_Audio_StdDescriptor_Format_t;
/** \brief Audio class-specific Streaming Endpoint Descriptor (LUFA naming conventions).
*
* Type define for an Audio class-specific endpoint descriptor. This contains a regular endpoint
* Type define for an Audio class-specific endpoint descriptor. This contains a regular endpoint
* descriptor with a few Audio-class-specific extensions. See the USB Audio specification for more details.
*
* \see \ref USB_Audio_StdDescriptor_StreamEndpoint_Std_t for the version of this type with standard element names.
@ -580,7 +580,7 @@
/** \brief Audio class-specific Streaming Endpoint Descriptor (USB-IF naming conventions).
*
* Type define for an Audio class-specific endpoint descriptor. This contains a regular endpoint
* Type define for an Audio class-specific endpoint descriptor. This contains a regular endpoint
* descriptor with a few Audio-class-specific extensions. See the USB Audio specification for more details.
*
* \see \ref USB_Audio_Descriptor_StreamEndpoint_Std_t for the version of this type with non-standard LUFA specific
@ -592,10 +592,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
@ -604,7 +604,7 @@
uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
* ISOCHRONOUS type.
*/
uint8_t bRefresh; /**< Always set to zero for Audio class devices. */
uint8_t bSynchAddress; /**< Endpoint address to send synchronization information to, if needed (zero otherwise). */
} USB_Audio_StdDescriptor_StreamEndpoint_Std_t;
@ -623,7 +623,7 @@
uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
* a value from the \ref Audio_CSEndpoint_SubTypes_t enum.
*/
uint8_t Attributes; /**< Audio class-specific endpoint attributes, such as ACCEPTS_SMALL_PACKETS. */
uint8_t LockDelayUnits; /**< Units used for the LockDelay field, see Audio class specification. */
@ -649,18 +649,19 @@
uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors,
* a value from the \ref Audio_CSEndpoint_SubTypes_t enum.
*/
uint8_t bmAttributes; /**< Audio class-specific endpoint attributes, such as ACCEPTS_SMALL_PACKETS. */
uint8_t bLockDelayUnits; /**< Units used for the LockDelay field, see Audio class specification. */
uint16_t wLockDelay; /**< Time required to internally lock endpoint's internal clock recovery circuitry. */
} USB_Audio_StdDescriptor_StreamEndpoint_Spc_t;
/* 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
@ -46,7 +46,7 @@
*
* @{
*/
#ifndef _CDC_CLASS_COMMON_H_
#define _CDC_CLASS_COMMON_H_
@ -64,7 +64,7 @@
#if !defined(__INCLUDE_FROM_CDC_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/Class/CDC.h instead.
#endif
/* Macros: */
/** Mask for the DTR handshake line for use with the \ref CDC_REQ_SetControlLineState class-specific request
* from the host, to indicate that the DTR line state should be high.
@ -75,7 +75,7 @@
* from the host, to indicate that the RTS line state should be high.
*/
#define CDC_CONTROL_LINE_OUT_RTS (1 << 1)
/** Mask for the DCD handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification
* from the device to the host, to indicate that the DCD line state is currently high.
*/
@ -110,7 +110,7 @@
* to indicate that a data overrun error has occurred on the virtual serial port.
*/
#define CDC_CONTROL_LINE_IN_OVERRUNERROR (1 << 6)
/** Macro to define a CDC class-specific functional descriptor. CDC functional descriptors have a
* uniform structure but variable sized data payloads, thus cannot be represented accurately by
* a single typedef struct. A macro is used instead so that functional descriptors can be created
@ -125,19 +125,19 @@
uint8_t SubType; \
uint8_t Data[DataSize]; \
}
/* Enums: */
/** Enum for the CDC class specific control requests that can be issued by the USB bus host. */
enum CDC_ClassRequests_t
{
{
CDC_REQ_SendEncapsulatedCommand = 0x00, /**< CDC class-specific request to send an encapsulated command to the device. */
CDC_REQ_GetEncapsulatedResponse = 0x01, /**< CDC class-specific request to retrieve an encapsulated command response from the device. */
CDC_REQ_GetEncapsulatedResponse = 0x01, /**< CDC class-specific request to retrieve an encapsulated command response from the device. */
CDC_REQ_SetLineEncoding = 0x20, /**< CDC class-specific request to set the current virtual serial port configuration settings. */
CDC_REQ_GetLineEncoding = 0x21, /**< CDC class-specific request to get the current virtual serial port configuration settings. */
CDC_REQ_SetControlLineState = 0x22, /**< CDC class-specific request to set the current virtual serial port handshake line states. */
CDC_REQ_SendBreak = 0x23, /**< CDC class-specific request to send a break to the receiver via the carrier channel. */
};
/** Enum for the CDC class specific notification requests that can be issued by a CDC device to a host. */
enum CDC_ClassNotifications_t
{
@ -147,7 +147,7 @@
* endpoint.
*/
};
/** Enum for the CDC class specific interface descriptor subtypes. */
enum CDC_DescriptorSubtypes_t
{
@ -169,7 +169,7 @@
CDC_DSUBTYPE_CSInterface_Ethernet = 0x0F, /**< CDC class-specific Ethernet functional descriptor. */
CDC_DSUBTYPE_CSInterface_ATM = 0x10, /**< CDC class-specific Asynchronous Transfer Mode functional descriptor. */
};
/** Enum for the possible line encoding formats of a virtual serial port. */
enum CDC_LineEncodingFormats_t
{
@ -177,7 +177,7 @@
CDC_LINEENCODING_OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits. */
CDC_LINEENCODING_TwoStopBits = 2, /**< Each frame contains two stop bits. */
};
/** Enum for the possible line encoding parity settings of a virtual serial port. */
enum CDC_LineEncodingParity_t
{
@ -270,7 +270,7 @@
* to the CDC ACM specification.
*/
} USB_CDC_StdDescriptor_FunctionalACM_t;
/** \brief CDC class-specific Functional Union Descriptor (LUFA naming conventions).
*
* Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific
@ -287,7 +287,7 @@
uint8_t MasterInterfaceNumber; /**< Interface number of the CDC Control interface. */
uint8_t SlaveInterfaceNumber; /**< Interface number of the CDC Data interface. */
} USB_CDC_Descriptor_FunctionalUnion_t;
/** \brief CDC class-specific Functional Union Descriptor (USB-IF naming conventions).
*
* Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific
@ -313,7 +313,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
@ -46,7 +46,7 @@
*
* @{
*/
#ifndef _HID_CLASS_COMMON_H_
#define _HID_CLASS_COMMON_H_
@ -59,8 +59,8 @@
#if !defined(__INCLUDE_FROM_HID_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/Class/HID.h instead.
#endif
/* Macros: */
/* Macros: */
/** Constant for a keyboard report modifier byte, indicating that the keyboard's left control key is currently pressed. */
#define HID_KEYBOARD_MODIFER_LEFTCTRL (1 << 0)
@ -84,10 +84,10 @@
/** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */
#define HID_KEYBOARD_MODIFER_RIGHTGUI (1 << 7)
/** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */
#define HID_KEYBOARD_LED_NUMLOCK (1 << 0)
/** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */
#define HID_KEYBOARD_LED_CAPSLOCK (1 << 1)
@ -108,14 +108,14 @@
HID_REQ_GetProtocol = 0x03, /**< HID class-specific Request to get the current HID report protocol mode. */
HID_REQ_SetProtocol = 0x0B, /**< HID class-specific Request to set the current HID report protocol mode. */
};
/** Enum for the HID class specific descriptor types. */
enum HID_DescriptorTypes_t
{
HID_DTYPE_HID = 0x21, /**< Descriptor header type value, to indicate a HID class HID descriptor. */
HID_DTYPE_Report = 0x22, /**< Descriptor header type value, to indicate a HID class HID report descriptor. */
};
/** Enum for the HID class boot protocols that may be supported by HID devices. */
enum HID_BootProtocols_t
{
@ -132,7 +132,7 @@
* Specification).
*/
};
/** Enum for the different types of HID reports. */
enum HID_ReportItemTypes_t
{
@ -151,10 +151,10 @@
typedef struct
{
USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
uint16_t HIDSpec; /**< BCD encoded version that the HID descriptor and device complies to. */
uint8_t CountryCode; /**< Country code of the localized device, or zero if universal. */
uint8_t TotalReportDescriptors; /**< Total number of HID report descriptors for the interface. */
uint8_t HIDReportType; /**< Type of HID report, set to \ref HID_DTYPE_Report. */
@ -175,10 +175,10 @@
uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
* given by the specific class.
*/
uint16_t bcdHID; /**< BCD encoded version that the HID descriptor and device complies to. */
uint8_t bCountryCode; /**< Country code of the localized device, or zero if universal. */
uint8_t bNumDescriptors; /**< Total number of HID report descriptors for the interface. */
uint8_t bDescriptorType2; /**< Type of HID report, set to \ref HID_DTYPE_Report. */
@ -195,7 +195,7 @@
int8_t X; /**< Current delta X movement of the mouse. */
int8_t Y; /**< Current delta Y movement on the mouse. */
} USB_MouseReport_Data_t;
/** \brief Standard HID Boot Protocol Keyboard Report.
*
* Type define for a standard Boot Protocol Keyboard report
@ -215,3 +215,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
@ -68,7 +68,7 @@
#if !defined(__INCLUDE_FROM_MIDI_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/Class/MIDI.h instead.
#endif
/* Macros: */
/** MIDI command for a note on (activation) event. */
#define MIDI_COMMAND_NOTE_ON 0x90
@ -78,21 +78,21 @@
/** Standard key press velocity value used for all note events. */
#define MIDI_STANDARD_VELOCITY 64
/** Convenience macro. MIDI channels are numbered from 1-10 (natural numbers) however the logical channel
* addresses are zero-indexed. This converts a natural MIDI channel number into the logical channel address.
*
* \param[in] channel MIDI channel number to address.
*/
#define MIDI_CHANNEL(channel) ((channel) - 1)
/* Enums: */
enum MIDI_JackTypes_t
{
MIDI_JACKTYPE_Embedded = 0x01, /**< MIDI class descriptor jack type value for an embedded (logical) MIDI input or output jack. */
MIDI_JACKTYPE_External = 0x02, /**< MIDI class descriptor jack type value for an external (physical) MIDI input or output jack. */
};
/* Type Defines: */
/** \brief MIDI class-specific Streaming Interface Descriptor (LUFA naming conventions).
*
@ -106,13 +106,13 @@
{
USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */
uint16_t AudioSpecification; /**< Binary coded decimal value, indicating the supported Audio Class
* specification version.
*/
uint16_t TotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */
} USB_MIDI_Descriptor_AudioInterface_AS_t;
/** \brief MIDI class-specific Streaming Interface Descriptor (USB-IF naming conventions).
*
* Type define for an Audio class-specific MIDI streaming interface descriptor. This indicates to the host
@ -130,7 +130,7 @@
*/
uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */
uint16_t bcdMSC; /**< Binary coded decimal value, indicating the supported MIDI Class specification version. */
uint16_t wTotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */
} USB_MIDI_StdDescriptor_AudioInterface_AS_t;
@ -149,7 +149,7 @@
uint8_t JackType; /**< Type of jack, one of the JACKTYPE_* mask values. */
uint8_t JackID; /**< ID value of this jack - must be a unique value within the device. */
uint8_t JackStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */
} USB_MIDI_Descriptor_InputJack_t;
@ -172,7 +172,7 @@
uint8_t bJackType; /**< Type of jack, one of the JACKTYPE_* mask values. */
uint8_t bJackID; /**< ID value of this jack - must be a unique value within the device. */
uint8_t iJack; /**< Index of a string descriptor describing this descriptor within the device. */
} USB_MIDI_StdDescriptor_InputJack_t;
@ -190,14 +190,14 @@
uint8_t JackType; /**< Type of jack, one of the JACKTYPE_* mask values. */
uint8_t JackID; /**< ID value of this jack - must be a unique value within the device. */
uint8_t NumberOfPins; /**< Number of output channels within the jack, either physical or logical. */
uint8_t SourceJackID[1]; /**< ID of each output pin's source data jack. */
uint8_t SourcePinID[1]; /**< Pin number in the input jack of each output pin's source data. */
uint8_t JackStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */
} USB_MIDI_Descriptor_OutputJack_t;
/** \brief MIDI class-specific Output Jack Descriptor (USB-IF naming conventions).
*
* Type define for an Audio class-specific MIDI OUT jack. This gives information to the host on a MIDI output, either
@ -217,11 +217,11 @@
uint8_t bJackType; /**< Type of jack, one of the JACKTYPE_* mask values. */
uint8_t bJackID; /**< ID value of this jack - must be a unique value within the device. */
uint8_t bNrInputPins; /**< Number of output channels within the jack, either physical or logical. */
uint8_t baSourceID[1]; /**< ID of each output pin's source data jack. */
uint8_t baSourcePin[1]; /**< Pin number in the input jack of each output pin's source data. */
uint8_t iJack; /**< Index of a string descriptor describing this descriptor within the device. */
} USB_MIDI_StdDescriptor_OutputJack_t;
@ -272,17 +272,18 @@
{
unsigned char Command : 4; /**< Upper nibble of the MIDI command being sent or received in the event packet. */
unsigned char CableNumber : 4; /**< Virtual cable number of the event being sent or received in the given MIDI interface. */
uint8_t Data1; /**< First byte of data in the MIDI event. */
uint8_t Data2; /**< Second byte of data in the MIDI event. */
uint8_t Data3; /**< Third byte of data in the MIDI event. */
uint8_t Data3; /**< Third byte of data in the MIDI event. */
} MIDI_EventPacket_t;
/* 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
@ -64,14 +64,14 @@
#if !defined(__INCLUDE_FROM_MS_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/Class/MassStorage.h instead.
#endif
/* Macros: */
/** Magic signature for a Command Block Wrapper used in the Mass Storage Bulk-Only transport protocol. */
#define MS_CBW_SIGNATURE 0x43425355UL
/** Magic signature for a Command Status Wrapper used in the Mass Storage Bulk-Only transport protocol. */
#define MS_CSW_SIGNATURE 0x53425355UL
/** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from host-to-device. */
#define MS_COMMAND_DIR_DATA_OUT (0 << 7)
@ -203,7 +203,7 @@
/** SCSI Additional Sense Qualifier Code to indicate that an operation is currently in progress. */
#define SCSI_ASENSEQ_OPERATION_IN_PROGRESS 0x07
/* Enums: */
/** Enum for the Mass Storage class specific control requests that can be issued by the USB bus host. */
enum MS_ClassRequests_t
@ -215,7 +215,7 @@
* ready for the next command.
*/
};
/** Enum for the possible command status wrapper return status codes. */
enum MS_CommandStatusCodes_t
{
@ -240,7 +240,7 @@
uint8_t SCSICommandLength; /**< Length of the issued SCSI command within the SCSI command data array. */
uint8_t SCSICommandData[16]; /**< Issued SCSI command in the Command Block. */
} MS_CommandBlockWrapper_t;
/** \brief Mass Storage Class Command Status Wrapper.
*
* Type define for a Command Status Wrapper, used in the Mass Storage Bulk-Only Transport protocol.
@ -252,9 +252,9 @@
uint32_t DataTransferResidue; /**< Number of bytes of data not processed in the SCSI command. */
uint8_t Status; /**< Status code of the issued command - a value from the \ref MS_CommandStatusCodes_t enum. */
} MS_CommandStatusWrapper_t;
/** \brief Mass Storage Class SCSI Sense Structure
*
*
* Type define for a SCSI Sense structure. Structures of this type are filled out by the
* device via the \ref MS_Host_RequestSense() function, indicating the current sense data of the
* device (giving explicit error codes for the last issued command). For details of the
@ -265,13 +265,13 @@
uint8_t ResponseCode;
uint8_t SegmentNumber;
unsigned char SenseKey : 4;
unsigned char Reserved : 1;
unsigned char ILI : 1;
unsigned char EOM : 1;
unsigned char FileMark : 1;
uint8_t Information[4];
uint8_t AdditionalLength;
uint8_t CmdSpecificInformation[4];
@ -293,12 +293,12 @@
{
unsigned char DeviceType : 5;
unsigned char PeripheralQualifier : 3;
unsigned char Reserved : 7;
unsigned char Removable : 1;
uint8_t Version;
unsigned char ResponseDataFormat : 4;
unsigned char Reserved2 : 1;
unsigned char NormACA : 1;
@ -316,17 +316,18 @@
unsigned char WideBus16Bit : 1;
unsigned char WideBus32Bit : 1;
unsigned char RelAddr : 1;
uint8_t VendorID[8];
uint8_t ProductID[16];
uint8_t RevisionID[4];
} SCSI_Inquiry_Response_t;
/* 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
@ -64,7 +64,7 @@
#if !defined(__INCLUDE_FROM_PRINTER_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/Class/Printer.h instead.
#endif
/* Macros: */
/** Port status mask for a printer device, indicating that an error has *not* occurred. */
#define PRNT_PORTSTATUS_NOTERROR (1 << 3)
@ -74,12 +74,13 @@
/** Port status mask for a printer device, indicating that the device is currently out of paper. */
#define PRNT_PORTSTATUS_PAPEREMPTY (1 << 5)
/* 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
@ -57,9 +57,9 @@
#include "../../USB.h"
#include "RNDISConstants.h"
#include "CDC.h"
#include <string.h>
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
@ -69,20 +69,20 @@
#if !defined(__INCLUDE_FROM_RNDIS_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/Class/RNDIS.h instead.
#endif
/* Macros: */
/** Implemented RNDIS Version Major. */
#define REMOTE_NDIS_VERSION_MAJOR 0x01
/** Implemented RNDIS Version Minor. */
#define REMOTE_NDIS_VERSION_MINOR 0x00
/** Maximum size in bytes of a RNDIS control message which can be sent or received. */
#define RNDIS_MESSAGE_BUFFER_SIZE 128
/** Maximum size in bytes of an Ethernet frame according to the Ethernet standard. */
#define ETHERNET_FRAME_SIZE_MAX 1500
/* Enums: */
/** Enum for the RNDIS class specific control requests that can be issued by the USB bus host. */
enum RNDIS_ClassRequests_t
@ -90,7 +90,7 @@
RNDIS_REQ_SendEncapsulatedCommand = 0x00, /**< RNDIS request to issue a host-to-device NDIS command. */
RNDIS_REQ_GetEncapsulatedResponse = 0x01, /**< RNDIS request to issue a device-to-host NDIS response. */
};
/** Enum for the possible NDIS adapter states. */
enum RNDIS_States_t
{
@ -114,7 +114,7 @@
NDIS_HardwareStatus_Closing, /**< Hardware currently closing. */
NDIS_HardwareStatus_NotReady /**< Hardware not ready to accept commands from the host. */
};
/* Type Defines: */
/** \brief MAC Address Structure.
*
@ -174,12 +174,12 @@
uint32_t MessageType;
uint32_t MessageLength;
uint32_t RequestId;
uint32_t MajorVersion;
uint32_t MinorVersion;
uint32_t MaxTransferSize;
} RNDIS_Initialize_Message_t;
/** \brief RNDIS Initialize Complete Message Structure.
*
* Type define for a RNDIS Initialize Complete response message.
@ -190,7 +190,7 @@
uint32_t MessageLength;
uint32_t RequestId;
uint32_t Status;
uint32_t MajorVersion;
uint32_t MinorVersion;
uint32_t DeviceFlags;
@ -201,7 +201,7 @@
uint32_t AFListOffset;
uint32_t AFListSize;
} RNDIS_Initialize_Complete_t;
/** \brief RNDIS Keep Alive Message Structure.
*
* Type define for a RNDIS Keep Alive command message.
@ -237,7 +237,7 @@
uint32_t AddressingReset;
} RNDIS_Reset_Complete_t;
/** \brief RNDIS OID Property Set Message Structure.
*
* Type define for a RNDIS OID Property Set command message.
@ -247,7 +247,7 @@
uint32_t MessageType;
uint32_t MessageLength;
uint32_t RequestId;
uint32_t Oid;
uint32_t InformationBufferLength;
uint32_t InformationBufferOffset;
@ -265,7 +265,7 @@
uint32_t RequestId;
uint32_t Status;
} RNDIS_Set_Complete_t;
/** \brief RNDIS OID Property Query Message Structure.
*
* Type define for a RNDIS OID Property Query command message.
@ -275,13 +275,13 @@
uint32_t MessageType;
uint32_t MessageLength;
uint32_t RequestId;
uint32_t Oid;
uint32_t InformationBufferLength;
uint32_t InformationBufferOffset;
uint32_t DeviceVcHandle;
} RNDIS_Query_Message_t;
/** \brief RNDIS OID Property Query Complete Message Structure.
*
* Type define for a RNDIS OID Property Query Complete response message.
@ -292,16 +292,17 @@
uint32_t MessageLength;
uint32_t RequestId;
uint32_t Status;
uint32_t InformationBufferLength;
uint32_t InformationBufferOffset;
} RNDIS_Query_Complete_t;
/* 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
@ -42,7 +42,7 @@
* RNDIS specification related constants. For more information on these
* constants, please refer to the Microsoft RNDIS specification.
*/
#ifndef _RNDIS_CONSTANTS_DEVICE_H_
#define _RNDIS_CONSTANTS_DEVICE_H_
@ -61,19 +61,19 @@
#define REMOTE_NDIS_SET_CMPLT 0x80000005UL
#define REMOTE_NDIS_RESET_CMPLT 0x80000006UL
#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008UL
#define REMOTE_NDIS_STATUS_SUCCESS 0x00000000UL
#define REMOTE_NDIS_STATUS_FAILURE 0xC0000001UL
#define REMOTE_NDIS_STATUS_INVALID_DATA 0xC0010015UL
#define REMOTE_NDIS_STATUS_NOT_SUPPORTED 0xC00000BBUL
#define REMOTE_NDIS_STATUS_MEDIA_CONNECT 0x4001000BUL
#define REMOTE_NDIS_STATUS_MEDIA_DISCONNECT 0x4001000CUL
#define REMOTE_NDIS_MEDIA_STATE_CONNECTED 0x00000000UL
#define REMOTE_NDIS_MEDIA_STATE_DISCONNECTED 0x00000001UL
#define REMOTE_NDIS_MEDIUM_802_3 0x00000000UL
#define REMOTE_NDIS_DF_CONNECTIONLESS 0x00000001UL
#define REMOTE_NDIS_DF_CONNECTION_ORIENTED 0x00000002UL
@ -88,8 +88,8 @@
#define REMOTE_NDIS_PACKET_GROUP 0x00001000UL
#define REMOTE_NDIS_PACKET_ALL_FUNCTIONAL 0x00002000UL
#define REMOTE_NDIS_PACKET_FUNCTIONAL 0x00004000UL
#define REMOTE_NDIS_PACKET_MAC_FRAME 0x00008000UL
#define REMOTE_NDIS_PACKET_MAC_FRAME 0x00008000UL
#define OID_GEN_SUPPORTED_LIST 0x00010101UL
#define OID_GEN_HARDWARE_STATUS 0x00010102UL
#define OID_GEN_MEDIA_SUPPORTED 0x00010103UL
@ -119,3 +119,4 @@
#define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103UL
#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
@ -54,7 +54,7 @@
#include "../../USB.h"
#include <string.h>
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
@ -64,7 +64,7 @@
#if !defined(__INCLUDE_FROM_SI_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/Class/StillImage.h instead.
#endif
/* Macros: */
/** Length in bytes of a given Unicode string's character length.
*
@ -73,7 +73,7 @@
* \return Number of bytes of the given unicode string.
*/
#define UNICODE_STRING_LENGTH(Chars) ((Chars) << 1)
/** Used in the DataLength field of a PIMA container, to give the total container size in bytes for
* a command container.
*
@ -97,8 +97,8 @@
SI_PIMA_CONTAINER_DataBlock = 2, /**< Data Block container type. */
SI_PIMA_CONTAINER_ResponseBlock = 3, /**< Response container type. */
SI_PIMA_CONTAINER_EventBlock = 4, /**< Event Block container type. */
};
};
/* Enums: */
/** Enums for the possible status codes of a returned Response Block from an attached PIMA compliant Still Image device. */
enum SI_PIMA_ResponseCodes_t
@ -118,7 +118,7 @@
* parameters are not supported by the device.
*/
};
/* Type Defines: */
/** \brief PIMA Still Image Device Command/Response Container.
*
@ -133,12 +133,13 @@
uint32_t TransactionID; /**< Unique container ID to link blocks together. */
uint32_t Params[3]; /**< Block parameters to be issued along with the block code (command blocks only). */
} SI_PIMA_Container_t;
/* 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
@ -39,7 +39,7 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi
{
if (!(Endpoint_IsSETUPReceived()))
return;
if (USB_ControlRequest.wIndex != AudioInterfaceInfo->Config.StreamingInterfaceNumber)
return;
@ -84,14 +84,14 @@ bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* const AudioIn
{
continue;
}
if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size, ENDPOINT_BANK_DOUBLE)))
{
return false;
}
}
return true;
}
#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
@ -56,7 +56,7 @@
/* Includes: */
#include "../../USB.h"
#include "../Common/Audio.h"
#include <string.h>
/* Enable C linkage for C++ Compilers: */
@ -97,7 +97,7 @@
*/
uint16_t DataOUTEndpointSize; /**< Size in bytes of the outgoing Audio Streaming data endpoint, if available
* (zero if unused).
*/
*/
} Config; /**< Config data for the USB class interface within the device. All elements in this section
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
*/
@ -108,9 +108,9 @@
*/
} State; /**< State data for the USB class interface within the device. All elements in this section
* are reset to their defaults when the interface is enumerated.
*/
*/
} USB_ClassInfo_Audio_Device_t;
/* Function Prototypes: */
/** Configures the endpoints of a given Audio interface, ready for use. This should be linked to the library
* \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the
@ -132,8 +132,8 @@
* \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
*/
void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/* Inline Functions: */
/* Inline Functions: */
/** General management task for a given Audio class interface, required for the correct operation of the interface. This should
* be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
*
@ -162,8 +162,8 @@
{
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(AudioInterfaceInfo->State.InterfaceEnabled))
return false;
Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataOUTEndpointNumber);
Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataOUTEndpointNumber);
return Endpoint_IsOUTReceived();
}
@ -183,7 +183,7 @@
{
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(AudioInterfaceInfo->State.InterfaceEnabled))
return false;
Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataINEndpointNumber);
return Endpoint_IsINReady();
}
@ -202,14 +202,14 @@
static inline int8_t Audio_Device_ReadSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)
{
int8_t Sample;
(void)AudioInterfaceInfo;
Sample = Endpoint_Read_Byte();
if (!(Endpoint_BytesInEndpoint()))
Endpoint_ClearOUT();
return Sample;
}
@ -231,7 +231,7 @@
(void)AudioInterfaceInfo;
Sample = (int16_t)Endpoint_Read_Word_LE();
if (!(Endpoint_BytesInEndpoint()))
Endpoint_ClearOUT();
@ -256,7 +256,7 @@
(void)AudioInterfaceInfo;
Sample = (((uint32_t)Endpoint_Read_Byte() << 16) | Endpoint_Read_Word_LE());
if (!(Endpoint_BytesInEndpoint()))
Endpoint_ClearOUT();
@ -325,7 +325,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 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter
{
if (!(Endpoint_IsSETUPReceived()))
return;
if (USB_ControlRequest.wIndex != CDCInterfaceInfo->Config.ControlInterfaceNumber)
return;
@ -58,7 +58,7 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter
Endpoint_Write_Control_Stream_LE(&CDCInterfaceInfo->State.LineEncoding, sizeof(CDCInterfaceInfo->State.LineEncoding));
Endpoint_ClearOUT();
}
break;
case CDC_REQ_SetLineEncoding:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
@ -69,11 +69,11 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter
EVENT_CDC_Device_LineEncodingChanged(CDCInterfaceInfo);
}
break;
case CDC_REQ_SetControlLineState:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{
{
Endpoint_ClearSETUP();
Endpoint_ClearStatusStage();
@ -81,11 +81,11 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter
EVENT_CDC_Device_ControLineStateChanged(CDCInterfaceInfo);
}
break;
case CDC_REQ_SendBreak:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{
{
Endpoint_ClearSETUP();
Endpoint_ClearStatusStage();
@ -132,14 +132,14 @@ bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfac
{
continue;
}
if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size,
DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
{
return false;
}
}
return true;
}
@ -147,7 +147,7 @@ void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
{
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
return;
CDC_Device_Flush(CDCInterfaceInfo);
}
@ -157,7 +157,7 @@ uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo
{
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
return ENDPOINT_RWSTREAM_DeviceDisconnected;
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
return Endpoint_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);
}
@ -195,11 +195,11 @@ uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
if (!(Endpoint_BytesInEndpoint()))
return ENDPOINT_READYWAIT_NoError;
bool BankFull = !(Endpoint_IsReadWriteAllowed());
Endpoint_ClearIN();
if (BankFull)
{
if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError)
@ -207,7 +207,7 @@ uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
Endpoint_ClearIN();
}
return ENDPOINT_READYWAIT_NoError;
}
@ -244,16 +244,16 @@ int16_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInf
int16_t ReceivedByte = -1;
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber);
if (Endpoint_IsOUTReceived())
{
if (Endpoint_BytesInEndpoint())
ReceivedByte = Endpoint_Read_Byte();
if (!(Endpoint_BytesInEndpoint()))
Endpoint_ClearOUT();
}
return ReceivedByte;
}
@ -263,7 +263,7 @@ void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDC
return;
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.NotificationEndpointNumber);
USB_Request_Header_t Notification = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
@ -313,17 +313,18 @@ static int CDC_Device_getchar(FILE* Stream)
static int CDC_Device_getchar_Blocking(FILE* Stream)
{
int16_t ReceivedByte;
while ((ReceivedByte = CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream))) < 0)
{
if (USB_DeviceState == DEVICE_STATE_Unattached)
return _FDEV_EOF;
CDC_Device_USBTask((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream));
USB_USBTask();
USB_USBTask();
}
return ReceivedByte;
}
#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,7 +50,7 @@
* \note There are several major drawbacks to the CDC-ACM standard USB class, however
* it is very standardized and thus usually available as a built-in driver on
* most platforms, and so is a better choice than a proprietary serial class.
*
*
* One major issue with CDC-ACM is that it requires two Interface descriptors,
* which will upset most hosts when part of a multi-function "Composite" USB
* device, as each interface will be loaded into a separate driver instance. To
@ -66,7 +66,7 @@
*
* @{
*/
#ifndef _CDC_CLASS_DEVICE_H_
#define _CDC_CLASS_DEVICE_H_
@ -86,7 +86,7 @@
#if !defined(__INCLUDE_FROM_CDC_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/Class/CDC.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Type Defines: */
/** \brief CDC Class Device Mode Configuration and State Structure.
@ -140,13 +140,13 @@
uint8_t DataBits; /**< Bits of data per character of the virtual serial port. */
} LineEncoding; /** Line encoding used in the virtual serial port, for the device's information. This is generally
* only used if the virtual serial port data is to be reconstructed on a physical UART.
*/
*/
} State; /**< State data for the USB class interface within the device. All elements in this section
* are reset to their defaults when the interface is enumerated.
*/
} USB_ClassInfo_CDC_Device_t;
/* Function Prototypes: */
/* Function Prototypes: */
/** Configures the endpoints of a given CDC interface, ready for use. This should be linked to the library
* \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing
* the given CDC interface is selected.
@ -183,7 +183,7 @@
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
*/
void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** CDC class driver event for a control line state change on a CDC interface. This event fires each time the host requests a
* control line state change (containing the virtual serial control line states, such as DTR) and may be hooked in the
* user program by declaring a handler function with the same name and parameters listed here. The new control line states
@ -205,7 +205,7 @@
/** Sends a given string to the attached USB host, if connected. If a host is not connected when the function is called, the
* string is discarded. Bytes will be queued for transmission to the host until either the endpoint bank becomes full, or the
* \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be
* \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be
* packed into a single endpoint packet, increasing data throughput.
*
* \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or
@ -220,10 +220,10 @@
uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
const char* const Data,
const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
/** Sends a given byte to the attached USB host, if connected. If a host is not connected when the function is called, the
* byte is discarded. Bytes will be queued for transmission to the host until either the endpoint bank becomes full, or the
* \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be
* \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be
* packed into a single endpoint packet, increasing data throughput.
*
* \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or
@ -236,7 +236,7 @@
*/
uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_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 host, waiting to be read. This indicates the number
* of bytes in the OUT endpoint bank only, and thus the number of calls to \ref CDC_Device_ReceiveByte() which are guaranteed to
* succeed immediately. If multiple bytes are to be received, they should be buffered by the user application, as the endpoint
@ -250,7 +250,7 @@
* \return Total number of buffered bytes received from the host.
*/
uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Reads a byte of data from the host. If no data is waiting to be read of if a USB host is not connected, the function
* returns a negative value. The \ref CDC_Device_BytesReceived() function may be queried in advance to determine how many
* bytes are currently buffered in the CDC interface's data receive endpoint bank, and thus how many repeated calls to this
@ -264,7 +264,7 @@
* \return Next received byte from the host, or a negative value if no data received.
*/
int16_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.
*
* \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or
@ -275,10 +275,10 @@
* \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum.
*/
uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Sends a Serial Control Line State Change notification to the host. This should be called when the virtual serial
* control lines (DCD, DSR, etc.) have changed states, or to give BREAK notifications to the host. Line states persist
* until they are cleared via a second notification. This should be called each time the CDC class driver's
* until they are cleared via a second notification. This should be called each time the CDC class driver's
* ControlLineStates.DeviceToHost value is updated to push the new states to the USB host.
*
* \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or
@ -323,7 +323,7 @@
FILE* Stream) ATTR_NON_NULL_PTR_ARG(2);
static int CDC_Device_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
static int CDC_Device_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
void CDC_Device_Event_Stub(void);
void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub);
@ -335,12 +335,13 @@
#endif
#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
@ -39,7 +39,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter
{
if (!(Endpoint_IsSETUPReceived()))
return;
if (USB_ControlRequest.wIndex != HIDInterfaceInfo->Config.InterfaceNumber)
return;
@ -56,7 +56,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter
memset(ReportData, 0, sizeof(ReportData));
CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportType, ReportData, &ReportSize);
if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL)
memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportData, HIDInterfaceInfo->Config.PrevReportINBufferSize);
@ -66,7 +66,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter
Endpoint_Write_Control_Stream_LE(ReportData, ReportSize);
Endpoint_ClearOUT();
}
break;
case HID_REQ_SetReport:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
@ -82,7 +82,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter
CALLBACK_HID_Device_ProcessHIDReport(HIDInterfaceInfo, ReportID, ReportType, ReportData, ReportSize);
}
break;
case HID_REQ_GetProtocol:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
@ -92,7 +92,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter
Endpoint_ClearIN();
Endpoint_ClearStatusStage();
}
break;
case HID_REQ_SetProtocol:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
@ -100,9 +100,9 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter
Endpoint_ClearSETUP();
Endpoint_ClearStatusStage();
HIDInterfaceInfo->State.UsingReportProtocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00);
HIDInterfaceInfo->State.UsingReportProtocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00);
}
break;
case HID_REQ_SetIdle:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
@ -112,11 +112,11 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter
HIDInterfaceInfo->State.IdleCount = ((USB_ControlRequest.wValue & 0xFF00) >> 6);
}
break;
case HID_REQ_GetIdle:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{
{
Endpoint_ClearSETUP();
Endpoint_Write_Byte(HIDInterfaceInfo->State.IdleCount >> 2);
Endpoint_ClearIN();
@ -139,17 +139,17 @@ bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* const HIDInterfac
{
return false;
}
return true;
}
void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)
{
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber);
if (Endpoint_IsReadWriteAllowed())
{
uint8_t ReportINData[HIDInterfaceInfo->Config.PrevReportINBufferSize];
@ -162,7 +162,7 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)
ReportINData, &ReportINSize);
bool StatesChanged = false;
bool IdlePeriodElapsed = (HIDInterfaceInfo->State.IdleCount && !(HIDInterfaceInfo->State.IdleMSRemaining));
if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL)
{
StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize) != 0);
@ -179,10 +179,11 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)
Endpoint_Write_Byte(ReportID);
Endpoint_Write_Stream_LE(ReportINData, ReportINSize, NO_STREAM_CALLBACK);
Endpoint_ClearIN();
}
}
}
#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
@ -49,7 +49,7 @@
*
* @{
*/
#ifndef _HID_CLASS_DEVICE_H_
#define _HID_CLASS_DEVICE_H_
@ -88,14 +88,14 @@
uint8_t InterfaceNumber; /**< Interface number of the HID interface within the device. */
uint8_t ReportINEndpointNumber; /**< Endpoint number of the HID interface's IN report endpoint. */
uint16_t ReportINEndpointSize; /**< Size in bytes of the HID interface's IN report endpoint. */
uint16_t ReportINEndpointSize; /**< Size in bytes of the HID interface's IN report endpoint. */
bool ReportINEndpointDoubleBank; /**< Indicates if the HID interface's IN report endpoint should use double banking. */
void* PrevReportINBuffer; /**< Pointer to a buffer where the previously created HID input report can be
* stored by the driver, for comparison purposes to detect report changes that
* must be sent immediately to the host. This should point to a buffer big enough
* to hold the largest HID input report sent from the HID interface. If this is set
* to NULL, it is up to the user to force transfers when needed in the
* to NULL, it is up to the user to force transfers when needed in the
* \ref CALLBACK_HID_Device_CreateHIDReport() callback function.
*
* \note Due to the single buffer, the internal driver can only correctly compare
@ -111,18 +111,18 @@
*/
} Config; /**< Config data for the USB class interface within the device. All elements in this section
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
*/
*/
struct
{
bool UsingReportProtocol; /**< Indicates if the HID interface is set to Boot or Report protocol mode. */
uint16_t IdleCount; /**< Report idle period, in milliseconds, set by the host. */
uint16_t IdleMSRemaining; /**< Total number of milliseconds remaining before the idle period elapsed - this
* should be decremented by the user application if non-zero each millisecond. */
uint16_t IdleMSRemaining; /**< Total number of milliseconds remaining before the idle period elapsed - this
* should be decremented by the user application if non-zero each millisecond. */
} State; /**< State data for the USB class interface within the device. All elements in this section
* are reset to their defaults when the interface is enumerated.
*/
} USB_ClassInfo_HID_Device_t;
/* Function Prototypes: */
/** Configures the endpoints of a given HID interface, ready for use. This should be linked to the library
* \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
@ -137,12 +137,12 @@
* \return Boolean true if the endpoints were successfully configured, false otherwise.
*/
bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Processes incoming control requests from the host, that are directed to the given HID class interface. This should be
* linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event.
*
* \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
*/
*/
void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** General management task for a given HID class interface, required for the correct operation of the interface. This should
@ -151,13 +151,13 @@
* \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
*/
void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** HID class driver callback for the user creation of a HID IN report. This callback may fire in response to either
* HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback the
* user is responsible for the creation of the next HID input report to be sent to the host.
*
* \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
* \param[in,out] ReportID If preset to a non-zero value, this is the report ID being requested by the host. If zero,
* \param[in,out] ReportID If preset to a non-zero value, this is the report ID being requested by the host. If zero,
* this should be set to the report ID of the generated HID input report (if any). If multiple
* reports are not sent via the given HID interface, this parameter should be ignored.
* \param[in] ReportType Type of HID report to generate, either \ref HID_REPORT_ITEM_In or \ref HID_REPORT_ITEM_Feature.
@ -173,7 +173,7 @@
void* ReportData,
uint16_t* const ReportSize) ATTR_NON_NULL_PTR_ARG(1)
ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(4) ATTR_NON_NULL_PTR_ARG(5);
/** HID class driver callback for the user processing of a received HID OUT report. This callback may fire in response to
* either HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback
* the user is responsible for the processing of the received HID output report from the host.
@ -205,12 +205,13 @@
if (HIDInterfaceInfo->State.IdleMSRemaining)
HIDInterfaceInfo->State.IdleMSRemaining--;
}
/* 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
@ -64,14 +64,14 @@ bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInter
{
continue;
}
if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size,
DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
{
return false;
}
}
return true;
}
@ -80,7 +80,7 @@ uint8_t MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInter
{
if (USB_DeviceState != DEVICE_STATE_Configured)
return ENDPOINT_RWSTREAM_DeviceDisconnected;
Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber);
if (Endpoint_IsReadWriteAllowed())
@ -93,7 +93,7 @@ uint8_t MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInter
if (!(Endpoint_IsReadWriteAllowed()))
Endpoint_ClearIN();
}
return ENDPOINT_RWSTREAM_NoError;
}
@ -101,7 +101,7 @@ uint8_t MIDI_Device_Flush(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo)
{
if (USB_DeviceState != DEVICE_STATE_Configured)
return ENDPOINT_RWSTREAM_DeviceDisconnected;
uint8_t ErrorCode;
Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber);
@ -122,18 +122,19 @@ bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInter
{
if (USB_DeviceState != DEVICE_STATE_Configured)
return false;
Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataOUTEndpointNumber);
if (!(Endpoint_IsReadWriteAllowed()))
return false;
Endpoint_Read_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NO_STREAM_CALLBACK);
if (!(Endpoint_IsReadWriteAllowed()))
Endpoint_ClearOUT();
return true;
}
#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
@ -92,15 +92,15 @@
bool DataOUTEndpointDoubleBank; /**< Indicates if the MIDI interface's IN data endpoint should use double banking. */
} Config; /**< Config data for the USB class interface within the device. All elements in this section
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
*/
*/
struct
{
// No state information for this class
} State; /**< State data for the USB class interface within the device. All elements in this section
* are reset to their defaults when the interface is enumerated.
*/
} USB_ClassInfo_MIDI_Device_t;
} USB_ClassInfo_MIDI_Device_t;
/* Function Prototypes: */
/** Configures the endpoints of a given MIDI interface, ready for use. This should be linked to the library
* \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
@ -115,7 +115,7 @@
* \return Boolean true if the endpoints were successfully configured, false otherwise.
*/
bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Sends a MIDI event packet to the host. If no host is connected, the event packet is discarded. Events are queued into the
* endpoint bank until either the endpoint bank is full, or \ref MIDI_Device_Flush() is called. This allows for multiple
* MIDI events to be packed into a single endpoint packet, increasing data throughput.
@ -166,12 +166,12 @@
{
(void)MIDIInterfaceInfo;
}
/** Processes incoming control requests from the host, that are directed to the given MIDI class interface. This should be
* linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event.
*
* \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
*/
*/
static inline void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
static inline void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo)
{
@ -182,7 +182,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
@ -42,7 +42,7 @@ void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfac
{
if (!(Endpoint_IsSETUPReceived()))
return;
if (USB_ControlRequest.wIndex != MSInterfaceInfo->Config.InterfaceNumber)
return;
@ -62,11 +62,11 @@ void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfac
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{
Endpoint_ClearSETUP();
Endpoint_Write_Byte(MSInterfaceInfo->Config.TotalLUNs - 1);
Endpoint_ClearIN();
Endpoint_Write_Byte(MSInterfaceInfo->Config.TotalLUNs - 1);
Endpoint_ClearIN();
Endpoint_ClearStatusStage();
}
break;
}
}
@ -100,14 +100,14 @@ bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
{
continue;
}
if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size,
DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
{
return false;
}
}
return true;
}
@ -117,14 +117,14 @@ void MS_Device_USBTask(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
return;
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber);
if (Endpoint_IsReadWriteAllowed())
{
if (MS_Device_ReadInCommandBlock(MSInterfaceInfo))
{
if (MSInterfaceInfo->State.CommandBlock.Flags & MS_COMMAND_DIR_DATA_IN)
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber);
MSInterfaceInfo->State.CommandStatus.Status = CALLBACK_MS_Device_SCSICommandReceived(MSInterfaceInfo) ?
MS_SCSI_COMMAND_Pass : MS_SCSI_COMMAND_Fail;
MSInterfaceInfo->State.CommandStatus.Signature = MS_CSW_SIGNATURE;
@ -136,16 +136,16 @@ void MS_Device_USBTask(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{
Endpoint_StallTransaction();
}
MS_Device_ReturnCommandStatus(MSInterfaceInfo);
}
}
if (MSInterfaceInfo->State.IsMassStoreReset)
{
Endpoint_ResetFIFO(MSInterfaceInfo->Config.DataOUTEndpointNumber);
Endpoint_ResetFIFO(MSInterfaceInfo->Config.DataINEndpointNumber);
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber);
Endpoint_ClearStall();
Endpoint_ResetDataToggle();
@ -168,7 +168,7 @@ static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInte
{
return false;
}
if ((MSInterfaceInfo->State.CommandBlock.Signature != MS_CBW_SIGNATURE) ||
(MSInterfaceInfo->State.CommandBlock.LUN >= MSInterfaceInfo->Config.TotalLUNs) ||
(MSInterfaceInfo->State.CommandBlock.Flags & 0x1F) ||
@ -178,7 +178,7 @@ static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInte
Endpoint_StallTransaction();
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber);
Endpoint_StallTransaction();
return false;
}
@ -191,7 +191,7 @@ static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInte
}
Endpoint_ClearOUT();
return true;
}
@ -216,11 +216,11 @@ static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_Device_t* const MSInt
#if !defined(INTERRUPT_CONTROL_ENDPOINT)
USB_USBTask();
#endif
if (MSInterfaceInfo->State.IsMassStoreReset)
return;
}
CallbackIsResetSource = &MSInterfaceInfo->State.IsMassStoreReset;
if (Endpoint_Write_Stream_LE(&MSInterfaceInfo->State.CommandStatus, sizeof(MS_CommandStatusWrapper_t),
StreamCallback_MS_Device_AbortOnMassStoreReset))
@ -244,3 +244,4 @@ static uint8_t StreamCallback_MS_Device_AbortOnMassStoreReset(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
@ -56,7 +56,7 @@
/* Includes: */
#include "../../USB.h"
#include "../Common/MassStorage.h"
#include <string.h>
/* Enable C linkage for C++ Compilers: */
@ -70,7 +70,7 @@
#endif
/* Public Interface - May be used in end-application: */
/* Type Defines: */
/* Type Defines: */
/** \brief Mass Storage Class Device Mode Configuration and State Structure.
*
* Class state structure. An instance of this structure should be made for each Mass Storage interface
@ -125,12 +125,12 @@
* \return Boolean true if the endpoints were successfully configured, false otherwise.
*/
bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Processes incoming control requests from the host, that are directed to the given Mass Storage class interface. This should be
* linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event.
*
* \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
*/
*/
void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** General management task for a given Mass Storage class interface, required for the correct operation of the interface. This should
@ -139,7 +139,7 @@
* \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage configuration and state.
*/
void MS_Device_USBTask(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Mass Storage class driver callback for the user processing of a received SCSI command. This callback will fire each time the
* host sends a SCSI command which requires processing by the user application. Inside this callback the user is responsible
* for the processing of the received SCSI command from the host. The SCSI command is available in the CommandBlock structure
@ -150,7 +150,7 @@
* \return Boolean true if the SCSI command was successfully processed, false otherwise.
*/
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Function Prototypes: */
@ -159,14 +159,15 @@
static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
static uint8_t StreamCallback_MS_Device_AbortOnMassStoreReset(void);
#endif
#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
@ -71,7 +71,7 @@ void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDI
{
if (!(Endpoint_IsSETUPReceived()))
return;
if (USB_ControlRequest.wIndex != RNDISInterfaceInfo->Config.ControlInterfaceNumber)
return;
@ -86,7 +86,7 @@ void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDI
RNDIS_Device_ProcessRNDISControlMessage(RNDISInterfaceInfo);
}
break;
case RNDIS_REQ_GetEncapsulatedResponse:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
@ -100,12 +100,12 @@ void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDI
}
Endpoint_ClearSETUP();
Endpoint_Write_Control_Stream_LE(RNDISInterfaceInfo->State.RNDISMessageBuffer, MessageHeader->MessageLength);
Endpoint_Write_Control_Stream_LE(RNDISInterfaceInfo->State.RNDISMessageBuffer, MessageHeader->MessageLength);
Endpoint_ClearOUT();
MessageHeader->MessageLength = 0;
}
break;
}
}
@ -146,14 +146,14 @@ bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISIn
{
continue;
}
if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size,
DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
{
return false;
}
}
return true;
}
@ -176,14 +176,14 @@ void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo
.wIndex = 0,
.wLength = 0,
};
Endpoint_Write_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NO_STREAM_CALLBACK);
Endpoint_ClearIN();
RNDISInterfaceInfo->State.ResponseReady = false;
}
if ((RNDISInterfaceInfo->State.CurrRNDISState == RNDIS_Data_Initialized) && !(MessageHeader->MessageLength))
{
RNDIS_Packet_Message_t RNDISPacketHeader;
@ -199,18 +199,18 @@ void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo
Endpoint_StallTransaction();
return;
}
Endpoint_Read_Stream_LE(RNDISInterfaceInfo->State.FrameIN.FrameData, RNDISPacketHeader.DataLength, NO_STREAM_CALLBACK);
Endpoint_ClearOUT();
RNDISInterfaceInfo->State.FrameIN.FrameLength = RNDISPacketHeader.DataLength;
RNDISInterfaceInfo->State.FrameIN.FrameInBuffer = true;
}
Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataINEndpointNumber);
if (Endpoint_IsINReady() && RNDISInterfaceInfo->State.FrameOUT.FrameInBuffer)
{
memset(&RNDISPacketHeader, 0, sizeof(RNDIS_Packet_Message_t));
@ -223,11 +223,11 @@ void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo
Endpoint_Write_Stream_LE(&RNDISPacketHeader, sizeof(RNDIS_Packet_Message_t), NO_STREAM_CALLBACK);
Endpoint_Write_Stream_LE(RNDISInterfaceInfo->State.FrameOUT.FrameData, RNDISPacketHeader.DataLength, NO_STREAM_CALLBACK);
Endpoint_ClearIN();
RNDISInterfaceInfo->State.FrameOUT.FrameInBuffer = false;
}
}
}
}
void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)
{
@ -240,19 +240,19 @@ void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const
{
case REMOTE_NDIS_INITIALIZE_MSG:
RNDISInterfaceInfo->State.ResponseReady = true;
RNDIS_Initialize_Message_t* INITIALIZE_Message =
(RNDIS_Initialize_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;
RNDIS_Initialize_Complete_t* INITIALIZE_Response =
(RNDIS_Initialize_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;
INITIALIZE_Response->MessageType = REMOTE_NDIS_INITIALIZE_CMPLT;
INITIALIZE_Response->MessageLength = sizeof(RNDIS_Initialize_Complete_t);
INITIALIZE_Response->RequestId = INITIALIZE_Message->RequestId;
INITIALIZE_Response->Status = REMOTE_NDIS_STATUS_SUCCESS;
INITIALIZE_Response->MajorVersion = REMOTE_NDIS_VERSION_MAJOR;
INITIALIZE_Response->MinorVersion = REMOTE_NDIS_VERSION_MINOR;
INITIALIZE_Response->MinorVersion = REMOTE_NDIS_VERSION_MINOR;
INITIALIZE_Response->DeviceFlags = REMOTE_NDIS_DF_CONNECTIONLESS;
INITIALIZE_Response->Medium = REMOTE_NDIS_MEDIUM_802_3;
INITIALIZE_Response->MaxPacketsPerTransfer = 1;
@ -260,9 +260,9 @@ void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const
INITIALIZE_Response->PacketAlignmentFactor = 0;
INITIALIZE_Response->AFListOffset = 0;
INITIALIZE_Response->AFListSize = 0;
RNDISInterfaceInfo->State.CurrRNDISState = RNDIS_Initialized;
break;
case REMOTE_NDIS_HALT_MSG:
RNDISInterfaceInfo->State.ResponseReady = false;
@ -273,40 +273,40 @@ void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const
break;
case REMOTE_NDIS_QUERY_MSG:
RNDISInterfaceInfo->State.ResponseReady = true;
RNDIS_Query_Message_t* QUERY_Message = (RNDIS_Query_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;
RNDIS_Query_Complete_t* QUERY_Response = (RNDIS_Query_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;
uint32_t Query_Oid = QUERY_Message->Oid;
void* QueryData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Message_Header_t) +
QUERY_Message->InformationBufferOffset];
void* ResponseData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Query_Complete_t)];
void* ResponseData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Query_Complete_t)];
uint16_t ResponseSize;
QUERY_Response->MessageType = REMOTE_NDIS_QUERY_CMPLT;
QUERY_Response->MessageLength = sizeof(RNDIS_Query_Complete_t);
if (RNDIS_Device_ProcessNDISQuery(RNDISInterfaceInfo, Query_Oid, QueryData, QUERY_Message->InformationBufferLength,
ResponseData, &ResponseSize))
{
QUERY_Response->Status = REMOTE_NDIS_STATUS_SUCCESS;
QUERY_Response->MessageLength += ResponseSize;
QUERY_Response->InformationBufferLength = ResponseSize;
QUERY_Response->InformationBufferOffset = (sizeof(RNDIS_Query_Complete_t) - sizeof(RNDIS_Message_Header_t));
}
else
{
{
QUERY_Response->Status = REMOTE_NDIS_STATUS_NOT_SUPPORTED;
QUERY_Response->InformationBufferLength = 0;
QUERY_Response->InformationBufferOffset = 0;
}
break;
case REMOTE_NDIS_SET_MSG:
RNDISInterfaceInfo->State.ResponseReady = true;
RNDIS_Set_Message_t* SET_Message = (RNDIS_Set_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;
RNDIS_Set_Complete_t* SET_Response = (RNDIS_Set_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;
uint32_t SET_Oid = SET_Message->Oid;
@ -317,14 +317,14 @@ void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const
void* SetData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Message_Header_t) +
SET_Message->InformationBufferOffset];
SET_Response->Status = RNDIS_Device_ProcessNDISSet(RNDISInterfaceInfo, SET_Oid, SetData,
SET_Message->InformationBufferLength) ?
REMOTE_NDIS_STATUS_SUCCESS : REMOTE_NDIS_STATUS_NOT_SUPPORTED;
break;
case REMOTE_NDIS_RESET_MSG:
RNDISInterfaceInfo->State.ResponseReady = true;
RNDIS_Reset_Complete_t* RESET_Response = (RNDIS_Reset_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;
RESET_Response->MessageType = REMOTE_NDIS_RESET_CMPLT;
@ -335,7 +335,7 @@ void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const
break;
case REMOTE_NDIS_KEEPALIVE_MSG:
RNDISInterfaceInfo->State.ResponseReady = true;
RNDIS_KeepAlive_Message_t* KEEPALIVE_Message =
(RNDIS_KeepAlive_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;
RNDIS_KeepAlive_Complete_t* KEEPALIVE_Response =
@ -345,7 +345,7 @@ void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const
KEEPALIVE_Response->MessageLength = sizeof(RNDIS_KeepAlive_Complete_t);
KEEPALIVE_Response->RequestId = KEEPALIVE_Message->RequestId;
KEEPALIVE_Response->Status = REMOTE_NDIS_STATUS_SUCCESS;
break;
}
}
@ -364,60 +364,60 @@ static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_Device_t* const RN
{
case OID_GEN_SUPPORTED_LIST:
*ResponseSize = sizeof(AdapterSupportedOIDList);
memcpy_P(ResponseData, AdapterSupportedOIDList, sizeof(AdapterSupportedOIDList));
return true;
case OID_GEN_PHYSICAL_MEDIUM:
*ResponseSize = sizeof(uint32_t);
/* Indicate that the device is a true ethernet link */
*((uint32_t*)ResponseData) = 0;
return true;
case OID_GEN_HARDWARE_STATUS:
*ResponseSize = sizeof(uint32_t);
*((uint32_t*)ResponseData) = NDIS_HardwareStatus_Ready;
return true;
case OID_GEN_MEDIA_SUPPORTED:
case OID_GEN_MEDIA_IN_USE:
*ResponseSize = sizeof(uint32_t);
*((uint32_t*)ResponseData) = REMOTE_NDIS_MEDIUM_802_3;
return true;
case OID_GEN_VENDOR_ID:
*ResponseSize = sizeof(uint32_t);
/* Vendor ID 0x0xFFFFFF is reserved for vendors who have not purchased a NDIS VID */
*((uint32_t*)ResponseData) = 0x00FFFFFF;
return true;
case OID_GEN_MAXIMUM_FRAME_SIZE:
case OID_GEN_TRANSMIT_BLOCK_SIZE:
case OID_GEN_RECEIVE_BLOCK_SIZE:
*ResponseSize = sizeof(uint32_t);
*((uint32_t*)ResponseData) = ETHERNET_FRAME_SIZE_MAX;
return true;
case OID_GEN_VENDOR_DESCRIPTION:
*ResponseSize = (strlen(RNDISInterfaceInfo->Config.AdapterVendorDescription) + 1);
memcpy(ResponseData, RNDISInterfaceInfo->Config.AdapterVendorDescription, *ResponseSize);
return true;
case OID_GEN_MEDIA_CONNECT_STATUS:
*ResponseSize = sizeof(uint32_t);
*((uint32_t*)ResponseData) = REMOTE_NDIS_MEDIA_STATE_CONNECTED;
return true;
case OID_GEN_LINK_SPEED:
*ResponseSize = sizeof(uint32_t);
/* Indicate 10Mb/s link speed */
*((uint32_t*)ResponseData) = 100000;
@ -425,23 +425,23 @@ static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_Device_t* const RN
case OID_802_3_PERMANENT_ADDRESS:
case OID_802_3_CURRENT_ADDRESS:
*ResponseSize = sizeof(MAC_Address_t);
memcpy(ResponseData, &RNDISInterfaceInfo->Config.AdapterMACAddress, sizeof(MAC_Address_t));
return true;
case OID_802_3_MAXIMUM_LIST_SIZE:
*ResponseSize = sizeof(uint32_t);
/* Indicate only one multicast address supported */
*((uint32_t*)ResponseData) = 1;
return true;
case OID_GEN_CURRENT_PACKET_FILTER:
*ResponseSize = sizeof(uint32_t);
*((uint32_t*)ResponseData) = RNDISInterfaceInfo->State.CurrPacketFilter;
return true;
return true;
case OID_GEN_XMIT_OK:
case OID_GEN_RCV_OK:
case OID_GEN_XMIT_ERROR:
@ -451,17 +451,17 @@ static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_Device_t* const RN
case OID_802_3_XMIT_ONE_COLLISION:
case OID_802_3_XMIT_MORE_COLLISIONS:
*ResponseSize = sizeof(uint32_t);
/* Unused statistic OIDs - always return 0 for each */
*((uint32_t*)ResponseData) = 0;
return true;
case OID_GEN_MAXIMUM_TOTAL_SIZE:
*ResponseSize = sizeof(uint32_t);
/* Indicate maximum overall buffer (Ethernet frame and RNDIS header) the adapter can handle */
*((uint32_t*)ResponseData) = (RNDIS_MESSAGE_BUFFER_SIZE + ETHERNET_FRAME_SIZE_MAX);
return true;
default:
return false;
@ -481,11 +481,11 @@ static bool RNDIS_Device_ProcessNDISSet(USB_ClassInfo_RNDIS_Device_t* const RNDI
RNDISInterfaceInfo->State.CurrPacketFilter = *((uint32_t*)SetData);
RNDISInterfaceInfo->State.CurrRNDISState = ((RNDISInterfaceInfo->State.CurrPacketFilter) ?
RNDIS_Data_Initialized : RNDIS_Data_Initialized);
return true;
case OID_802_3_MULTICAST_LIST:
/* Do nothing - throw away the value from the host as it is unused */
return true;
default:
return false;
@ -493,3 +493,4 @@ static bool RNDIS_Device_ProcessNDISSet(USB_ClassInfo_RNDIS_Device_t* const RNDI
}
#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
@ -56,9 +56,9 @@
/* Includes: */
#include "../../USB.h"
#include "../Common/RNDIS.h"
#include <string.h>
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
@ -68,9 +68,9 @@
#if !defined(__INCLUDE_FROM_RNDIS_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/Class/RNDIS.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Type Defines: */
/* Type Defines: */
/** \brief RNDIS Class Device Mode Configuration and State Structure.
*
* Class state structure. An instance of this structure should be made for each RNDIS interface
@ -94,7 +94,7 @@
uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used. */
uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used. */
bool NotificationEndpointDoubleBank; /**< Indicates if the RNDIS interface's notification endpoint should use double banking. */
char* AdapterVendorDescription; /**< String description of the adapter vendor. */
MAC_Address_t AdapterMACAddress; /**< MAC address of the adapter. */
} Config; /**< Config data for the USB class interface within the device. All elements in this section.
@ -118,7 +118,7 @@
* are reset to their defaults when the interface is enumerated.
*/
} USB_ClassInfo_RNDIS_Device_t;
/* Function Prototypes: */
/** Configures the endpoints of a given RNDIS interface, ready for use. This should be linked to the library
* \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
@ -138,23 +138,23 @@
* linked to the library \ref EVENT_USB_Device_UnhandledControlRequest() event.
*
* \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.
*/
*/
void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** General management task for a given HID class interface, required for the correct operation of the interface. This should
* be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
*
* \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.
*/
void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_RNDIS_CLASS_DEVICE_C)
static void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)
ATTR_NON_NULL_PTR_ARG(1);
static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo,
static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo,
const uint32_t OId,
void* const QueryData,
const uint16_t QuerySize,
@ -167,14 +167,15 @@
const uint16_t SetSize) ATTR_NON_NULL_PTR_ARG(1)
ATTR_NON_NULL_PTR_ARG(3);
#endif
#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
@ -47,8 +47,8 @@
* - LUFA/Drivers/USB/Class/Host/HIDParser.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
*
* \section Module Description
* HID Class Driver module. This module contains an internal implementation of the USB HID Class, for both Device
* and Host USB modes. User applications can use this class driver instead of implementing the HID class manually
* HID Class Driver module. This module contains an internal implementation of the USB HID Class, for both Device
* and Host USB modes. User applications can use this class driver instead of implementing the HID class manually
* via the low-level LUFA APIs.
*
* This module is designed to simplify the user code by exposing only the required interface needed to interface with
@ -56,14 +56,14 @@
*
* @{
*/
#ifndef _HID_CLASS_H_
#define _HID_CLASS_H_
/* Macros: */
#define __INCLUDE_FROM_HID_DRIVER
#define __INCLUDE_FROM_USB_DRIVER
/* Includes: */
#include "../HighLevel/USBMode.h"
@ -74,11 +74,12 @@
#if defined(USB_CAN_BE_DEVICE)
#include "Device/HID.h"
#endif
#if defined(USB_CAN_BE_HOST)
#include "Host/HID.h"
#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
@ -62,7 +62,7 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
DCOMP_CDC_Host_NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{
return CDC_ENUMERROR_NoCompatibleInterfaceFound;
}
}
DataINEndpoint = NULL;
DataOUTEndpoint = NULL;
@ -79,10 +79,10 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
NotificationEndpoint = NULL;
}
continue;
}
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
@ -97,7 +97,7 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
DataOUTEndpoint = EndpointData;
}
}
for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
{
if (PipeNum == CDCInterfaceInfo->Config.DataINPipeNumber)
@ -141,7 +141,7 @@ static uint8_t DCOMP_CDC_Host_NextCDCControlInterface(void* const CurrentDescrip
{
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if ((CurrentInterface->Class == CDC_CONTROL_CLASS) &&
(CurrentInterface->SubClass == CDC_CONTROL_SUBCLASS) &&
(CurrentInterface->Protocol == CDC_CONTROL_PROTOCOL))
@ -149,7 +149,7 @@ static uint8_t DCOMP_CDC_Host_NextCDCControlInterface(void* const CurrentDescrip
return DESCRIPTOR_SEARCH_Found;
}
}
return DESCRIPTOR_SEARCH_NotFound;
}
@ -159,7 +159,7 @@ static uint8_t DCOMP_CDC_Host_NextCDCDataInterface(void* const CurrentDescriptor
{
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if ((CurrentInterface->Class == CDC_DATA_CLASS) &&
(CurrentInterface->SubClass == CDC_DATA_SUBCLASS) &&
(CurrentInterface->Protocol == CDC_DATA_PROTOCOL))
@ -167,7 +167,7 @@ static uint8_t DCOMP_CDC_Host_NextCDCDataInterface(void* const CurrentDescriptor
return DESCRIPTOR_SEARCH_Found;
}
}
return DESCRIPTOR_SEARCH_NotFound;
}
@ -177,9 +177,9 @@ static uint8_t DCOMP_CDC_Host_NextCDCInterfaceEndpoint(void* const CurrentDescri
{
USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Endpoint_t);
uint8_t EndpointType = (CurrentEndpoint->Attributes & EP_TYPE_MASK);
if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&
!(Pipe_IsEndpointBound(CurrentEndpoint->EndpointAddress)))
{
@ -198,7 +198,7 @@ void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))
return;
Pipe_SelectPipe(CDCInterfaceInfo->Config.NotificationPipeNumber);
Pipe_Unfreeze();
@ -206,14 +206,14 @@ void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
{
USB_Request_Header_t Notification;
Pipe_Read_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NO_STREAM_CALLBACK);
if ((Notification.bRequest == CDC_NOTIF_SerialState) &&
(Notification.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)))
{
Pipe_Read_Stream_LE(&CDCInterfaceInfo->State.ControlLineStates.DeviceToHost,
sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost),
NO_STREAM_CALLBACK);
Pipe_ClearIN();
EVENT_CDC_Host_ControLineStateChanged(CDCInterfaceInfo);
@ -223,7 +223,7 @@ void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
Pipe_ClearIN();
}
}
Pipe_Freeze();
CDC_Host_Flush(CDCInterfaceInfo);
@ -241,7 +241,7 @@ uint8_t CDC_Host_SetLineEncoding(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInf
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(&CDCInterfaceInfo->State.LineEncoding);
}
@ -257,7 +257,7 @@ uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* const CDCI
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(NULL);
}
@ -274,7 +274,7 @@ uint8_t CDC_Host_SendBreak(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(NULL);
}
@ -287,12 +287,12 @@ uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
uint8_t ErrorCode;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
ErrorCode = Pipe_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);
Pipe_Freeze();
return ErrorCode;
}
@ -301,12 +301,12 @@ uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))
return PIPE_READYWAIT_DeviceDisconnected;
uint8_t ErrorCode;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
if (!(Pipe_IsReadWriteAllowed()))
{
Pipe_ClearOUT();
@ -315,9 +315,9 @@ uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
return ErrorCode;
}
Pipe_Write_Byte(Data);
Pipe_Write_Byte(Data);
Pipe_Freeze();
return PIPE_READYWAIT_NoError;
}
@ -325,7 +325,7 @@ uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))
return 0;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
@ -346,7 +346,7 @@ uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
else
{
Pipe_Freeze();
return 0;
}
}
@ -355,7 +355,7 @@ int16_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))
return -1;
int16_t ReceivedByte = -1;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);
@ -369,7 +369,7 @@ int16_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
if (!(Pipe_BytesInPipe()))
Pipe_ClearIN();
}
Pipe_Freeze();
return ReceivedByte;
@ -379,12 +379,12 @@ uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
{
if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))
return PIPE_READYWAIT_DeviceDisconnected;
uint8_t ErrorCode;
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
if (!(Pipe_BytesInPipe()))
return PIPE_READYWAIT_NoError;
@ -401,7 +401,7 @@ uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
}
Pipe_Freeze();
return PIPE_READYWAIT_NoError;
}
@ -438,7 +438,7 @@ static int CDC_Host_getchar(FILE* Stream)
static int CDC_Host_getchar_Blocking(FILE* Stream)
{
int16_t ReceivedByte;
while ((ReceivedByte = CDC_Host_ReceiveByte((USB_ClassInfo_CDC_Host_t*)fdev_get_udata(Stream))) < 0)
{
if (USB_HostState == HOST_STATE_Unattached)
@ -457,3 +457,4 @@ void CDC_Host_Event_Stub(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
@ -59,7 +59,7 @@
#include <stdio.h>
#include <string.h>
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
@ -88,7 +88,7 @@
uint8_t DataOUTPipeNumber; /**< Pipe number of the CDC interface's OUT data pipe. */
bool DataOUTPipeDoubleBank; /**< Indicates if the CDC interface's OUT data pipe should use double banking. */
uint8_t NotificationPipeNumber; /**< Pipe number of the CDC interface's IN notification endpoint, if used. */
uint8_t NotificationPipeNumber; /**< Pipe number of the CDC interface's IN notification endpoint, if used. */
bool NotificationPipeDoubleBank; /**< Indicates if the CDC interface's notification pipe should use double banking. */
} Config; /**< Config data for the USB class interface within the device. All elements in this section
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
@ -100,11 +100,11 @@
* Configured state.
*/
uint8_t ControlInterfaceNumber; /**< Interface index of the CDC-ACM control interface within the attached device. */
uint16_t DataINPipeSize; /**< Size in bytes of the CDC interface's IN data pipe. */
uint16_t DataOUTPipeSize; /**< Size in bytes of the CDC interface's OUT data pipe. */
uint16_t NotificationPipeSize; /**< Size in bytes of the CDC interface's IN notification pipe, if used. */
struct
{
uint8_t HostToDevice; /**< Control line states from the host to device, as a set of CDC_CONTROL_LINE_OUT_*
@ -115,7 +115,7 @@
* masks. This value is updated each time \ref CDC_Host_USBTask() is called.
*/
} ControlLineStates; /**< Current states of the virtual serial port's control lines between the device and host. */
struct
{
uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second. */
@ -136,7 +136,7 @@
* the interface is enumerated.
*/
} USB_ClassInfo_CDC_Host_t;
/* Enums: */
/** Enum for the possible error codes returned by the \ref CDC_Host_ConfigurePipes() function. */
enum CDC_Host_EnumerationFailure_ErrorCodes_t
@ -145,7 +145,7 @@
CDC_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */
CDC_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible CDC interface was not found in the device's Configuration Descriptor. */
};
/* Function Prototypes: */
/** General management task for a given CDC host class interface, required for the correct operation of the interface. This should
* be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
@ -153,7 +153,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* 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
* state values and configures the pipes required to communicate with the interface if it is found within the device.
@ -173,7 +173,7 @@
uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
uint16_t ConfigDescriptorSize,
void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);
/** Sets the line encoding for the attached device's virtual serial port. This should be called when the LineEncoding
* values of the interface have been changed to push the new settings to the USB device.
*
@ -193,7 +193,7 @@
* \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.
*/
uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Sends a Send Break request to the device. This is generally used to separate data data or to indicate a special condition
* to the receiving device.
*
@ -204,10 +204,10 @@
*/
uint8_t CDC_Host_SendBreak(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
const uint8_t Duration) 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. Bytes will be queued for transmission to the device until either the pipe bank becomes full, or the
* \ref CDC_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be
* \ref CDC_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be
* packed into a single pipe packet, increasing data throughput.
*
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
@ -222,10 +222,10 @@
uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
const char* const Data,
const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
/** Sends a given byte to the attached USB device, if connected. If a device is not connected when the function is called, the
* byte is discarded. Bytes will be queued for transmission to the device until either the pipe bank becomes full, or the
* \ref CDC_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be
* \ref CDC_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be
* packed into a single pipe packet, increasing data throughput.
*
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
@ -265,7 +265,7 @@
* \return Next received byte from the device, or a negative value if no data received.
*/
int16_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.
*
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
@ -335,7 +335,7 @@
static uint8_t DCOMP_CDC_Host_NextCDCInterfaceEndpoint(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
#endif
#endif
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
@ -344,3 +344,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
@ -44,9 +44,9 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;
USB_Descriptor_Interface_t* HIDInterface = NULL;
USB_HID_Descriptor_HID_t* HIDDescriptor = NULL;
memset(&HIDInterfaceInfo->State, 0x00, sizeof(HIDInterfaceInfo->State));
if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
return HID_ENUMERROR_InvalidConfigDescriptor;
@ -58,7 +58,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
{
if (DataINEndpoint || DataOUTEndpoint)
break;
do
{
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
@ -66,11 +66,11 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
{
return HID_ENUMERROR_NoCompatibleInterfaceFound;
}
HIDInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);
} while (HIDInterfaceInfo->Config.HIDInterfaceProtocol &&
(HIDInterface->Protocol != HIDInterfaceInfo->Config.HIDInterfaceProtocol));
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
DCOMP_HID_Host_NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
{
@ -84,15 +84,15 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
continue;
}
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
DataINEndpoint = EndpointData;
else
DataOUTEndpoint = EndpointData;
DataOUTEndpoint = EndpointData;
}
for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
{
if (PipeNum == HIDInterfaceInfo->Config.DataINPipeNumber)
@ -101,7 +101,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
HIDInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
Pipe_SetInterruptPeriod(DataINEndpoint->PollingIntervalMS);
HIDInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
}
else if (PipeNum == HIDInterfaceInfo->Config.DataOUTPipeNumber)
@ -115,13 +115,13 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
HIDInterfaceInfo->State.DeviceUsesOUTPipe = true;
}
}
HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber;
HIDInterfaceInfo->State.HIDReportSize = HIDDescriptor->HIDReportLength;
HIDInterfaceInfo->State.SupportsBootProtocol = (HIDInterface->SubClass != HID_BOOTP_NonBootProtocol);
HIDInterfaceInfo->State.LargestReportSize = 8;
HIDInterfaceInfo->State.IsActive = true;
return HID_ENUMERROR_NoError;
}
@ -131,11 +131,11 @@ static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor)
{
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if (CurrentInterface->Class == HID_INTERFACE_CLASS)
return DESCRIPTOR_SEARCH_Found;
}
return DESCRIPTOR_SEARCH_NotFound;
}
@ -154,7 +154,7 @@ static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescri
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
{
USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Endpoint_t);
USB_Descriptor_Endpoint_t);
if (!(Pipe_IsEndpointBound(CurrentEndpoint->EndpointAddress)))
return DESCRIPTOR_SEARCH_Found;
@ -182,11 +182,11 @@ uint8_t HID_Host_ReceiveReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceI
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(Buffer);
}
#endif
uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,
void* Buffer)
{
@ -197,7 +197,7 @@ uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,
Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
uint16_t ReportSize;
uint8_t* BufferPos = Buffer;
@ -205,13 +205,13 @@ uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,
if (!(HIDInterfaceInfo->State.UsingBootProtocol))
{
uint8_t ReportID = 0;
if (HIDInterfaceInfo->Config.HIDParserData->UsingReportIDs)
{
ReportID = Pipe_Read_Byte();
*(BufferPos++) = ReportID;
}
ReportSize = USB_GetHIDReportSize(HIDInterfaceInfo->Config.HIDParserData, ReportID, HID_REPORT_ITEM_In);
}
else
@ -222,10 +222,10 @@ uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,
if ((ErrorCode = Pipe_Read_Stream_LE(BufferPos, ReportSize, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
Pipe_ClearIN();
Pipe_Freeze();
return PIPE_RWSTREAM_NoError;
}
@ -244,19 +244,19 @@ uint8_t HID_Host_SendReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
if (HIDInterfaceInfo->State.DeviceUsesOUTPipe && (ReportType == HID_REPORT_ITEM_Out))
{
uint8_t ErrorCode;
Pipe_SelectPipe(HIDInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
if (ReportID)
Pipe_Write_Stream_LE(&ReportID, sizeof(ReportID), NO_STREAM_CALLBACK);
if ((ErrorCode = Pipe_Write_Stream_LE(Buffer, ReportSize, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
Pipe_ClearOUT();
Pipe_Freeze();
return PIPE_RWSTREAM_NoError;
}
else
@ -276,7 +276,7 @@ uint8_t HID_Host_SendReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(Buffer);
}
}
@ -290,11 +290,11 @@ bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo)
Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
ReportReceived = Pipe_IsINReceived();
Pipe_Freeze();
return ReportReceived;
}
@ -312,7 +312,7 @@ uint8_t HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInf
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
if (!(HIDInterfaceInfo->State.SupportsBootProtocol))
return HID_ERROR_LOGICAL;
@ -321,7 +321,7 @@ uint8_t HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInf
HIDInterfaceInfo->State.LargestReportSize = 8;
HIDInterfaceInfo->State.UsingBootProtocol = true;
return HOST_SENDCONTROL_Successful;
}
@ -331,7 +331,7 @@ uint8_t HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceI
uint8_t ErrorCode;
uint8_t HIDReportData[HIDInterfaceInfo->State.HIDReportSize];
USB_ControlRequest = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE),
@ -345,7 +345,7 @@ uint8_t HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceI
if ((ErrorCode = USB_Host_SendControlRequest(HIDReportData)) != HOST_SENDCONTROL_Successful)
return ErrorCode;
if (HIDInterfaceInfo->State.UsingBootProtocol)
{
USB_ControlRequest = (USB_Request_Header_t)
@ -362,10 +362,10 @@ uint8_t HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceI
HIDInterfaceInfo->State.UsingBootProtocol = false;
}
if (HIDInterfaceInfo->Config.HIDParserData == NULL)
return HID_ERROR_LOGICAL;
if ((ErrorCode = USB_ProcessHIDReport(HIDReportData, HIDInterfaceInfo->State.HIDReportSize,
HIDInterfaceInfo->Config.HIDParserData)) != HID_PARSE_Successful)
{
@ -380,3 +380,4 @@ uint8_t HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceI
#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
@ -58,7 +58,7 @@
#include "../../USB.h"
#include "../Common/HID.h"
#include "HIDParser.h"
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
@ -73,7 +73,7 @@
/* Macros: */
/** Error code for some HID Host functions, indicating a logical (and not hardware) error. */
#define HID_ERROR_LOGICAL 0x80
/* Type Defines: */
/** \brief HID Class Host Mode Configuration and State Structure.
*
@ -116,7 +116,7 @@
uint16_t DataINPipeSize; /**< Size in bytes of the HID interface's IN data pipe. */
uint16_t DataOUTPipeSize; /**< Size in bytes of the HID interface's OUT data pipe. */
bool SupportsBootProtocol; /**< Indicates if the current interface instance supports the HID Boot
* Protocol when enabled via \ref HID_Host_SetBootProtocol().
*/
@ -125,7 +125,7 @@
*/
bool UsingBootProtocol; /**< Indicates that the interface is currently initialized in Boot Protocol mode */
uint16_t HIDReportSize; /**< Size in bytes of the HID report descriptor in the device. */
uint8_t LargestReportSize; /**< Largest report the device will send, in bytes. */
} State; /**< State data for the USB class interface within the device. All elements in this section
* <b>may</b> be set to initial values, but may also be ignored to default to sane values when
@ -141,7 +141,7 @@
HID_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */
HID_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible HID interface was not found in the device's Configuration Descriptor. */
};
/* Function Prototypes: */
/** 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
@ -169,7 +169,7 @@
/** Receives a HID IN report from the attached HID device, when a report has been received on the HID IN Data pipe.
*
*
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
* call will fail.
*
@ -202,7 +202,7 @@
const uint8_t ReportID,
void* Buffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);
#endif
/** Sends an OUT or FEATURE report to the currently attached HID device, using the device's OUT pipe if available,
* or the device's Control pipe if not.
*
@ -244,7 +244,7 @@
* \return Boolean true if a report has been received, false otherwise.
*/
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.
*
* \note When the HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, this method must still be called
@ -276,7 +276,7 @@
*/
uint8_t HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
#endif
/* Inline Functions: */
/** General management task for a given Human Interface Class host class interface, required for the correct operation of
* the interface. This should be called frequently in the main program loop, before the master USB management task
@ -288,7 +288,7 @@
static inline void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo)
{
(void)HIDInterfaceInfo;
}
}
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
@ -300,9 +300,9 @@
static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
static uint8_t DCOMP_HID_Host_NextHID(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
#endif
#endif
#endif
#endif
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
@ -311,3 +311,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
@ -41,7 +41,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
HID_StateTable_t StateTable[HID_STATETABLE_STACK_DEPTH];
HID_StateTable_t* CurrStateTable = &StateTable[0];
HID_CollectionPath_t* CurrCollectionPath = NULL;
HID_ReportSizeInfo_t* CurrReportIDInfo = &ParserData->ReportIDSizes[0];
HID_ReportSizeInfo_t* CurrReportIDInfo = &ParserData->ReportIDSizes[0];
uint16_t UsageList[HID_USAGE_STACK_DEPTH];
uint8_t UsageListSize = 0;
HID_MinMax_t UsageMinMax = {0, 0};
@ -50,16 +50,16 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
memset(CurrStateTable, 0x00, sizeof(HID_StateTable_t));
memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t));
ParserData->TotalDeviceReports = 1;
ParserData->TotalDeviceReports = 1;
while (ReportSize)
{
uint8_t HIDReportItem = *ReportData;
uint32_t ReportItemData = 0;
ReportData++;
ReportSize--;
switch (HIDReportItem & DATA_SIZE_MASK)
{
case DATA_SIZE_4:
@ -84,7 +84,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
case (TYPE_GLOBAL | TAG_GLOBAL_PUSH):
if (CurrStateTable == &StateTable[HID_STATETABLE_STACK_DEPTH - 1])
return HID_PARSE_HIDStackOverflow;
memcpy((CurrStateTable + 1),
CurrStateTable,
sizeof(HID_ReportItem_t));
@ -94,7 +94,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
case (TYPE_GLOBAL | TAG_GLOBAL_POP):
if (CurrStateTable == &StateTable[0])
return HID_PARSE_HIDStackUnderflow;
CurrStateTable--;
break;
case (TYPE_GLOBAL | TAG_GLOBAL_USAGEPAGE):
@ -139,25 +139,25 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
break;
}
}
if (CurrReportIDInfo == NULL)
{
if (ParserData->TotalDeviceReports == HID_MAX_REPORT_IDS)
return HID_PARSE_InsufficientReportIDItems;
CurrReportIDInfo = &ParserData->ReportIDSizes[ParserData->TotalDeviceReports++];
memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t));
}
}
ParserData->UsingReportIDs = true;
CurrReportIDInfo->ReportID = CurrStateTable->ReportID;
break;
case (TYPE_LOCAL | TAG_LOCAL_USAGE):
if (UsageListSize == HID_USAGE_STACK_DEPTH)
return HID_PARSE_UsageListOverflow;
UsageList[UsageListSize++] = ReportItemData;
break;
case (TYPE_LOCAL | TAG_LOCAL_USAGEMIN):
@ -174,42 +174,42 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
else
{
HID_CollectionPath_t* ParentCollectionPath = CurrCollectionPath;
CurrCollectionPath = &ParserData->CollectionPaths[1];
while (CurrCollectionPath->Parent != NULL)
{
if (CurrCollectionPath == &ParserData->CollectionPaths[HID_MAX_COLLECTIONS - 1])
return HID_PARSE_InsufficientCollectionPaths;
CurrCollectionPath++;
}
CurrCollectionPath->Parent = ParentCollectionPath;
}
CurrCollectionPath->Type = ReportItemData;
CurrCollectionPath->Usage.Page = CurrStateTable->Attributes.Usage.Page;
if (UsageListSize)
{
CurrCollectionPath->Usage.Usage = UsageList[0];
for (uint8_t i = 0; i < UsageListSize; i++)
UsageList[i] = UsageList[i + 1];
UsageListSize--;
}
else if (UsageMinMax.Minimum <= UsageMinMax.Maximum)
{
CurrCollectionPath->Usage.Usage = UsageMinMax.Minimum++;
}
break;
case (TYPE_MAIN | TAG_MAIN_ENDCOLLECTION):
if (CurrCollectionPath == NULL)
return HID_PARSE_UnexpectedEndCollection;
CurrCollectionPath = CurrCollectionPath->Parent;
break;
case (TYPE_MAIN | TAG_MAIN_INPUT):
@ -218,60 +218,60 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
for (uint8_t ReportItemNum = 0; ReportItemNum < CurrStateTable->ReportCount; ReportItemNum++)
{
HID_ReportItem_t NewReportItem;
memcpy(&NewReportItem.Attributes,
&CurrStateTable->Attributes,
sizeof(HID_ReportItem_Attributes_t));
NewReportItem.ItemFlags = ReportItemData;
NewReportItem.CollectionPath = CurrCollectionPath;
NewReportItem.ReportID = CurrStateTable->ReportID;
if (UsageListSize)
{
NewReportItem.Attributes.Usage.Usage = UsageList[0];
for (uint8_t i = 0; i < UsageListSize; i++)
UsageList[i] = UsageList[i + 1];
UsageListSize--;
}
else if (UsageMinMax.Minimum <= UsageMinMax.Maximum)
{
NewReportItem.Attributes.Usage.Usage = UsageMinMax.Minimum++;
}
uint8_t ItemTag = (HIDReportItem & TAG_MASK);
if (ItemTag == TAG_MAIN_INPUT)
NewReportItem.ItemType = HID_REPORT_ITEM_In;
else if (ItemTag == TAG_MAIN_OUTPUT)
NewReportItem.ItemType = HID_REPORT_ITEM_Out;
else
NewReportItem.ItemType = HID_REPORT_ITEM_Feature;
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType];
CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType] += CurrStateTable->Attributes.BitSize;
if (ParserData->LargestReportSizeBits < NewReportItem.BitOffset)
ParserData->LargestReportSizeBits = NewReportItem.BitOffset;
if (!(ReportItemData & IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem))
{
if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS)
return HID_PARSE_InsufficientReportItems;
memcpy(&ParserData->ReportItems[ParserData->TotalReportItems],
&NewReportItem, sizeof(HID_ReportItem_t));
ParserData->TotalReportItems++;
}
}
break;
}
if ((HIDReportItem & TYPE_MASK) == TYPE_MAIN)
{
UsageMinMax.Minimum = 0;
@ -279,10 +279,10 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
UsageListSize = 0;
}
}
if (!(ParserData->TotalReportItems))
return HID_PARSE_NoUnfilteredReportItems;
return HID_PARSE_Successful;
}
@ -292,27 +292,27 @@ bool USB_GetHIDReportItemInfo(const uint8_t* ReportData,
uint16_t DataBitsRem = ReportItem->Attributes.BitSize;
uint16_t CurrentBit = ReportItem->BitOffset;
uint32_t BitMask = (1 << 0);
if (ReportItem->ReportID)
{
if (ReportItem->ReportID != ReportData[0])
return false;
ReportData++;
}
ReportItem->PreviousValue = ReportItem->Value;
ReportItem->Value = 0;
while (DataBitsRem--)
{
if (ReportData[CurrentBit / 8] & (1 << (CurrentBit % 8)))
ReportItem->Value |= BitMask;
CurrentBit++;
BitMask <<= 1;
}
return true;
}
@ -322,20 +322,20 @@ void USB_SetHIDReportItemInfo(uint8_t* ReportData,
uint16_t DataBitsRem = ReportItem->Attributes.BitSize;
uint16_t CurrentBit = ReportItem->BitOffset;
uint32_t BitMask = (1 << 0);
if (ReportItem->ReportID)
{
ReportData[0] = ReportItem->ReportID;
ReportData++;
}
ReportItem->PreviousValue = ReportItem->Value;
while (DataBitsRem--)
{
if (ReportItem->Value & (1 << (CurrentBit % 8)))
ReportData[CurrentBit / 8] |= BitMask;
CurrentBit++;
BitMask <<= 1;
}
@ -348,7 +348,7 @@ uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData,
for (uint8_t i = 0; i < HID_MAX_REPORT_IDS; i++)
{
uint16_t ReportSizeBits = ParserData->ReportIDSizes[i].ReportSizeBits[ReportType];
if (ParserData->ReportIDSizes[i].ReportID == ReportID)
return ((ReportSizeBits >> 3) + ((ReportSizeBits & 0x07) ? 1 : 0));
}
@ -357,3 +357,4 @@ uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData,
}
#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
@ -35,7 +35,7 @@
* a HID device transmits to the host. It also provides an easy API for extracting and processing the data
* elements inside a HID report sent from an attached HID device.
*/
/** \ingroup Group_USB
* @defgroup Group_HIDParser HID Report Parser
*
@ -86,7 +86,7 @@
*/
#define HID_STATETABLE_STACK_DEPTH 2
#endif
#if !defined(HID_USAGE_STACK_DEPTH) || defined(__DOXYGEN__)
/** Constant indicating the maximum stack depth of the usage table. A larger usage table
* allows for more USAGE items to be indicated sequentially for REPORT COUNT entries of more than
@ -107,17 +107,17 @@
*/
#define HID_MAX_COLLECTIONS 10
#endif
#if !defined(HID_MAX_REPORTITEMS) || defined(__DOXYGEN__)
/** Constant indicating the maximum number of report items (IN, OUT or FEATURE) that can be processed
/** Constant indicating the maximum number of report items (IN, OUT or FEATURE) that can be processed
* in the report item descriptor and stored in the user HID Report Info structure. A large value allows
* for more report items to be stored, but consumes more memory. By default this is set to 20 items,
* for more report items to be stored, but consumes more memory. By default this is set to 20 items,
* but this can be overridden by defining HID_MAX_REPORTITEMS to another value in the user project
* makefile, and passing the define to the compiler using the -D compiler switch.
*/
#define HID_MAX_REPORTITEMS 20
#endif
#if !defined(HID_MAX_REPORT_IDS) || defined(__DOXYGEN__)
/** Constant indicating the maximum number of unique report IDs that can be processed in the report item
* descriptor for the report size information array in the user HID Report Info structure. A large value
@ -141,12 +141,12 @@
#define HID_ALIGN_DATA(ReportItem, Type) ((Type)(ReportItem->Value << ((8 * sizeof(Type)) - ReportItem->Attributes.BitSize)))
/* Public Interface - May be used in end-application: */
/* Enums: */
/* Enums: */
/** Enum for the possible error codes in the return value of the \ref USB_ProcessHIDReport() function. */
enum HID_Parse_ErrorCodes_t
{
HID_PARSE_Successful = 0, /**< Successful parse of the HID report descriptor, no error. */
HID_PARSE_HIDStackOverflow = 1, /**< More than \ref HID_STATETABLE_STACK_DEPTH nested PUSHes in the report. */
HID_PARSE_HIDStackOverflow = 1, /**< More than \ref HID_STATETABLE_STACK_DEPTH nested PUSHes in the report. */
HID_PARSE_HIDStackUnderflow = 2, /**< A POP was found when the state table stack was empty. */
HID_PARSE_InsufficientReportItems = 3, /**< More than \ref HID_MAX_REPORTITEMS report items in the report. */
HID_PARSE_UnexpectedEndCollection = 4, /**< An END COLLECTION item found without matching COLLECTION item. */
@ -155,8 +155,8 @@
HID_PARSE_InsufficientReportIDItems = 7, /**< More than \ref HID_MAX_REPORT_IDS report IDs in the device. */
HID_PARSE_NoUnfilteredReportItems = 8, /**< All report items from the device were filtered by the filtering callback routine. */
};
/* Type Defines: */
/* Type Defines: */
/** \brief HID Parser Report Item Min/Max Structure.
*
* Type define for an attribute with both minimum and maximum values (e.g. Logical Min/Max).
@ -176,7 +176,7 @@
uint32_t Type; /**< Unit type (refer to HID specifications for details). */
uint8_t Exponent; /**< Unit exponent (refer to HID specifications for details). */
} HID_Unit_t;
/** \brief HID Parser Report Item Usage Structure.
*
* Type define for the Usage attributes of a report item.
@ -206,13 +206,13 @@
typedef struct
{
uint8_t BitSize; /**< Size in bits of the report item's data. */
HID_Usage_t Usage; /**< Usage of the report item. */
HID_Unit_t Unit; /**< Unit type and exponent of the report item. */
HID_MinMax_t Logical; /**< Logical minimum and maximum of the report item. */
HID_MinMax_t Physical; /**< Physical minimum and maximum of the report item. */
} HID_ReportItem_Attributes_t;
/** \brief HID Parser Report Item Details Structure.
*
* Type define for a report item (IN, OUT or FEATURE) layout attributes and other details.
@ -226,13 +226,13 @@
HID_CollectionPath_t* CollectionPath; /**< Collection path of the item. */
HID_ReportItem_Attributes_t Attributes; /**< Report item attributes. */
uint32_t Value; /**< Current value of the report item - use \ref HID_ALIGN_DATA() when processing
* a retrieved value so that it is aligned to a specific type.
*/
uint32_t PreviousValue; /**< Previous value of the report item. */
uint32_t PreviousValue; /**< Previous value of the report item. */
} HID_ReportItem_t;
/** \brief HID Parser Report Size Structure.
*
* Type define for a report item size information structure, to retain the size of a device's reports by ID.
@ -267,7 +267,7 @@
* element in its HID report descriptor.
*/
} HID_ReportInfo_t;
/* Function Prototypes: */
/** Function to process a given HID report returned from an attached device, and store it into a given
* \ref HID_ReportInfo_t structure.
@ -285,7 +285,7 @@
/** Extracts the given report item's value out of the given HID report and places it into the Value
* member of the report item's \ref HID_ReportItem_t structure.
*
* When called on a report with an item that exists in that report, this copies the report item's Value
* When called on a report with an item that exists in that report, this copies the report item's Value
* to it's PreviousValue element for easy checking to see if an item's value has changed before processing
* a report. If the given item does not exist in the report, the function does not modify the report item's
* data.
@ -348,7 +348,7 @@
uint8_t ReportID;
} HID_StateTable_t;
#endif
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
@ -357,3 +357,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
@ -42,7 +42,7 @@
*
* @{
*/
#ifndef __HIDREPORTDATA_H__
#define __HIDREPORTDATA_H__
@ -107,11 +107,11 @@
#define DATA_SIZE_1 0x01
#define DATA_SIZE_2 0x02
#define DATA_SIZE_4 0x03
#define TYPE_MAIN 0x00
#define TYPE_GLOBAL 0x04
#define TYPE_LOCAL 0x08
#define TAG_MAIN_INPUT 0x80
#define TAG_MAIN_OUTPUT 0x90
#define TAG_MAIN_COLLECTION 0xA0
@ -130,12 +130,13 @@
#define TAG_GLOBAL_REPORTCOUNT 0x90
#define TAG_GLOBAL_PUSH 0xA0
#define TAG_GLOBAL_POP 0xB0
#define TAG_LOCAL_USAGE 0x00
#define TAG_LOCAL_USAGEMIN 0x10
#define TAG_LOCAL_USAGEMAX 0x20
#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
@ -68,7 +68,7 @@ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceI
continue;
}
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
@ -76,7 +76,7 @@ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceI
else
DataOUTEndpoint = EndpointData;
}
for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
{
if (PipeNum == MIDIInterfaceInfo->Config.DataINPipeNumber)
@ -84,16 +84,16 @@ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceI
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
MIDIInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
MIDIInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
MIDIInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
}
else if (PipeNum == MIDIInterfaceInfo->Config.DataOUTPipeNumber)
{
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT,
DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
MIDIInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
MIDIInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
MIDIInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
}
}
@ -117,7 +117,7 @@ static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingInterface(void* const CurrentDes
return DESCRIPTOR_SEARCH_Found;
}
}
return DESCRIPTOR_SEARCH_NotFound;
}
@ -127,9 +127,9 @@ static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingDataEndpoint(void* const Current
{
USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Endpoint_t);
uint8_t EndpointType = (CurrentEndpoint->Attributes & EP_TYPE_MASK);
if ((EndpointType == EP_TYPE_BULK) && !(Pipe_IsEndpointBound(CurrentEndpoint->EndpointAddress)))
return DESCRIPTOR_SEARCH_Found;
}
@ -145,7 +145,7 @@ uint8_t MIDI_Host_Flush(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo)
{
if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive))
return PIPE_RWSTREAM_DeviceDisconnected;
uint8_t ErrorCode;
Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataOUTPipeNumber);
@ -166,7 +166,7 @@ uint8_t MIDI_Host_SendEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterface
{
if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnected;
Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataOUTPipeNumber);
if (Pipe_IsReadWriteAllowed())
@ -179,7 +179,7 @@ uint8_t MIDI_Host_SendEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterface
if (!(Pipe_IsReadWriteAllowed()))
Pipe_ClearOUT();
}
return PIPE_RWSTREAM_NoError;
}
@ -188,7 +188,7 @@ bool MIDI_Host_ReceiveEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterface
{
if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnected;
Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataINPipeNumber);
if (!(Pipe_IsReadWriteAllowed()))
@ -198,8 +198,9 @@ bool MIDI_Host_ReceiveEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterface
if (!(Pipe_IsReadWriteAllowed()))
Pipe_ClearIN();
return true;
}
#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
@ -56,7 +56,7 @@
/* Includes: */
#include "../../USB.h"
#include "../Common/MIDI.h"
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
@ -66,7 +66,7 @@
#if !defined(__INCLUDE_FROM_MIDI_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/Class/MIDI.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Type Defines: */
/** \brief MIDI Class Host Mode Configuration and State Structure.
@ -81,7 +81,7 @@
{
uint8_t DataINPipeNumber; /**< Pipe number of the MIDI interface's streaming IN data pipe. */
bool DataINPipeDoubleBank; /**< Indicates if the MIDI interface's IN data pipe should use double banking. */
uint8_t DataOUTPipeNumber; /**< Pipe number of the MIDI interface's streaming OUT data pipe. */
bool DataOUTPipeDoubleBank; /**< Indicates if the MIDI interface's OUT data pipe should use double banking. */
} Config; /**< Config data for the USB class interface within the device. All elements in this section
@ -102,7 +102,7 @@
* the interface is enumerated.
*/
} USB_ClassInfo_MIDI_Host_t;
/* Enums: */
/** Enum for the possible error codes returned by the \ref MIDI_Host_ConfigurePipes() function. */
enum MIDI_Host_EnumerationFailure_ErrorCodes_t
@ -111,7 +111,7 @@
MIDI_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */
MIDI_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible MIDI interface was not found in the device's Configuration Descriptor. */
};
/* Function Prototypes: */
/** Host interface configuration routine, to configure a given MIDI host interface instance using the Configuration
* Descriptor read from an attached USB device. This function automatically updates the given MIDI Host instance's
@ -156,7 +156,7 @@
* \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.
*/
uint8_t MIDI_Host_Flush(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Receives a MIDI event packet from the device.
*
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
@ -193,9 +193,9 @@
#if defined(__INCLUDE_FROM_MIDI_CLASS_HOST_C)
static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingDataEndpoint(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
#endif
#endif
#endif
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
@ -204,3 +204,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
@ -68,7 +68,7 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
continue;
}
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
@ -76,7 +76,7 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
else
DataOUTEndpoint = EndpointData;
}
for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
{
if (PipeNum == MSInterfaceInfo->Config.DataINPipeNumber)
@ -84,16 +84,16 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
MSInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
MSInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
MSInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
}
else if (PipeNum == MSInterfaceInfo->Config.DataOUTPipeNumber)
{
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT,
DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
MSInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
MSInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
MSInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
}
}
@ -117,7 +117,7 @@ static uint8_t DCOMP_MS_Host_NextMSInterface(void* const CurrentDescriptor)
return DESCRIPTOR_SEARCH_Found;
}
}
return DESCRIPTOR_SEARCH_NotFound;
}
@ -174,7 +174,7 @@ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInf
Pipe_Freeze();
return ErrorCode;
}
return ErrorCode;
}
@ -189,7 +189,7 @@ static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInte
while (!(Pipe_IsINReceived()))
{
uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
if (CurrentFrameNumber != PreviousFrameNumber)
{
PreviousFrameNumber = CurrentFrameNumber;
@ -197,7 +197,7 @@ static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInte
if (!(TimeoutMSRem--))
return PIPE_RWSTREAM_Timeout;
}
Pipe_Freeze();
Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
@ -208,7 +208,7 @@ static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInte
return PIPE_RWSTREAM_PipeStalled;
}
Pipe_Freeze();
Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
@ -219,14 +219,14 @@ static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInte
return PIPE_RWSTREAM_PipeStalled;
}
if (USB_HostState == HOST_STATE_Unattached)
return PIPE_RWSTREAM_DeviceDisconnected;
};
Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber);
Pipe_Freeze();
Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Freeze();
@ -250,7 +250,7 @@ static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfac
Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
if ((ErrorCode = Pipe_Read_Stream_LE(BufferPtr, BytesRem, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
@ -265,7 +265,7 @@ static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfac
return ErrorCode;
Pipe_ClearOUT();
while (!(Pipe_IsOUTReady()))
{
if (USB_HostState == HOST_STATE_Unattached)
@ -288,19 +288,19 @@ static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* const MSInterf
Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
if ((ErrorCode = Pipe_Read_Stream_LE(SCSICommandStatus, sizeof(MS_CommandStatusWrapper_t),
NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
{
return ErrorCode;
}
Pipe_ClearIN();
Pipe_Freeze();
if (SCSICommandStatus->Status != MS_SCSI_COMMAND_Pass)
ErrorCode = MS_ERROR_LOGICAL_CMD_FAILED;
return ErrorCode;
}
@ -314,7 +314,7 @@ uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo)
.wIndex = MSInterfaceInfo->State.InterfaceNumber,
.wLength = 0,
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(NULL);
@ -333,7 +333,7 @@ uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
.wIndex = MSInterfaceInfo->State.InterfaceNumber,
.wLength = 1,
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
if ((ErrorCode = USB_Host_SendControlRequest(MaxLUNIndex)) != HOST_SENDCONTROL_Successful)
@ -341,7 +341,7 @@ uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
*MaxLUNIndex = 0;
ErrorCode = HOST_SENDCONTROL_Successful;
}
return ErrorCode;
}
@ -351,7 +351,7 @@ uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
{
if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))
return HOST_SENDCONTROL_DeviceDisconnected;
uint8_t ErrorCode;
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
@ -370,12 +370,12 @@ uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
0x00 // Unused (control)
}
};
MS_CommandStatusWrapper_t SCSICommandStatus;
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, InquiryData)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
return ErrorCode;
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
@ -406,12 +406,12 @@ uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
0x00 // Unused (control)
}
};
MS_CommandStatusWrapper_t SCSICommandStatus;
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
return ErrorCode;
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
@ -447,7 +447,7 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInf
0x00 // Unused (control)
}
};
MS_CommandStatusWrapper_t SCSICommandStatus;
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError)
@ -455,7 +455,7 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInf
SwapEndian_n(&DeviceCapacity->Blocks, sizeof(DeviceCapacity->Blocks));
SwapEndian_n(&DeviceCapacity->BlockSize, sizeof(DeviceCapacity->BlockSize));
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
@ -487,7 +487,7 @@ uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
0x00 // Unused (control)
}
};
MS_CommandStatusWrapper_t SCSICommandStatus;
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, SenseData)) != PIPE_RWSTREAM_NoError)
@ -524,12 +524,12 @@ uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* const MSInter
0x00 // Unused (control)
}
};
MS_CommandStatusWrapper_t SCSICommandStatus;
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
@ -617,7 +617,7 @@ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
@ -625,3 +625,4 @@ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo
}
#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
@ -56,7 +56,7 @@
/* Includes: */
#include "../../USB.h"
#include "../Common/MassStorage.h"
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
@ -71,7 +71,7 @@
/* Macros: */
/** Error code for some Mass Storage Host functions, indicating a logical (and not hardware) error. */
#define MS_ERROR_LOGICAL_CMD_FAILED 0x80
/* Type Defines: */
/** \brief Mass Storage Class Host Mode Configuration and State Structure.
*
@ -101,14 +101,14 @@
uint16_t DataINPipeSize; /**< Size in bytes of the Mass Storage interface's IN data pipe. */
uint16_t DataOUTPipeSize; /**< Size in bytes of the Mass Storage interface's OUT data pipe. */
uint32_t TransactionTag; /**< Current transaction tag for data synchronizing of packets. */
} State; /**< State data for the USB class interface within the device. All elements in this section
* <b>may</b> be set to initial values, but may also be ignored to default to sane values when
* the interface is enumerated.
*/
} USB_ClassInfo_MS_Host_t;
/** \brief SCSI Device LUN Capacity Structure.
*
* SCSI capacity structure, to hold the total capacity of the device in both the number
@ -128,7 +128,7 @@
MS_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */
MS_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Mass Storage interface was not found in the device's Configuration Descriptor. */
};
/* Function Prototypes: */
/** 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
@ -217,7 +217,7 @@
const uint8_t LUNIndex,
SCSI_Capacity_t* const DeviceCapacity) ATTR_NON_NULL_PTR_ARG(1)
ATTR_NON_NULL_PTR_ARG(3);
/** Retrieves the device sense data, indicating the current device state and error codes for the previously
* issued command.
*
@ -234,7 +234,7 @@
const uint8_t LUNIndex,
SCSI_Request_Sense_Response_t* const SenseData) ATTR_NON_NULL_PTR_ARG(1)
ATTR_NON_NULL_PTR_ARG(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.
*
@ -250,7 +250,7 @@
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.
*
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
@ -271,7 +271,7 @@
const uint8_t Blocks,
const uint16_t BlockSize,
void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6);
/** Writes blocks of data to the attached Mass Storage device's medium.
*
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
@ -318,22 +318,22 @@
#define CBW_SIGNATURE 0x43425355UL
#define CSW_SIGNATURE 0x53425355UL
#define COMMAND_DIRECTION_DATA_OUT (0 << 7)
#define COMMAND_DIRECTION_DATA_IN (1 << 7)
#define COMMAND_DATA_TIMEOUT_MS 10000
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_MS_CLASS_HOST_C)
#if defined(__INCLUDE_FROM_MS_CLASS_HOST_C)
static uint8_t DCOMP_MS_Host_NextMSInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
static uint8_t DCOMP_MS_Host_NextMSInterfaceEndpoint(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
MS_CommandBlockWrapper_t* const SCSICommandBlock,
const void* const BufferPtr) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
MS_CommandBlockWrapper_t* const SCSICommandBlock,
void* BufferPtr) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
@ -341,7 +341,7 @@
ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
#endif
#endif
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
@ -350,3 +350,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
@ -48,7 +48,7 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
if (DESCRIPTOR_TYPE(DeviceConfigDescriptor) != DTYPE_Configuration)
return PRNT_ENUMERROR_InvalidConfigDescriptor;
while (!(DataINEndpoint) || !(DataOUTEndpoint))
{
if (!(PrinterInterface) ||
@ -60,15 +60,15 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
{
return PRNT_ENUMERROR_NoCompatibleInterfaceFound;
}
PrinterInterface = DESCRIPTOR_PCAST(DeviceConfigDescriptor, USB_Descriptor_Interface_t);
PrinterInterface = DESCRIPTOR_PCAST(DeviceConfigDescriptor, USB_Descriptor_Interface_t);
DataINEndpoint = NULL;
DataOUTEndpoint = NULL;
continue;
}
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(DeviceConfigDescriptor, USB_Descriptor_Endpoint_t);
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
@ -76,7 +76,7 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
else
DataOUTEndpoint = EndpointData;
}
for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
{
if (PipeNum == PRNTInterfaceInfo->Config.DataINPipeNumber)
@ -84,16 +84,16 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN,
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize,
PRNTInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
PRNTInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
PRNTInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
}
else if (PipeNum == PRNTInterfaceInfo->Config.DataOUTPipeNumber)
{
Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT,
DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize,
PRNTInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
PRNTInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
PRNTInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize;
}
}
@ -118,7 +118,7 @@ static uint8_t DCOMP_PRNT_Host_NextPRNTInterface(void* CurrentDescriptor)
return DESCRIPTOR_SEARCH_Found;
}
}
return DESCRIPTOR_SEARCH_NotFound;
}
@ -150,7 +150,7 @@ uint8_t PRNT_Host_SetBidirectionalMode(USB_ClassInfo_PRNT_Host_t* const PRNTInte
if (PRNTInterfaceInfo->State.AlternateSetting)
{
uint8_t ErrorCode;
USB_ControlRequest = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE),
@ -159,13 +159,13 @@ uint8_t PRNT_Host_SetBidirectionalMode(USB_ClassInfo_PRNT_Host_t* const PRNTInte
.wIndex = PRNTInterfaceInfo->State.InterfaceNumber,
.wLength = 0,
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)
return ErrorCode;
}
return HOST_SENDCONTROL_Successful;
}
@ -206,12 +206,12 @@ uint8_t PRNT_Host_Flush(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo)
{
if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive))
return PIPE_READYWAIT_DeviceDisconnected;
uint8_t ErrorCode;
Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
if (!(Pipe_BytesInPipe()))
return PIPE_READYWAIT_NoError;
@ -228,7 +228,7 @@ uint8_t PRNT_Host_Flush(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo)
}
Pipe_Freeze();
return PIPE_READYWAIT_NoError;
}
@ -237,12 +237,12 @@ uint8_t PRNT_Host_SendByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
{
if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive))
return PIPE_READYWAIT_DeviceDisconnected;
uint8_t ErrorCode;
Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
if (!(Pipe_IsReadWriteAllowed()))
{
Pipe_ClearOUT();
@ -251,9 +251,9 @@ uint8_t PRNT_Host_SendByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
return ErrorCode;
}
Pipe_Write_Byte(Data);
Pipe_Write_Byte(Data);
Pipe_Freeze();
return PIPE_READYWAIT_NoError;
}
@ -268,14 +268,14 @@ uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
if ((ErrorCode = Pipe_Write_Stream_LE(Buffer, Length, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
Pipe_ClearOUT();
ErrorCode = Pipe_WaitUntilReady();
Pipe_Freeze();
return ErrorCode;
@ -285,7 +285,7 @@ uint16_t PRNT_Host_BytesReceived(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
{
if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive))
return 0;
Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
@ -306,7 +306,7 @@ uint16_t PRNT_Host_BytesReceived(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
else
{
Pipe_Freeze();
return 0;
}
}
@ -329,7 +329,7 @@ int16_t PRNT_Host_ReceiveByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo
if (!(Pipe_BytesInPipe()))
Pipe_ClearIN();
}
Pipe_Freeze();
return ReceivedByte;
@ -350,33 +350,34 @@ uint8_t PRNT_Host_GetDeviceID(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo
.wIndex = PRNTInterfaceInfo->State.InterfaceNumber,
.wLength = sizeof(DeviceIDStringLength),
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
if ((ErrorCode = USB_Host_SendControlRequest(&DeviceIDStringLength)) != HOST_SENDCONTROL_Successful)
return ErrorCode;
if (!(DeviceIDStringLength))
{
DeviceIDString[0] = 0x00;
return HOST_SENDCONTROL_Successful;
}
DeviceIDStringLength = SwapEndian_16(DeviceIDStringLength);
if (DeviceIDStringLength > BufferSize)
DeviceIDStringLength = BufferSize;
USB_ControlRequest.wLength = DeviceIDStringLength;
if ((ErrorCode = USB_Host_SendControlRequest(DeviceIDString)) != HOST_SENDCONTROL_Successful)
return ErrorCode;
memmove(&DeviceIDString[0], &DeviceIDString[2], DeviceIDStringLength - 2);
DeviceIDString[DeviceIDStringLength - 2] = 0x00;
return HOST_SENDCONTROL_Successful;
}
#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
@ -56,7 +56,7 @@
/* Includes: */
#include "../../USB.h"
#include "../Common/Printer.h"
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
@ -111,7 +111,7 @@
PRNT_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */
PRNT_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Printer interface was not found in the device's Configuration Descriptor. */
};
/* Function Prototypes: */
/** General management task for a given Printer host class interface, required for the correct operation of
* the interface. This should be called frequently in the main program loop, before the master USB management task
@ -140,7 +140,7 @@
uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
uint16_t ConfigDescriptorSize,
void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);
/** Configures the printer to enable Bidirectional mode, if it is not already in this mode. This should be called
* once the connected device's configuration has been set, to ensure the printer is ready to accept commands.
*
@ -149,7 +149,7 @@
* \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.
*/
uint8_t PRNT_Host_SetBidirectionalMode(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Retrieves the status of the virtual Printer port's inbound status lines. The result can then be masked against the
* PRNT_PORTSTATUS_* macros to determine the printer port's status.
*
@ -195,12 +195,12 @@
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
*/
uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
void* Buffer,
void* Buffer,
const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
/** Sends a given byte to the attached USB device, if connected. If a device is not connected when the function is called, the
* byte is discarded. Bytes will be queued for transmission to the device until either the pipe bank becomes full, or the
* \ref PRNT_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be
* \ref PRNT_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be
* packed into a single pipe packet, increasing data throughput.
*
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
@ -226,8 +226,8 @@
*
* \return Total number of buffered bytes received from the device.
*/
uint16_t PRNT_Host_BytesReceived(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo);
uint16_t PRNT_Host_BytesReceived(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo);
/** 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 a negative value. The \ref PRNT_Host_BytesReceived() function may be queried in advance to determine how many bytes
* are currently buffered in the Printer interface's data receive pipe.
@ -240,7 +240,7 @@
* \return Next received byte from the device, or a negative value if no data received.
*/
int16_t PRNT_Host_ReceiveByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo);
/** Retrieves the attached printer device's ID string, formatted according to IEEE 1284. This string is sent as a
* Unicode string from the device and is automatically converted to an ASCII encoded C string by this function, thus
* the maximum reportable string length is two less than the size given (to accommodate the Unicode string length
@ -268,14 +268,14 @@
#define REQ_GetDeviceID 0
#define REQ_GetPortStatus 1
#define REQ_SoftReset 2
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_PRINTER_CLASS_HOST_C)
#if defined(__INCLUDE_FROM_PRINTER_CLASS_HOST_C)
static uint8_t DCOMP_PRNT_Host_NextPRNTInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
static uint8_t DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
#endif
#endif
/* 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
@ -64,7 +64,7 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa
DCOMP_RNDIS_Host_NextRNDISDataInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{
return RNDIS_ENUMERROR_NoCompatibleInterfaceFound;
}
}
DataINEndpoint = NULL;
DataOUTEndpoint = NULL;
@ -76,15 +76,15 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa
{
return RNDIS_ENUMERROR_NoCompatibleInterfaceFound;
}
RNDISControlInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);
NotificationEndpoint = NULL;
}
continue;
}
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
@ -99,7 +99,7 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa
DataOUTEndpoint = EndpointData;
}
}
for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
{
if (PipeNum == RNDISInterfaceInfo->Config.DataINPipeNumber)
@ -141,7 +141,7 @@ static uint8_t DCOMP_RNDIS_Host_NextRNDISControlInterface(void* const CurrentDes
{
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if ((CurrentInterface->Class == RNDIS_CONTROL_CLASS) &&
(CurrentInterface->SubClass == RNDIS_CONTROL_SUBCLASS) &&
(CurrentInterface->Protocol == RNDIS_CONTROL_PROTOCOL))
@ -149,7 +149,7 @@ static uint8_t DCOMP_RNDIS_Host_NextRNDISControlInterface(void* const CurrentDes
return DESCRIPTOR_SEARCH_Found;
}
}
return DESCRIPTOR_SEARCH_NotFound;
}
@ -159,7 +159,7 @@ static uint8_t DCOMP_RNDIS_Host_NextRNDISDataInterface(void* const CurrentDescri
{
USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Interface_t);
if ((CurrentInterface->Class == RNDIS_DATA_CLASS) &&
(CurrentInterface->SubClass == RNDIS_DATA_SUBCLASS) &&
(CurrentInterface->Protocol == RNDIS_DATA_PROTOCOL))
@ -167,7 +167,7 @@ static uint8_t DCOMP_RNDIS_Host_NextRNDISDataInterface(void* const CurrentDescri
return DESCRIPTOR_SEARCH_Found;
}
}
return DESCRIPTOR_SEARCH_NotFound;
}
@ -177,9 +177,9 @@ static uint8_t DCOMP_RNDIS_Host_NextRNDISInterfaceEndpoint(void* const CurrentDe
{
USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Endpoint_t);
uint8_t EndpointType = (CurrentEndpoint->Attributes & EP_TYPE_MASK);
if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&
!(Pipe_IsEndpointBound(CurrentEndpoint->EndpointAddress)))
{
@ -223,7 +223,7 @@ static uint8_t RNDIS_GetEncapsulatedResponse(USB_ClassInfo_RNDIS_Host_t* const R
.wIndex = RNDISInterfaceInfo->State.ControlInterfaceNumber,
.wLength = Length,
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(Buffer);
}
@ -234,7 +234,7 @@ uint8_t RNDIS_Host_SendKeepAlive(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfac
RNDIS_KeepAlive_Message_t KeepAliveMessage;
RNDIS_KeepAlive_Complete_t KeepAliveMessageResponse;
KeepAliveMessage.MessageType = REMOTE_NDIS_KEEPALIVE_MSG;
KeepAliveMessage.MessageLength = sizeof(RNDIS_KeepAlive_Message_t);
KeepAliveMessage.RequestId = RNDISInterfaceInfo->State.RequestID++;
@ -244,13 +244,13 @@ uint8_t RNDIS_Host_SendKeepAlive(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfac
{
return ErrorCode;
}
if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &KeepAliveMessageResponse,
sizeof(RNDIS_KeepAlive_Complete_t))) != HOST_SENDCONTROL_Successful)
{
return ErrorCode;
}
return HOST_SENDCONTROL_Successful;
}
@ -268,13 +268,13 @@ uint8_t RNDIS_Host_InitializeDevice(USB_ClassInfo_RNDIS_Host_t* const RNDISInter
InitMessage.MajorVersion = REMOTE_NDIS_VERSION_MAJOR;
InitMessage.MinorVersion = REMOTE_NDIS_VERSION_MINOR;
InitMessage.MaxTransferSize = RNDISInterfaceInfo->Config.HostMaxPacketSize;
if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &InitMessage,
sizeof(RNDIS_Initialize_Message_t))) != HOST_SENDCONTROL_Successful)
{
return ErrorCode;
}
if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &InitMessageResponse,
sizeof(RNDIS_Initialize_Complete_t))) != HOST_SENDCONTROL_Successful)
{
@ -283,9 +283,9 @@ uint8_t RNDIS_Host_InitializeDevice(USB_ClassInfo_RNDIS_Host_t* const RNDISInter
if (InitMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS)
return RNDIS_COMMAND_FAILED;
RNDISInterfaceInfo->State.DeviceMaxPacketSize = InitMessageResponse.MaxTransferSize;
return HOST_SENDCONTROL_Successful;
}
@ -301,18 +301,18 @@ uint8_t RNDIS_Host_SetRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInter
RNDIS_Set_Message_t SetMessage;
uint8_t ContiguousBuffer[Length];
} SetMessageData;
RNDIS_Set_Complete_t SetMessageResponse;
SetMessageData.SetMessage.MessageType = REMOTE_NDIS_SET_MSG;
SetMessageData.SetMessage.MessageLength = sizeof(RNDIS_Set_Message_t) + Length;
SetMessageData.SetMessage.RequestId = RNDISInterfaceInfo->State.RequestID++;
SetMessageData.SetMessage.Oid = Oid;
SetMessageData.SetMessage.InformationBufferLength = Length;
SetMessageData.SetMessage.InformationBufferOffset = (sizeof(RNDIS_Set_Message_t) - sizeof(RNDIS_Message_Header_t));
SetMessageData.SetMessage.DeviceVcHandle = 0;
memcpy(&SetMessageData.ContiguousBuffer, Buffer, Length);
if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &SetMessageData,
@ -320,7 +320,7 @@ uint8_t RNDIS_Host_SetRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInter
{
return ErrorCode;
}
if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &SetMessageResponse,
sizeof(RNDIS_Set_Complete_t))) != HOST_SENDCONTROL_Successful)
{
@ -329,7 +329,7 @@ uint8_t RNDIS_Host_SetRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInter
if (SetMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS)
return RNDIS_COMMAND_FAILED;
return HOST_SENDCONTROL_Successful;
}
@ -351,7 +351,7 @@ uint8_t RNDIS_Host_QueryRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInt
QueryMessage.MessageType = REMOTE_NDIS_QUERY_MSG;
QueryMessage.MessageLength = sizeof(RNDIS_Query_Message_t);
QueryMessage.RequestId = RNDISInterfaceInfo->State.RequestID++;
QueryMessage.Oid = Oid;
QueryMessage.InformationBufferLength = 0;
QueryMessage.InformationBufferOffset = 0;
@ -362,7 +362,7 @@ uint8_t RNDIS_Host_QueryRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInt
{
return ErrorCode;
}
if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &QueryMessageResponseData,
sizeof(QueryMessageResponseData))) != HOST_SENDCONTROL_Successful)
{
@ -385,11 +385,11 @@ bool RNDIS_Host_IsPacketReceived(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfac
return false;
Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
PacketWaiting = Pipe_IsINReceived();
PacketWaiting = Pipe_IsINReceived();
Pipe_Freeze();
return PacketWaiting;
}
@ -404,19 +404,19 @@ uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
if (!(Pipe_IsReadWriteAllowed()))
{
if (Pipe_IsINReceived())
Pipe_ClearIN();
*PacketLength = 0;
Pipe_Freeze();
return PIPE_RWSTREAM_NoError;
}
RNDIS_Packet_Message_t DeviceMessage;
if ((ErrorCode = Pipe_Read_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t),
NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
{
@ -424,17 +424,17 @@ uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
}
*PacketLength = (uint16_t)DeviceMessage.DataLength;
Pipe_Discard_Stream(DeviceMessage.DataOffset - (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)),
NO_STREAM_CALLBACK);
Pipe_Read_Stream_LE(Buffer, *PacketLength, NO_STREAM_CALLBACK);
if (!(Pipe_BytesInPipe()))
Pipe_ClearIN();
Pipe_Freeze();
return PIPE_RWSTREAM_NoError;
}
@ -454,7 +454,7 @@ uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
DeviceMessage.MessageLength = (sizeof(RNDIS_Packet_Message_t) + PacketLength);
DeviceMessage.DataOffset = (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t));
DeviceMessage.DataLength = PacketLength;
Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
@ -468,8 +468,9 @@ uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
Pipe_ClearOUT();
Pipe_Freeze();
return PIPE_RWSTREAM_NoError;
}
#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
@ -60,7 +60,7 @@
#include <stdio.h>
#include <string.h>
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
@ -89,9 +89,9 @@
uint8_t DataOUTPipeNumber; /**< Pipe number of the RNDIS interface's OUT data pipe. */
bool DataOUTPipeDoubleBank; /**< Indicates if the RNDIS interface's OUT data pipe should use double banking. */
uint8_t NotificationPipeNumber; /**< Pipe number of the RNDIS interface's IN notification endpoint, if used. */
uint8_t NotificationPipeNumber; /**< Pipe number of the RNDIS interface's IN notification endpoint, if used. */
bool NotificationPipeDoubleBank; /**< Indicates if the RNDIS interface's notification pipe should use double banking. */
uint32_t HostMaxPacketSize; /**< Maximum size of a packet which can be buffered by the host. */
} Config; /**< Config data for the USB class interface within the device. All elements in this section
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
@ -103,20 +103,20 @@
* Configured state.
*/
uint8_t ControlInterfaceNumber; /**< Interface index of the RNDIS control interface within the attached device. */
uint16_t DataINPipeSize; /**< Size in bytes of the RNDIS interface's IN data pipe. */
uint16_t DataOUTPipeSize; /**< Size in bytes of the RNDIS interface's OUT data pipe. */
uint16_t NotificationPipeSize; /**< Size in bytes of the RNDIS interface's IN notification pipe, if used. */
uint16_t NotificationPipeSize; /**< Size in bytes of the RNDIS interface's IN notification pipe, if used. */
uint32_t DeviceMaxPacketSize; /**< Maximum size of a packet which can be buffered by the attached RNDIS device. */
uint32_t RequestID; /**< Request ID counter to give a unique ID for each command/response pair. */
} State; /**< State data for the USB class interface within the device. All elements in this section
* <b>may</b> be set to initial values, but may also be ignored to default to sane values when
* the interface is enumerated.
*/
} USB_ClassInfo_RNDIS_Host_t;
/* Enums: */
/** Enum for the possible error codes returned by the \ref RNDIS_Host_ConfigurePipes() function. */
enum RNDIS_Host_EnumerationFailure_ErrorCodes_t
@ -211,7 +211,7 @@
* \return Boolean true if a packet is waiting to be read in by the host, false otherwise.
*/
bool RNDIS_Host_IsPacketReceived(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Retrieves the next pending packet from the device, discarding the remainder of the RNDIS packet header to leave
* only the packet contents for processing by the host in the nominated buffer.
*
@ -268,7 +268,7 @@
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_RNDIS_CLASS_HOST_C)
static uint8_t RNDIS_SendEncapsulatedCommand(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,
static uint8_t RNDIS_SendEncapsulatedCommand(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,
void* Buffer,
const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1)
ATTR_NON_NULL_PTR_ARG(2);
@ -291,3 +291,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
@ -46,7 +46,7 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
USB_Descriptor_Interface_t* StillImageInterface = NULL;
memset(&SIInterfaceInfo->State, 0x00, sizeof(SIInterfaceInfo->State));
if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
return SI_ENUMERROR_InvalidConfigDescriptor;
@ -63,7 +63,7 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
}
StillImageInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);
DataINEndpoint = NULL;
DataOUTEndpoint = NULL;
EventsEndpoint = NULL;
@ -85,7 +85,7 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
DataOUTEndpoint = EndpointData;
}
}
for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++)
{
if (PipeNum == SIInterfaceInfo->Config.DataINPipeNumber)
@ -113,8 +113,8 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
SIInterfaceInfo->State.EventsPipeSize = EventsEndpoint->EndpointSize;
}
}
}
SIInterfaceInfo->State.InterfaceNumber = StillImageInterface->InterfaceNumber;
SIInterfaceInfo->State.IsActive = true;
@ -135,7 +135,7 @@ uint8_t DCOMP_SI_Host_NextSIInterface(void* const CurrentDescriptor)
return DESCRIPTOR_SEARCH_Found;
}
}
return DESCRIPTOR_SEARCH_NotFound;
}
@ -145,7 +145,7 @@ uint8_t DCOMP_SI_Host_NextSIInterfaceEndpoint(void* const CurrentDescriptor)
{
USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,
USB_Descriptor_Endpoint_t);
uint8_t EndpointType = (CurrentEndpoint->Attributes & EP_TYPE_MASK);
if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&
@ -166,7 +166,7 @@ uint8_t SI_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
SI_PIMA_Container_t* const PIMAHeader)
{
uint8_t ErrorCode;
if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))
return PIPE_RWSTREAM_DeviceDisconnected;
@ -178,7 +178,7 @@ uint8_t SI_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
if ((ErrorCode = Pipe_Write_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
uint8_t ParamBytes = (PIMAHeader->DataLength - PIMA_COMMAND_SIZE(0));
if (ParamBytes)
@ -186,10 +186,10 @@ uint8_t SI_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
if ((ErrorCode = Pipe_Write_Stream_LE(&PIMAHeader->Params, ParamBytes, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
}
Pipe_ClearOUT();
Pipe_Freeze();
return PIPE_RWSTREAM_NoError;
}
@ -204,11 +204,11 @@ uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInf
Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipeNumber);
Pipe_Unfreeze();
while (!(Pipe_IsINReceived()))
{
uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
if (CurrentFrameNumber != PreviousFrameNumber)
{
PreviousFrameNumber = CurrentFrameNumber;
@ -216,7 +216,7 @@ uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInf
if (!(TimeoutMSRem--))
return PIPE_RWSTREAM_Timeout;
}
Pipe_Freeze();
Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
@ -236,25 +236,25 @@ uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInf
USB_Host_ClearPipeStall(SIInterfaceInfo->Config.DataINPipeNumber);
return PIPE_RWSTREAM_PipeStalled;
}
if (USB_HostState == HOST_STATE_Unattached)
return PIPE_RWSTREAM_DeviceDisconnected;
}
Pipe_Read_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NO_STREAM_CALLBACK);
if (PIMAHeader->Type == SI_PIMA_CONTAINER_ResponseBlock)
{
uint8_t ParamBytes = (PIMAHeader->DataLength - PIMA_COMMAND_SIZE(0));
if (ParamBytes)
Pipe_Read_Stream_LE(&PIMAHeader->Params, ParamBytes, NO_STREAM_CALLBACK);
Pipe_ClearIN();
}
Pipe_Freeze();
return PIPE_RWSTREAM_NoError;
}
@ -269,12 +269,12 @@ uint8_t SI_Host_SendData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
ErrorCode = Pipe_Write_Stream_LE(Buffer, Bytes, NO_STREAM_CALLBACK);
Pipe_ClearOUT();
Pipe_Freeze();
return ErrorCode;
}
@ -293,7 +293,7 @@ uint8_t SI_Host_ReadData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
ErrorCode = Pipe_Read_Stream_LE(Buffer, Bytes, NO_STREAM_CALLBACK);
Pipe_Freeze();
return ErrorCode;
}
@ -306,12 +306,12 @@ bool SI_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
Pipe_SelectPipe(SIInterfaceInfo->Config.EventsPipeNumber);
Pipe_Unfreeze();
if (Pipe_BytesInPipe())
IsEventReceived = true;
Pipe_Freeze();
return IsEventReceived;
}
@ -325,12 +325,12 @@ uint8_t SI_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInf
Pipe_SelectPipe(SIInterfaceInfo->Config.EventsPipeNumber);
Pipe_Unfreeze();
ErrorCode = Pipe_Read_Stream_LE(PIMAHeader, sizeof(SI_PIMA_Container_t), NO_STREAM_CALLBACK);
Pipe_ClearIN();
Pipe_Freeze();
return ErrorCode;
}
@ -351,16 +351,16 @@ uint8_t SI_Host_OpenSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
.Code = 0x1002,
.Params = {1},
};
if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
if ((PIMABlock.Type != SI_PIMA_CONTAINER_ResponseBlock) || (PIMABlock.Code != 0x2001))
return SI_ERROR_LOGICAL_CMD_FAILED;
SIInterfaceInfo->State.IsSessionOpen = true;
return PIPE_RWSTREAM_NoError;
@ -380,10 +380,10 @@ uint8_t SI_Host_CloseSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
.Code = 0x1003,
.Params = {1},
};
if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
@ -411,9 +411,9 @@ uint8_t SI_Host_SendCommand(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
.Type = SI_PIMA_CONTAINER_CommandBlock,
.Code = Operation,
};
memcpy(&PIMABlock.Params, Params, sizeof(uint32_t) * TotalParams);
if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
@ -433,8 +433,9 @@ uint8_t SI_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
if ((PIMABlock.Type != SI_PIMA_CONTAINER_ResponseBlock) || (PIMABlock.Code != 0x2001))
return SI_ERROR_LOGICAL_CMD_FAILED;
return PIPE_RWSTREAM_NoError;
}
#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
@ -56,7 +56,7 @@
/* Includes: */
#include "../../USB.h"
#include "../Common/StillImage.h"
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
@ -66,7 +66,7 @@
#if !defined(__INCLUDE_FROM_SI_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/Class/StillImage.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Error code for some Still Image Host functions, indicating a logical (and not hardware) error. */
@ -89,7 +89,7 @@
uint8_t DataOUTPipeNumber; /**< Pipe number of the Still Image interface's OUT data pipe. */
bool DataOUTPipeDoubleBank; /**< Indicates if the Still Image interface's OUT data pipe should use double banking. */
uint8_t EventsPipeNumber; /**< Pipe number of the Still Image interface's IN events endpoint, if used. */
uint8_t EventsPipeNumber; /**< Pipe number of the Still Image interface's IN events endpoint, if used. */
bool EventsPipeDoubleBank; /**< Indicates if the Still Image interface's events data pipe should use double banking. */
} Config; /**< Config data for the USB class interface within the device. All elements in this section
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
@ -105,7 +105,7 @@
uint16_t DataINPipeSize; /**< Size in bytes of the Still Image interface's IN data pipe. */
uint16_t DataOUTPipeSize; /**< Size in bytes of the Still Image interface's OUT data pipe. */
uint16_t EventsPipeSize; /**< Size in bytes of the Still Image interface's IN events pipe. */
bool IsSessionOpen; /**< Indicates if a PIMA session is currently open with the attached device. */
uint32_t TransactionID; /**< Transaction ID for the next transaction to send to the device. */
} State; /**< State data for the USB class interface within the device. All elements in this section
@ -113,7 +113,7 @@
* the interface is enumerated.
*/
} USB_ClassInfo_SI_Host_t;
/* Enums: */
/** Enum for the possible error codes returned by the \ref SI_Host_ConfigurePipes() function. */
enum SI_Host_EnumerationFailure_ErrorCodes_t
@ -148,7 +148,7 @@
/** Opens a new PIMA session with the attached device. This should be used before any session-orientated PIMA commands
* are issued to the device. Only one session can be open at the one time.
*
*
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
* call will fail.
*
@ -186,7 +186,7 @@
uint8_t SI_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
SI_PIMA_Container_t* const PIMAHeader) ATTR_NON_NULL_PTR_ARG(1)
ATTR_NON_NULL_PTR_ARG(2);
/** Receives a raw PIMA block header to the device. This can be used to receive arbitrary PIMA blocks from the device with
* or without parameters.
*
@ -203,7 +203,7 @@
ATTR_NON_NULL_PTR_ARG(2);
/** Sends a given PIMA command to the attached device, filling out the PIMA command header's Transaction ID automatically.
*
*
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
* call will fail.
*
@ -258,7 +258,7 @@
uint8_t SI_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
SI_PIMA_Container_t* const PIMAHeader) ATTR_NON_NULL_PTR_ARG(1)
ATTR_NON_NULL_PTR_ARG(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.
*
@ -290,7 +290,7 @@
uint8_t SI_Host_ReadData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
void* Buffer,
const uint16_t Bytes) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
/* Inline Functions: */
/** General management task for a given Still Image host class interface, required for the correct operation of the
* interface. This should be called frequently in the main program loop, before the master USB management task
@ -302,7 +302,7 @@
static inline void SI_Host_USBTask(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
{
(void)SIInterfaceInfo;
}
}
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
@ -312,14 +312,14 @@
#define STILL_IMAGE_PROTOCOL 0x01
#define COMMAND_DATA_TIMEOUT_MS 10000
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_SI_CLASS_HOST_C)
static uint8_t DCOMP_SI_Host_NextSIInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
static uint8_t DCOMP_SI_Host_NextSIInterfaceEndpoint(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
#endif
#endif
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
@ -328,3 +328,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
@ -65,7 +65,7 @@
/* Macros: */
#define __INCLUDE_FROM_MIDI_DRIVER
#define __INCLUDE_FROM_USB_DRIVER
/* Includes: */
#include "../HighLevel/USBMode.h"
@ -80,7 +80,8 @@
#if defined(USB_CAN_BE_HOST)
#include "Host/MIDI.h"
#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
@ -62,7 +62,7 @@
/* Macros: */
#define __INCLUDE_FROM_MS_DRIVER
#define __INCLUDE_FROM_USB_DRIVER
/* Includes: */
#include "../HighLevel/USBMode.h"
@ -73,11 +73,12 @@
#if defined(USB_CAN_BE_DEVICE)
#include "Device/MassStorage.h"
#endif
#if defined(USB_CAN_BE_HOST)
#include "Host/MassStorage.h"
#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
@ -66,7 +66,7 @@
/* Includes: */
#include "../HighLevel/USBMode.h"
#if defined(NO_STREAM_CALLBACKS)
#error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers.
#endif
@ -74,7 +74,8 @@
#if defined(USB_CAN_BE_HOST)
#include "Host/Printer.h"
#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
@ -62,7 +62,7 @@
/* Macros: */
#define __INCLUDE_FROM_RNDIS_DRIVER
#define __INCLUDE_FROM_USB_DRIVER
/* Includes: */
#include "../HighLevel/USBMode.h"
@ -73,11 +73,12 @@
#if defined(USB_CAN_BE_DEVICE)
#include "Device/RNDIS.h"
#endif
#if defined(USB_CAN_BE_HOST)
#include "Host/RNDIS.h"
#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
@ -61,10 +61,10 @@
/* Macros: */
#define __INCLUDE_FROM_SI_DRIVER
#define __INCLUDE_FROM_USB_DRIVER
/* Includes: */
#include "../HighLevel/USBMode.h"
#if defined(NO_STREAM_CALLBACKS)
#error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers.
#endif
@ -72,7 +72,8 @@
#if defined(USB_CAN_BE_HOST)
#include "Host/StillImage.h"
#endif
#endif
/** @} */