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 ( 8 ) |
---|
56 |
#define partstALL_OUTPUTS_OFF ( ( unsigned portLONG ) 0xff ) |
---|
57 |
|
---|
58 |
/*----------------------------------------------------------- |
---|
59 |
* Simple parallel port IO routines. |
---|
60 |
*-----------------------------------------------------------*/ |
---|
61 |
|
---|
62 |
void vParTestInitialise( void ) |
---|
63 |
{ |
---|
64 |
PINSEL10 = 0; |
---|
65 |
FIO2DIR = 0x000000FF; |
---|
66 |
FIO2MASK = 0x00000000; |
---|
67 |
FIO2CLR = 0xFF; |
---|
68 |
SCS |= (1<<0); //fast mode for port 0 and 1 |
---|
69 |
|
---|
70 |
FIO2CLR = partstALL_OUTPUTS_OFF; |
---|
71 |
} |
---|
72 |
/*-----------------------------------------------------------*/ |
---|
73 |
|
---|
74 |
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) |
---|
75 |
{ |
---|
76 |
unsigned portLONG ulLED = partstFIRST_IO; |
---|
77 |
|
---|
78 |
if( uxLED < partstNUM_LEDS ) |
---|
79 |
{ |
---|
80 |
/* Rotate to the wanted bit of port */ |
---|
81 |
ulLED <<= ( unsigned portLONG ) uxLED; |
---|
82 |
|
---|
83 |
/* Set of clear the output. */ |
---|
84 |
if( xValue ) |
---|
85 |
{ |
---|
86 |
FIO2CLR = ulLED; |
---|
87 |
} |
---|
88 |
else |
---|
89 |
{ |
---|
90 |
FIO2SET = ulLED; |
---|
91 |
} |
---|
92 |
} |
---|
93 |
} |
---|
94 |
/*-----------------------------------------------------------*/ |
---|
95 |
|
---|
96 |
void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) |
---|
97 |
{ |
---|
98 |
unsigned portLONG ulLED = partstFIRST_IO, ulCurrentState; |
---|
99 |
|
---|
100 |
if( uxLED < partstNUM_LEDS ) |
---|
101 |
{ |
---|
102 |
/* Rotate to the wanted bit of port 0. Only P10 to P13 have an LED |
---|
103 |
attached. */ |
---|
104 |
ulLED <<= ( unsigned portLONG ) uxLED; |
---|
105 |
|
---|
106 |
/* If this bit is already set, clear it, and visa versa. */ |
---|
107 |
ulCurrentState = FIO2PIN; |
---|
108 |
if( ulCurrentState & ulLED ) |
---|
109 |
{ |
---|
110 |
FIO2CLR = ulLED; |
---|
111 |
} |
---|
112 |
else |
---|
113 |
{ |
---|
114 |
FIO2SET = ulLED; |
---|
115 |
} |
---|
116 |
} |
---|
117 |
} |
---|
118 |
|
---|
119 |
/*-----------------------------------------------------------*/ |
---|
120 |
unsigned portBASE_TYPE uxParTextGetLED( unsigned portBASE_TYPE uxLED ) |
---|
121 |
{ |
---|
122 |
unsigned portLONG ulLED = partstFIRST_IO; |
---|
123 |
|
---|
124 |
ulLED <<= ( unsigned portLONG ) uxLED; |
---|
125 |
|
---|
126 |
return ( FIO2PIN & ulLED ); |
---|
127 |
} |
---|
128 |
|
---|
129 |
|
---|