LUFA Library  120219
Endpoint Management (XMEGA)

Endpoint management definitions for the Atmel AVR XMEGA architecture. More...

Defines

#define ENDPOINT_CONTROLEP_DEFAULT_SIZE   8
#define ENDPOINT_MAX_SIZE(EPIndex)   _ENDPOINT_GET_MAXSIZE(EPIndex)
#define ENDPOINT_BANKS_SUPPORTED(EPIndex)   _ENDPOINT_GET_BANKS(EPIndex)
#define ENDPOINT_TOTAL_ENDPOINTS   ENDPOINT_DETAILS_MAXEP

Functions

static void Endpoint_SelectEndpoint (const uint8_t EndpointNumber)
static bool Endpoint_ConfigureEndpoint (const uint8_t Number, const uint8_t Type, const uint8_t Direction, const uint16_t Size, const uint8_t Banks) ATTR_ALWAYS_INLINE
static uint8_t Endpoint_GetCurrentEndpoint (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
static void Endpoint_ResetEndpoint (const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE
static bool Endpoint_IsEnabled (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
static bool Endpoint_IsConfigured (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
static uint8_t Endpoint_GetEndpointInterrupts (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
static bool Endpoint_HasEndpointInterrupted (const uint8_t EndpointNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
static void Endpoint_ResetDataToggle (void) ATTR_ALWAYS_INLINE
static uint8_t Endpoint_GetEndpointDirection (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
void Endpoint_ClearStatusStage (void)

Variables

uint8_t USB_Device_ControlEndpointSize

Endpoint Bank Mode Masks

#define ENDPOINT_BANK_SINGLE   0
#define ENDPOINT_BANK_DOUBLE   USB_EP_PINGPONG_bm

Detailed Description

Functions, macros and enums related to endpoint management when in USB Device mode. This module contains the endpoint management macros, as well as endpoint interrupt and data send/receive functions for various data types.


Define Documentation

#define ENDPOINT_BANK_DOUBLE   USB_EP_PINGPONG_bm

Mask for the bank mode selection for the Endpoint_ConfigureEndpoint() macro. This indicates that the endpoint should have two banks, which requires more USB FIFO memory but results in faster transfers as one USB device (the AVR or the host) can access one bank while the other accesses the second bank.

#define ENDPOINT_BANK_SINGLE   0

Mask for the bank mode selection for the 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 bank at the one time.

#define ENDPOINT_BANKS_SUPPORTED (   EPIndex)    _ENDPOINT_GET_BANKS(EPIndex)

Retrieves the total number of banks supported by the given endpoint.

Note:
This macro will only work correctly on endpoint indexes that are compile-time constants defined by the preprocessor.
Parameters:
[in]EPIndexEndpoint number, a value between 0 and (ENDPOINT_TOTAL_ENDPOINTS - 1)

Default size of the default control endpoint's bank, until altered by the control endpoint bank size value in the device descriptor. Not available if the FIXED_CONTROL_ENDPOINT_SIZE token is defined.

#define ENDPOINT_MAX_SIZE (   EPIndex)    _ENDPOINT_GET_MAXSIZE(EPIndex)

Retrieves the maximum bank size in bytes of a given endpoint.

Note:
This macro will only work correctly on endpoint indexes that are compile-time constants defined by the preprocessor.
Parameters:
[in]EPIndexEndpoint number, a value between 0 and (ENDPOINT_TOTAL_ENDPOINTS - 1)
#define ENDPOINT_TOTAL_ENDPOINTS   ENDPOINT_DETAILS_MAXEP

Total number of endpoints (including the default control endpoint at address 0) which may be used in the device. Different USB AVR models support different amounts of endpoints, this value reflects the maximum number of endpoints for the currently selected AVR model.


Function Documentation

void Endpoint_ClearStatusStage ( void  )

Completes the status stage of a control transfer on a CONTROL type endpoint automatically, with respect to the data direction. This is a convenience function which can be used to simplify user control request handling.

static bool Endpoint_ConfigureEndpoint ( const uint8_t  Number,
const uint8_t  Type,
const uint8_t  Direction,
const uint16_t  Size,
const uint8_t  Banks 
) [inline, static]

Configures the specified endpoint number with the given endpoint type, direction, bank size and banking mode. Once configured, the endpoint may be read from or written to, depending on its direction.

Parameters:
[in]NumberEndpoint number to configure. This must be more than 0 and less than ENDPOINT_TOTAL_ENDPOINTS.
[in]TypeType of endpoint to configure, a EP_TYPE_* mask. Not all endpoint types are available on Low Speed USB devices - refer to the USB 2.0 specification.
[in]DirectionEndpoint data direction, either ENDPOINT_DIR_OUT or ENDPOINT_DIR_IN. All endpoints (except Control type) are unidirectional - data may only be read from or written to the endpoint bank based on its direction, not both.
[in]SizeSize of the endpoint's bank, where packets are stored before they are transmitted to the USB host, or after they have been received from the USB host (depending on the endpoint's data direction). The bank size must indicate the maximum packet size that the endpoint can handle.
[in]BanksNumber of banks to use for the endpoint being configured, an ENDPOINT_BANK_* mask. More banks uses more USB DPRAM, but offers better performance. Isochronous type endpoints must have at least two banks.
Note:
The default control endpoint should not be manually configured by the user application, as it is automatically configured by the library internally.

This routine will automatically select the specified endpoint.
Returns:
Boolean true if the configuration succeeded, false otherwise.
static uint8_t Endpoint_GetCurrentEndpoint ( void  ) [inline, static]

Get the endpoint address of the currently selected endpoint. This is typically used to save the currently selected endpoint number so that it can be restored after another endpoint has been manipulated.

Returns:
Index of the currently selected endpoint.
static uint8_t Endpoint_GetEndpointDirection ( void  ) [inline, static]

Determines the currently selected endpoint's direction.

Returns:
The currently selected endpoint's direction, as a ENDPOINT_DIR_* mask.
static uint8_t Endpoint_GetEndpointInterrupts ( void  ) [inline, static]

Returns a mask indicating which INTERRUPT type endpoints have interrupted - i.e. their interrupt duration has elapsed. Which endpoints have interrupted can be determined by masking the return value against (1 << {Endpoint Number}).

Returns:
Mask whose bits indicate which endpoints have interrupted.
static bool Endpoint_HasEndpointInterrupted ( const uint8_t  EndpointNumber) [inline, static]

Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type endpoints).

Parameters:
[in]EndpointNumberIndex of the endpoint whose interrupt flag should be tested.
Returns:
Boolean true if the specified endpoint has interrupted, false otherwise.
static bool Endpoint_IsConfigured ( void  ) [inline, static]

Determines if the currently selected endpoint is configured.

Returns:
Boolean true if the currently selected endpoint has been configured, false otherwise.
static bool Endpoint_IsEnabled ( void  ) [inline, static]

Determines if the currently selected endpoint is enabled, but not necessarily configured.

Returns:
Boolean true if the currently selected endpoint is enabled, false otherwise.
static void Endpoint_ResetDataToggle ( void  ) [inline, static]

Resets the data toggle of the currently selected endpoint.

static void Endpoint_ResetEndpoint ( const uint8_t  EndpointNumber) [inline, static]

Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's data In and Out pointers to the bank's contents.

Parameters:
[in]EndpointNumberEndpoint number whose FIFO buffers are to be reset.
static void Endpoint_SelectEndpoint ( const uint8_t  EndpointNumber) [inline, static]

Selects the given endpoint number. If the address from the device descriptors is used, the value should be masked with the ENDPOINT_EPNUM_MASK constant to extract only the endpoint number (and discarding the endpoint direction bit).

Any endpoint operations which do not require the endpoint number to be indicated will operate on the currently selected endpoint.

Parameters:
[in]EndpointNumberEndpoint number to select.

Variable Documentation

Global indicating the maximum packet size of the default control endpoint located at address 0 in the device. This value is set to the value indicated in the device descriptor in the user project once the USB interface is initialized into device mode.

If space is an issue, it is possible to fix this to a static value by defining the control endpoint size in the FIXED_CONTROL_ENDPOINT_SIZE token passed to the compiler in the makefile via the -D switch. When a fixed control endpoint size is used, the size is no longer dynamically read from the descriptors at runtime and instead fixed to the given value. When used, it is important that the descriptor control endpoint size value matches the size given as the FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the FIXED_CONTROL_ENDPOINT_SIZE token be used in the device descriptors to ensure this.

Note:
This variable should be treated as read-only in the user application, and never manually changed in value.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines