]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/ARM7_STR71x_IAR/ParTest/ParTest.c
d76e6c93a59662ce8bb7d3d503e611f20ea8120a
[freertos] / FreeRTOS / Demo / ARM7_STR71x_IAR / ParTest / ParTest.c
1 /*\r
2  * FreeRTOS Kernel V10.0.0\r
3  * Copyright (C) 2017 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. If you wish to use our Amazon\r
14  * FreeRTOS name, please do so in a fair use way that does not cause confusion.\r
15  *\r
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
22  *\r
23  * http://www.FreeRTOS.org\r
24  * http://aws.amazon.com/freertos\r
25  *\r
26  * 1 tab == 4 spaces!\r
27  */\r
28 \r
29 /* Library includes. */\r
30 #include "GPIO.h"\r
31 \r
32 /* Scheduler includes. */\r
33 #include "FreeRTOS.h"\r
34 \r
35 /* Demo application includes. */\r
36 #include "partest.h"\r
37 \r
38 /*-----------------------------------------------------------\r
39  * Simple parallel port IO routines for the LED's - which are\r
40  * connected to the second nibble of GPIO port 1.\r
41  *-----------------------------------------------------------*/\r
42 \r
43 #define partstLED_3             0x0080\r
44 #define partstLED_2             0x0040\r
45 #define partstLED_1             0x0020\r
46 #define partstLED_0             0x0010\r
47 #define partstON_BOARD  0x0100  /* The LED built onto the KickStart board. */\r
48 \r
49 #define partstALL_LEDs  ( partstLED_0 | partstLED_1 | partstLED_2 | partstLED_3 | partstON_BOARD )\r
50 \r
51 #define partstFIRST_LED_BIT 4\r
52 \r
53 /* This demo application uses files that are common to all port demo \r
54 applications.  These files assume 6 LED's are available, whereas I have\r
55 only 5 (including the LED built onto the development board).  To prevent\r
56 two tasks trying to use the same LED a bit of remapping is performed. \r
57 The ComTest tasks will try and use LED's 6 and 7.  LED 6 is ignored and\r
58 has no effect, LED 7 is mapped to LED3.   The LED usage is described in\r
59 the port documentation available from the FreeRTOS.org WEB site. */\r
60 #define partstCOM_TEST_LED      7\r
61 #define partstRX_CHAR_LED       3\r
62 \r
63 /*-----------------------------------------------------------*/\r
64 \r
65 void vParTestInitialise( void )\r
66 {       \r
67     /* Configure the bits used to flash LED's on port 1 as output. */\r
68     GPIO_Config(GPIO1, partstALL_LEDs, GPIO_OUT_OD);\r
69 }\r
70 /*-----------------------------------------------------------*/\r
71 \r
72 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )\r
73 {\r
74         if( uxLED == partstCOM_TEST_LED )\r
75         {\r
76                 /* Remap as described above. */\r
77                 uxLED = partstRX_CHAR_LED;\r
78         }\r
79 \r
80         /* Adjust the LED value to map to the port pins actually being used,\r
81         then write the required value to the port. */\r
82         uxLED += partstFIRST_LED_BIT;\r
83     GPIO_BitWrite( GPIO1, uxLED, !xValue );\r
84 }\r
85 /*-----------------------------------------------------------*/\r
86 \r
87 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )\r
88 {\r
89         if( uxLED == partstCOM_TEST_LED )\r
90         {\r
91                 /* Remap as described above. */\r
92                 uxLED = partstRX_CHAR_LED;\r
93         }\r
94 \r
95         /* Adjust the LED value to map to the port pins actually being used,\r
96         then write the opposite value to the current state to the port pin. */\r
97         uxLED += partstFIRST_LED_BIT;\r
98     GPIO_BitWrite(GPIO1, uxLED, ~GPIO_BitRead( GPIO1, uxLED ) );\r
99 }\r
100 \r
101 \r
102 \r
103 \r