EFM32 Pearl Gecko 12 Software Documentation  efm32pg12-doc-5.1.2
Functions

Detailed Description

Functions

void USBX_apiCallbackDisable (void)
 Inhibits user API call-backs and does NOT disable the USB interrupt.
 
void USBX_apiCallbackEnable (USBX_apiCallback_t f)
 Enables user API call-backs. More...
 
int USBX_blockRead (uint8_t *block, uint32_t numBytes, uint32_t *countPtr)
 User API function to get data from host. More...
 
int USBX_blockWrite (uint8_t *block, uint32_t numBytes, uint32_t *countPtr)
 User API function to send data to host. More...
 
void USBX_disable (void)
 Disables the USB interface.
 
uint32_t USBX_getCallbackSource (void)
 User API function to get the call-back source. More...
 
uint_least16_t USBX_getLibraryVersion (void)
 Returns the USBXpress library version. More...
 
void USBX_init (USBX_Init_t *p)
 User API USB initialization function. More...
 

Function Documentation

void USBX_apiCallbackEnable ( USBX_apiCallback_t  f)

Enables user API call-backs.

Parameters
fPointer to user-defined call-back function.

Enables USB interrupts and sets the API call-back function pointer to the passed function.

Definition at line 164 of file em_usbxpress.c.

References APIEA_GIE.

int USBX_blockRead ( uint8_t *  block,
uint32_t  numBytes,
uint32_t *  countPtr 
)

User API function to get data from host.

Parameters
blockPointer to user's array where received data will be stored.
numBytesNumber of bytes to receive from host
[out]countPtrPointer to user's storage for number of bytes actually received from the host. This will be valid upon the subsequent USBX_RX_COMPLETE call-back.
Returns
This function returns a status word. 0 indicates that the read was successfully started. Any other value indicates that the request was ignored. The most common reason is USBX_STATUS_EP_BUSY meaning that a read is already in progress.

Valid return codes are fond in USB Status Flags

A USBX_RX_COMPLETE call-back will occur when the read transfer has completed. For example if the user reads a block of 100 bytes, two packets will be received (one 64 byte packet and one 36 byte packet), but the USBX_RX_COMPLETE call-back will only occur after the final packet has been received.

If the device receives more data than the value specified by numBytes, the USBX_RX_COMPLETE call-back will occur when numBytes number of bytes has been received. At this point, the USBX_RX_OVERRUN status flag will also be set, indicating that more data was received than is available to write to the buffer at block. At this point, the application may call USBX_blockRead() again to receive the remaining data from the transfer.

This function utilizes the EFM32 USB Library's USBD_Read() function, which only prepares for a read. The actual read will occur over time as the host transmits data.

Definition at line 172 of file em_usbxpress.c.

References USBX_outXferCompleteCb(), USBXCORE_rxOverflowPacketAvailable, and USBXCORE_rxOverflowPacketSize.

int USBX_blockWrite ( uint8_t *  block,
uint32_t  numBytes,
uint32_t *  countPtr 
)

User API function to send data to host.

Parameters
blockPointer to user's array where data to be transmitted is stored.
numBytesNumber of bytes to send to host
[out]countPtrPointer to user's storage for number of bytes actually transmitted to the host. This will be valid upon the subsequent USBX_TX_COMPLETE call-back.
Returns
This function returns a status word. 0 indicates that the write was successfully started. Any other value indicates that the request was ignored. The most common reason is USBX_STATUS_EP_BUSY meaning that a write is already in progress.

Valid return codes are fond in USB Status Flags

A USBX_TX_COMPLETE call-back will occur when the entire transfer has completed. For example if the user writes a block of 100 bytes, two packets will be sent (one 64 byte packet and one 36 byte packet), but the USBX_TX_COMPLETE call-back will only occur after the final packet has been sent.

This function utilizes the EFM32 USB Library's USBD_Write() function, which only prepares for a write. The actual write will occur over time as the host transmits data.

Definition at line 226 of file em_usbxpress.c.

References USBX_inXferCompleteCb().

uint32_t USBX_getCallbackSource ( void  )

User API function to get the call-back source.

Returns an 32-bit value indicating the reason(s) for the API call-back, and clears the USBXpress API call-back pending flag(s). This function should be called at the beginning of the user's call-back service routine to determine which event(s) has/have occurred.

Returns
An unsigned 32-bit code indicating the reason(s) for the API interrupt. The code can indicate more than one type of interrupt at the same time. Valid flags are found in USB Status Flags

Definition at line 239 of file em_usbxpress.c.

References USBXCORE_apiIntValue.

uint_least16_t USBX_getLibraryVersion ( void  )

Returns the USBXpress library version.

Returns
Library version

Library version is returned in binary-coded decimal format.

Definition at line 252 of file em_usbxpress.c.

References USBXPRESS_LIBRARY_VERSION.

void USBX_init ( USBX_Init_t p)

User API USB initialization function.

Parameters
pPointer to USBX_Init_t structure. Not modified by this routine.

To minimize user XRAM use, the user should pass initialization parameters from code memory to the USBX_init() function.

Parameters
pPointer to USBX_Init_t structure. Not modified by this routine.

The use of this initialization function is similar to that of the USBD_Init() function in the EFM32 USB Library. The primary differences are:

  • Parameters are placed in USBX_Init_t structure for code organization.

Definition at line 87 of file em_usbxpress.c.

References USBX_DeviceStateChangeCb(), USBX_ResetCb(), USBX_SetupCmdCb(), USBXCORE_buffMult, USBXCORE_configDesc, USBXCORE_configDescInit, USBXCORE_stringDescTable, and USBXCORE_stringLangDesc.