LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Endpoint_LPC.h File Reference

Go to the source code of this file.

Macros

#define ENDPOINT_CONTROLEP_DEFAULT_SIZE   64
 
#define ENDPOINT_MAX_SIZE(EPIndex)   512
 
#define ENDPOINT_TOTAL_ENDPOINTS   ENDPOINT_DETAILS_MAXEP
 
Endpoint Bank Mode Masks
#define ENDPOINT_BANK_SINGLE   (0 << 1)
 
#define ENDPOINT_BANK_DOUBLE   (1 << 1)
 

Enumerations

enum  Endpoint_WaitUntilReady_ErrorCodes_t {
  ENDPOINT_READYWAIT_NoError = 0, ENDPOINT_READYWAIT_EndpointStalled = 1, ENDPOINT_READYWAIT_DeviceDisconnected = 2, ENDPOINT_READYWAIT_BusSuspended = 3,
  ENDPOINT_READYWAIT_Timeout = 4
}
 

Functions

static PRAGMA_ALWAYS_INLINE uint8_t Endpoint_GetCurrentEndpoint (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
 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 PRAGMA_ALWAYS_INLINE void Endpoint_SelectEndpoint (const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE
 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).
 
static PRAGMA_ALWAYS_INLINE uint8_t Endpoint_Read_8 (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
 Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints.
 
static PRAGMA_ALWAYS_INLINE uint8_t Endpoint_GetEndpointDirection (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
 Determines the currently selected endpoint's direction.
 
static PRAGMA_ALWAYS_INLINE bool Endpoint_IsReadWriteAllowed (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
 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 is an OUT direction and no packet (or an empty packet) has been received, or if the endpoint is an IN direction and the endpoint bank is full.
 
static PRAGMA_ALWAYS_INLINE void Endpoint_Write_8 (const uint8_t Data) ATTR_ALWAYS_INLINE
 Writes one byte to the currently selected endpoint's bank, for IN direction endpoints.
 
static PRAGMA_ALWAYS_INLINE void Endpoint_Discard_8 (void) ATTR_ALWAYS_INLINE
 Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.
 
static PRAGMA_ALWAYS_INLINE
uint16_t 
Endpoint_Read_16_LE (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
 Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT direction endpoints.
 
static PRAGMA_ALWAYS_INLINE
uint16_t 
Endpoint_Read_16_BE (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
 Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT direction endpoints.
 
static PRAGMA_ALWAYS_INLINE void Endpoint_Write_16_LE (const uint16_t Data) ATTR_ALWAYS_INLINE
 Writes two bytes to the currently selected endpoint's bank in little endian format, for IN direction endpoints.
 
static PRAGMA_ALWAYS_INLINE void Endpoint_Write_16_BE (const uint16_t Data) ATTR_ALWAYS_INLINE
 Writes two bytes to the currently selected endpoint's bank in big endian format, for IN direction endpoints.
 
static PRAGMA_ALWAYS_INLINE void Endpoint_Discard_16 (void) ATTR_ALWAYS_INLINE
 Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.
 
static PRAGMA_ALWAYS_INLINE
uint32_t 
Endpoint_Read_32_LE (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
 Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT direction endpoints.
 
static PRAGMA_ALWAYS_INLINE
uint32_t 
Endpoint_Read_32_BE (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE
 Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT direction endpoints.
 
static PRAGMA_ALWAYS_INLINE void Endpoint_Write_32_LE (const uint32_t Data) ATTR_ALWAYS_INLINE
 Writes four bytes to the currently selected endpoint's bank in little endian format, for IN direction endpoints.
 
static PRAGMA_ALWAYS_INLINE void Endpoint_Write_32_BE (const uint32_t Data) ATTR_ALWAYS_INLINE
 Writes four bytes to the currently selected endpoint's bank in big endian format, for IN direction endpoints.
 
static PRAGMA_ALWAYS_INLINE void Endpoint_Discard_32 (void) ATTR_ALWAYS_INLINE
 Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.
 
void Endpoint_GetSetupPackage (uint8_t *pData)
 

Macro Definition Documentation

#define ENDPOINT_BANK_DOUBLE   (1 << 1)

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 LPC or the host) can access one bank while the other accesses the second bank.

Definition at line 64 of file Endpoint_LPC.h.

#define ENDPOINT_BANK_SINGLE   (0 << 1)

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 LPC or the host) can access the endpoint's bank at the one time.

Definition at line 57 of file Endpoint_LPC.h.

#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.

Definition at line 71 of file Endpoint_LPC.h.

#define ENDPOINT_MAX_SIZE (   EPIndex)    512

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
EPIndexEndpoint number, a value between 0 and (ENDPOINT_TOTAL_ENDPOINTS - 1)

Definition at line 81 of file Endpoint_LPC.h.

#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 LPC models support different amounts of endpoints, this value reflects the maximum number of endpoints for the currently selected LPC model.

Definition at line 88 of file Endpoint_LPC.h.

Enumeration Type Documentation

Enum for the possible error return codes of the Endpoint_WaitUntilReady() function.

Enumerator:
ENDPOINT_READYWAIT_NoError 

Endpoint is ready for next packet, no error.

ENDPOINT_READYWAIT_EndpointStalled 

The endpoint was stalled during the stream transfer by the host or device.

ENDPOINT_READYWAIT_DeviceDisconnected 

Device was disconnected from the host while waiting for the endpoint to become ready.

ENDPOINT_READYWAIT_BusSuspended 

The USB bus has been suspended by the host and no USB endpoint traffic can occur until the bus has resumed.

ENDPOINT_READYWAIT_Timeout 

The host failed to accept or send the next packet within the software timeout period set by the USB_STREAM_TIMEOUT_MS macro.

Definition at line 98 of file Endpoint_LPC.h.

Function Documentation

static void Endpoint_Discard_16 ( void  )
inlinestatic

Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.

Returns
Nothing

Definition at line 335 of file Endpoint_LPC.h.

static void Endpoint_Discard_32 ( void  )
inlinestatic

Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.

Returns
Nothing

Definition at line 440 of file Endpoint_LPC.h.

static void Endpoint_Discard_8 ( void  )
inlinestatic

Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.

Returns
Nothing

Definition at line 240 of file Endpoint_LPC.h.

static uint8_t Endpoint_GetCurrentEndpoint ( void  )
inlinestatic

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

Definition at line 125 of file Endpoint_LPC.h.

static uint8_t Endpoint_GetEndpointDirection ( void  )
inlinestatic

Determines the currently selected endpoint's direction.

Returns
The currently selected endpoint's direction, as a ENDPOINT_DIR_* mask.

Definition at line 183 of file Endpoint_LPC.h.

void Endpoint_GetSetupPackage ( uint8_t *  pData)
static bool Endpoint_IsReadWriteAllowed ( void  )
inlinestatic

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 is an OUT direction and no packet (or an empty packet) has been received, or if the endpoint is an IN direction and the endpoint bank is full.

Returns
Boolean true if the currently selected endpoint may be read from or written to, depending on its direction.

Definition at line 203 of file Endpoint_LPC.h.

static uint16_t Endpoint_Read_16_BE ( void  )
inlinestatic

Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT direction endpoints.

Returns
Next two bytes in the currently selected endpoint's FIFO buffer.

Definition at line 279 of file Endpoint_LPC.h.

static uint16_t Endpoint_Read_16_LE ( void  )
inlinestatic

Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT direction endpoints.

Returns
Next two bytes in the currently selected endpoint's FIFO buffer.

Definition at line 257 of file Endpoint_LPC.h.

static uint32_t Endpoint_Read_32_BE ( void  )
inlinestatic

Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT direction endpoints.

Returns
Next four bytes in the currently selected endpoint's FIFO buffer.

Definition at line 378 of file Endpoint_LPC.h.

static uint32_t Endpoint_Read_32_LE ( void  )
inlinestatic

Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT direction endpoints.

Returns
Next four bytes in the currently selected endpoint's FIFO buffer.

Definition at line 354 of file Endpoint_LPC.h.

static uint8_t Endpoint_Read_8 ( void  )
inlinestatic

Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints.

Returns
Next byte in the currently selected endpoint's FIFO buffer

Definition at line 160 of file Endpoint_LPC.h.

static void Endpoint_SelectEndpoint ( const uint8_t  EndpointNumber)
inlinestatic

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
EndpointNumber: Endpoint number to select
Returns
Nothing

Definition at line 144 of file Endpoint_LPC.h.

static void Endpoint_Write_16_BE ( const uint16_t  Data)
inlinestatic

Writes two bytes to the currently selected endpoint's bank in big endian format, for IN direction endpoints.

Parameters
Data: Data to write to the currently selected endpoint's FIFO buffer
Returns
Nothing

Definition at line 320 of file Endpoint_LPC.h.

static void Endpoint_Write_16_LE ( const uint16_t  Data)
inlinestatic

Writes two bytes to the currently selected endpoint's bank in little endian format, for IN direction endpoints.

Parameters
Data: Data to write to the currently selected endpoint's FIFO buffer
Returns
Nothing

Definition at line 302 of file Endpoint_LPC.h.

static void Endpoint_Write_32_BE ( const uint32_t  Data)
inlinestatic

Writes four bytes to the currently selected endpoint's bank in big endian format, for IN direction endpoints.

Parameters
Data: Data to write to the currently selected endpoint's FIFO buffer
Returns
Nothing

Definition at line 423 of file Endpoint_LPC.h.

static void Endpoint_Write_32_LE ( const uint32_t  Data)
inlinestatic

Writes four bytes to the currently selected endpoint's bank in little endian format, for IN direction endpoints.

Parameters
Data: Data to write to the currently selected endpoint's FIFO buffer
Returns
Nothing

Definition at line 403 of file Endpoint_LPC.h.

static void Endpoint_Write_8 ( const uint8_t  Data)
inlinestatic

Writes one byte to the currently selected endpoint's bank, for IN direction endpoints.

Parameters
Data: Data to write into the the currently selected endpoint's FIFO buffer
Returns
Nothing

Definition at line 219 of file Endpoint_LPC.h.