]> git.sur5r.net Git - freertos/blob - Demo/PIC18_WizC/serial/isrSerialTx.c
Update to V5.4.2. See http://www.freertos.org/History.txt .
[freertos] / Demo / PIC18_WizC / serial / isrSerialTx.c
1 /*\r
2         FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.\r
3 \r
4         This file is part of the FreeRTOS distribution.\r
5 \r
6         FreeRTOS is free software; you can redistribute it and/or modify it     under \r
7         the terms of the GNU General Public License (version 2) as published by the \r
8         Free Software Foundation and modified by the FreeRTOS exception.\r
9         **NOTE** The exception to the GPL is included to allow you to distribute a\r
10         combined work that includes FreeRTOS without being obliged to provide the \r
11         source code for proprietary components outside of the FreeRTOS kernel.  \r
12         Alternative commercial license and support terms are also available upon \r
13         request.  See the licensing section of http://www.FreeRTOS.org for full \r
14         license details.\r
15 \r
16         FreeRTOS is distributed in the hope that it will be useful,     but WITHOUT\r
17         ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
18         FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
19         more details.\r
20 \r
21         You should have received a copy of the GNU General Public License along\r
22         with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59\r
23         Temple Place, Suite 330, Boston, MA  02111-1307  USA.\r
24 \r
25 \r
26         ***************************************************************************\r
27         *                                                                         *\r
28         * Looking for a quick start?  Then check out the FreeRTOS eBook!          *\r
29         * See http://www.FreeRTOS.org/Documentation for details                   *\r
30         *                                                                         *\r
31         ***************************************************************************\r
32 \r
33         1 tab == 4 spaces!\r
34 \r
35         Please ensure to read the configuration and relevant port sections of the\r
36         online documentation.\r
37 \r
38         http://www.FreeRTOS.org - Documentation, latest information, license and\r
39         contact details.\r
40 \r
41         http://www.SafeRTOS.com - A version that is certified for use in safety\r
42         critical systems.\r
43 \r
44         http://www.OpenRTOS.com - Commercial support, development, porting,\r
45         licensing and training services.\r
46 */\r
47 \r
48 /*\r
49 Changes from V3.0.0\r
50         + ISRcode pulled inline to reduce stack-usage.\r
51 \r
52         + Added functionality to only call vTaskSwitchContext() once\r
53           when handling multiple interruptsources in a single interruptcall.\r
54 \r
55         + Filename changed to a .c extension to allow stepping through code\r
56           using F7.\r
57 \r
58 Changes from V3.0.1\r
59 */\r
60 \r
61 #ifndef _FREERTOS_SERIAL_ISRSERIALTX_C\r
62 #define _FREERTOS_SERIAL_ISRSERIALTX_C\r
63 \r
64 #define serINTERRUPT_DISABLED   ( 0 )\r
65 \r
66 \r
67 {\r
68         /*\r
69          * Was the interrupt the Tx register becoming empty?\r
70          */\r
71         if( bTXIF && bTXIE)\r
72         {\r
73                 /*\r
74                  * Queue to interface between comms API and interrupt routine.\r
75                 */\r
76                 extern xQueueHandle xCharsForTx;\r
77 \r
78                 /*\r
79                  * Because we are not allowed to use local variables here,\r
80                  * PRODL and PRODH are (ab)used as temporary storage. This\r
81                  * is allowed because these SFR's will be restored before\r
82                  * exiting the ISR.\r
83                  */\r
84                 extern portCHAR                         cChar;\r
85                 #pragma locate cChar            &PRODL\r
86                 extern portBASE_TYPE            pxTaskWoken;\r
87                 #pragma locate pxTaskWoken      &PRODH\r
88 \r
89                 if( xQueueReceiveFromISR( xCharsForTx, &cChar, &pxTaskWoken ) == pdTRUE )\r
90                 {\r
91                         /*\r
92                          * Send the next character queued for Tx.\r
93                          */\r
94                         TXREG = cChar;\r
95                 }\r
96                 else\r
97                 {\r
98                         /*\r
99                          * Queue empty, nothing to send.\r
100                          */\r
101                         bTXIE = serINTERRUPT_DISABLED;\r
102                 }\r
103 \r
104                 /*\r
105                  * If we woke another task, ask for a contextswitch\r
106                  */\r
107                 if( pxTaskWoken == pdTRUE )\r
108                 {\r
109                         uxSwitchRequested = pdTRUE;\r
110                 }\r
111         }\r
112 }\r
113 \r
114 #endif  /* _FREERTOS_SERIAL_ISRSERIALTX_C */\r