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