]> git.sur5r.net Git - freertos/blobdiff - Demo/ARM7_AT91SAM7S64_IAR/USB/USBSample.c
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / ARM7_AT91SAM7S64_IAR / USB / USBSample.c
index cb098fa4d3333102c2527d519179aa823615bbd6..ab575203590227d387c2f2a7f31749e69174b05c 100644 (file)
@@ -1,52 +1,67 @@
 /*\r
-       FreeRTOS.org V5.3.1 - Copyright (C) 2003-2009 Richard Barry.\r
-\r
-       This file is part of the FreeRTOS.org distribution.\r
-\r
-       FreeRTOS.org is free software; you can redistribute it and/or modify it\r
-       under the terms of the GNU General Public License (version 2) as published\r
-       by the Free Software Foundation and modified by the FreeRTOS exception.\r
-       **NOTE** The exception to the GPL is included to allow you to distribute a\r
-       combined work that includes FreeRTOS.org without being obliged to provide\r
-       the source code for any proprietary components.  Alternative commercial\r
-       license and support terms are also available upon request.  See the \r
-       licensing section of http://www.FreeRTOS.org for full details.\r
-\r
-       FreeRTOS.org is distributed in the hope that it will be useful, but WITHOUT\r
-       ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
-       FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
-       more details.\r
-\r
-       You should have received a copy of the GNU General Public License along\r
-       with FreeRTOS.org; if not, write to the Free Software Foundation, Inc., 59\r
-       Temple Place, Suite 330, Boston, MA  02111-1307  USA.\r
-\r
-\r
-       ***************************************************************************\r
-       *                                                                         *\r
-       * Get the FreeRTOS eBook!  See http://www.FreeRTOS.org/Documentation      *\r
-       *                                                                         *\r
-       * This is a concise, step by step, 'hands on' guide that describes both   *\r
-       * general multitasking concepts and FreeRTOS specifics. It presents and   *\r
-       * explains numerous examples that are written using the FreeRTOS API.     *\r
-       * Full source code for all the examples is provided in an accompanying    *\r
-       * .zip file.                                                              *\r
-       *                                                                         *\r
-       ***************************************************************************\r
-\r
-       1 tab == 4 spaces!\r
-\r
-       Please ensure to read the configuration and relevant port sections of the\r
-       online documentation.\r
-\r
-       http://www.FreeRTOS.org - Documentation, latest information, license and\r
-       contact details.\r
-\r
-       http://www.SafeRTOS.com - A version that is certified for use in safety\r
-       critical systems.\r
-\r
-       http://www.OpenRTOS.com - Commercial support, development, porting,\r
-       licensing and training services.\r
+    FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.\r
+       \r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
+     *    Complete, revised, and edited pdf reference manuals are also       *\r
+     *    available.                                                         *\r
+     *                                                                       *\r
+     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
+     *    ensuring you get running as quickly as possible and with an        *\r
+     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
+     *    the FreeRTOS project to continue with its mission of providing     *\r
+     *    professional grade, cross platform, de facto standard solutions    *\r
+     *    for microcontrollers - completely free of charge!                  *\r
+     *                                                                       *\r
+     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
+     *                                                                       *\r
+     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
+    >>>NOTE<<< The modification to the GPL is included to allow you to\r
+    distribute a combined work that includes FreeRTOS without being obliged to\r
+    provide the source code for proprietary components outside of the FreeRTOS\r
+    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
+    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
+    more details. You should have received a copy of the GNU General Public\r
+    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
+    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
+    by writing to Richard Barry, contact details for whom are available on the\r
+    FreeRTOS WEB site.\r
+\r
+    1 tab == 4 spaces!\r
+    \r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    Having a problem?  Start by reading the FAQ "My application does   *\r
+     *    not run, what could be wrong?                                      *\r
+     *                                                                       *\r
+     *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    \r
+    http://www.FreeRTOS.org - Documentation, training, latest information, \r
+    license and contact details.\r
+    \r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool.\r
+\r
+    Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
+    the code with commercial support, indemnification, and middleware, under \r
+    the OpenRTOS brand: http://www.OpenRTOS.com.  High Integrity Systems also\r
+    provide a safety engineered and independently SIL3 certified version under \r
+    the SafeRTOS brand: http://www.SafeRTOS.com.\r
 */\r
 \r
 /*\r
@@ -143,7 +158,7 @@ little odd. */
 /* Misc application definitions. */\r
 #define usbINTERRUPT_PRIORITY                          ( 3 )\r
 #define usbQUEUE_LENGTH                                                ( 0x3 ) /* Must have all bits set! */\r
