]> begriffs open source - cmsis-freertos/blob - Demo/ARM7_STR75x_IAR/ParTest/ParTest.c
Update cmsis_os2.c
[cmsis-freertos] / Demo / ARM7_STR75x_IAR / ParTest / ParTest.c
1 /*
2     FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
3     All rights reserved
4
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
6
7     This file is part of the FreeRTOS distribution.
8
9     FreeRTOS is free software; you can redistribute it and/or modify it under
10     the terms of the GNU General Public License (version 2) as published by the
11     Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
12
13     ***************************************************************************
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<
16     >>!   obliged to provide the source code for proprietary components     !<<
17     >>!   outside of the FreeRTOS kernel.                                   !<<
18     ***************************************************************************
19
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following
23     link: http://www.freertos.org/a00114.html
24
25     ***************************************************************************
26      *                                                                       *
27      *    FreeRTOS provides completely free yet professionally developed,    *
28      *    robust, strictly quality controlled, supported, and cross          *
29      *    platform software that is more than just the market leader, it     *
30      *    is the industry's de facto standard.                               *
31      *                                                                       *
32      *    Help yourself get started quickly while simultaneously helping     *
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *
34      *    tutorial book, reference manual, or both:                          *
35      *    http://www.FreeRTOS.org/Documentation                              *
36      *                                                                       *
37     ***************************************************************************
38
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading
40     the FAQ page "My application does not run, what could be wrong?".  Have you
41     defined configASSERT()?
42
43     http://www.FreeRTOS.org/support - In return for receiving this top quality
44     embedded software for free we request you assist our global community by
45     participating in the support forum.
46
47     http://www.FreeRTOS.org/training - Investing in training allows your team to
48     be as productive as possible as early as possible.  Now you can receive
49     FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
50     Ltd, and the world's leading authority on the world's leading RTOS.
51
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.
55
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
58
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS
61     licenses offer ticketed support, indemnification and commercial middleware.
62
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety
64     engineered and independently SIL3 certified version for use in safety and
65     mission critical applications that require provable dependability.
66
67     1 tab == 4 spaces!
68 */
69
70 /* Library includes. */
71 #include "75x_GPIO.h"
72 #include "75x_map.h"
73
74 /* Scheduler includes. */
75 #include "FreeRTOS.h"
76
77 /* Demo application includes. */
78 #include "partest.h"
79
80 /*-----------------------------------------------------------
81  * Simple parallel port IO routines for the LED's 
82  *-----------------------------------------------------------*/
83
84 #define partstNUM_LEDS  4
85
86 typedef struct GPIOMAP
87 {
88         GPIO_TypeDef    *pxPort;
89         unsigned long ulPin;
90         unsigned long ulValue;
91 } GPIO_MAP;
92
93 static GPIO_MAP xLEDMap[ partstNUM_LEDS ] =
94 {
95         { ( GPIO_TypeDef        * )GPIO1_BASE, GPIO_Pin_1, 0UL },
96         { ( GPIO_TypeDef        * )GPIO0_BASE, GPIO_Pin_16, 0UL },
97         { ( GPIO_TypeDef        * )GPIO2_BASE, GPIO_Pin_18, 0UL },      
98         { ( GPIO_TypeDef        * )GPIO2_BASE, GPIO_Pin_19, 0UL }       
99 };
100
101 /*-----------------------------------------------------------*/
102
103 void vParTestInitialise( void )
104 {       
105 GPIO_InitTypeDef GPIO_InitStructure ;
106
107     /* Configure the bits used to flash LED's on port 1 as output. */
108
109         /* Configure LED3 */
110         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
111         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_16;
112         GPIO_Init(GPIO0,&GPIO_InitStructure);
113
114         /* Configure LED2 */
115         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
116         GPIO_Init(GPIO1, &GPIO_InitStructure);
117
118         /* Configure LED4 and LED5 */
119         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_18 | GPIO_Pin_19;
120         GPIO_Init(GPIO2, &GPIO_InitStructure);
121
122         vParTestSetLED( 0, 0 );
123         vParTestSetLED( 1, 0 );
124         vParTestSetLED( 2, 0 );
125         vParTestSetLED( 3, 0 );
126 }
127 /*-----------------------------------------------------------*/
128
129 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
130 {
131         if( uxLED < partstNUM_LEDS )
132         {
133                 portENTER_CRITICAL();
134                 {
135                         if( xValue )
136                         {
137                                 GPIO_WriteBit( xLEDMap[ uxLED ].pxPort, xLEDMap[ uxLED ].ulPin, Bit_RESET );
138                                 xLEDMap[ uxLED ].ulValue = 0;
139                         }
140                         else
141                         {
142                                 GPIO_WriteBit( xLEDMap[ uxLED ].pxPort, xLEDMap[ uxLED ].ulPin, Bit_SET );
143                                 xLEDMap[ uxLED ].ulValue = 1;                   
144                         }
145                 }
146                 portEXIT_CRITICAL();
147         }
148 }
149 /*-----------------------------------------------------------*/
150
151 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
152 {
153         if( uxLED < partstNUM_LEDS )
154         {
155                 portENTER_CRITICAL();
156                 {
157                         if( xLEDMap[ uxLED ].ulValue == 1 )
158                         {
159                                 GPIO_WriteBit( xLEDMap[ uxLED ].pxPort, xLEDMap[ uxLED ].ulPin, Bit_RESET );
160                                 xLEDMap[ uxLED ].ulValue = 0;
161                         }
162                         else
163                         {
164                                 GPIO_WriteBit( xLEDMap[ uxLED ].pxPort, xLEDMap[ uxLED ].ulPin, Bit_SET );
165                                 xLEDMap[ uxLED ].ulValue = 1;                   
166                         }
167                 }
168                 portEXIT_CRITICAL();
169         }
170 }
171
172
173
174