]> begriffs open source - freertos/blob - Demo/PIC18_WizC/ParTest/ParTest.c
Updated to V4.0.5
[freertos] / Demo / PIC18_WizC / ParTest / ParTest.c
1 /*\r
2         FreeRTOS.org V4.0.5 - Copyright (C) 2003-2006 Richard Barry.\r
3 \r
4         This file is part of the FreeRTOS.org distribution.\r
5 \r
6         FreeRTOS.org is free software; you can redistribute it and/or modify\r
7         it under the terms of the GNU General Public License as published by\r
8         the Free Software Foundation; either version 2 of the License, or\r
9         (at your option) any later version.\r
10 \r
11         FreeRTOS.org is distributed in the hope that it will be useful,\r
12         but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14         GNU General Public License for more details.\r
15 \r
16         You should have received a copy of the GNU General Public License\r
17         along with FreeRTOS.org; if not, write to the Free Software\r
18         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
19 \r
20         A special exception to the GPL can be applied should you wish to distribute\r
21         a combined work that includes FreeRTOS.org, without being obliged to provide\r
22         the source code for any proprietary components.  See the licensing section \r
23         of http://www.FreeRTOS.org for full details of how and when the exception\r
24         can be applied.\r
25 \r
26         ***************************************************************************\r
27         See http://www.FreeRTOS.org for documentation, latest information, license \r
28         and contact details.  Please ensure to read the configuration and relevant \r
29         port sections of the online documentation.\r
30         ***************************************************************************\r
31 */\r
32 \r
33 /* \r
34 Changes from V3.0.0\r
35 \r
36 Changes from V3.0.1\r
37 */\r
38 \r
39 /* Scheduler include files. */\r
40 #include "FreeRTOS.h"\r
41 #include <task.h>\r
42 \r
43 #include "partest.h"\r
44 \r
45 /*-----------------------------------------------------------\r
46  * Simple parallel port IO routines for the FED 40pin demo board.\r
47  * The four LED's are connected to D4 to D7.\r
48  *-----------------------------------------------------------*/\r
49 \r
50 #define partstBIT_AS_OUTPUT                     ( ( unsigned portSHORT ) 0 )\r
51 #define partstSET_OUTPUT                        ( ( unsigned portSHORT ) 1 )\r
52 #define partstCLEAR_OUTPUT                      ( ( unsigned portSHORT ) 0 )\r
53 \r
54 #define partstENABLE_GENERAL_IO         ( ( unsigned portCHAR ) 7 )\r
55 \r
56 /*-----------------------------------------------------------*/\r
57 \r
58 void vParTestInitialise( void )\r
59 {\r
60         /* Set the top four bits of port D to output. */\r
61         bTRD7           = partstBIT_AS_OUTPUT;\r
62         bTRD6           = partstBIT_AS_OUTPUT;\r
63         bTRD5           = partstBIT_AS_OUTPUT;\r
64         bTRD4           = partstBIT_AS_OUTPUT;\r
65 \r
66         /* Start with all bits off. */\r
67         bRD7            = partstCLEAR_OUTPUT;\r
68         bRD6            = partstCLEAR_OUTPUT;\r
69         bRD5            = partstCLEAR_OUTPUT;\r
70         bRD4            = partstCLEAR_OUTPUT;\r
71 \r
72         /* Enable the driver. */\r
73         ADCON1          = partstENABLE_GENERAL_IO;\r
74         bTRE2           = partstBIT_AS_OUTPUT;\r
75         bRE2            = partstSET_OUTPUT;     \r
76 }\r
77 /*-----------------------------------------------------------*/\r
78 \r
79 void vParTestSetLED( unsigned portCHAR ucLED, portCHAR cValue )\r
80 {\r
81         /* We are only using the top nibble, so LED 0 corresponds to bit 4. */  \r
82         vTaskSuspendAll();\r
83         {\r
84                 switch( ucLED )\r
85                 {\r
86                         case 3  :       bRD7 = ( portSHORT ) cValue;\r
87                                                 break;\r
88                         case 2  :       bRD6 = ( portSHORT ) cValue;\r
89                                                 break;\r
90                         case 1  :       bRD5 = ( portSHORT ) cValue;\r
91                                                 break;\r
92                         case 0  :       bRD4 = ( portSHORT ) cValue;\r
93                                                 break;\r
94                         default :       /* There are only 4 LED's. */\r
95                                                 break;\r
96                 }\r
97         }\r
98         xTaskResumeAll();\r
99 }\r
100 /*-----------------------------------------------------------*/\r
101 \r
102 void vParTestToggleLED( unsigned portCHAR ucLED )\r
103 {\r
104         /* We are only using the top nibble, so LED 0 corresponds to bit 4. */  \r
105         vTaskSuspendAll();\r
106         {\r
107                 switch( ucLED )\r
108                 {\r
109                         case 3  :       bRD7 = !bRD7;\r
110                                                 break;\r
111                         case 2  :       bRD6 = !bRD6;\r
112                                                 break;\r
113                         case 1  :       bRD5 = !bRD5;\r
114                                                 break;\r
115                         case 0  :       bRD4 = !bRD4 );\r
116                                                 break;\r
117                         default :       /* There are only 4 LED's. */\r
118                                                 break;\r
119                 }\r
120         }\r
121         xTaskResumeAll();\r
122 }\r
123 \r
124 \r
125 \r