-#define usbFIFO_LENGTH                                         ( ( unsigned portLONG ) 8 )\r
+#define usbFIFO_LENGTH                                         ( ( unsigned long ) 8 )\r
 #define usbEND_POINT_0                                         ( 0 )\r
 #define usbEND_POINT_1                                         ( 1 )\r
 #define usbXUP                                                         ( 1 )\r
@@ -152,14 +167,14 @@ little odd. */
 #define usbYDOWN                                                       ( 4 )\r
 #define usbMAX_COORD                                           ( 120 )\r
 #define usbMAX_TX_MESSAGE_SIZE                         ( 128 )\r
-#define usbRX_COUNT_MASK                                       ( ( unsigned portLONG ) 0x7ff )\r
+#define usbRX_COUNT_MASK                                       ( ( unsigned long ) 0x7ff )\r
 #define AT91C_UDP_STALLSENT                                    AT91C_UDP_ISOERROR\r
 #define usbSHORTEST_DELAY                                      ( ( portTickType ) 1 )\r
 #define usbINIT_DELAY                                          ( ( portTickType ) 500 / portTICK_RATE_MS )\r
 #define usbSHORT_DELAY                                         ( ( portTickType ) 50 / portTICK_RATE_MS )\r
-#define usbEND_POINT_RESET_MASK                                ( ( unsigned portLONG ) 0x0f )\r
-#define usbDATA_INC                                                    ( ( portCHAR ) 5 )\r
-#define usbEXPECTED_NUMBER_OF_BYTES                    ( ( unsigned portLONG ) 8 )\r
+#define usbEND_POINT_RESET_MASK                                ( ( unsigned long ) 0x0f )\r
+#define usbDATA_INC                                                    ( ( char ) 5 )\r
+#define usbEXPECTED_NUMBER_OF_BYTES                    ( ( unsigned long ) 8 )\r
 \r
 /* Control request types. */\r
 #define usbSTANDARD_DEVICE_REQUEST                     ( 0 )\r
@@ -172,19 +187,19 @@ little odd. */
 /* Structure used to take a snapshot of the USB status from within the ISR. */\r
 typedef struct X_ISR_STATUS\r
 {\r
-       unsigned portLONG ulISR;\r
-       unsigned portLONG ulCSR0;\r
-       unsigned portCHAR ucFifoData[ 8 ];\r
+       unsigned long ulISR;\r
+       unsigned long ulCSR0;\r
+       unsigned char ucFifoData[ 8 ];\r
 } xISRStatus;\r
 \r
 /* Structure used to hold the received requests. */\r
 typedef struct\r
 {\r
-       unsigned portCHAR ucReqType;\r
-       unsigned portCHAR ucRequest;\r
-       unsigned portSHORT usValue;\r
-       unsigned portSHORT usIndex;\r
-       unsigned portSHORT usLength;\r
+       unsigned char ucReqType;\r
+       unsigned char ucRequest;\r
+       unsigned short usValue;\r
+       unsigned short usIndex;\r
+       unsigned short usLength;\r
 } xUSB_REQUEST;\r
 \r
 typedef enum\r
@@ -200,9 +215,9 @@ typedef enum
 /* Structure used to control the data being sent to the host. */\r
 typedef struct\r
 {\r
-       unsigned portCHAR ucTxBuffer[ usbMAX_TX_MESSAGE_SIZE ];\r
-       unsigned portLONG ulNextCharIndex;\r
-       unsigned portLONG ulTotalDataLength;\r
+       unsigned char ucTxBuffer[ usbMAX_TX_MESSAGE_SIZE ];\r
+       unsigned long ulNextCharIndex;\r
+       unsigned long ulTotalDataLength;\r
 } xTX_MESSAGE;\r
 \r
 /*-----------------------------------------------------------*/\r
@@ -275,7 +290,7 @@ static void prvHandleClassInterfaceRequest( xUSB_REQUEST *pxRequest );
  * in response to TXCOMP interrupts until the entire buffer has been\r
  * sent.\r
  */\r
