]> git.sur5r.net Git - freertos/blobdiff - Demo/WizNET_DEMO_GCC_ARM7/i2cISR.c
Update lwIP port layer for the Microblaze Ethernet Lite IP.
[freertos] / Demo / WizNET_DEMO_GCC_ARM7 / i2cISR.c
index 45b94708e6123f280d0d4de129c856e88b891243..320ba6021d8ef3eb12551155e61f3caa227703be 100644 (file)
@@ -1,50 +1,54 @@
 /*\r
-       FreeRTOS.org V4.8.0 - Copyright (C) 2003-2008 Richard Barry.\r
+    FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
+       \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
+     *                                                                       *\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
-       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
+    This file is part of the FreeRTOS distribution.\r
 \r
-    ***************************************************************************\r
-    ***************************************************************************\r
-    *                                                                         *\r
-    * SAVE TIME AND MONEY!  We can port FreeRTOS.org to your own hardware,    *\r
-    * and even write all or part of your application on your behalf.          *\r
-    * See http://www.OpenRTOS.com for details of the services we provide to   *\r
-    * expedite your project.                                                  *\r
-    *                                                                         *\r
-    ***************************************************************************\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
-       Please ensure to read the configuration and relevant port sections of the\r
-       online documentation.\r
+    1 tab == 4 spaces!\r
 \r
-       http://www.FreeRTOS.org - Documentation, latest information, license and \r
-       contact details.\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
+    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
+    http://www.OpenRTOS.com - Commercial support, development, porting,\r
+    licensing and training services.\r
 */\r
 \r
 \r
 /*-----------------------------------------------------------*/\r
 \r
 /* Bit definitions within the I2CONCLR register. */\r
-#define i2cSTA_BIT             ( ( unsigned portCHAR ) 0x20 )\r
-#define i2cSI_BIT              ( ( unsigned portCHAR ) 0x08 )\r
-#define i2cSTO_BIT             ( ( unsigned portCHAR ) 0x10 )\r
-#define i2cAA_BIT              ( ( unsigned portCHAR ) 0x04 )\r
+#define i2cSTA_BIT             ( ( unsigned char ) 0x20 )\r
+#define i2cSI_BIT              ( ( unsigned char ) 0x08 )\r
+#define i2cSTO_BIT             ( ( unsigned char ) 0x10 )\r
+#define i2cAA_BIT              ( ( unsigned char ) 0x04 )\r
 \r
 /* Status codes for the I2STAT register. */\r
 #define i2cSTATUS_START_TXED                   ( 0x08 )\r
@@ -112,16 +116,16 @@ volatile xI2CMessage *pxCurrentMessage = NULL;
 static xQueueHandle xMessagesForTx;\r
 \r
 /* Flag used to indicate whether or not the ISR is amid sending a message. */\r
-unsigned portLONG ulBusFree = ( unsigned portLONG ) pdTRUE;\r
+unsigned long ulBusFree = ( unsigned long ) pdTRUE;\r
 \r
 /* Setting this to true will cause the TCP task to think a message is \r
 complete and thus restart.  It can therefore be used under error states\r
 to force a restart. */\r
-volatile portLONG lTransactionCompleted = pdTRUE;\r
+volatile long lTransactionCompleted = pdTRUE;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
-void vI2CISRCreateQueues( unsigned portBASE_TYPE uxQueueLength, xQueueHandle *pxTxMessages, unsigned portLONG **ppulBusFree )\r
+void vI2CISRCreateQueues( unsigned portBASE_TYPE uxQueueLength, xQueueHandle *pxTxMessages, unsigned long **ppulBusFree )\r
 {\r
        /* Create the queues used to hold Rx and Tx characters. */\r
        xMessagesForTx = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( xI2CMessage * ) );\r
