Specifications

20
6263A–ATARM–10-Oct-06
Application Note
do that, an interrupt must be programmed when the status of VBus changes. The ISR should
call the USB_Attach function as follows:
void ISR_VBus()
{
USB_Attach(&sUsb);
// Acknowledge the interrupt by making a dummy write in ISR
AT91C_PIO_VBUS->PIO_ISR = 0;
}
How to register both ISRs is detailed in Section 5.4.
5.4 Callbacks
A typical application based on this USB framework needs to instantiate most of the callbacks
available. This section describes how to do that for a simple enumeration program.
5.4.1 Init
When an OS is not being used, the primary function that the Init callback must perform is inter-
rupt handler installation. The two previously defined ISRs (see Section 5.3) are thus configured
and enabled here, along the configuration of the VBus pin:
static void CBK_Init(const S_usb *pUsb)
{
// Configure and enable the USB controller interrupt
AT91F_AIC_ConfigureIt(AT91C_BASE_AIC,
USB_GetDriverID(pUsb),
AT91C_AIC_PRIOR_LOWEST,
AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL,
ISR_Driver);
AT91F_AIC_EnableIt(AT91C_BASE_AIC, USB_GetDriverID(pUsb));
// Configure VBus monitoring
BRD_ConfigureVBus(USB_GetDriverInterface(pUsb));
// Configure and enable the Vbus detection interrupt
AT91F_AIC_ConfigureIt(AT91C_BASE_AIC,
AT91C_ID_VBUS,
AT91C_AIC_PRIOR_LOWEST,
AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL,
ISR_VBus);
AT91F_PIO_InterruptEnable(AT91C_PIO_VBUS, AT91C_VBUS);
AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_VBUS);
}
If the target board uses the USB as its power supply, or no pin is connected to the VBus line,
then the Init callback should call the USB_Attach method instead of doing the second ISR
initialization.