-static void prvSendControlData( unsigned portCHAR *pucData, unsigned portSHORT usRequestedLength, unsigned portLONG ulLengthLeftToSend, portLONG lSendingDescriptor );\r
+static void prvSendControlData( unsigned char *pucData, unsigned short usRequestedLength, unsigned long ulLengthLeftToSend, long lSendingDescriptor );\r
 \r
 /*\r
  * Examine the Tx buffer to see if there is any more data to be transmitted.\r
@@ -338,14 +353,14 @@ These take the form:
        Data\r
 }\r
 */\r
-const portCHAR pxLanguageStringDescriptor[] =\r
+const char pxLanguageStringDescriptor[] =\r
 {\r
        4,\r
        usbDESCRIPTOR_TYPE_STRING,\r
        0x09, 0x04\r
 };\r
 \r
-const portCHAR pxManufacturerStringDescriptor[] =\r
+const char pxManufacturerStringDescriptor[] =\r
 {\r
        18,\r
        usbDESCRIPTOR_TYPE_STRING,\r
@@ -360,7 +375,7 @@ const portCHAR pxManufacturerStringDescriptor[] =
        'S', 0x00       \r
 };\r
 \r
-const portCHAR pxProductStringDescriptor[] =\r
+const char pxProductStringDescriptor[] =\r
 {\r
        44,\r
        usbDESCRIPTOR_TYPE_STRING,\r
@@ -388,7 +403,7 @@ const portCHAR pxProductStringDescriptor[] =
        'k', 0x00\r
 };\r
 \r
-const portCHAR pxConfigurationStringDescriptor[] =\r
+const char pxConfigurationStringDescriptor[] =\r
 {\r
        38,\r
        usbDESCRIPTOR_TYPE_STRING,\r
@@ -413,7 +428,7 @@ const portCHAR pxConfigurationStringDescriptor[] =
        'e', 0x00\r
 };\r
 \r
-const portCHAR pxInterfaceStringDescriptor[] =\r
+const char pxInterfaceStringDescriptor[] =\r
 {\r
        30,\r
        usbDESCRIPTOR_TYPE_STRING,\r
@@ -435,7 +450,7 @@ const portCHAR pxInterfaceStringDescriptor[] =
 };\r
 \r
 /* Enumeration descriptors. */\r
-const portCHAR pxReportDescriptor[] =\r
+const char pxReportDescriptor[] =\r
 {\r
         0x05,  0x01,   /* USAGE_PAGE (Generic Desktop)         */\r
         0x09,  0x04,   /* USAGE (Joystick)                                     */\r
@@ -517,8 +532,8 @@ const char pxConfigDescriptor[] = {
 /*-----------------------------------------------------------*/\r
 \r
 /* File scope state variables. */\r
-static unsigned portCHAR ucUSBConfig = ( unsigned portCHAR ) 0;\r
-static unsigned portLONG ulReceivedAddress = ( unsigned portLONG ) 0;\r
+static unsigned char ucUSBConfig = ( unsigned char ) 0;\r
+static unsigned long ulReceivedAddress = ( unsigned long ) 0;\r
 static eDRIVER_STATE eDriverState = eNOTHING;\r
 \r
 /* Array in which the USB interrupt status is passed between the ISR and task. */\r
@@ -549,14 +564,14 @@ unchanged by writing with a 1. */
        /* Set TXCOMP, RX_DATA_BK0, RXSETUP, */                                                                                         \\r
        /* STALLSENT and RX_DATA_BK1 to 1 so the */                                                                                     \\r
        /* write has no effect. */                                                                                                                      \\r
-       ( * ( ( unsigned portLONG * ) pulValueNow ) ) |= ( unsigned portLONG ) 0x4f;            \\r
+       ( * ( ( unsigned long * ) pulValueNow ) ) |= ( unsigned long ) 0x4f;            \\r
                                                                                                                                                                                \\r
        /* Clear the FORCE_STALL and TXPKTRDY bits */                                                                           \\r
        /* so the write has no effect. */                                                                                                       \\r
-       ( * ( ( unsigned portLONG * ) pulValueNow ) ) &= ( unsigned portLONG ) 0xffffffcf;      \\r
+       ( * ( ( unsigned long * ) pulValueNow ) ) &= ( unsigned long ) 0xffffffcf;      \\r
                                                                                                                                                                                \\r
        /* Set whichever bit we want set. */                                                                                            \\r
-       ( * ( ( unsigned portLONG * ) pulValueNow ) ) |= ( ulBit );                                                     \\r
+       ( * ( ( unsigned long * ) pulValueNow ) ) |= ( ulBit );                                                 \\r
 }\r
 \r
 #define usbCSR_CLEAR_BIT( pulValueNow, ulBit )                                                                                 \\r
@@ -564,14 +579,14 @@ unchanged by writing with a 1. */
        /* Set TXCOMP, RX_DATA_BK0, RXSETUP, */                                                                                         \\r
        /* STALLSENT and RX_DATA_BK1 to 1 so the */                                                                                     \\r
        /* write has no effect. */                                                                                                                      \\r
-       ( * ( ( unsigned portLONG * ) pulValueNow ) ) |= ( unsigned portLONG ) 0x4f;            \\r
+       ( * ( ( unsigned long * ) pulValueNow ) ) |= ( unsigned long ) 0x4f;            \\r
                                                                                                                                                                                \\r
        /* Clear the FORCE_STALL and TXPKTRDY bits */                                                                           \\r
        /* so the write has no effect. */                                                                                                       \\r
-       ( * ( ( unsigned portLONG * ) pulValueNow ) ) &= ( unsigned portLONG ) 0xffffffcf;      \\r
+       ( * ( ( unsigned long * ) pulValueNow ) ) &= ( unsigned long ) 0xffffffcf;      \\r
                                                                                                                                                                                \\r
        /* Clear whichever bit we want clear. */                                                                                        \\r
-       ( * ( ( unsigned portLONG * ) pulValueNow ) ) &= ( ~ulBit );                                            \\r
+       ( * ( ( unsigned long * ) pulValueNow ) ) &= ( ~ulBit );                                                \\r
 }\r
 \r
 /*-----------------------------------------------------------*/\r
