Specifications

21
6263A–ATARM–10-Oct-06
Application Note
5.4.2 Suspend & Resume
The Suspend callback is used by the USB API to notify the device that it should enter low-power
mode if required. Since a method is provided to perform this operation in the core_device.c file,
it can be called here:
static void CBK_Suspend(const S_usb *pUsb)
{
DEV_Suspend();
}
The Resume callback has to perform the reverse operation, which can be done by calling the
DEV_Resume method.
Note that it is not necessary to disable the USB controller logic (transceiver, clocks, peripheral)
here. This is done directly by the USB_Handler function prior to triggering the callback. Typically,
the DEV_Suspend method must carry out the following operations:
Disable the PLL
Switch to the slow 32 kHz clock
Turn off the clocks of used peripherals
5.4.3 NewRequest
Since this example software should only perform the USB enumeration, the NewRequest call-
back can simply forward the call to the standard request handler method:
static void CBK_NewRequest(const S_usb *pUsb) {
STD_RequestHandler(&sClass);
}
5.5 Main
The Main function of the program is used for driver initialization (Class and USB), software con-
nection of the device (by using USB_Connect), and implementation of the product functionality.
In this case, the Main performs the first two steps. After that, since the enumeration is done
through the event handler and the device does not do anything, it can simply enter an infinite
loop:
int main()
{
// Initialize the USB driver
USB_Init(&sUsb);
// Try to connect the device
USB_Connect(&sUsb);
// Main loop
while (1) {
// Put USB class driver implementation here
}
}