]> begriffs open source - cmsis-freertos/blob - Demo/CORTEX_LPC1768_GCC_Rowley/ParTest.c
This is a FreeRTOS header, not RTX.
[cmsis-freertos] / Demo / CORTEX_LPC1768_GCC_Rowley / ParTest.c
1 /*
2  * FreeRTOS Kernel V10.0.1
3  * Copyright (C) 2017 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 /* FreeRTOS.org includes. */
29 #include "FreeRTOS.h"
30
31 /* Demo application includes. */
32 #include "partest.h"
33
34 #define partstFIRST_IO                  ( ( unsigned long ) 0x04 )
35 #define partstFIO2_BITS                 ( ( unsigned long ) 0x0000007C )
36 #define partstFIO1_BITS                 ( ( unsigned long ) 0xB0000000 )
37 #define partstNUM_LEDS                  ( 5 )
38 #define partstALL_OUTPUTS_OFF   ( ( unsigned long ) 0xff )
39
40 /*-----------------------------------------------------------
41  * Simple parallel port IO routines.
42  *-----------------------------------------------------------*/
43
44 void vParTestInitialise( void )
45 {
46         /* LEDs on ports 1 and 2 to output. */
47         GPIO2->FIODIR  = partstFIO2_BITS;
48     GPIO1->FIODIR  = partstFIO1_BITS;
49
50         /* Start will all LEDs off. */
51     GPIO2->FIOCLR = partstFIO2_BITS;
52     GPIO1->FIOCLR = partstFIO1_BITS;
53 }
54 /*-----------------------------------------------------------*/
55
56 void vParTestSetLED( unsigned long ulLEDIn, signed long xValue )
57 {
58 unsigned long ulLED = partstFIRST_IO;
59
60         /* Used to set and clear LEDs on FIO2. */
61
62         if( ulLEDIn < partstNUM_LEDS )
63         {
64                 /* Rotate to the wanted bit of port */
65                 ulLED <<= ( unsigned long ) ulLEDIn;
66
67                 /* Set of clear the output. */
68                 if( xValue )
69                 {
70                         GPIO2->FIOCLR = ulLED;
71                 }
72                 else
73                 {
74                         GPIO2->FIOSET = ulLED;
75                 }
76         }
77 }
78 /*-----------------------------------------------------------*/
79
80 void vParTestToggleLED( unsigned long ulLEDIn )
81 {
82 unsigned long ulLED = partstFIRST_IO, ulCurrentState;
83
84         /* Used to toggle LEDs on FIO2. */
85
86         if( ulLEDIn < partstNUM_LEDS )
87         {
88                 /* Rotate to the wanted bit of port 0.  Only P10 to P13 have an LED
89                 attached. */
90                 ulLED <<= ( unsigned long ) ulLEDIn;
91
92                 /* If this bit is already set, clear it, and vice versa. */
93                 ulCurrentState = GPIO2->FIOPIN;
94                 if( ulCurrentState & ulLED )
95                 {
96                         GPIO2->FIOCLR = ulLED;
97                 }
98                 else
99                 {
100                         GPIO2->FIOSET = ulLED;
101                 }
102         }
103 }
104 /*-----------------------------------------------------------*/
105
106 long lParTestGetLEDState( void )
107 {
108         /* Returns the state of the LEDs on FIO1. */
109         if( ( GPIO1->FIOPIN & partstFIO1_BITS ) != 0 )
110         {
111                 return pdFALSE;
112         }
113         else
114         {
115                 return pdTRUE;
116         }
117 }
118 /*-----------------------------------------------------------*/
119
120 void vParTestSetLEDState( long lState )
121 {
122         /* Used to set and clear the LEDs on FIO1. */
123         if( lState != pdFALSE )
124         {
125                 GPIO1->FIOSET = partstFIO1_BITS;
126         }
127         else
128         {
129                 GPIO1->FIOCLR = partstFIO1_BITS;
130         }
131 }
132 /*-----------------------------------------------------------*/
133