[an error occurred while processing this directive]
|
void vUSB_Init( void )
{// Initialise a few state variables.
pxCharsForTx.ulNextCharIndex = 0;
ucUSBConfig = 0;
eDriverState = eNOTHING;// HARDWARE SETUP
// Set the PLL USB Divider
AT91C_BASE_CKGR->CKGR_PLLR |= AT91C_CKGR_USBDIV_1;// Enables the 48MHz USB clock UDPCK and System Peripheral USB Clock.
AT91C_BASE_PMC->PMC_SCER = AT91C_PMC_UDP;
AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_UDP);
// When using the USB debugger the peripheral registers do not always get
// set to the correct default values. To make sure set the relevant registers
// manually here.
AT91C_BASE_UDP->UDP_IDR = (unsigned long)0xffffffff;
AT91C_BASE_UDP->UDP_ICR = (unsigned long)0xffffffff;
AT91C_BASE_UDP->UDP_CSR[ 0 ] = (unsigned long )0x00;
AT91C_BASE_UDP->UDP_CSR[ 1 ] = (unsigned long )0x00;
AT91C_BASE_UDP->UDP_GLBSTATE = 0;
AT91C_BASE_UDP->UDP_FADDR = 0;// Enable the transceiver.
AT91C_BASE_UDP->UDP_TXVC = 0;// Enable the USB interrupts - other interrupts get enabled as the
// enumeration process progresses.
AT91F_AIC_Init( AT91C_BASE_AIC, AT91C_ID_UDP, usbINTERRUPT_PRIORITY, AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE, USB_c_irq_handler );// Enable Interrupt
AT91C_BASE_AIC->AIC_IECR = 1 << AT91C_ID_UDP;
AT91C_BASE_AIC->AIC_EOICR = 0xffffffff; // эта строка только для корректной работы с J-link !!!
}
E-mail: info@telesys.ru