LUFA Library  140302
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Endpoint Management (EFM32GG)

Endpoint management definitions for the Silabs EFM32 Giant Gecko architecture. More...

Macros

#define ENDPOINT_CONTROLEP_DEFAULT_SIZE   64
 
#define ENDPOINT_TOTAL_ENDPOINTS   7
 

Functions

void Endpoint_ClearStatusStage (void)
 
bool Endpoint_ConfigureEndpoint (const uint8_t Address, const uint8_t Type, const uint16_t Size, const uint8_t Banks)
 
bool Endpoint_ConfigureEndpointTable (const USB_Endpoint_Table_t *const Table, const uint8_t Entries)
 
static INLINENON void Endpoint_DisableEndpoint (void) ATTR_ALWAYS_INLINE2
 
static INLINENON void Endpoint_EnableEndpoint (void) ATTR_ALWAYS_INLINE2
 
static INLINENON uint8_t Endpoint_GetCurrentEndpoint (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE2
 
static INLINENON uint32_t Endpoint_GetEndpointDirection (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE2
 
static INLINENON uint32_t Endpoint_GetEndpointInterrupts (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE2
 
static INLINENON bool Endpoint_HasEndpointInterrupted (const uint8_t Address) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE2
 
static INLINENON bool Endpoint_IsConfigured (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE2
 
static INLINENON bool Endpoint_IsEnabled (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE2
 
static INLINENON void Endpoint_ResetDataToggle (void) ATTR_ALWAYS_INLINE2
 
static INLINENON void Endpoint_ResetEndpoint (const uint8_t Address) ATTR_ALWAYS_INLINE2
 
static INLINENON void Endpoint_SelectEndpoint (const uint8_t Address) ATTR_ALWAYS_INLINE2
 
static INLINENON void Endpoint_SetEndpointDirection (const uint32_t DirectionMask) ATTR_ALWAYS_INLINE2
 

Variables

uint8_t USB_Device_ControlEndpointSize
 

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.

Macro Definition Documentation

#define ENDPOINT_CONTROLEP_DEFAULT_SIZE   64

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_TOTAL_ENDPOINTS   7

Total number of endpoints (including the default control endpoint at address 0) which may be used in the device. Different EFM32 models support different amounts of endpoints, this value reflects the maximum number of endpoints for the currently selected EFM32 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.

Note
This routine should not be called on non CONTROL type endpoints.
static bool Endpoint_ConfigureEndpoint ( const uint8_t  Address,
const uint8_t  Type,
const uint16_t  Size,
const uint8_t  Banks 
)
inline

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

Parameters
[in]AddressEndpoint address to configure.
[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]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 hardware banks to use for the endpoint being configured.
Attention
When the ORDERED_EP_CONFIG compile time option is used, Endpoints must be configured in ascending order, or bank corruption will occur.
Note
Different endpoints may have different maximum packet sizes based on the endpoint's index - refer to the chosen microcontroller model's datasheet to determine the maximum bank size for each endpoint.

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 upon success. Upon failure, the endpoint which failed to reconfigure correctly will be selected.
Returns
Boolean true if the configuration succeeded, false otherwise.
bool Endpoint_ConfigureEndpointTable ( const USB_Endpoint_Table_t *const  Table,
const uint8_t  Entries 
)

Configures a table of endpoint descriptions, in sequence. This function can be used to configure multiple endpoints at the same time.

Note
Endpoints with a zero address will be ignored, thus this function cannot be used to configure the control endpoint.
Parameters
[in]TablePointer to a table of endpoint descriptions.
[in]EntriesNumber of entries in the endpoint table to configure.
Returns
Boolean true if all endpoints configured successfully, false otherwise.
static INLINENON void Endpoint_DisableEndpoint ( void  )
static

Disables the currently selected endpoint so that data cannot be sent and received through it to and from a host.

static INLINENON void Endpoint_EnableEndpoint ( void  )
static

Enables the currently selected endpoint so that data can be sent and received through it to and from a host.

Note
Endpoints must first be configured properly via Endpoint_ConfigureEndpoint().
static INLINENON uint8_t Endpoint_GetCurrentEndpoint ( void  )
static

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

Returns
Index of the currently selected endpoint.
static INLINENON uint32_t Endpoint_GetEndpointDirection ( void  )
static

Determines the currently selected endpoint's direction.

Returns
The currently selected endpoint's direction, as a ENDPOINT_DIR_* mask.
static INLINENON uint32_t Endpoint_GetEndpointInterrupts ( void  )
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 INLINENON bool Endpoint_HasEndpointInterrupted ( const uint8_t  Address)
static

Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type endpoints). Endpoint out interrupt start from bit 16, Endpoint in interrupt start from 0.

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

Determines if the currently selected endpoint is configured.

Returns
Boolean true if the currently selected endpoint has been configured, false otherwise.
static INLINENON bool Endpoint_IsEnabled ( void  )
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 INLINENON void Endpoint_ResetDataToggle ( void  )
static

Resets the data toggle of the currently selected endpoint.

static INLINENON void Endpoint_ResetEndpoint ( const uint8_t  Address)
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]AddressEndpoint number whose FIFO buffers are to be reset.
static INLINENON void Endpoint_SelectEndpoint ( const uint8_t  Address)
static

Selects the given endpoint address.

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

Parameters
[in]AddressEndpoint address to select.
static INLINENON void Endpoint_SetEndpointDirection ( const uint32_t  DirectionMask)
static

Sets the direction of the currently selected endpoint.

Parameters
[in]DirectionMaskNew endpoint direction, as a ENDPOINT_DIR_* mask.

Variable Documentation

uint8_t USB_Device_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 device descriptors to ensure this.

Attention
This variable should be treated as read-only in the user application, and never manually changed in value.