2 * FreeRTOS Kernel V10.2.1
3 * Copyright (C) 2019 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 /*-----------------------------------------------------------
29 * Simple parallel port IO routines.
30 *-----------------------------------------------------------*/
32 /* Kernel includes. */
36 /* Library includes. */
39 #define partstMAX_LEDS 8
41 static volatile unsigned long ulGPIOState = 0UL;
43 /*-----------------------------------------------------------*/
45 void vParTestInitialise( void )
49 /* Initialise the GPIO */
52 /* Set up GPIO for the LEDs. */
53 for( x = 0; x < partstMAX_LEDS; x++ )
55 MSS_GPIO_config( ( mss_gpio_id_t ) x , MSS_GPIO_OUTPUT_MODE );
58 /* All LEDs start off. */
59 ulGPIOState = 0xffffffffUL;
60 MSS_GPIO_set_outputs( ulGPIOState );
62 /*-----------------------------------------------------------*/
64 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
66 if( uxLED < partstMAX_LEDS )
68 /* A critical section is used as the LEDs are also accessed from an
72 if( xValue == pdTRUE )
74 ulGPIOState &= ~( 1UL << uxLED );
78 ulGPIOState |= ( 1UL << uxLED );
81 MSS_GPIO_set_outputs( ulGPIOState );
86 /*-----------------------------------------------------------*/
88 void vParTestSetLEDFromISR( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
90 unsigned portBASE_TYPE uxInterruptFlags;
92 uxInterruptFlags = portSET_INTERRUPT_MASK_FROM_ISR();
94 if( uxLED < partstMAX_LEDS )
96 if( xValue == pdTRUE )
98 ulGPIOState &= ~( 1UL << uxLED );
102 ulGPIOState |= ( 1UL << uxLED );
105 MSS_GPIO_set_outputs( ulGPIOState );
108 portCLEAR_INTERRUPT_MASK_FROM_ISR( uxInterruptFlags );
110 /*-----------------------------------------------------------*/
112 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
114 if( uxLED < partstMAX_LEDS )
116 /* A critical section is used as the LEDs are also accessed from an
118 taskENTER_CRITICAL();
120 if( ( ulGPIOState & ( 1UL << uxLED ) ) != 0UL )
122 ulGPIOState &= ~( 1UL << uxLED );
126 ulGPIOState |= ( 1UL << uxLED );
129 MSS_GPIO_set_outputs( ulGPIOState );
134 /*-----------------------------------------------------------*/
136 long lParTestGetLEDState( unsigned long ulLED )
138 long lReturn = pdFALSE;
140 if( ulLED < partstMAX_LEDS )
142 taskENTER_CRITICAL();
144 if( ( ulGPIOState & ( 1UL << ulLED ) ) == 0UL )
154 /*-----------------------------------------------------------*/