]> begriffs open source - freertos/blob - Demo/lwIP_AVR32_UC3/PARTEST/ParTest.c
Add AVR32 port and demo files.
[freertos] / Demo / lwIP_AVR32_UC3 / PARTEST / ParTest.c
1 /* This source file is part of the ATMEL FREERTOS-0.9.0 Release */\r
2 \r
3 /*This file has been prepared for Doxygen automatic documentation generation.*/\r
4 /*! \file *********************************************************************\r
5  *\r
6  * \brief FreeRTOS Led Driver example for AVR32 UC3.\r
7  *\r
8  * - Compiler:           IAR EWAVR32 and GNU GCC for AVR32\r
9  * - Supported devices:  All AVR32 devices can be used.\r
10  * - AppNote:\r
11  *\r
12  * \author               Atmel Corporation: http://www.atmel.com \n\r
13  *                       Support email: avr32@atmel.com\r
14  *\r
15  *****************************************************************************/\r
16 \r
17 /* Copyright (c) 2007, Atmel Corporation All rights reserved.\r
18  *\r
19  * Redistribution and use in source and binary forms, with or without\r
20  * modification, are permitted provided that the following conditions are met:\r
21  *\r
22  * 1. Redistributions of source code must retain the above copyright notice,\r
23  * this list of conditions and the following disclaimer.\r
24  *\r
25  * 2. Redistributions in binary form must reproduce the above copyright notice,\r
26  * this list of conditions and the following disclaimer in the documentation\r
27  * and/or other materials provided with the distribution.\r
28  *\r
29  * 3. The name of ATMEL may not be used to endorse or promote products derived\r
30  * from this software without specific prior written permission.\r
31  *\r
32  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED\r
33  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
34  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND\r
35  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,\r
36  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
37  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
38  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
39  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
40  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
41  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
42  */\r
43 \r
44 \r
45 #if __GNUC__\r
46 #  include <avr32/io.h>\r
47 #elif __ICCAVR32__\r
48 #  include <avr32/iouc3a0512.h>\r
49 #else\r
50 #  error Unknown compiler\r
51 #endif\r
52 \r
53 #include "FreeRTOS.h"\r
54 #include "task.h"\r
55 #include "partest.h"\r
56 \r
57 \r
58 /*-----------------------------------------------------------\r
59  * Simple parallel port IO routines.\r
60  *-----------------------------------------------------------*/\r
61 \r
62 #define partstALL_OUTPUTS_OFF     ( ( unsigned portCHAR ) 0x00 )\r
63 #define partstMAX_OUTPUT_LED      ( ( unsigned portCHAR ) 8 )\r
64 \r
65 static volatile unsigned portCHAR ucCurrentOutputValue = partstALL_OUTPUTS_OFF; /*lint !e956 File scope parameters okay here. */\r
66 \r
67 /*-----------------------------------------------------------*/\r
68 \r
69 void vParTestInitialise( void )\r
70 {\r
71         LED_Display(partstALL_OUTPUTS_OFF); /* Start with all LEDs off. */\r
72 }\r
73 /*-----------------------------------------------------------*/\r
74 \r
75 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )\r
76 {\r
77 unsigned portCHAR ucBit;\r
78 \r
79         if( uxLED >= partstMAX_OUTPUT_LED )\r
80         {\r
81                 return;\r
82         }\r
83 \r
84         ucBit = ( ( unsigned portCHAR ) 1 ) << uxLED;\r
85 \r
86         vTaskSuspendAll();\r
87         {\r
88                 if( xValue == pdTRUE )\r
89                 {\r
90                   ucCurrentOutputValue |= ucBit;\r
91                 }\r
92                 else\r
93                 {\r
94                   ucCurrentOutputValue &= ~ucBit;\r
95                 }\r
96 \r
97                 LED_Display(ucCurrentOutputValue);\r
98         }\r
99         xTaskResumeAll();\r
100 }\r
101 /*-----------------------------------------------------------*/\r
102 \r
103 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )\r
104 {\r
105         unsigned portCHAR ucBit;\r
106 \r
107         if( uxLED >= partstMAX_OUTPUT_LED )\r
108         {\r
109                 return;\r
110         }\r
111 \r
112         ucBit = ( ( unsigned portCHAR ) 1 ) << uxLED;\r
113 \r
114         vTaskSuspendAll();\r
115         {\r
116                 ucCurrentOutputValue ^= ucBit;\r
117                 LED_Display(ucCurrentOutputValue);\r
118         }\r
119         xTaskResumeAll();\r
120 }\r
121 \r