]> git.sur5r.net Git - freertos/blob - Demo/Cygnal/ParTest/ParTest.c
Remove unnecessary use of portLONG, portCHAR and portSHORT.
[freertos] / Demo / Cygnal / ParTest / ParTest.c
1 /*\r
2     FreeRTOS V6.0.0 - 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     * The FreeRTOS eBook and reference manual are available to purchase for a *\r
29     * small fee. Help yourself get started quickly while also helping the     *\r
30     * FreeRTOS project! See http://www.FreeRTOS.org/Documentation for details *\r
31     *                                                                         *\r
32     ***************************************************************************\r
33 \r
34     1 tab == 4 spaces!\r
35 \r
36     Please ensure to read the configuration and relevant port sections of the\r
37     online documentation.\r
38 \r
39     http://www.FreeRTOS.org - Documentation, latest information, license and\r
40     contact details.\r
41 \r
42     http://www.SafeRTOS.com - A version that is certified for use in safety\r
43     critical systems.\r
44 \r
45     http://www.OpenRTOS.com - Commercial support, development, porting,\r
46     licensing and training services.\r
47 */\r
48 #include <c8051f120.h>\r
49 \r
50 #include "FreeRTOS.h"\r
51 #include "task.h"\r
52 #include "partest.h"\r
53 \r
54 #define partstPUSH_PULL                 ( ( unsigned char ) 0xff )\r
55 #define partstALL_OUTPUTS_OFF   ( ( unsigned char ) 0xff )\r
56 \r
57 /* LED to output is dependent on how the LED's are wired. */\r
58 #define partstOUTPUT_0                  ( ( unsigned char ) 0x02 )\r
59 #define partstOUTPUT_1                  ( ( unsigned char ) 0x08 )\r
60 #define partstOUTPUT_2                  ( ( unsigned char ) 0x20 )\r
61 #define partstOUTPUT_3                  ( ( unsigned char ) 0x01 )\r
62 #define partstOUTPUT_4                  ( ( unsigned char ) 0x04 )\r
63 #define partstOUTPUT_5                  ( ( unsigned char ) 0x10 )\r
64 #define partstOUTPUT_6                  ( ( unsigned char ) 0x40 )\r
65 #define partstOUTPUT_7                  ( ( unsigned char ) 0x80 )\r
66 \r
67 /*-----------------------------------------------------------\r
68  * Simple parallel port IO routines.\r
69  *-----------------------------------------------------------*/\r
70 \r
71 void vParTestInitialise( void )\r
72 {\r
73 unsigned char ucOriginalSFRPage;\r
74 \r
75         /* Remember the SFR page before it is changed so it can get set back\r
76         before the function exits. */\r
77         ucOriginalSFRPage = SFRPAGE;\r
78 \r
79         /* Setup the SFR page to access the config SFR's. */\r
80         SFRPAGE = CONFIG_PAGE;\r
81 \r
82         /* Set the on board LED to push pull. */\r
83         P3MDOUT |= partstPUSH_PULL;\r
84 \r
85         /* Return the SFR page. */\r
86         SFRPAGE = ucOriginalSFRPage;\r
87 \r
88         P3 = partstALL_OUTPUTS_OFF;\r
89 }\r
90 /*-----------------------------------------------------------*/\r
91 \r
92 void vParTestSetLED( unsigned portBASE_TYPE uxLED, portBASE_TYPE xValue )\r
93 {\r
94 portBASE_TYPE xError = pdFALSE;\r
95 \r
96         vTaskSuspendAll();\r
97         {\r
98                 if( xValue == pdFALSE )\r
99                 {\r
100                         switch( uxLED )\r
101                         {\r
102                                 case 0  :       P3 |= partstOUTPUT_0;\r
103                                                         break;\r
104                                 case 1  :       P3 |= partstOUTPUT_1;\r
105                                                         break;\r
106                                 case 2  :       P3 |= partstOUTPUT_2;\r
107                                                         break;\r
108                                 case 3  :       P3 |= partstOUTPUT_3;\r
109                                                         break;\r
110                                 case 4  :       P3 |= partstOUTPUT_4;\r
111                                                         break;\r
112                                 case 5  :       P3 |= partstOUTPUT_5;\r
113                                                         break;\r
114                                 case 6  :       P3 |= partstOUTPUT_6;\r
115                                                         break;\r
116                                 case 7  :       P3 |= partstOUTPUT_7;\r
117                                                         break;\r
118                                 default :       /* There are no other LED's wired in. */\r
119                                                         xError = pdTRUE;\r
120                                                         break;\r
121                         }\r
122                 }\r
123                 else\r
124                 {\r
125                         switch( uxLED )\r
126                         {\r
127                                 case 0  :       P3 &= ~partstOUTPUT_0;\r
128                                                         break;\r
129                                 case 1  :       P3 &= ~partstOUTPUT_1;\r
130                                                         break;\r
131                                 case 2  :       P3 &= ~partstOUTPUT_2;\r
132                                                         break;\r
133                                 case 3  :       P3 &= ~partstOUTPUT_3;\r
134                                                         break;\r
135                                 case 4  :       P3 &= ~partstOUTPUT_4;\r
136                                                         break;\r
137                                 case 5  :       P3 &= ~partstOUTPUT_5;\r
138                                                         break;\r
139                                 case 6  :       P3 &= ~partstOUTPUT_6;\r
140                                                         break;\r
141                                 case 7  :       P3 &= ~partstOUTPUT_7;\r
142                                                         break;\r
143                                 default :       /* There are no other LED's wired in. */\r
144                                                         break;\r
145                         }\r
146                 }\r
147         }\r
148         xTaskResumeAll();\r
149 }\r
150 /*-----------------------------------------------------------*/\r
151 \r
152 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )\r
153 {\r
154 unsigned char ucBit;\r
155 portBASE_TYPE xError = pdFALSE;\r
156 \r
157         vTaskSuspendAll();\r
158         {\r
159                 switch( uxLED )\r
160                 {\r
161                         case 0  :       ucBit = partstOUTPUT_0;\r
162                                                 break;\r
163                         case 1  :       ucBit = partstOUTPUT_1;\r
164                                                 break;\r
165                         case 2  :       ucBit = partstOUTPUT_2;\r
166                                                 break;\r
167                         case 3  :       ucBit = partstOUTPUT_3;\r
168                                                 break;\r
169                         case 4  :       ucBit = partstOUTPUT_4;\r
170                                                 break;\r
171                         case 5  :       ucBit = partstOUTPUT_5;\r
172                                                 break;\r
173                         case 6  :       ucBit = partstOUTPUT_6;\r
174                                                 break;\r
175                         case 7  :       ucBit = partstOUTPUT_7;\r
176                                                 break;\r
177                         default :       /* There are no other LED's wired in. */\r
178                                                 xError = pdTRUE;\r
179                                                 break;\r
180                 }\r
181 \r
182                 if( xError != pdTRUE )\r
183                 {\r
184                         if( P3 & ucBit )\r
185                         {\r
186                                 P3 &= ~ucBit;\r
187                         }\r
188                         else\r
189                         {\r
190                                 P3 |= ucBit;\r
191                         }\r
192                 }\r
193         }\r
194         xTaskResumeAll();\r
195 }\r
196 \r
197 \r