@@ -160,9 +164,9 @@ void vI2C_ISR_Handler( void )
 {\r
 /* Holds the current transmission state. */                                                    \r
 static I2C_STATE eCurrentState = eSentStart;\r
-static portLONG lMessageIndex = -i2cBUFFER_ADDRESS_BYTES; /* There are two address bytes to send prior to the data. */\r
-portBASE_TYPE xTaskWokenByTx = pdFALSE;\r
-portLONG lBytesLeft;\r
+static long lMessageIndex = -i2cBUFFER_ADDRESS_BYTES; /* There are two address bytes to send prior to the data. */\r
+portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
+long lBytesLeft;\r
 \r
        /* The action taken for this interrupt depends on our current state. */\r
        switch( eCurrentState )\r
@@ -258,7 +262,7 @@ portLONG lBytesLeft;
 \r
                                        /* How many more bytes are we expecting to receive? */\r
                                        lBytesLeft = pxCurrentMessage->lMessageLength - lMessageIndex;\r
-                                       if( lBytesLeft == ( unsigned portLONG ) 0 )\r
+                                       if( lBytesLeft == ( unsigned long ) 0 )\r
                                        {\r
                                                /* This was the last byte in the message. */\r
                                                i2cEND_TRANSMISSION( pdPASS );\r
@@ -268,11 +272,11 @@ portLONG lBytesLeft;
                                                must 'give' the semaphore so the task is woken.*/\r
                                                if( pxCurrentMessage->xMessageCompleteSemaphore )\r
                                                {\r
-                                                       xTaskWokenByTx = xSemaphoreGiveFromISR( pxCurrentMessage->xMessageCompleteSemaphore, xTaskWokenByTx );\r
+                                                       xSemaphoreGiveFromISR( pxCurrentMessage->xMessageCompleteSemaphore, &xHigherPriorityTaskWoken );\r
                                                }\r
 \r
                                                /* Are there any other messages to transact? */\r
-                                               if( xQueueReceiveFromISR( xMessagesForTx, &pxCurrentMessage, &xTaskWokenByTx ) == pdTRUE )\r
+                                               if( xQueueReceiveFromISR( xMessagesForTx, &pxCurrentMessage, &xHigherPriorityTaskWoken ) == pdTRUE )\r
                                                {\r
                                                        /* Start the next message - which was\r
                                                        retrieved from the queue. */\r
@@ -282,7 +286,7 @@ portLONG lBytesLeft;
                                                {\r
                                                        /* No more messages were found to be waiting for\r
                                                        transaction so the bus is free. */\r
-                                                       ulBusFree = ( unsigned portLONG ) pdTRUE;                       \r
+                                                       ulBusFree = ( unsigned long ) pdTRUE;                   \r
                                                }                                               \r
                                        }\r
                                        else\r
@@ -336,11 +340,11 @@ portLONG lBytesLeft;
                                                semaphore must be 'given' to wake the task. */\r
                                                if( pxCurrentMessage->xMessageCompleteSemaphore )\r
                                                {\r
-                                                       xTaskWokenByTx = xSemaphoreGiveFromISR( pxCurrentMessage->xMessageCompleteSemaphore, xTaskWokenByTx );\r
+                                                       xSemaphoreGiveFromISR( pxCurrentMessage->xMessageCompleteSemaphore, &xHigherPriorityTaskWoken );\r
                                                }\r
 \r
                                                /* Are there any other messages to transact? */\r
-                                               if( xQueueReceiveFromISR( xMessagesForTx, &pxCurrentMessage, &xTaskWokenByTx ) == pdTRUE )\r
+                                               if( xQueueReceiveFromISR( xMessagesForTx, &pxCurrentMessage, &xHigherPriorityTaskWoken ) == pdTRUE )\r
                                                {\r
                                                        /* Start the next message from the Tx queue. */\r
                                                        I2C_I2CONSET = i2cSTA_BIT;\r
@@ -349,7 +353,7 @@ portLONG lBytesLeft;
                                                {\r
                                                        /* No more message were queues for transaction so \r
                                                        the bus is free. */\r
-                                                       ulBusFree = ( unsigned portLONG ) pdTRUE;                       \r
+                                                       ulBusFree = ( unsigned long ) pdTRUE;                   \r
                                                }\r
                                        }\r
                                }\r
@@ -371,7 +375,7 @@ portLONG lBytesLeft;
        I2C_I2CONCLR = i2cSI_BIT;\r
        VICVectAddr = i2cCLEAR_VIC_INTERRUPT;\r
 \r
-       if( xTaskWokenByTx )\r
+       if( xHigherPriorityTaskWoken )\r
        {\r
                portYIELD_FROM_ISR();\r
        }\r