]> begriffs open source - cmsis-freertos/blob - Demo/MB96350_Softune_Dice_Kit/ParTest/ParTest.c
Update cmsis_os2.c
[cmsis-freertos] / Demo / MB96350_Softune_Dice_Kit / 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 /*-----------------------------------------------------------
71  * Simple parallel port IO routines.
72  *-----------------------------------------------------------*/
73
74 /* FreeRTOS includes. */
75 #include "FreeRTOS.h"
76 #include "task.h"
77
78 /* Demo includes. */
79 #include "partest.h"
80
81 #define partstTOTAL_NUM_LEDs            16
82 #define partstNUM_LEDs_PER_DISPLAY      8
83
84 volatile unsigned char *pucDisplayOutput[ 2 ] = { ( unsigned char * ) 3, ( unsigned char * ) 5 };
85
86 void vParTestInitialise( void )
87 {
88         /* In this case all the initialisation is performed in prvSetupHardware()
89         in main.c. */   
90 }
91 /*-----------------------------------------------------------*/
92
93 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
94 {
95 unsigned portBASE_TYPE uxLEDMask = 0x01;
96
97         if( uxLED < partstNUM_LEDs_PER_DISPLAY )
98         {
99                 uxLEDMask <<= uxLED;
100                 
101                 taskENTER_CRITICAL();
102                 {
103                         if( xValue )
104                         {
105                                 *pucDisplayOutput[ 0 ] &= ~uxLEDMask;
106                         }
107                         else
108                         {
109                                 *pucDisplayOutput[ 0 ] |= uxLEDMask;                            
110                         }
111                 }
112                 taskEXIT_CRITICAL();
113         }
114         else if( uxLED < partstTOTAL_NUM_LEDs )
115         {
116                 uxLED -= partstNUM_LEDs_PER_DISPLAY;
117
118                 uxLEDMask <<= uxLED;
119                 
120                 taskENTER_CRITICAL();
121                 {
122                         if( xValue )
123                         {
124                                 *pucDisplayOutput[ 1 ] &= ~uxLEDMask;
125                         }
126                         else
127                         {
128                                 *pucDisplayOutput[ 1 ] |= uxLEDMask;                            
129                         }
130                 }
131                 taskEXIT_CRITICAL();
132         }
133 }
134 /*-----------------------------------------------------------*/
135
136 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
137 {
138 unsigned portBASE_TYPE uxLEDMask = 0x01;
139
140         if( uxLED < partstNUM_LEDs_PER_DISPLAY )
141         {
142                 uxLEDMask <<= uxLED;
143                 
144                 taskENTER_CRITICAL();
145                 {
146                         if( *pucDisplayOutput[ 0 ] & uxLEDMask )
147                         {
148                                 *pucDisplayOutput[ 0 ] &= ~uxLEDMask;
149                         }
150                         else
151                         {
152                                 *pucDisplayOutput[ 0 ] |= uxLEDMask;
153                         }
154                 }
155                 taskEXIT_CRITICAL();
156         }
157         else if( uxLED < partstTOTAL_NUM_LEDs )
158         {
159                 uxLED -= partstNUM_LEDs_PER_DISPLAY;
160
161                 uxLEDMask <<= uxLED;
162                 
163                 taskENTER_CRITICAL();
164                 {
165                         if( *pucDisplayOutput[ 1 ] & uxLEDMask )
166                         {
167                                 *pucDisplayOutput[ 1 ] &= ~uxLEDMask;
168                         }
169                         else
170                         {
171                                 *pucDisplayOutput[ 1 ] |= uxLEDMask;
172                         }
173                 }
174                 taskEXIT_CRITICAL();
175         }
176 }
177
178
179
180