]> begriffs open source - cmsis-freertos/blob - Demo/CORTEX_LM3S102_GCC/ParTest/ParTest.c
Update README.md - branch main is now the base branch
[cmsis-freertos] / Demo / CORTEX_LM3S102_GCC / ParTest / ParTest.c
1 /*
2  * FreeRTOS V202111.00
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://www.FreeRTOS.org
23  * http://aws.amazon.com/freertos
24  *
25  * 1 tab == 4 spaces!
26  */
27
28 /*-----------------------------------------------------------
29  * Simple parallel port IO routines.
30  *-----------------------------------------------------------*/
31
32 /*
33 */
34
35
36 #include "FreeRTOS.h"
37 #include "task.h"
38 #include "partest.h"
39
40 #include "pdc.h"
41
42 #define partstPINS      (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 Z | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7)
43
44 #define partstALL_OUTPUTS_OFF   ( ( unsigned char ) 0x00 )
45 #define partstMAX_OUTPUT_LED    ( ( unsigned char ) 8 )
46
47 static volatile unsigned char ucOutputValue = partstALL_OUTPUTS_OFF;
48
49 void vParTestInitialise( void )
50 {
51         PDCInit();
52         PDCWrite( PDC_LED, ucOutputValue );
53 }
54 /*-----------------------------------------------------------*/
55
56 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
57 {
58 unsigned char ucBit = ( unsigned char ) 1;
59
60         vTaskSuspendAll();
61         {
62                 if( uxLED < partstMAX_OUTPUT_LED )
63                 {
64                         ucBit = ( ( unsigned char ) 1 ) << uxLED;
65
66                         if( xValue == pdFALSE )
67                         {
68                                 ucBit ^= ( unsigned char ) 0xff;
69                                 ucOutputValue &= ucBit;
70                         }
71                         else
72                         {
73                                 ucOutputValue |= ucBit;
74                         }
75
76                         PDCWrite( PDC_LED, ucOutputValue );
77                 }       
78         }
79         xTaskResumeAll();
80 }
81 /*-----------------------------------------------------------*/
82
83 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
84 {
85 unsigned char ucBit;
86
87         vTaskSuspendAll();
88         {
89                 if( uxLED < partstMAX_OUTPUT_LED )
90                 {
91                         ucBit = ( ( unsigned char ) 1 ) << uxLED;
92
93                         if( ucOutputValue & ucBit )
94                         {
95                                 ucOutputValue &= ~ucBit;
96                         }
97                         else
98                         {
99                                 ucOutputValue |= ucBit;
100                         }
101
102                         PDCWrite( PDC_LED, ucOutputValue );
103                 }
104         }
105         xTaskResumeAll();
106 }
107