* Handler installed on the VBUS pin to detect connect() and disconnect()\r
* events.\r
*/\r
-static void prvVBusISRHandler( const Pin *pxPin );\r
+static void prvVBusISRHandler( void );\r
\r
/*\r
* USB handler defined by the driver, installed after the CDC driver has been\r
}\r
/*-----------------------------------------------------------*/\r
\r
-static void prvVBusISRHandler( const Pin *pxPin )\r
+static void prvVBusISRHandler( void )\r
{\r
- /* NOTE: As this was written for the XPlained board, which is powered\r
- through the USB and cannot be on without the USB connected, this function\r
- has not been exercised. */\r
+const Pin xVBusPin = PIN_USB_VBUS;\r
\r
/* Check current level on VBus to detect a connect/disconnect. */\r
- if( PIO_Get( pxPin ) != 0 )\r
+ if( PIO_Get( &xVBusPin ) != 0 )\r
{\r
USBD_Connect();\r
}\r
static void prvConfigureVBus( void )\r
{\r
const Pin xVBusPin = PIN_USB_VBUS;\r
+const uint32_t ulPriority = 7; /* Highest. */\r
\r
/* Configure PIO to generate an interrupt on status change. */\r
- PIO_Configure( &xVBusPin, 1 );\r
- PIO_ConfigureIt( &xVBusPin, prvVBusISRHandler );\r
+ PIO_Configure( &xVBusPin, 1 );\r
+ PIO_ConfigureIt( &xVBusPin );\r
+\r
+ /* Ensure interrupt is disabled before setting the mode and installing the\r
+ handler. The priority of the tick interrupt should always be set to the\r
+ lowest possible. */\r
+ AIC->AIC_SSR = ID_PIOE;\r
+ AIC->AIC_IDCR = AIC_IDCR_INTD;\r
+ AIC->AIC_SMR = AIC_SMR_SRCTYPE_EXT_POSITIVE_EDGE | ulPriority;\r
+ AIC->AIC_SVR = ( uint32_t ) prvVBusISRHandler;\r
+\r
+ /* Start with the interrupt clear. */\r
+ AIC->AIC_ICCR = AIC_ICCR_INTCLR;\r
PIO_EnableIt( &xVBusPin );\r
+ AIC_EnableIT( ID_PIOE );\r
\r
/* Check current level on VBus */\r
if( PIO_Get( &xVBusPin ) != pdFALSE )\r
{\r
- /* if VBUS present, force the connect */\r
+ /* If VBUS present, force the connect */\r
USBD_Connect();\r
}\r
else\r
the USB driver has been initialised. By default, configures the UDP/UDPHS\r
interrupt. The interrupt priority is set to the highest to ensure the\r
interrupt nesting tests interfer as little as possible with the USB. */\r
- IRQ_ConfigureIT( ID_UDPHS, 7, USBD_IrqHandler );\r
- IRQ_EnableIT( ID_UDPHS );\r
+ AIC_EnableIT( ID_UDPHS );\r
}\r
/*-----------------------------------------------------------*/\r
\r