2 * FreeRTOS Kernel V10.3.1
3 * Copyright (C) 2020 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 /* Fujitsu drivers/libraries. */
37 #include "mb9bf506n.h"
38 #include "system_mb9bf50x.h"
40 /* Only the LEDs on one of the two seven segment displays are used. */
41 #define partstMAX_LEDS 8
43 /* The LEDs are controlled by bits 8 to 15 of the IO port. */
44 #define partstLED_0_OFFSET 8
46 /*-----------------------------------------------------------*/
48 void vParTestInitialise( void )
50 const unsigned short usGPIOState = 0xFF00U;
52 /* Analog inputs are not used on the LED outputs. */
53 FM3_GPIO->ADE = 0x00FF;
55 /* LED seg1 to GPIO output (P18->P1F). */
56 FM3_GPIO->DDR1 = 0xFF00;
57 FM3_GPIO->PFR1 = 0x0000;
59 /* LED seg2 to GPIO output (P30->P3F). */
60 FM3_GPIO->DDR3 = 0xFF00;
61 FM3_GPIO->PFR3 = 0x0000;
63 /* Start with all LEDs off. */
64 FM3_GPIO->PDOR3 = usGPIOState;
65 FM3_GPIO->PDOR1 = usGPIOState;
67 /*-----------------------------------------------------------*/
69 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
71 if( uxLED < partstMAX_LEDS )
73 /* A critical section is used as the LEDs are also accessed from an
77 if( xValue == pdTRUE )
79 FM3_GPIO->PDOR3 &= ~( 1UL << ( uxLED + partstLED_0_OFFSET ) );
83 FM3_GPIO->PDOR3 |= ( 1UL << ( uxLED + partstLED_0_OFFSET ) );
89 /*-----------------------------------------------------------*/
91 void vParTestSetLEDFromISR( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
93 unsigned portBASE_TYPE uxInterruptFlags;
95 uxInterruptFlags = portSET_INTERRUPT_MASK_FROM_ISR();
97 if( uxLED < partstMAX_LEDS )
99 if( xValue == pdTRUE )
101 FM3_GPIO->PDOR3 &= ~( 1UL << ( uxLED + partstLED_0_OFFSET ) );
105 FM3_GPIO->PDOR3 |= ( 1UL << ( uxLED + partstLED_0_OFFSET ) );
109 portCLEAR_INTERRUPT_MASK_FROM_ISR( uxInterruptFlags );
111 /*-----------------------------------------------------------*/
113 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
115 if( uxLED < partstMAX_LEDS )
117 /* A critical section is used as the LEDs are also accessed from an
119 taskENTER_CRITICAL();
121 if( ( FM3_GPIO->PDOR3 & ( 1UL << ( uxLED + partstLED_0_OFFSET ) ) ) != 0UL )
123 FM3_GPIO->PDOR3 &= ~( 1UL << ( uxLED + partstLED_0_OFFSET ) );
127 FM3_GPIO->PDOR3 |= ( 1UL << ( uxLED + partstLED_0_OFFSET ) );
133 /*-----------------------------------------------------------*/
135 long lParTestGetLEDState( unsigned long ulLED )
137 long lReturn = pdFALSE;
139 if( ulLED < partstMAX_LEDS )
141 taskENTER_CRITICAL();
143 if( ( FM3_GPIO->PDOR3 & ( 1UL << ( ulLED + partstLED_0_OFFSET ) ) ) == 0UL )
153 /*-----------------------------------------------------------*/