2 * FreeRTOS Kernel V10.0.1
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
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.
22 * http://www.FreeRTOS.org
23 * http://aws.amazon.com/freertos
28 /* FreeRTOS.org includes. */
31 /* Demo application includes. */
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 )
40 /*-----------------------------------------------------------
41 * Simple parallel port IO routines.
42 *-----------------------------------------------------------*/
44 void vParTestInitialise( void )
46 /* LEDs on ports 1 and 2 to output. */
47 GPIO2->FIODIR = partstFIO2_BITS;
48 GPIO1->FIODIR = partstFIO1_BITS;
50 /* Start will all LEDs off. */
51 GPIO2->FIOCLR = partstFIO2_BITS;
52 GPIO1->FIOCLR = partstFIO1_BITS;
54 /*-----------------------------------------------------------*/
56 void vParTestSetLED( unsigned long ulLEDIn, signed long xValue )
58 unsigned long ulLED = partstFIRST_IO;
60 /* Used to set and clear LEDs on FIO2. */
62 if( ulLEDIn < partstNUM_LEDS )
64 /* Rotate to the wanted bit of port */
65 ulLED <<= ( unsigned long ) ulLEDIn;
67 /* Set of clear the output. */
70 GPIO2->FIOCLR = ulLED;
74 GPIO2->FIOSET = ulLED;
78 /*-----------------------------------------------------------*/
80 void vParTestToggleLED( unsigned long ulLEDIn )
82 unsigned long ulLED = partstFIRST_IO, ulCurrentState;
84 /* Used to toggle LEDs on FIO2. */
86 if( ulLEDIn < partstNUM_LEDS )
88 /* Rotate to the wanted bit of port 0. Only P10 to P13 have an LED
90 ulLED <<= ( unsigned long ) ulLEDIn;
92 /* If this bit is already set, clear it, and vice versa. */
93 ulCurrentState = GPIO2->FIOPIN;
94 if( ulCurrentState & ulLED )
96 GPIO2->FIOCLR = ulLED;
100 GPIO2->FIOSET = ulLED;
104 /*-----------------------------------------------------------*/
106 long lParTestGetLEDState( void )
108 /* Returns the state of the LEDs on FIO1. */
109 if( ( GPIO1->FIOPIN & partstFIO1_BITS ) != 0 )
118 /*-----------------------------------------------------------*/
120 void vParTestSetLEDState( long lState )
122 /* Used to set and clear the LEDs on FIO1. */
123 if( lState != pdFALSE )
125 GPIO1->FIOSET = partstFIO1_BITS;
129 GPIO1->FIOCLR = partstFIO1_BITS;
132 /*-----------------------------------------------------------*/