blob: 6b5017cce8c5a297f50000a9e92ce7ca9856a23c [file] [log] [blame]
Richard Barry6456c002006-10-20 15:12:17 +00001/*
Richard Barry83686002009-07-07 09:29:47 +00002 FreeRTOS.org V5.4.0 - Copyright (C) 2003-2009 Richard Barry.
Richard Barry6456c002006-10-20 15:12:17 +00003
4 This file is part of the FreeRTOS.org distribution.
5
Richard Barryc0126512009-05-30 15:56:05 +00006 FreeRTOS.org is free software; you can redistribute it and/or modify it
Richard Barry2f40ad72009-03-14 19:20:12 +00007 under the terms of the GNU General Public License (version 2) as published
8 by the Free Software Foundation and modified by the FreeRTOS exception.
Richard Barryc0126512009-05-30 15:56:05 +00009 **NOTE** The exception to the GPL is included to allow you to distribute a
10 combined work that includes FreeRTOS.org without being obliged to provide
11 the source code for any proprietary components. Alternative commercial
12 license and support terms are also available upon request. See the
13 licensing section of http://www.FreeRTOS.org for full details.
Richard Barry6456c002006-10-20 15:12:17 +000014
Richard Barry2f40ad72009-03-14 19:20:12 +000015 FreeRTOS.org is distributed in the hope that it will be useful, but WITHOUT
Richard Barryc0126512009-05-30 15:56:05 +000016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
Richard Barry2f40ad72009-03-14 19:20:12 +000018 more details.
Richard Barry6456c002006-10-20 15:12:17 +000019
Richard Barryc0126512009-05-30 15:56:05 +000020 You should have received a copy of the GNU General Public License along
21 with FreeRTOS.org; if not, write to the Free Software Foundation, Inc., 59
Richard Barry2f40ad72009-03-14 19:20:12 +000022 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
Richard Barry6456c002006-10-20 15:12:17 +000023
Richard Barry2f40ad72009-03-14 19:20:12 +000024
25 ***************************************************************************
26 * *
27 * Get the FreeRTOS eBook! See http://www.FreeRTOS.org/Documentation *
Richard Barry52ba0e62009-02-09 20:21:35 +000028 * *
29 * This is a concise, step by step, 'hands on' guide that describes both *
30 * general multitasking concepts and FreeRTOS specifics. It presents and *
31 * explains numerous examples that are written using the FreeRTOS API. *
32 * Full source code for all the examples is provided in an accompanying *
33 * .zip file. *
Richard Barry2f40ad72009-03-14 19:20:12 +000034 * *
35 ***************************************************************************
36
37 1 tab == 4 spaces!
Richard Barry0a6d59a2007-04-01 20:47:49 +000038
Richard Barry527fb6a2008-03-25 21:22:13 +000039 Please ensure to read the configuration and relevant port sections of the
Richard Barryc86dcf72008-02-03 19:45:58 +000040 online documentation.
41
Richard Barry2f40ad72009-03-14 19:20:12 +000042 http://www.FreeRTOS.org - Documentation, latest information, license and
Richard Barry527fb6a2008-03-25 21:22:13 +000043 contact details.
Richard Barryc86dcf72008-02-03 19:45:58 +000044
Richard Barry2f40ad72009-03-14 19:20:12 +000045 http://www.SafeRTOS.com - A version that is certified for use in safety
Richard Barry527fb6a2008-03-25 21:22:13 +000046 critical systems.
Richard Barryc86dcf72008-02-03 19:45:58 +000047
Richard Barry2f40ad72009-03-14 19:20:12 +000048 http://www.OpenRTOS.com - Commercial support, development, porting,
Richard Barry527fb6a2008-03-25 21:22:13 +000049 licensing and training services.
Richard Barry6456c002006-10-20 15:12:17 +000050*/
51
52/* Library includes. */
53#include "75x_GPIO.h"
54#include "75x_map.h"
55
56/* Scheduler includes. */
57#include "FreeRTOS.h"
58
59/* Demo application includes. */
60#include "partest.h"
61
62/*-----------------------------------------------------------
Richard Barryc1d020f2006-10-20 15:32:33 +000063 * Simple parallel port IO routines for the LED's
Richard Barry6456c002006-10-20 15:12:17 +000064 *-----------------------------------------------------------*/
65
Richard Barry6456c002006-10-20 15:12:17 +000066#define partstNUM_LEDS 4
67
68typedef struct GPIOMAP
69{
70 GPIO_TypeDef *pxPort;
71 unsigned portLONG ulPin;
72 unsigned portLONG ulValue;
73} GPIO_MAP;
74
75static GPIO_MAP xLEDMap[ partstNUM_LEDS ] =
76{
77 { ( GPIO_TypeDef * )GPIO1_BASE, GPIO_Pin_1, 0UL },
78 { ( GPIO_TypeDef * )GPIO0_BASE, GPIO_Pin_16, 0UL },
79 { ( GPIO_TypeDef * )GPIO2_BASE, GPIO_Pin_18, 0UL },
Richard Barryc1d020f2006-10-20 15:32:33 +000080 { ( GPIO_TypeDef * )GPIO2_BASE, GPIO_Pin_19, 0UL }
Richard Barry6456c002006-10-20 15:12:17 +000081};
82
83/*-----------------------------------------------------------*/
Richard Barry6456c002006-10-20 15:12:17 +000084
85void vParTestInitialise( void )
86{
Richard Barryc1d020f2006-10-20 15:32:33 +000087GPIO_InitTypeDef GPIO_InitStructure ;
88
Richard Barry6456c002006-10-20 15:12:17 +000089 /* Configure the bits used to flash LED's on port 1 as output. */
Richard Barryc1d020f2006-10-20 15:32:33 +000090
91 /* Configure LED3 */
92 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
93 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_16;
94 GPIO_Init(GPIO0,&GPIO_InitStructure);
95
96 /* Configure LED2 */
97 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
98 GPIO_Init(GPIO1, &GPIO_InitStructure);
99
100 /* Configure LED4 and LED5 */
101 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_18 | GPIO_Pin_19;
102 GPIO_Init(GPIO2, &GPIO_InitStructure);
Richard Barry6456c002006-10-20 15:12:17 +0000103
104 vParTestSetLED( 0, 0 );
105 vParTestSetLED( 1, 0 );
106 vParTestSetLED( 2, 0 );
107 vParTestSetLED( 3, 0 );
108}
109/*-----------------------------------------------------------*/
110
111void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
112{
113 if( uxLED < partstNUM_LEDS )
114 {
Richard Barryc1d020f2006-10-20 15:32:33 +0000115 portENTER_CRITICAL();
Richard Barry6456c002006-10-20 15:12:17 +0000116 {
Richard Barryc1d020f2006-10-20 15:32:33 +0000117 if( xValue )
118 {
119 GPIO_WriteBit( xLEDMap[ uxLED ].pxPort, xLEDMap[ uxLED ].ulPin, Bit_RESET );
120 xLEDMap[ uxLED ].ulValue = 0;
121 }
122 else
123 {
124 GPIO_WriteBit( xLEDMap[ uxLED ].pxPort, xLEDMap[ uxLED ].ulPin, Bit_SET );
125 xLEDMap[ uxLED ].ulValue = 1;
126 }
Richard Barry6456c002006-10-20 15:12:17 +0000127 }
Richard Barryc1d020f2006-10-20 15:32:33 +0000128 portEXIT_CRITICAL();
Richard Barry6456c002006-10-20 15:12:17 +0000129 }
130}
131/*-----------------------------------------------------------*/
132
133void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
134{
135 if( uxLED < partstNUM_LEDS )
136 {
Richard Barryc1d020f2006-10-20 15:32:33 +0000137 portENTER_CRITICAL();
Richard Barry6456c002006-10-20 15:12:17 +0000138 {
Richard Barryc1d020f2006-10-20 15:32:33 +0000139 if( xLEDMap[ uxLED ].ulValue == 1 )
140 {
141 GPIO_WriteBit( xLEDMap[ uxLED ].pxPort, xLEDMap[ uxLED ].ulPin, Bit_RESET );
142 xLEDMap[ uxLED ].ulValue = 0;
143 }
144 else
145 {
146 GPIO_WriteBit( xLEDMap[ uxLED ].pxPort, xLEDMap[ uxLED ].ulPin, Bit_SET );
147 xLEDMap[ uxLED ].ulValue = 1;
148 }
Richard Barry6456c002006-10-20 15:12:17 +0000149 }
Richard Barryc1d020f2006-10-20 15:32:33 +0000150 portEXIT_CRITICAL();
Richard Barry6456c002006-10-20 15:12:17 +0000151 }
152}
153
154
155
156