2 FreeRTOS.org V4.1.0 - Copyright (C) 2003-2006 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
30 ***************************************************************************
\r
33 /*-----------------------------------------------------------
\r
34 * Simple parallel port IO routines.
\r
35 *-----------------------------------------------------------*/
\r
37 /* Kernel includes. */
\r
38 #include "FreeRTOS.h"
\r
40 /* Demo application includes. */
\r
41 #include "partest.h"
\r
43 /* Library includes. */
\r
44 #include "xgpio_l.h"
\r
46 /* Misc hardware specific definitions. */
\r
47 #define partstALL_AS_OUTPUT 0x00
\r
48 #define partstCHANNEL_1 0x01
\r
49 #define partstMAX_4BIT_LED 0x03
\r
51 /* The outputs are split into two IO sections, these variables maintain the
\r
52 current value of either section. */
\r
53 static unsigned portBASE_TYPE uxCurrentOutput4Bit, uxCurrentOutput5Bit;
\r
55 /*-----------------------------------------------------------*/
\r
57 * Setup the IO for the LED outputs.
\r
59 void vParTestInitialise( void )
\r
61 /* Set both sets of LED's on the demo board to outputs. */
\r
62 XGpio_mSetDataDirection( XPAR_LEDS_4BIT_BASEADDR, partstCHANNEL_1, partstALL_AS_OUTPUT );
\r
63 XGpio_mSetDataDirection( XPAR_LEDS_POSITIONS_BASEADDR, partstCHANNEL_1, partstALL_AS_OUTPUT );
\r
65 /* Start with all outputs off. */
\r
66 uxCurrentOutput4Bit = 0;
\r
67 XGpio_mSetDataReg( XPAR_LEDS_4BIT_BASEADDR, partstCHANNEL_1, 0x00 );
\r
68 uxCurrentOutput5Bit = 0;
\r
69 XGpio_mSetDataReg( XPAR_LEDS_POSITIONS_BASEADDR, partstCHANNEL_1, 0x00 );
\r
71 /*-----------------------------------------------------------*/
\r
73 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
\r
75 unsigned portBASE_TYPE uxBaseAddress, *puxCurrentValue;
\r
77 portENTER_CRITICAL();
\r
79 /* Which IO section does the LED being set/cleared belong to? The
\r
80 4 bit or 5 bit outputs? */
\r
81 if( uxLED <= partstMAX_4BIT_LED )
\r
83 uxBaseAddress = XPAR_LEDS_4BIT_BASEADDR;
\r
84 puxCurrentValue = &uxCurrentOutput4Bit;
\r
88 uxBaseAddress = XPAR_LEDS_POSITIONS_BASEADDR;
\r
89 puxCurrentValue = &uxCurrentOutput5Bit;
\r
90 uxLED -= partstMAX_4BIT_LED;
\r
93 /* Setup the bit mask accordingly. */
\r
94 uxLED = 0x01 << uxLED;
\r
96 /* Maintain the current output value. */
\r
99 *puxCurrentValue |= uxLED;
\r
103 *puxCurrentValue &= ~uxLED;
\r
106 /* Write the value to the port. */
\r
107 XGpio_mSetDataReg( uxBaseAddress, partstCHANNEL_1, *puxCurrentValue );
\r
109 portEXIT_CRITICAL();
\r
111 /*-----------------------------------------------------------*/
\r
113 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
\r
115 unsigned portBASE_TYPE uxBaseAddress, *puxCurrentValue;
\r
117 portENTER_CRITICAL();
\r
119 /* Which IO section does the LED being toggled belong to? The
\r
120 4 bit or 5 bit outputs? */
\r
121 if( uxLED <= partstMAX_4BIT_LED )
\r
123 uxBaseAddress = XPAR_LEDS_4BIT_BASEADDR;
\r
124 puxCurrentValue = &uxCurrentOutput4Bit;
\r
128 uxBaseAddress = XPAR_LEDS_POSITIONS_BASEADDR;
\r
129 puxCurrentValue = &uxCurrentOutput5Bit;
\r
130 uxLED -= partstMAX_4BIT_LED;
\r
133 /* Setup the bit mask accordingly. */
\r
134 uxLED = 0x01 << uxLED;
\r
136 /* Maintain the current output value. */
\r
137 if( *puxCurrentValue & uxLED )
\r
139 *puxCurrentValue &= ~uxLED;
\r
143 *puxCurrentValue |= uxLED;
\r
146 /* Write the value to the port. */
\r
147 XGpio_mSetDataReg(uxBaseAddress, partstCHANNEL_1, *puxCurrentValue );
\r
149 portEXIT_CRITICAL();
\r