X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/f29fc1abc40dd862689ca8765e244c1212742744..57fe6b4fb97668eb15c4fa56095c0abd746d6c99:/LUFA/Drivers/USB/LowLevel/Endpoint.h diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index 5bbbb87b5..93412f500 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -1,21 +1,21 @@ /* LUFA Library - Copyright (C) Dean Camera, 2009. + Copyright (C) Dean Camera, 2010. dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ /* - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, 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 + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + 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 + 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 software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -28,6 +28,16 @@ this software. */ +/** \file + * \brief USB device endpoint management definitions. + * + * This file contains structures, function prototypes and macros related to the management of the device's + * data endpoints when the library is initialized in USB device mode. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + /** \ingroup Group_USB * @defgroup Group_EndpointManagement Endpoint Management * @@ -83,6 +93,11 @@ extern "C" { #endif + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + /* Public Interface - May be used in end-application: */ /* Macros: */ /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint @@ -126,6 +141,11 @@ */ #define ENDPOINT_EPNUM_MASK 0x07 + /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's + * direction for comparing with the ENDPOINT_DESCRIPTOR_DIR_* masks. + */ + #define ENDPOINT_EPDIR_MASK 0x80 + /** Endpoint bank size mask, for masking against endpoint addresses to retrieve the endpoint's * bank size in the device. */ @@ -338,9 +358,11 @@ */ static inline void Endpoint_SetEndpointDirection(uint8_t DirectionMask); #else - #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__) + #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) #define Endpoint_BytesInEndpoint() UEBCX - #else + #elif defined(USB_SERIES_4_AVR) + #define Endpoint_BytesInEndpoint() (((uint16_t)UEBCHX << 8) | UEBCLX) + #elif defined(USB_SERIES_2_AVR) #define Endpoint_BytesInEndpoint() UEBCLX #endif @@ -353,7 +375,7 @@ #if !defined(CONTROL_ONLY_DEVICE) #define Endpoint_SelectEndpoint(epnum) MACROS{ UENUM = (epnum); }MACROE #else - #define Endpoint_SelectEndpoint(epnum) (void)epnum + #define Endpoint_SelectEndpoint(epnum) (void)(epnum) #endif #define Endpoint_ResetFIFO(epnum) MACROS{ UERST = (1 << (epnum)); UERST = 0; }MACROE @@ -383,15 +405,13 @@ #define Endpoint_ClearSETUP() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE #if !defined(CONTROL_ONLY_DEVICE) - #define Endpoint_ClearIN() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \ - UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE + #define Endpoint_ClearIN() MACROS{ UEINTX &= ~((1 << TXINI) | (1 << FIFOCON)); }MACROE #else #define Endpoint_ClearIN() MACROS{ UEINTX &= ~(1 << TXINI); }MACROE #endif #if !defined(CONTROL_ONLY_DEVICE) - #define Endpoint_ClearOUT() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << RXOUTI)); \ - UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE + #define Endpoint_ClearOUT() MACROS{ UEINTX &= ~((1 << RXOUTI) | (1 << FIFOCON)); }MACROE #else #define Endpoint_ClearOUT() MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE #endif @@ -422,8 +442,12 @@ */ ENDPOINT_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while * waiting for the endpoint to become ready. - */ - ENDPOINT_READYWAIT_Timeout = 3, /**< The host failed to accept or send the next packet + */ + ENDPOINT_READYWAIT_BusSuspended = 3, /**< The USB bus has been suspended by the host and + * no USB endpoint traffic can occur until the bus + * has resumed. + */ + ENDPOINT_READYWAIT_Timeout = 4, /**< The host failed to accept or send the next packet * within the software timeout period set by the * \ref USB_STREAM_TIMEOUT_MS macro. */ @@ -442,11 +466,15 @@ ENDPOINT_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during * the transfer. */ - ENDPOINT_RWSTREAM_Timeout = 3, /**< The host failed to accept or send the next packet + ENDPOINT_RWSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and + * no USB endpoint traffic can occur until the bus + * has resumed. + */ + ENDPOINT_RWSTREAM_Timeout = 4, /**< The host failed to accept or send the next packet * within the software timeout period set by the * \ref USB_STREAM_TIMEOUT_MS macro. */ - ENDPOINT_RWSTREAM_CallbackAborted = 4, /**< Indicates that the stream's callback function + ENDPOINT_RWSTREAM_CallbackAborted = 5, /**< Indicates that the stream's callback function * aborted the transfer early. */ }; @@ -462,6 +490,10 @@ ENDPOINT_RWCSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during * the transfer. */ + ENDPOINT_RWCSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and + * no USB endpoint traffic can occur until the bus + * has resumed. + */ }; /* Inline Functions: */ @@ -725,7 +757,8 @@ * The banking mode may be either \ref ENDPOINT_BANK_SINGLE or \ref ENDPOINT_BANK_DOUBLE. * * \note The default control endpoint does not have to be manually configured, as it is automatically - * configured by the library internally. + * configured by the library internally. + * \n\n * * \note This routine will select the specified endpoint, and the endpoint will remain selected * once the routine completes regardless of if the endpoint configuration succeeds. @@ -735,7 +768,7 @@ bool Endpoint_ConfigureEndpoint(const uint8_t Number, const uint8_t Type, const uint8_t Direction, const uint16_t Size, const uint8_t Banks); - /** Spinloops until the currently selected non-control endpoint is ready for the next packet of data + /** Spin-loops until the currently selected non-control endpoint is ready for the next packet of data * to be read or written to it. * * \note This routine should not be called on CONTROL type endpoints. @@ -949,6 +982,7 @@ * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. + * \n\n * * \note This routine should only be used on CONTROL type endpoints. * @@ -968,6 +1002,7 @@ * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. + * \n\n * * \note This routine should only be used on CONTROL type endpoints. * @@ -987,8 +1022,10 @@ * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. + * \n\n * * \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * \n\n * * \note This routine should only be used on CONTROL type endpoints. * @@ -1011,6 +1048,7 @@ * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. + * \n\n * * \note This routine should only be used on CONTROL type endpoints. * @@ -1030,6 +1068,7 @@ * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. + * \n\n * * \note This routine should only be used on CONTROL type endpoints. * @@ -1049,8 +1088,10 @@ * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. + * \n\n * * \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * \n\n * * \note This routine should only be used on CONTROL type endpoints. * @@ -1073,6 +1114,7 @@ * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. + * \n\n * * \note This routine should only be used on CONTROL type endpoints. * @@ -1092,6 +1134,7 @@ * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. + * \n\n * * \note This routine should only be used on CONTROL type endpoints. * @@ -1114,6 +1157,7 @@ * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. + * \n\n * * \note This routine should only be used on CONTROL type endpoints. * @@ -1133,6 +1177,7 @@ * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. + * \n\n * * \note This routine should only be used on CONTROL type endpoints. * @@ -1205,7 +1250,7 @@ } return (MaskVal << EPSIZE0); - }; + } #endif