root/webserver/example/freeRTOS/Demo/ARM7_LPC2368_Rowley/ParTest/ParTest.c

Revision 17, 5.1 kB (checked in by phil, 15 years ago)

adaptated example for LED flash to ETT eval board with 1 LED flashing,
changed portable.h to rowley setup
etc.

Line 
1 /*
2         FreeRTOS V5.4.1 - Copyright (C) 2009 Real Time Engineers Ltd.
3
4         This file is part of the FreeRTOS distribution.
5
6         FreeRTOS is free software; you can redistribute it and/or modify it     under
7         the terms of the GNU General Public License (version 2) as published by the
8         Free Software Foundation and modified by the FreeRTOS exception.
9         **NOTE** The exception to the GPL is included to allow you to distribute a
10         combined work that includes FreeRTOS without being obliged to provide the
11         source code for proprietary components outside of the FreeRTOS kernel. 
12         Alternative commercial license and support terms are also available upon
13         request.  See the licensing section of http://www.FreeRTOS.org for full
14         license details.
15
16         FreeRTOS is distributed in the hope that it will be useful,     but WITHOUT
17         ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18         FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
19         more details.
20
21         You should have received a copy of the GNU General Public License along
22         with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
23         Temple Place, Suite 330, Boston, MA  02111-1307  USA.
24
25
26         ***************************************************************************
27         *                                                                         *
28         * Looking for a quick start?  Then check out the FreeRTOS eBook!          *
29         * See http://www.FreeRTOS.org/Documentation for details                   *
30         *                                                                         *
31         ***************************************************************************
32
33         1 tab == 4 spaces!
34
35         Please ensure to read the configuration and relevant port sections of the
36         online documentation.
37
38         http://www.FreeRTOS.org - Documentation, latest information, license and
39         contact details.
40
41         http://www.SafeRTOS.com - A version that is certified for use in safety
42         critical systems.
43
44         http://www.OpenRTOS.com - Commercial support, development, porting,
45         licensing and training services.
46 */
47
48 /* FreeRTOS.org includes. */
49 #include "FreeRTOS.h"
50
51 /* Demo application includes. */
52 #include "partest.h"
53
54 #define partstFIRST_IO                  ( ( unsigned portLONG ) 0x01 )
55 #define partstNUM_LEDS                  ( 2 )
56 #define partstALL_OUTPUTS_OFF   ( ( unsigned portLONG ) 0xff )
57
58 // Pin I/O LED Control Maskbit
59 #define  LED1       0x02000000                                                          // P3.25(0000 00x0 0000 0000 0000 0000 0000 0000)
60 #define  LED2       0x04000000                                                          // P3.26(0000 0x00 0000 0000 0000 0000 0000 0000)
61
62 #define  LED1_ON()  FIO3CLR = LED1                                              // LED1 Pin = 0 (ON LED)
63 #define  LED1_OFF() FIO3SET = LED1                                                      // LED1 Pin = 1 (OFF LED)
64 #define  LED2_ON()  FIO3CLR = LED2                                                      // LED2 Pin = 0 (ON LED)
65 #define  LED2_OFF() FIO3SET = LED2                                                      // LED2 Pin = 1 (OFF LED)
66
67 int led_1_state;
68 int led_2_state;
69
70
71 /*-----------------------------------------------------------
72  * Simple parallel port IO routines.
73  *-----------------------------------------------------------*/
74
75 void vParTestInitialise( void )
76 {
77
78  // Config Pin GPIO3[26:25]   
79   PINSEL7  &= 0xFFC3FFFF;                                                                       // P3[26:25] = GPIO Function(xxxx xxxx xx00 00xx xxxx xxxx xxxx xxxx)
80   PINMODE7 &= 0xFFC3FFFF;                                                                       // Enable Puul-Up on P3[26:25]
81    
82   FIO3DIR  |= LED1;                                                                     // Set GPIO-3[26:25] = Output(xxxx x11x xxxx xxxx xxxx xxxx xxxx xxxx)
83   FIO3DIR  |= LED2;
84   LED1_OFF();                                                                                           // Default LED Status
85   LED2_OFF();
86
87 //      PINSEL10 = 0;
88 //      FIO2DIR  = 0x000000FF;
89 //      FIO2MASK = 0x00000000;
90 //      FIO2CLR  = 0xFF;
91 //      SCS |= (1<<0); //fast mode for port 0 and 1
92
93 //    FIO2CLR = partstALL_OUTPUTS_OFF;
94 }
95 /*-----------------------------------------------------------*/
96
97 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
98 {
99 unsigned portLONG ulLED = partstFIRST_IO;
100 #if 0
101         if( uxLED < partstNUM_LEDS )
102         {
103                 /* Rotate to the wanted bit of port */
104                 ulLED <<= ( unsigned portLONG ) uxLED;
105
106                 /* Set of clear the output. */
107                 if( xValue )
108                 {
109                         FIO2CLR = ulLED;
110                 }
111                 else
112                 {
113                         FIO2SET = ulLED;
114                 }
115         }
116 #endif
117 }
118 /*-----------------------------------------------------------*/
119
120 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
121 {
122 unsigned portLONG ulLED = partstFIRST_IO, ulCurrentState;
123
124
125     if (led_1_state == 0)
126     {
127       LED1_ON();
128
129       led_1_state = 1;
130     }
131       else
132     {
133       LED1_OFF();
134       led_1_state = 0;
135     }
136
137
138 #if 0
139         if( uxLED < partstNUM_LEDS )
140         {
141                 /* Rotate to the wanted bit of port 0.  Only P10 to P13 have an LED
142                 attached. */
143                 ulLED <<= ( unsigned portLONG ) uxLED;
144
145                 /* If this bit is already set, clear it, and visa versa. */
146                 ulCurrentState = FIO2PIN;
147                 if( ulCurrentState & ulLED )
148                 {
149                         FIO2CLR = ulLED;
150                 }
151                 else
152                 {
153                         FIO2SET = ulLED;                       
154                 }
155         }       
156 #endif
157 }
158
159 /*-----------------------------------------------------------*/
160 unsigned portBASE_TYPE uxParTextGetLED( unsigned portBASE_TYPE uxLED )
161 {
162 #if 0
163 unsigned portLONG ulLED = partstFIRST_IO;
164    
165     ulLED <<= ( unsigned portLONG ) uxLED;
166
167     return ( FIO2PIN & ulLED );
168 #endif
169         return 0;
170 }
171
172
Note: See TracBrowser for help on using the browser.