@@ -579,9 +594,9 @@ unchanged by writing with a 1. */
 __arm void vUSB_ISR( void )\r
 {\r
 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
-static volatile unsigned portLONG ulNextMessage = 0;\r
+static volatile unsigned long ulNextMessage = 0;\r
 xISRStatus *pxMessage;\r
-unsigned portLONG ulTemp, ulRxBytes;\r
+unsigned long ulTemp, ulRxBytes;\r
 \r
        /* Take the next message from the queue.  Note that usbQUEUE_LENGTH *must*\r
        be all 1's, as in 0x01, 0x03, 0x07, etc. */\r
@@ -695,11 +710,11 @@ xISRStatus *pxMessage;
 \r
 static void prvTransmitSampleValues( void )\r
 {\r
-unsigned portLONG ulStatus;\r
-static portLONG lState = usbXUP;\r
+unsigned long ulStatus;\r
+static long lState = usbXUP;\r
 \r
 /* Variables to hold dummy x, y and z joystick axis data. */\r
-static signed portCHAR x = 0, y = 0, z = 0;\r
+static signed char x = 0, y = 0, z = 0;\r
 \r
        /* Generate some sample data in the x and y axis - draw a square. */\r
        switch( lState )\r
@@ -758,7 +773,7 @@ static signed portCHAR x = 0, y = 0, z = 0;
 \r
 static void prvUSBTransmitNull( void )\r
 {\r
-unsigned portLONG ulStatus;\r
+unsigned long ulStatus;\r
 \r
        /* Wait until the FIFO is free - even though we are not going to use it.\r
        THERE IS NO TIMEOUT HERE! */\r
@@ -785,7 +800,7 @@ unsigned portLONG ulStatus;
 \r
 static void prvSendStall( void )\r
 {\r
-unsigned portLONG ulStatus;\r
+unsigned long ulStatus;\r
 \r
        portENTER_CRITICAL();\r
        {\r
@@ -800,13 +815,13 @@ unsigned portLONG ulStatus;
 \r
 static void prvResetEndPoints( void )\r
 {\r
-unsigned portLONG ulTemp;\r
+unsigned long ulTemp;\r
 \r
        eDriverState = eJUST_RESET;\r
 \r
        /* Reset all the end points. */\r
        AT91C_BASE_UDP->UDP_RSTEP  = usbEND_POINT_RESET_MASK;\r
-       AT91C_BASE_UDP->UDP_RSTEP  = ( unsigned portLONG ) 0x00;\r
+       AT91C_BASE_UDP->UDP_RSTEP  = ( unsigned long ) 0x00;\r
 \r
        /* Enable data to be sent and received. */\r
        AT91C_BASE_UDP->UDP_FADDR = AT91C_UDP_FEN;\r
@@ -815,7 +830,7 @@ unsigned portLONG ulTemp;
        portENTER_CRITICAL();\r
        {\r
                ulTemp = AT91C_BASE_UDP->UDP_CSR[ usbEND_POINT_0 ];\r
-               usbCSR_SET_BIT( &ulTemp, ( ( unsigned portLONG ) ( AT91C_UDP_EPEDS | AT91C_UDP_EPTYPE_CTRL ) ) );\r
+               usbCSR_SET_BIT( &ulTemp, ( ( unsigned long ) ( AT91C_UDP_EPEDS | AT91C_UDP_EPTYPE_CTRL ) ) );\r
                AT91C_BASE_UDP->UDP_CSR[ usbEND_POINT_0 ] = ulTemp;\r
                AT91F_UDP_EnableIt( AT91C_BASE_UDP, AT91C_UDP_EPINT0 );\r
        }\r
@@ -847,7 +862,7 @@ static void prvProcessEndPoint0Interrupt( xISRStatus *pxMessage )
                        /* Read the end point for data transfer. */\r
                        portENTER_CRITICAL();\r
                        {\r
-                               unsigned portLONG ulTemp;\r
+                               unsigned long ulTemp;\r
 \r
                                ulTemp = AT91C_BASE_UDP->UDP_CSR[ usbEND_POINT_1 ];                                     \r
                                usbCSR_SET_BIT( &ulTemp, AT91C_UDP_EPEDS | AT91C_UDP_EPTYPE_INT_IN );\r
@@ -862,7 +877,7 @@ static void prvProcessEndPoint0Interrupt( xISRStatus *pxMessage )
                {\r
                        /* We sent an acknowledgement of a SET_ADDRESS request.  Move\r
                        to the addressed state. */\r
-                       if( ulReceivedAddress != ( unsigned portLONG ) 0 )\r
+                       if( ulReceivedAddress != ( unsigned long ) 0 )\r
                        {                       \r
                                AT91C_BASE_UDP->UDP_GLBSTATE = AT91C_UDP_FADDEN;\r
                        }\r
@@ -885,8 +900,8 @@ static void prvProcessEndPoint0Interrupt( xISRStatus *pxMessage )
        if( pxMessage->ulCSR0 & AT91C_UDP_RXSETUP )\r
        {\r
                xUSB_REQUEST xRequest;\r
-               unsigned portCHAR ucRequest;\r
-               unsigned portLONG ulRxBytes;\r
+               unsigned char ucRequest;\r
+               unsigned long ulRxBytes;\r
 \r
                /* A data packet is available. */       \r
                ulRxBytes = pxMessage->ulCSR0 >> 16;\r
@@ -956,11 +971,11 @@ static void prvGetStandardDeviceDescriptor( xUSB_REQUEST *pxRequest )
        switch( ( pxRequest->usValue & 0xff00 ) >> 8 )\r
        {\r
            case usbDESCRIPTOR_TYPE_DEVICE:\r
-                       prvSendControlData( ( unsigned portCHAR * ) &pxDeviceDescriptor, pxRequest->usLength, sizeof( pxDeviceDescriptor ), pdTRUE );\r
+                       prvSendControlData( ( unsigned char * ) &pxDeviceDescriptor, pxRequest->usLength, sizeof( pxDeviceDescriptor ), pdTRUE );\r
                    break;\r
        \r
            case usbDESCRIPTOR_TYPE_CONFIGURATION:\r
-                       prvSendControlData( ( unsigned portCHAR * ) &( pxConfigDescriptor ), pxRequest->usLength, sizeof( pxConfigDescriptor ), pdTRUE );\r
+                       prvSendControlData( ( unsigned char * ) &( pxConfigDescriptor ), pxRequest->usLength, sizeof( pxConfigDescriptor ), pdTRUE );\r
                    break;\r
 \r
            case usbDESCRIPTOR_TYPE_STRING:\r
@@ -969,23 +984,23 @@ static void prvGetStandardDeviceDescriptor( xUSB_REQUEST *pxRequest )
                    switch( pxRequest->usValue & 0xff )\r
                        {                       \r
                        case usbLANGUAGE_STRING:\r
-                                       prvSendControlData( ( unsigned portCHAR * ) &pxLanguageStringDescriptor, pxRequest->usLength, sizeof(pxLanguageStringDescriptor), pdTRUE );\r
+                                       prvSendControlData( ( unsigned char * ) &pxLanguageStringDescriptor, pxRequest->usLength, sizeof(pxLanguageStringDescriptor), pdTRUE );\r
                                break;\r
 \r
                        case usbMANUFACTURER_STRING:\r
-                                       prvSendControlData( ( unsigned portCHAR * ) &pxManufacturerStringDescriptor, pxRequest->usLength, sizeof( pxManufacturerStringDescriptor ), pdTRUE );\r
+                                       prvSendControlData( ( unsigned char * ) &pxManufacturerStringDescriptor, pxRequest->usLength, sizeof( pxManufacturerStringDescriptor ), pdTRUE );\r
                                break;\r
 \r
                        case usbPRODUCT_STRING:\r
-                                       prvSendControlData( ( unsigned portCHAR * ) &pxProductStringDescriptor, pxRequest->usLength, sizeof( pxProductStringDescriptor ), pdTRUE );\r
+                                       prvSendControlData( ( unsigned char * ) &pxProductStringDescriptor, pxRequest->usLength, sizeof( pxProductStringDescriptor ), pdTRUE );\r
                                break;\r
 \r
                        case usbCONFIGURATION_STRING:\r
-                                       prvSendControlData( ( unsigned portCHAR * ) &pxConfigurationStringDescriptor, pxRequest->usLength, sizeof( pxConfigurationStringDescriptor ), pdTRUE );\r
+                                       prvSendControlData( ( unsigned char * ) &pxConfigurationStringDescriptor, pxRequest->usLength, sizeof( pxConfigurationStringDescriptor ), pdTRUE );\r
                                break;\r
 \r
                        case usbINTERFACE_STRING:\r
-                                       prvSendControlData( ( unsigned portCHAR * ) &pxInterfaceStringDescriptor, pxRequest->usLength, sizeof( pxInterfaceStringDescriptor ), pdTRUE );\r
+                                       prvSendControlData( ( unsigned char * ) &pxInterfaceStringDescriptor, pxRequest->usLength, sizeof( pxInterfaceStringDescriptor ), pdTRUE );\r
                                break;\r
 \r
                        default:\r
@@ -1006,13 +1021,13 @@ static void prvGetStandardDeviceDescriptor( xUSB_REQUEST *pxRequest )
 \r
 static void prvHandleStandardDeviceRequest( xUSB_REQUEST *pxRequest )\r
 {\r
-unsigned portSHORT usStatus = 0;\r
+unsigned short usStatus = 0;\r
 \r
        switch( pxRequest->ucRequest )\r
        {\r
            case usbGET_STATUS_REQUEST:\r
                        /* Just send two byte dummy status. */\r
-                       prvSendControlData( ( unsigned portCHAR * ) &usStatus, sizeof( usStatus ), sizeof( usStatus ), pdFALSE );\r
+                       prvSendControlData( ( unsigned char * ) &usStatus, sizeof( usStatus ), sizeof( usStatus ), pdFALSE );\r
                    break;\r
 \r
            case usbGET_DESCRIPTOR_REQUEST:\r
@@ -1022,7 +1037,7 @@ unsigned portSHORT usStatus = 0;
 \r
            case usbGET_CONFIGURATION_REQUEST:\r
                        /* Send selected device configuration */\r
-                       prvSendControlData( ( unsigned portCHAR * ) &ucUSBConfig, sizeof( ucUSBConfig ), sizeof( ucUSBConfig ), pdFALSE );\r
+                       prvSendControlData( ( unsigned char * ) &ucUSBConfig, sizeof( ucUSBConfig ), sizeof( ucUSBConfig ), pdFALSE );\r
                    break;\r
 \r
                case usbSET_FEATURE_REQUEST:\r
@@ -1037,7 +1052,7 @@ unsigned portSHORT usStatus = 0;
                        address and set our state so we know we have received the address. */\r
                prvUSBTransmitNull();                   \r
                        eDriverState = eJUST_GOT_ADDRESS;               \r
-                       ulReceivedAddress = ( unsigned portLONG ) pxRequest->usValue;\r
+                       ulReceivedAddress = ( unsigned long ) pxRequest->usValue;\r
                    break;\r
 \r
            case usbSET_CONFIGURATION_REQUEST:\r
@@ -1046,7 +1061,7 @@ unsigned portSHORT usStatus = 0;
                        we cannot actually move to the configured state until we get a\r
                        TXCOMP interrupt from this NULL packet.  Therefore we just remember the\r
                        config and set our state so we know we have received the go ahead. */                   \r
-                       ucUSBConfig = ( unsigned portCHAR ) ( pxRequest->usValue & 0xff );\r
+                       ucUSBConfig = ( unsigned char ) ( pxRequest->usValue & 0xff );\r
                        eDriverState = eJUST_GOT_CONFIG;\r
                        prvUSBTransmitNull();\r
                    break;\r
@@ -1084,10 +1099,10 @@ static void prvHandleClassInterfaceRequest( xUSB_REQUEST *pxRequest )
 \r
 static void prvGetStandardInterfaceDescriptor( xUSB_REQUEST *pxRequest )\r
 {\r
-       switch( ( pxRequest->usValue & ( unsigned portSHORT ) 0xff00 ) >> 8 )\r
+       switch( ( pxRequest->usValue & ( unsigned short ) 0xff00 ) >> 8 )\r
        {\r
            case usbHID_REPORT_DESCRIPTOR:\r
-                       prvSendControlData( ( unsigned portCHAR * ) pxReportDescriptor, pxRequest->usLength, sizeof( pxReportDescriptor ), pdTRUE );\r
+                       prvSendControlData( ( unsigned char * ) pxReportDescriptor, pxRequest->usLength, sizeof( pxReportDescriptor ), pdTRUE );\r
                    break;\r
 \r
            default:\r
@@ -1101,13 +1116,13 @@ static void prvGetStandardInterfaceDescriptor( xUSB_REQUEST *pxRequest )
 \r
 static void prvHandleStandardInterfaceRequest( xUSB_REQUEST *pxRequest )\r
 {\r
-unsigned portSHORT usStatus = 0;\r
+unsigned short usStatus = 0;\r
 \r
        switch( pxRequest->ucRequest )\r
        {\r
            case usbGET_STATUS_REQUEST:\r
                        /* Send dummy 2 bytes. */\r
-                       prvSendControlData( ( unsigned portCHAR * ) &usStatus, sizeof( usStatus ), sizeof( usStatus ), pdFALSE );\r
+                       prvSendControlData( ( unsigned char * ) &usStatus, sizeof( usStatus ), sizeof( usStatus ), pdFALSE );\r
                        break;\r
 \r
            case usbGET_DESCRIPTOR_REQUEST:\r
@@ -1144,14 +1159,14 @@ static void prvHandleStandardEndPointRequest( xUSB_REQUEST *pxRequest )
 \r
 static void vInitUSBInterface( void )\r
 {\r
-volatile unsigned portLONG ulTemp;\r
+volatile unsigned long ulTemp;\r
 \r
        /* Create the queue used to communicate between the USB ISR and task. */\r
        xUSBInterruptQueue = xQueueCreate( usbQUEUE_LENGTH + 1, sizeof( xISRStatus * ) );\r
 \r
        /* Initialise a few state variables. */\r
-       pxCharsForTx.ulNextCharIndex = ( unsigned portLONG ) 0;\r
-       ucUSBConfig = ( unsigned portCHAR ) 0;\r
+       pxCharsForTx.ulNextCharIndex = ( unsigned long ) 0;\r
+       ucUSBConfig = ( unsigned char ) 0;\r
        eDriverState = eNOTHING;\r
 \r
        /* HARDWARE SETUP */\r
@@ -1173,10 +1188,10 @@ volatile unsigned portLONG ulTemp;
        /* When using the USB debugger the peripheral registers do not always get\r
        set to the correct default values.  To make sure set the relevant registers\r
        manually here. */\r
-       AT91C_BASE_UDP->UDP_IDR = ( unsigned portLONG ) 0xffffffff;\r
-       AT91C_BASE_UDP->UDP_ICR = ( unsigned portLONG ) 0xffffffff;\r
-       AT91C_BASE_UDP->UDP_CSR[ 0 ] = ( unsigned portLONG ) 0x00;\r
-       AT91C_BASE_UDP->UDP_CSR[ 1 ] = ( unsigned portLONG ) 0x00;\r
+       AT91C_BASE_UDP->UDP_IDR = ( unsigned long ) 0xffffffff;\r
+       AT91C_BASE_UDP->UDP_ICR = ( unsigned long ) 0xffffffff;\r
+       AT91C_BASE_UDP->UDP_CSR[ 0 ] = ( unsigned long ) 0x00;\r
+       AT91C_BASE_UDP->UDP_CSR[ 1 ] = ( unsigned long ) 0x00;\r
        AT91C_BASE_UDP->UDP_GLBSTATE = 0;\r
        AT91C_BASE_UDP->UDP_FADDR = 0;\r
 \r
@@ -1194,14 +1209,14 @@ volatile unsigned portLONG ulTemp;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvSendControlData( unsigned portCHAR *pucData, unsigned portSHORT usRequestedLength, unsigned portLONG ulLengthToSend, portLONG lSendingDescriptor )\r
+static void prvSendControlData( unsigned char *pucData, unsigned short usRequestedLength, unsigned long ulLengthToSend, long lSendingDescriptor )\r
 {\r
-       if( ( ( unsigned portLONG ) usRequestedLength < ulLengthToSend ) )\r
+       if( ( ( unsigned long ) usRequestedLength < ulLengthToSend ) )\r
        {\r
                /* Cap the data length to that requested. */\r
-               ulLengthToSend = ( unsigned portSHORT ) usRequestedLength;\r
+               ulLengthToSend = ( unsigned short ) usRequestedLength;\r
        }\r
-       else if( ( ulLengthToSend < ( unsigned portLONG ) usRequestedLength ) && lSendingDescriptor )\r
+       else if( ( ulLengthToSend < ( unsigned long ) usRequestedLength ) && lSendingDescriptor )\r
        {\r
                /* We are sending a descriptor.  If the descriptor is an exact\r
                multiple of the FIFO length then it will have to be terminated\r
@@ -1223,7 +1238,7 @@ static void prvSendControlData( unsigned portCHAR *pucData, unsigned portSHORT u
        /* Reinitialise the buffer index so we start sending from the start of\r
        the data. */\r
        pxCharsForTx.ulTotalDataLength = ulLengthToSend;\r
-       pxCharsForTx.ulNextCharIndex = ( unsigned portLONG ) 0;\r
+       pxCharsForTx.ulNextCharIndex = ( unsigned long ) 0;\r
 \r
        /* Send the first 8 bytes now.  The rest will get sent in response to\r
        TXCOMP interrupts. */\r
@@ -1233,7 +1248,7 @@ static void prvSendControlData( unsigned portCHAR *pucData, unsigned portSHORT u
 \r
 static void prvSendNextSegment( void )\r
 {\r
-volatile unsigned portLONG ulNextLength, ulStatus, ulLengthLeftToSend;\r
+volatile unsigned long ulNextLength, ulStatus, ulLengthLeftToSend;\r
 \r
        /* Is there any data to send? */\r
        if( pxCharsForTx.ulTotalDataLength > pxCharsForTx.ulNextCharIndex )\r
@@ -1258,7 +1273,7 @@ volatile unsigned portLONG ulNextLength, ulStatus, ulLengthLeftToSend;
                }\r
 \r
                /* Write the data to the FIFO. */\r
-               while( ulNextLength > ( unsigned portLONG ) 0 )\r
+               while( ulNextLength > ( unsigned long ) 0 )\r
                {\r
                        AT91C_BASE_UDP->UDP_FDR[ usbEND_POINT_0 ] = pxCharsForTx.ucTxBuffer[ pxCharsForTx.ulNextCharIndex ];\r
        \r
@@ -1270,7 +1285,7 @@ volatile unsigned portLONG ulNextLength, ulStatus, ulLengthLeftToSend;
                portENTER_CRITICAL();\r
                {\r
                        ulStatus = AT91C_BASE_UDP->UDP_CSR[ usbEND_POINT_0 ];\r
-                       usbCSR_SET_BIT( &ulStatus, ( ( unsigned portLONG ) 0x10 ) );\r
+                       usbCSR_SET_BIT( &ulStatus, ( ( unsigned long ) 0x10 ) );\r
                        AT91C_BASE_UDP->UDP_CSR[ usbEND_POINT_0 ] = ulStatus;\r
                }\r
                portEXIT_CRITICAL();\r