]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/PIC18_WizC/ParTest/ParTest.c
0f80beb9a30a38332a7bc30242554ec1fbf331ba
[freertos] / FreeRTOS / Demo / PIC18_WizC / ParTest / ParTest.c
1 /*\r
2  * FreeRTOS Kernel V10.3.0\r
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 /* \r
29 Changes from V3.0.0\r
30 \r
31 Changes from V3.0.1\r
32 */\r
33 \r
34 /* Scheduler include files. */\r
35 #include "FreeRTOS.h"\r
36 #include <task.h>\r
37 \r
38 #include "partest.h"\r
39 \r
40 /*-----------------------------------------------------------\r
41  * Simple parallel port IO routines for the FED 40pin demo board.\r
42  * The four LED's are connected to D4 to D7.\r
43  *-----------------------------------------------------------*/\r
44 \r
45 #define partstBIT_AS_OUTPUT                     ( ( unsigned short ) 0 )\r
46 #define partstSET_OUTPUT                        ( ( unsigned short ) 1 )\r
47 #define partstCLEAR_OUTPUT                      ( ( unsigned short ) 0 )\r
48 \r
49 #define partstENABLE_GENERAL_IO         ( ( unsigned char ) 7 )\r
50 \r
51 /*-----------------------------------------------------------*/\r
52 \r
53 void vParTestInitialise( void )\r
54 {\r
55         /* Set the top four bits of port D to output. */\r
56         bTRD7           = partstBIT_AS_OUTPUT;\r
57         bTRD6           = partstBIT_AS_OUTPUT;\r
58         bTRD5           = partstBIT_AS_OUTPUT;\r
59         bTRD4           = partstBIT_AS_OUTPUT;\r
60 \r
61         /* Start with all bits off. */\r
62         bRD7            = partstCLEAR_OUTPUT;\r
63         bRD6            = partstCLEAR_OUTPUT;\r
64         bRD5            = partstCLEAR_OUTPUT;\r
65         bRD4            = partstCLEAR_OUTPUT;\r
66 \r
67         /* Enable the driver. */\r
68         ADCON1          = partstENABLE_GENERAL_IO;\r
69         bTRE2           = partstBIT_AS_OUTPUT;\r
70         bRE2            = partstSET_OUTPUT;     \r
71 }\r
72 /*-----------------------------------------------------------*/\r
73 \r
74 void vParTestSetLED( unsigned char ucLED, char cValue )\r
75 {\r
76         /* We are only using the top nibble, so LED 0 corresponds to bit 4. */  \r
77         vTaskSuspendAll();\r
78         {\r
79                 switch( ucLED )\r
80                 {\r
81                         case 3  :       bRD7 = ( short ) cValue;\r
82                                                 break;\r
83                         case 2  :       bRD6 = ( short ) cValue;\r
84                                                 break;\r
85                         case 1  :       bRD5 = ( short ) cValue;\r
86                                                 break;\r
87                         case 0  :       bRD4 = ( short ) cValue;\r
88                                                 break;\r
89                         default :       /* There are only 4 LED's. */\r
90                                                 break;\r
91                 }\r
92         }\r
93         xTaskResumeAll();\r
94 }\r
95 /*-----------------------------------------------------------*/\r
96 \r
97 void vParTestToggleLED( unsigned char ucLED )\r
98 {\r
99         /* We are only using the top nibble, so LED 0 corresponds to bit 4. */  \r
100         vTaskSuspendAll();\r
101         {\r
102                 switch( ucLED )\r
103                 {\r
104                         case 3  :       bRD7 = !bRD7;\r
105                                                 break;\r
106                         case 2  :       bRD6 = !bRD6;\r
107                                                 break;\r
108                         case 1  :       bRD5 = !bRD5;\r
109                                                 break;\r
110                         case 0  :       bRD4 = !bRD4 );\r
111                                                 break;\r
112                         default :       /* There are only 4 LED's. */\r
113                                                 break;\r
114                 }\r
115         }\r
116         xTaskResumeAll();\r
117 }\r
118 \r
119 \r
120 \r