]> git.sur5r.net Git - freertos/blobdiff - Demo/ARM7_AT91SAM7X256_Eclipse/RTOSDemo/webserver/SAM7_EMAC.c
Remove unnecessary use of portLONG, portCHAR and portSHORT.
[freertos] / Demo / ARM7_AT91SAM7X256_Eclipse / RTOSDemo / webserver / SAM7_EMAC.c
index 1b304fae68c178916c1784826c2b11a2f0290e74..64638fc974a1a1501f391cb45deab03b65eff6ea 100644 (file)
@@ -1,37 +1,49 @@
 /*\r
-       FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 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\r
-       it under the terms of the GNU General Public License as published by\r
-       the Free Software Foundation; either version 2 of the License, or\r
-       (at your option) any later version.\r
-\r
-       FreeRTOS.org is distributed in the hope that it will be useful,\r
-       but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-       GNU General Public License for more details.\r
-\r
-       You should have received a copy of the GNU General Public License\r
-       along with FreeRTOS.org; if not, write to the Free Software\r
-       Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
-\r
-       A special exception to the GPL can be applied should you wish to distribute\r
-       a combined work that includes FreeRTOS.org, without being obliged to provide\r
-       the source code for any proprietary components.  See the licensing section \r
-       of http://www.FreeRTOS.org for full details of how and when the exception\r
-       can be applied.\r
-\r
-       ***************************************************************************\r
-       See http://www.FreeRTOS.org for documentation, latest information, license \r
-       and contact details.  Please ensure to read the configuration and relevant \r
-       port sections of the online documentation.\r
-\r
-       Also see http://www.SafeRTOS.com a version that has been certified for use\r
-       in safety critical systems, plus commercial licensing, development and\r
-       support options.\r
-       ***************************************************************************\r
+    FreeRTOS V6.0.0 - Copyright (C) 2009 Real Time Engineers Ltd.\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 exception to the GPL is included to allow you to distribute a\r
+    combined work that includes FreeRTOS without being obliged to provide the\r
+    source code for proprietary components outside of the FreeRTOS kernel.\r
+    Alternative commercial license and support terms are also available upon\r
+    request.  See the licensing section of http://www.FreeRTOS.org for full\r
+    license details.\r
+\r
+    FreeRTOS 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; 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
+    * The FreeRTOS eBook and reference manual are available to purchase for a *\r
+    * small fee. Help yourself get started quickly while also helping the     *\r
+    * FreeRTOS project! See http://www.FreeRTOS.org/Documentation for details *\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
 */\r
 \r
 /* Standard includes. */\r
@@ -61,15 +73,15 @@ to use an MII interface. */
 /* The buffer addresses written into the descriptors must be aligned so the\r
 last few bits are zero.  These bits have special meaning for the EMAC\r
 peripheral and cannot be used as part of the address. */\r
-#define emacADDRESS_MASK                       ( ( unsigned portLONG ) 0xFFFFFFFC )\r
+#define emacADDRESS_MASK                       ( ( unsigned long ) 0xFFFFFFFC )\r
 \r
 /* Bit used within the address stored in the descriptor to mark the last\r
 descriptor in the array. */\r
-#define emacRX_WRAP_BIT                                ( ( unsigned portLONG ) 0x02 )\r
+#define emacRX_WRAP_BIT                                ( ( unsigned long ) 0x02 )\r
 \r
 /* Bit used within the Tx descriptor status to indicate whether the\r
 descriptor is under the control of the EMAC or the software. */\r
-#define emacTX_BUF_USED                                ( ( unsigned portLONG ) 0x80000000 )\r
+#define emacTX_BUF_USED                                ( ( unsigned long ) 0x80000000 )\r
 \r
 /* A short delay is used to wait for a buffer to become available, should\r
 one not be immediately available when trying to transmit a frame. */\r
@@ -81,31 +93,31 @@ one not be immediately available when trying to transmit a frame. */
 #define emacNO_DELAY                           ( 0 )\r
 #define emacTOTAL_FRAME_HEADER_SIZE    ( 54 )\r
 #define emacPHY_INIT_DELAY                     ( 5000 / portTICK_RATE_MS )\r
