]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_A5_SAMA5D4x_EK_IAR/CDCCommandConsole.c
Core kernel code:
[freertos] / FreeRTOS / Demo / CORTEX_A5_SAMA5D4x_EK_IAR / CDCCommandConsole.c
index 83f0a908f9b5b506d6bde9d70eeb2cc32ac11c44..753636c7dc3a67e5ac55d0a21e07dccfb3b45621 100644 (file)
@@ -113,7 +113,7 @@ static void prvCDCInit( void );
  * 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
@@ -387,14 +387,12 @@ const TickType_t xTransferCompleteDelay = pdMS_TO_TICKS( 750UL );
 }\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
@@ -454,16 +452,29 @@ BaseType_t xHigherPriorityTaskWoken = pdFALSE;
 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
@@ -479,8 +490,7 @@ void USBDCallbacks_Initialized( void )
        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