]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/ARM7_AT91SAM7X256_Eclipse/RTOSDemo/webserver/EMAC_ISR.c
5c5a282d6a025d73ff9d08f9157f02d188b01920
[freertos] / FreeRTOS / Demo / ARM7_AT91SAM7X256_Eclipse / RTOSDemo / webserver / EMAC_ISR.c
1 /*\r
2     FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     This file is part of the FreeRTOS distribution.\r
8 \r
9     FreeRTOS is free software; you can redistribute it and/or modify it under\r
10     the terms of the GNU General Public License (version 2) as published by the\r
11     Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
12 \r
13     ***************************************************************************\r
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
16     >>!   obliged to provide the source code for proprietary components     !<<\r
17     >>!   outside of the FreeRTOS kernel.                                   !<<\r
18     ***************************************************************************\r
19 \r
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
23     link: http://www.freertos.org/a00114.html\r
24 \r
25     ***************************************************************************\r
26      *                                                                       *\r
27      *    FreeRTOS provides completely free yet professionally developed,    *\r
28      *    robust, strictly quality controlled, supported, and cross          *\r
29      *    platform software that is more than just the market leader, it     *\r
30      *    is the industry's de facto standard.                               *\r
31      *                                                                       *\r
32      *    Help yourself get started quickly while simultaneously helping     *\r
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
34      *    tutorial book, reference manual, or both:                          *\r
35      *    http://www.FreeRTOS.org/Documentation                              *\r
36      *                                                                       *\r
37     ***************************************************************************\r
38 \r
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
40     the FAQ page "My application does not run, what could be wrong?".  Have you\r
41     defined configASSERT()?\r
42 \r
43     http://www.FreeRTOS.org/support - In return for receiving this top quality\r
44     embedded software for free we request you assist our global community by\r
45     participating in the support forum.\r
46 \r
47     http://www.FreeRTOS.org/training - Investing in training allows your team to\r
48     be as productive as possible as early as possible.  Now you can receive\r
49     FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
50     Ltd, and the world's leading authority on the world's leading RTOS.\r
51 \r
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
55 \r
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
58 \r
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
61     licenses offer ticketed support, indemnification and commercial middleware.\r
62 \r
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
64     engineered and independently SIL3 certified version for use in safety and\r
65     mission critical applications that require provable dependability.\r
66 \r
67     1 tab == 4 spaces!\r
68 */\r
69 \r
70 #include "FreeRTOS.h"\r
71 #include "semphr.h"\r
72 #include "task.h"\r
73 \r
74 /* Wrapper for the EMAC interrupt. */\r
75 void vEMACISR_Wrapper( void ) __attribute__((naked));\r
76 \r
77 /* Handler called by the ISR wrapper.  This must be kept a separate\r
78 function to ensure the stack frame is correctly set up. */\r
79 void vEMACISR_Handler( void ) __attribute__((noinline));\r
80 \r
81 static SemaphoreHandle_t xEMACSemaphore;\r
82 \r
83 /*-----------------------------------------------------------*/\r
84 \r
85 void vPassEMACSemaphore( SemaphoreHandle_t xSemaphore )\r
86 {\r
87         xEMACSemaphore = xSemaphore;\r
88 }\r
89 /*-----------------------------------------------------------*/\r
90 \r
91 void vEMACISR_Handler( void )\r
92 {\r
93 volatile unsigned long ulIntStatus, ulRxStatus;\r
94 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
95 \r
96         ulIntStatus = AT91C_BASE_EMAC->EMAC_ISR;\r
97         ulRxStatus = AT91C_BASE_EMAC->EMAC_RSR;\r
98 \r
99         if( ( ulIntStatus & AT91C_EMAC_RCOMP ) || ( ulRxStatus & AT91C_EMAC_REC ) )\r
100         {\r
101                 /* A frame has been received, signal the uIP task so it can process\r
102                 the Rx descriptors. */\r
103                 xSemaphoreGiveFromISR( xEMACSemaphore, &xHigherPriorityTaskWoken );\r
104                 AT91C_BASE_EMAC->EMAC_RSR = AT91C_EMAC_REC;\r
105         }\r
106 \r
107         /* Clear the interrupt. */\r
108         AT91C_BASE_AIC->AIC_EOICR = 0;\r
109         \r
110     /* Switch to the uIP task. */\r
111     if( xHigherPriorityTaskWoken )\r
112     {\r
113         /* If a task of higher priority than the interrupted task was\r
114         unblocked by the ISR then this call will ensure that the \r
115         unblocked task is the task the ISR returns to. */\r
116         portYIELD_FROM_ISR();\r
117     }\r
118 }\r
119 /*-----------------------------------------------------------*/\r
120 \r
121 void vEMACISR_Wrapper( void )\r
122 {\r
123         /* Save the context of the interrupted task. */\r
124         portSAVE_CONTEXT();\r
125         \r
126         /* Call the handler task to do the actual work.  This must be a separate\r
127         function to ensure the stack frame is correctly set up. */\r
128         __asm volatile ("bl vEMACISR_Handler");\r
129         \r
130         /* Restore the context of whichever task is the next to run. */\r
131         portRESTORE_CONTEXT();\r
132 }\r
133 \r
134 \r