-#define emacRESET_KEY                          ( ( unsigned portLONG ) 0xA5000000 )\r
-#define emacRESET_LENGTH                       ( ( unsigned portLONG ) ( 0x01 << 8 ) )\r
+#define emacRESET_KEY                          ( ( unsigned long ) 0xA5000000 )\r
+#define emacRESET_LENGTH                       ( ( unsigned long ) ( 0x01 << 8 ) )\r
 \r
 /* The Atmel header file only defines the TX frame length mask. */\r
 #define emacRX_LENGTH_FRAME                    ( 0xfff )\r
 \r
 /* Peripheral setup for the EMAC. */\r
-#define emacPERIPHERAL_A_SETUP                 ( ( unsigned portLONG ) AT91C_PB2_ETX0                  ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB12_ETXER                ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB16_ECOL                 ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB11_ETX3                 ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB6_ERX1                  ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB15_ERXDV                ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB13_ERX2                 ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB3_ETX1                  ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB8_EMDC                  ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB5_ERX0                  ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB14_ERX3                 ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB4_ECRS_ECRSDV   ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB1_ETXEN                 ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB10_ETX2                 ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB0_ETXCK_EREFCK  ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB9_EMDIO                 ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB7_ERXER                 ) | \\r
-                                                                       ( ( unsigned portLONG ) AT91C_PB17_ERXCK                );\r
+#define emacPERIPHERAL_A_SETUP                 ( ( unsigned long ) AT91C_PB2_ETX0                      ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB12_ETXER            ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB16_ECOL                     ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB11_ETX3                     ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB6_ERX1                      ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB15_ERXDV            ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB13_ERX2                     ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB3_ETX1                      ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB8_EMDC                      ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB5_ERX0                      ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB14_ERX3                     ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB4_ECRS_ECRSDV       ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB1_ETXEN                     ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB10_ETX2                     ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB0_ETXCK_EREFCK      ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB9_EMDIO                     ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB7_ERXER                     ) | \\r
+                                                                       ( ( unsigned long ) AT91C_PB17_ERXCK            );\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -133,9 +145,9 @@ static void prvSetupEMACInterrupt( void );
 /*\r
  * Some initialisation functions taken from the Atmel EMAC sample code.\r
  */\r
-static void vReadPHY( unsigned portCHAR ucPHYAddress, unsigned portCHAR ucAddress, unsigned portLONG *pulValue );\r
+static void vReadPHY( unsigned char ucPHYAddress, unsigned char ucAddress, unsigned long *pulValue );\r
 #if USE_RMII_INTERFACE != 1\r
-       static void vWritePHY( unsigned portCHAR ucPHYAddress, unsigned portCHAR ucAddress, unsigned portLONG ulValue);\r
+       static void vWritePHY( unsigned char ucPHYAddress, unsigned char ucAddress, unsigned long ulValue);\r
 #endif\r
 static portBASE_TYPE xGetLinkSpeed( void );\r
 static portBASE_TYPE prvProbePHY( void );\r
@@ -145,12 +157,12 @@ static portBASE_TYPE prvProbePHY( void );
 /* Buffer written to by the EMAC DMA.  Must be aligned as described by the\r
 comment above the emacADDRESS_MASK definition. */\r
 #pragma data_alignment=8\r
-static volatile portCHAR pcRxBuffer[ NB_RX_BUFFERS * ETH_RX_BUFFER_SIZE ];\r
+static volatile char pcRxBuffer[ NB_RX_BUFFERS * ETH_RX_BUFFER_SIZE ];\r
 \r
 /* Buffer read by the EMAC DMA.  Must be aligned as described by he comment\r
 above the emacADDRESS_MASK definition. */\r
 #pragma data_alignment=8\r
-static portCHAR pcTxBuffer[ NB_TX_BUFFERS * ETH_TX_BUFFER_SIZE ];\r
+static char pcTxBuffer[ NB_TX_BUFFERS * ETH_TX_BUFFER_SIZE ];\r
 \r
 /* Descriptors used to communicate between the program and the EMAC peripheral.\r
 These descriptors hold the locations and state of the Rx and Tx buffers. */\r
