USB Component  Version 6.4
MDK-Professional Middleware for USB Device and Host
 All Data Structures Functions Variables Enumerations Enumerator Groups Pages
Core Functions

Initialize and manage the USB Device Core. More...

Functions

usbStatus USBD_Initialize (uint8_t device)
 Initialize USB Device stack and controller.
 
usbStatus USBD_Uninitialize (uint8_t device)
 De-initialize USB Device stack and controller.
 
usbStatus USBD_Connect (uint8_t device)
 Activate pull-up on D+ or D- line to signal USB Device connection on USB Bus.
 
usbStatus USBD_Disconnect (uint8_t device)
 Disconnect USB Device from USB Bus.
 
bool USBD_Configured (uint8_t device)
 Return USB Device configuration status.
 

Description

Initialize and manage the USB Device Core.

The functions initialize and start the USB Device Core along with the related device classes. Use these functions prior to using any other class specific function. The two most important functions of the USB Device Core are:

Function Documentation

bool USBD_Configured ( uint8_t  device)

Return USB Device configuration status.

Parameters
[in]deviceindex of USB Device.
Returns
true device is in configured state and ready to communicate.
false device is not configured and not ready to communicate.

The function USBD_Configured retrieves the configuration status of the USB Device. It determines whether the USB Device has been configured and is ready to communicate.

The argument device specifies the instance of the USB Device.

usbStatus USBD_Connect ( uint8_t  device)

Activate pull-up on D+ or D- line to signal USB Device connection on USB Bus.

Parameters
[in]deviceindex of USB Device.
Returns
status code that indicates the execution status of the function as defined with usbStatus.

The function USBD_Connect connects the USB Device to the USB Bus. This typically initiates the enumeration on the USB Host side for the USB Device.

The argument device specifies the instance of the USB Device.

Code Example

#include "cmsis_os.h"
#include "rl_usb.h"
int main (void) {
...
USBD_Initialize (0); // USB Device 0 Initialization
USBD_Connect (0); // USB Device 0 Connect
while (1) { // Loop forever
...
}
}
usbStatus USBD_Disconnect ( uint8_t  device)

Disconnect USB Device from USB Bus.

Parameters
[in]deviceindex of USB Device.
Returns
status code that indicates the execution status of the function as defined with usbStatus.

The function USBD_Disconnect disconnects the USB Device from the USB Bus. After executing this function the USB Device can no longer be accessed from the USB Host.

The argument device specifies the instance of the USB Device.

usbStatus USBD_Initialize ( uint8_t  device)

Initialize USB Device stack and controller.

Parameters
[in]deviceindex of USB Device.
Returns
status code that indicates the execution status of the function as defined with usbStatus.

The function USBD_Initialize initializes the USB Device Controller Core and Hardware Driver (such as the USB clock and pins). It starts all the tasks and sets up the main USB interrupt service routine. In any application, the USBD_Initialize function must be called before invoking any other USB Device function. The function does not initialize any non-USB hardware features.

The argument device specifies the instance of the USB Device.

Code Example

#include "cmsis_os.h"
#include "rl_usb.h"
int main (void) {
...
USBD_Initialize (0); // USB Device 0 Initialization
USBD_Connect (0); // USB Device 0 Connect
while (1) { // Loop forever
...
}
}
usbStatus USBD_Uninitialize ( uint8_t  device)

De-initialize USB Device stack and controller.

Parameters
[in]deviceindex of USB Device.
Returns
status code that indicates the execution status of the function as defined with usbStatus.

De-initialize the USB Device Controller Core and Hardware Driver. Invoke this function when USB is not to be used any more.

The argument device specifies the instance of the USB Device.