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 ENDPOINT_BANK_DOUBLE (1 << EPBK0) |
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 << EPBK0) |
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_CONTROLEP 0 |
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.
#define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8 |
Default size of the default control endpoint's bank, until altered by the Endpoint0Size value in the device descriptor. Not available if the FIXED_CONTROL_ENDPOINT_SIZE token is defined.
#define ENDPOINT_DIR_IN (1 << EPDIR) |
Endpoint data direction mask for Endpoint_ConfigureEndpoint(). This indicates that the endpoint should be initialized in the IN direction - i.e. data flows from device to host.
#define ENDPOINT_DIR_OUT (0 << EPDIR) |
Endpoint data direction mask for Endpoint_ConfigureEndpoint(). This indicates that the endpoint should be initialized in the OUT direction - i.e. data flows from host to device.
#define ENDPOINT_DOUBLEBANK_SUPPORTED | ( | n | ) | _ENDPOINT_GET_DOUBLEBANK(n) |
Indicates if the given endpoint supports double banking.
[in] | n | Endpoint number, a value between 0 and (ENDPOINT_TOTAL_ENDPOINTS - 1) |
#define ENDPOINT_EPDIR_MASK 0x80 |
Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's direction for comparing with the ENDPOINT_DESCRIPTOR_DIR_* masks.
#define ENDPOINT_EPNUM_MASK 0x07 |
Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's numerical address in the device.
#define ENDPOINT_EPSIZE_MASK 0x7FF |
Endpoint bank size mask, for masking against endpoint addresses to retrieve the endpoint's bank size in the device.
#define ENDPOINT_MAX_SIZE | ( | n | ) | _ENDPOINT_GET_MAXSIZE(n) |
Maximum size in bytes of a given endpoint.
[in] | n | Endpoint number, a value between 0 and (ENDPOINT_TOTAL_ENDPOINTS - 1) |
#define ENDPOINT_TOTAL_ENDPOINTS 7 |
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.
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.
bool Endpoint_ConfigureEndpoint | ( | const uint8_t | Number, | |
const uint8_t | Type, | |||
const uint8_t | Direction, | |||
const uint16_t | Size, | |||
const uint8_t | Banks | |||
) |
Configures the specified endpoint number with the given endpoint type, direction, bank size and banking mode. Endpoints should be allocated in ascending order by their address in the device (i.e. endpoint 1 should be configured before endpoint 2 and so on) to prevent fragmentation of the USB FIFO memory.
The endpoint type may be one of the EP_TYPE_* macros listed in LowLevel.h and the direction may be either ENDPOINT_DIR_OUT or ENDPOINT_DIR_IN.
The bank size must indicate the maximum packet size that the endpoint can handle. Different endpoint numbers can handle different maximum packet sizes - refer to the chosen USB AVR's datasheet to determine the maximum bank size for each endpoint.
The banking mode may be either ENDPOINT_BANK_SINGLE or ENDPOINT_BANK_DOUBLE.
static void Endpoint_DisableEndpoint | ( | void | ) | [inline, static] |
Disables the currently selected endpoint so that data cannot be sent and received through it to and from a host.
static void Endpoint_EnableEndpoint | ( | void | ) | [inline, static] |
Enables the currently selected endpoint so that data can be sent and received through it to and from a host.
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.
static uint8_t Endpoint_GetEndpointDirection | ( | void | ) | [inline, static] |
Determines the currently selected endpoint's direction.
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}).
static bool Endpoint_HasEndpointInterrupted | ( | uint8_t | EndpointNumber | ) | [inline, static] |
Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type endpoints).
[in] | EndpointNumber | Index of the endpoint whose interrupt flag should be tested |
static bool Endpoint_IsConfigured | ( | void | ) | [inline, static] |
Determines if the currently selected endpoint is configured.
static bool Endpoint_IsEnabled | ( | void | ) | [inline, static] |
Determines if the currently selected endpoint is enabled, but not necessarily configured.
static void Endpoint_ResetDataToggle | ( | void | ) | [inline, static] |
Resets the data toggle of the currently selected endpoint.
static void Endpoint_ResetFIFO | ( | uint8_t | EndpointNumber | ) | [inline, static] |
Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's In and Out pointers to the bank's contents.
[in] | EndpointNumber | Endpoint number whose FIFO buffers are to be reset |
static void Endpoint_SelectEndpoint | ( | 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.
[in] | EndpointNumber | Endpoint number to select |
static void Endpoint_SetEndpointDirection | ( | uint8_t | DirectionMask | ) | [inline, static] |
Sets the direction of the currently selected endpoint.
[in] | DirectionMask | New endpoint direction, as a ENDPOINT_DIR_* mask. |
uint8_t USB_ControlEndpointSize |
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 descriptors to ensure this.