@@ -158,7 +170,7 @@ static volatile AT91S_TxTdDescriptor xTxDescriptors[ NB_TX_BUFFERS ];
 static volatile AT91S_RxTdDescriptor xRxDescriptors[ NB_RX_BUFFERS ];\r
 \r
 /* The IP and Ethernet addresses are read from the uIP setup. */\r
-const portCHAR cMACAddress[ 6 ] = { uipMAC_ADDR0, uipMAC_ADDR1, uipMAC_ADDR2, uipMAC_ADDR3, uipMAC_ADDR4, uipMAC_ADDR5 };\r
+const char cMACAddress[ 6 ] = { uipMAC_ADDR0, uipMAC_ADDR1, uipMAC_ADDR2, uipMAC_ADDR3, uipMAC_ADDR4, uipMAC_ADDR5 };\r
 const unsigned char ucIPAddress[ 4 ]  = { uipIP_ADDR0, uipIP_ADDR1, uipIP_ADDR2, uipIP_ADDR3 };\r
 \r
 /* The semaphore used by the EMAC ISR to wake the EMAC task. */\r
@@ -213,7 +225,7 @@ xSemaphoreHandle xEMACInit( void )
        /* PHY configuration. */\r
        #if USE_RMII_INTERFACE != 1\r
        {\r
-               unsigned portLONG ulControl;\r
+               unsigned long ulControl;\r
 \r
                /* PHY has internal pull down : disable MII isolate. */\r
                vReadPHY( AT91C_PHY_ADDR, MII_BMCR, &ulControl );\r
@@ -259,12 +271,12 @@ xSemaphoreHandle xEMACInit( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-portLONG lEMACSend( void )\r
+long lEMACSend( void )\r
 {\r
 static unsigned portBASE_TYPE uxTxBufferIndex = 0;\r
 portBASE_TYPE xWaitCycles = 0;\r
-portLONG lReturn = pdPASS;\r
-portCHAR *pcBuffer;\r
+long lReturn = pdPASS;\r
+char *pcBuffer;\r
 \r
        /* Is a buffer available? */\r
        while( !( xTxDescriptors[ uxTxBufferIndex ].U_Status.status & AT91C_TRANSMIT_OK ) )\r
@@ -288,7 +300,7 @@ portCHAR *pcBuffer;
        if( lReturn == pdPASS )\r
        {\r
                /* Copy the headers into the Tx buffer.  These will be in the uIP buffer. */\r
-               pcBuffer = ( portCHAR * ) xTxDescriptors[ uxTxBufferIndex ].addr;\r
+               pcBuffer = ( char * ) xTxDescriptors[ uxTxBufferIndex ].addr;\r
                memcpy( ( void * ) pcBuffer, ( void * ) uip_buf, emacTOTAL_FRAME_HEADER_SIZE );\r
 \r
                /* If there is room, also copy in the application data if any. */\r
@@ -303,7 +315,7 @@ portCHAR *pcBuffer;
                        if( uxTxBufferIndex >= ( NB_TX_BUFFERS - 1 ) )\r
                        {\r
                                /* Fill out the necessary in the descriptor to get the data sent. */\r
-                               xTxDescriptors[ uxTxBufferIndex ].U_Status.status =     ( uip_len & ( unsigned portLONG ) AT91C_LENGTH_FRAME )\r
+                               xTxDescriptors[ uxTxBufferIndex ].U_Status.status =     ( uip_len & ( unsigned long ) AT91C_LENGTH_FRAME )\r
                                                                                                                                                | AT91C_LAST_BUFFER\r
                                                                                                                                                | AT91C_TRANSMIT_WRAP;\r
                                uxTxBufferIndex = 0;\r
@@ -311,7 +323,7 @@ portCHAR *pcBuffer;
                        else\r
                        {\r
                                /* Fill out the necessary in the descriptor to get the data sent. */\r
-                               xTxDescriptors[ uxTxBufferIndex ].U_Status.status =     ( uip_len & ( unsigned portLONG ) AT91C_LENGTH_FRAME )\r
+                               xTxDescriptors[ uxTxBufferIndex ].U_Status.status =     ( uip_len & ( unsigned long ) AT91C_LENGTH_FRAME )\r
                                                                                                                                                | AT91C_LAST_BUFFER;\r
                                uxTxBufferIndex++;\r
                        }\r
@@ -325,11 +337,11 @@ portCHAR *pcBuffer;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-unsigned portLONG ulEMACPoll( void )\r
+unsigned long ulEMACPoll( void )\r
 {\r
 static unsigned portBASE_TYPE ulNextRxBuffer = 0;\r
-unsigned portLONG ulSectionLength = 0, ulLengthSoFar = 0, ulEOF = pdFALSE;\r
-portCHAR *pcSource;\r
+unsigned long ulSectionLength = 0, ulLengthSoFar = 0, ulEOF = pdFALSE;\r
+char *pcSource;\r
 \r
        /* Skip any fragments. */\r
        while( ( xRxDescriptors[ ulNextRxBuffer ].addr & AT91C_OWNERSHIP_BIT ) && !( xRxDescriptors[ ulNextRxBuffer ].U_Status.status & AT91C_SOF ) )\r
@@ -347,7 +359,7 @@ portCHAR *pcSource;
 \r
        while( ( xRxDescriptors[ ulNextRxBuffer ].addr & AT91C_OWNERSHIP_BIT ) && !ulSectionLength )\r
        {\r
-               pcSource = ( portCHAR * )( xRxDescriptors[ ulNextRxBuffer ].addr & emacADDRESS_MASK );\r
+               pcSource = ( char * )( xRxDescriptors[ ulNextRxBuffer ].addr & emacADDRESS_MASK );\r
                ulSectionLength = xRxDescriptors[ ulNextRxBuffer ].U_Status.status & emacRX_LENGTH_FRAME;\r
 \r
                if( ulSectionLength == 0 )\r
@@ -406,13 +418,13 @@ portCHAR *pcSource;
 static void prvSetupDescriptors(void)\r
 {\r
 unsigned portBASE_TYPE xIndex;\r
-unsigned portLONG ulAddress;\r
+unsigned long ulAddress;\r
 \r
        /* Initialise xRxDescriptors descriptor. */\r
        for( xIndex = 0; xIndex < NB_RX_BUFFERS; ++xIndex )\r
        {\r
                /* Calculate the address of the nth buffer within the array. */\r
-               ulAddress = ( unsigned portLONG )( pcRxBuffer + ( xIndex * ETH_RX_BUFFER_SIZE ) );\r
+               ulAddress = ( unsigned long )( pcRxBuffer + ( xIndex * ETH_RX_BUFFER_SIZE ) );\r
 \r
                /* Write the buffer address into the descriptor.  The DMA will place\r
                the data at this address when this descriptor is being used.  Mask off\r
@@ -428,7 +440,7 @@ unsigned portLONG ulAddress;
        for( xIndex = 0; xIndex < NB_TX_BUFFERS; ++xIndex )\r
        {\r
                /* Calculate the address of the nth buffer within the array. */\r
-               ulAddress = ( unsigned portLONG )( pcTxBuffer + ( xIndex * ETH_TX_BUFFER_SIZE ) );\r
+               ulAddress = ( unsigned long )( pcTxBuffer + ( xIndex * ETH_TX_BUFFER_SIZE ) );\r
 \r
                /* Write the buffer address into the descriptor.  The DMA will read\r
                data from here when the descriptor is being used. */\r
@@ -441,8 +453,8 @@ unsigned portLONG ulAddress;
        xTxDescriptors[ NB_TX_BUFFERS - 1 ].U_Status.status = AT91C_TRANSMIT_WRAP | AT91C_TRANSMIT_OK;\r
 \r
        /* Tell the EMAC where to find the descriptors. */\r
-       AT91C_BASE_EMAC->EMAC_RBQP = ( unsigned portLONG ) xRxDescriptors;\r
-       AT91C_BASE_EMAC->EMAC_TBQP = ( unsigned portLONG ) xTxDescriptors;\r
+       AT91C_BASE_EMAC->EMAC_RBQP = ( unsigned long ) xRxDescriptors;\r
+       AT91C_BASE_EMAC->EMAC_TBQP = ( unsigned long ) xTxDescriptors;\r
        \r
        /* Clear all the bits in the receive status register. */\r
        AT91C_BASE_EMAC->EMAC_RSR = ( AT91C_EMAC_OVR | AT91C_EMAC_REC | AT91C_EMAC_BNA );\r
@@ -459,12 +471,12 @@ unsigned portLONG ulAddress;
 static void prvSetupMACAddress( void )\r
 {\r
        /* Must be written SA1L then SA1H. */\r
-       AT91C_BASE_EMAC->EMAC_SA1L =    ( ( unsigned portLONG ) cMACAddress[ 3 ] << 24 ) |\r
-                                                                       ( ( unsigned portLONG ) cMACAddress[ 2 ] << 16 ) |\r
-                                                                       ( ( unsigned portLONG ) cMACAddress[ 1 ] << 8  ) |\r
+       AT91C_BASE_EMAC->EMAC_SA1L =    ( ( unsigned long ) cMACAddress[ 3 ] << 24 ) |\r
+                                                                       ( ( unsigned long ) cMACAddress[ 2 ] << 16 ) |\r
+                                                                       ( ( unsigned long ) cMACAddress[ 1 ] << 8  ) |\r
                                                                        cMACAddress[ 0 ];\r
 \r
-       AT91C_BASE_EMAC->EMAC_SA1H =    ( ( unsigned portLONG ) cMACAddress[ 5 ] << 8 ) |\r
+       AT91C_BASE_EMAC->EMAC_SA1H =    ( ( unsigned long ) cMACAddress[ 5 ] << 8 ) |\r
                                                                        cMACAddress[ 4 ];\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -502,7 +514,7 @@ static void prvSetupEMACInterrupt( void )
 \r
 static portBASE_TYPE prvProbePHY( void )\r
 {\r
-unsigned portLONG ulPHYId1, ulPHYId2, ulStatus;\r
+unsigned long ulPHYId1, ulPHYId2, ulStatus;\r
 portBASE_TYPE xReturn = pdPASS;\r
        \r
        /* Code supplied by Atmel (reformatted) -----------------*/\r
@@ -545,7 +557,7 @@ portBASE_TYPE xReturn = pdPASS;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void vReadPHY( unsigned portCHAR ucPHYAddress, unsigned portCHAR ucAddress, unsigned portLONG *pulValue )\r
+static void vReadPHY( unsigned char ucPHYAddress, unsigned char ucAddress, unsigned long *pulValue )\r
 {\r
        /* Code supplied by Atmel (reformatted) ----------------------*/\r
 \r
@@ -567,7 +579,7 @@ static void vReadPHY( unsigned portCHAR ucPHYAddress, unsigned portCHAR ucAddres
 /*-----------------------------------------------------------*/\r
 \r
 #if USE_RMII_INTERFACE != 1\r
-static void vWritePHY( unsigned portCHAR ucPHYAddress, unsigned portCHAR ucAddress, unsigned portLONG ulValue )\r
+static void vWritePHY( unsigned char ucPHYAddress, unsigned char ucAddress, unsigned long ulValue )\r
 {\r
        /* Code supplied by Atmel (reformatted) ----------------------*/\r
 \r
@@ -590,7 +602,7 @@ static void vWritePHY( unsigned portCHAR ucPHYAddress, unsigned portCHAR ucAddre
 \r
 static portBASE_TYPE xGetLinkSpeed( void )\r
 {\r
-       unsigned portLONG ulBMSR, ulBMCR, ulLPA, ulMACCfg, ulSpeed, ulDuplex;\r
+       unsigned long ulBMSR, ulBMCR, ulLPA, ulMACCfg, ulSpeed, ulDuplex;\r
 \r
        /* Code supplied by Atmel (reformatted) -----------------*/\r
 \r