X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/5a4def747897c1c6ffbe465506d846c7c686d3e9..d41cd9a41aca81eaa21e65e6c53672fe604fa3d5:/LUFA/Drivers/USB/LowLevel/Endpoint.h diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index 25ed9bad9..ea2e8cc53 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -3,7 +3,7 @@ Copyright (C) Dean Camera, 2010. dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com + www.lufa-lib.org */ /* @@ -93,30 +93,30 @@ /* Macros: */ #define _ENDPOINT_GET_MAXSIZE(EPIndex) _ENDPOINT_GET_MAXSIZE2(ENDPOINT_DETAILS_EP ## EPIndex) #define _ENDPOINT_GET_MAXSIZE2(EPDetails) _ENDPOINT_GET_MAXSIZE3(EPDetails) - #define _ENDPOINT_GET_MAXSIZE3(MaxSize, DB) (MaxSize) + #define _ENDPOINT_GET_MAXSIZE3(MaxSize, Banks) (MaxSize) - #define _ENDPOINT_GET_DOUBLEBANK(EPIndex) _ENDPOINT_GET_DOUBLEBANK2(ENDPOINT_DETAILS_EP ## EPIndex) - #define _ENDPOINT_GET_DOUBLEBANK2(EPDetails) _ENDPOINT_GET_DOUBLEBANK3(EPDetails) - #define _ENDPOINT_GET_DOUBLEBANK3(MaxSize, DB) (DB) + #define _ENDPOINT_GET_BANKS(EPIndex) _ENDPOINT_GET_BANKS2(ENDPOINT_DETAILS_EP ## EPIndex) + #define _ENDPOINT_GET_BANKS2(EPDetails) _ENDPOINT_GET_BANKS3(EPDetails) + #define _ENDPOINT_GET_BANKS3(MaxSize, Banks) (Banks) #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) #define ENDPOINT_DETAILS_MAXEP 7 - #define ENDPOINT_DETAILS_EP0 64, true - #define ENDPOINT_DETAILS_EP1 256, true - #define ENDPOINT_DETAILS_EP2 64, true - #define ENDPOINT_DETAILS_EP3 64, true - #define ENDPOINT_DETAILS_EP4 64, true - #define ENDPOINT_DETAILS_EP5 64, true - #define ENDPOINT_DETAILS_EP6 64, true + #define ENDPOINT_DETAILS_EP0 64, 2 + #define ENDPOINT_DETAILS_EP1 256, 2 + #define ENDPOINT_DETAILS_EP2 64, 2 + #define ENDPOINT_DETAILS_EP3 64, 2 + #define ENDPOINT_DETAILS_EP4 64, 2 + #define ENDPOINT_DETAILS_EP5 64, 2 + #define ENDPOINT_DETAILS_EP6 64, 2 #else #define ENDPOINT_DETAILS_MAXEP 5 - #define ENDPOINT_DETAILS_EP0 64, true - #define ENDPOINT_DETAILS_EP1 64, false - #define ENDPOINT_DETAILS_EP2 64, false - #define ENDPOINT_DETAILS_EP3 64, true - #define ENDPOINT_DETAILS_EP4 64, true + #define ENDPOINT_DETAILS_EP0 64, 2 + #define ENDPOINT_DETAILS_EP1 64, 1 + #define ENDPOINT_DETAILS_EP2 64, 1 + #define ENDPOINT_DETAILS_EP3 64, 2 + #define ENDPOINT_DETAILS_EP4 64, 2 #endif /* Inline Functions: */ @@ -146,6 +146,8 @@ /* Public Interface - May be used in end-application: */ /* Macros: */ + /** \name Endpoint Direction Masks */ + //@{ /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint * should be initialized in the OUT direction - i.e. data flows from host to device. */ @@ -155,7 +157,10 @@ * should be initialized in the IN direction - i.e. data flows from device to host. */ #define ENDPOINT_DIR_IN (1 << EPDIR) - + //@} + + /** \name Endpoint Bank Mode Masks */ + //@{ /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates * that the endpoint should have one single bank, which requires less USB FIFO memory but results * in slower transfers as only one USB device (the AVR or the host) can access the endpoint's @@ -169,7 +174,8 @@ * accesses the second bank. */ #define ENDPOINT_BANK_DOUBLE (1 << EPBK0) - + //@} + /** Endpoint address for the default control endpoint, which always resides in address 0. This is * defined for convenience to give more readable code when used with the endpoint macros. */ @@ -203,11 +209,11 @@ */ #define ENDPOINT_MAX_SIZE(EPIndex) _ENDPOINT_GET_MAXSIZE(EPIndex) - /** Indicates if the given endpoint supports double banking. + /** Indicates the total number of banks supported by the given endpoint. * * \param[in] EPIndex Endpoint number, a value between 0 and (ENDPOINT_TOTAL_ENDPOINTS - 1) */ - #define ENDPOINT_DOUBLEBANK_SUPPORTED(EPIndex) _ENDPOINT_GET_DOUBLEBANK(EPIndex) + #define ENDPOINT_BANKS_SUPPORTED(EPIndex) _ENDPOINT_GET_BANKS(EPIndex) #if !defined(CONTROL_ONLY_DEVICE) || defined(__DOXYGEN__) /** Total number of endpoints (including the default control endpoint at address 0) which may @@ -394,6 +400,35 @@ return ((UECONX & (1 << EPEN)) ? true : false); } + /** Aborts all pending IN transactions on the currently selected endpoint, once the bank + * has been queued for transmission to the host via \ref Endpoint_ClearIN(). This function + * will terminate all queued transactions, resetting the endpoint banks ready for a new + * packet. + * + * \ingroup Group_EndpointPacketManagement + */ + static inline void Endpoint_AbortPendingIN(void) + { + while (UESTA0X & (0x03 << NBUSYBK0)) + { + UEINTX |= (1 << RXOUTI); + while (UEINTX & (1 << RXOUTI)); + } + } + + /** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for + * transmission via the \ref Endpoint_ClearIN() command, or are awaiting acknowledgement via the + * \ref Endpoint_ClearOUT() command. + * + * \ingroup Group_EndpointPacketManagement + * + * \return Total number of busy banks in the selected endpoint. + */ + static inline uint8_t Endpoint_GetBusyBanks(void) + { + return (UESTA0X & (0x03 << NBUSYBK0)); + } + /** Determines if the currently selected endpoint may be read from (if data is waiting in the endpoint * bank and the endpoint is an OUT direction, or if the bank is not yet full if the endpoint is an IN * direction). This function will return false if an error has occurred in the endpoint, if the endpoint