]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/H8S/RTOSDemo/ParTest/ParTest.c
Update copyright date ready for tagging V10.1.0.
[freertos] / FreeRTOS / Demo / H8S / RTOSDemo / ParTest / ParTest.c
1 /*\r
2  * FreeRTOS Kernel V10.1.0\r
3  * Copyright (C) 2018 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 /* Scheduler include files. */\r
29 #include "FreeRTOS.h"\r
30 #include "portable.h"\r
31 \r
32 /* Demo application include files. */\r
33 #include "partest.h"\r
34 \r
35 /*-----------------------------------------------------------\r
36  * Simple parallel port IO routines.\r
37  *\r
38  * This is for the demo application which uses port 2 for LED outputs.\r
39  *-----------------------------------------------------------*/\r
40 \r
41 /* Value for the LED to be off. */\r
42 #define partstLED_OUTPUTS               ( ( unsigned char ) 0xff )\r
43 \r
44 /* P2.0 is not used as an output so there are only 7 LEDs on port 2. */\r
45 #define partstMAX_LEDs                  ( 7 )\r
46 #define partstALL_OUTPUTS_OFF   ( ( unsigned char ) 0 )\r
47 \r
48 /* Maps the LED outputs used by the standard demo application files to\r
49 convenient outputs for the EDK2329.  Mainly this insures that the LED\r
50 used by the Check task is one of the on board LEDs so the demo can be\r
51 executed on an EDK without any modification. */\r
52 static inline unsigned char prvMapLED( unsigned portBASE_TYPE uxLED );\r
53 \r
54 /*-----------------------------------------------------------*/\r
55 \r
56 void vParTestInitialise( void )\r
57 {\r
58         /* LED's are connected to port 2.  P2.1 and P2.2 are built onto the EDK.\r
59         P2.3 to P2.7 are soldered onto the expansion port. */\r
60         P2DDR = partstLED_OUTPUTS;\r
61         P2DR = partstALL_OUTPUTS_OFF;\r
62 }\r
63 /*-----------------------------------------------------------*/\r
64 \r
65 /*\r
66  * Described at the top of the file.\r
67  */\r
68 static inline unsigned char prvMapLED( unsigned portBASE_TYPE uxLED )\r
69 {\r
70         switch( uxLED )\r
71         {\r
72                 case 0  :       return ( unsigned char ) 2;\r
73                 case 1  :       return ( unsigned char ) 3;\r
74                 case 2  :       return ( unsigned char ) 4;\r
75                 case 3  :       return ( unsigned char ) 5;\r
76                 case 4  :       return ( unsigned char ) 6;\r
77                 case 5  :       return ( unsigned char ) 0;\r
78                 case 6  :       return ( unsigned char ) 1;\r
79                 default :       return 0;\r
80         }\r
81 }\r
82 /*-----------------------------------------------------------*/\r
83 \r
84 /*\r
85  * Turn an LED on or off.\r
86  */\r
87 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )\r
88 {\r
89 unsigned char ucLED;\r
90 \r
91         if( uxLED < partstMAX_LEDs )\r
92         {\r
93                 ucLED = prvMapLED( uxLED );\r
94 \r
95                 /* Set a bit in the required LED position.  LED 0 is bit 1. */\r
96                 ucLED = ( unsigned char ) 1 << ( ucLED + 1 );\r
97 \r
98                 if( xValue )\r
99                 {\r
100                         portENTER_CRITICAL();\r
101                                 P2DR |= ucLED;\r
102                         portEXIT_CRITICAL();\r
103                 }\r
104                 else\r
105                 {\r
106                         portENTER_CRITICAL();\r
107                                 P2DR &= ~ucLED;\r
108                         portEXIT_CRITICAL();\r
109                 }               \r
110         }\r
111 }\r
112 /*-----------------------------------------------------------*/\r
113 \r
114 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )\r
115 {\r
116 unsigned char ucLED;\r
117 \r
118         if( uxLED < partstMAX_LEDs )\r
119         {\r
120                 ucLED = prvMapLED( uxLED );\r
121 \r
122                 /* Set a bit in the required LED position.  LED 0 is bit 1. */\r
123                 ucLED = ( unsigned char ) 1 << ( ucLED + 1 );\r
124 \r
125                 portENTER_CRITICAL();\r
126                 {\r
127                         if( P2DR & ucLED )\r
128                         {\r
129                                 P2DR &= ~ucLED;\r
130                         }\r
131                         else\r
132                         {\r
133                                 P2DR |= ucLED;\r
134                         }\r
135                 }\r
136                 portEXIT_CRITICAL();\r
137         }       \r
138 }\r
139 \r
140 \r
141 \r