2 FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
\r
4 This file is part of the FreeRTOS.org distribution.
\r
6 FreeRTOS.org is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 FreeRTOS.org is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with FreeRTOS.org; if not, write to the Free Software
\r
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
20 A special exception to the GPL can be applied should you wish to distribute
\r
21 a combined work that includes FreeRTOS.org, without being obliged to provide
\r
22 the source code for any proprietary components. See the licensing section
\r
23 of http://www.FreeRTOS.org for full details of how and when the exception
\r
26 ***************************************************************************
\r
27 See http://www.FreeRTOS.org for documentation, latest information, license
\r
28 and contact details. Please ensure to read the configuration and relevant
\r
29 port sections of the online documentation.
\r
31 Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
\r
32 with commercial development and support options.
\r
33 ***************************************************************************
\r
36 /*-----------------------------------------------------------
\r
37 * Simple parallel port IO routines.
\r
38 *-----------------------------------------------------------*/
\r
40 /* Kernel includes. */
\r
41 #include "FreeRTOS.h"
\r
43 /* Demo application includes. */
\r
44 #include "partest.h"
\r
46 /* Library includes. */
\r
47 #include "xgpio_l.h"
\r
49 /* Misc hardware specific definitions. */
\r
50 #define partstALL_AS_OUTPUT 0x00
\r
51 #define partstCHANNEL_1 0x01
\r
52 #define partstMAX_4BIT_LED 0x03
\r
54 /* The outputs are split into two IO sections, these variables maintain the
\r
55 current value of either section. */
\r
56 static unsigned portBASE_TYPE uxCurrentOutput4Bit, uxCurrentOutput5Bit;
\r
58 /*-----------------------------------------------------------*/
\r
60 * Setup the IO for the LED outputs.
\r
62 void vParTestInitialise( void )
\r
64 /* Set both sets of LED's on the demo board to outputs. */
\r
65 XGpio_mSetDataDirection( XPAR_LEDS_4BIT_BASEADDR, partstCHANNEL_1, partstALL_AS_OUTPUT );
\r
66 XGpio_mSetDataDirection( XPAR_LEDS_POSITIONS_BASEADDR, partstCHANNEL_1, partstALL_AS_OUTPUT );
\r
68 /* Start with all outputs off. */
\r
69 uxCurrentOutput4Bit = 0;
\r
70 XGpio_mSetDataReg( XPAR_LEDS_4BIT_BASEADDR, partstCHANNEL_1, 0x00 );
\r
71 uxCurrentOutput5Bit = 0;
\r
72 XGpio_mSetDataReg( XPAR_LEDS_POSITIONS_BASEADDR, partstCHANNEL_1, 0x00 );
\r
74 /*-----------------------------------------------------------*/
\r
76 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
\r
78 unsigned portBASE_TYPE uxBaseAddress, *puxCurrentValue;
\r
80 portENTER_CRITICAL();
\r
82 /* Which IO section does the LED being set/cleared belong to? The
\r
83 4 bit or 5 bit outputs? */
\r
84 if( uxLED <= partstMAX_4BIT_LED )
\r
86 uxBaseAddress = XPAR_LEDS_4BIT_BASEADDR;
\r
87 puxCurrentValue = &uxCurrentOutput4Bit;
\r
91 uxBaseAddress = XPAR_LEDS_POSITIONS_BASEADDR;
\r
92 puxCurrentValue = &uxCurrentOutput5Bit;
\r
93 uxLED -= partstMAX_4BIT_LED;
\r
96 /* Setup the bit mask accordingly. */
\r
97 uxLED = 0x01 << uxLED;
\r
99 /* Maintain the current output value. */
\r
102 *puxCurrentValue |= uxLED;
\r
106 *puxCurrentValue &= ~uxLED;
\r
109 /* Write the value to the port. */
\r
110 XGpio_mSetDataReg( uxBaseAddress, partstCHANNEL_1, *puxCurrentValue );
\r
112 portEXIT_CRITICAL();
\r
114 /*-----------------------------------------------------------*/
\r
116 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
\r
118 unsigned portBASE_TYPE uxBaseAddress, *puxCurrentValue;
\r
120 portENTER_CRITICAL();
\r
122 /* Which IO section does the LED being toggled belong to? The
\r
123 4 bit or 5 bit outputs? */
\r
124 if( uxLED <= partstMAX_4BIT_LED )
\r
126 uxBaseAddress = XPAR_LEDS_4BIT_BASEADDR;
\r
127 puxCurrentValue = &uxCurrentOutput4Bit;
\r
131 uxBaseAddress = XPAR_LEDS_POSITIONS_BASEADDR;
\r
132 puxCurrentValue = &uxCurrentOutput5Bit;
\r
133 uxLED -= partstMAX_4BIT_LED;
\r
136 /* Setup the bit mask accordingly. */
\r
137 uxLED = 0x01 << uxLED;
\r
139 /* Maintain the current output value. */
\r
140 if( *puxCurrentValue & uxLED )
\r
142 *puxCurrentValue &= ~uxLED;
\r
146 *puxCurrentValue |= uxLED;
\r
149 /* Write the value to the port. */
\r
150 XGpio_mSetDataReg(uxBaseAddress, partstCHANNEL_1, *puxCurrentValue );
\r
152 portEXIT_CRITICAL();
\r