2 * FreeRTOS Kernel V10.0.0
\r
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software. If you wish to use our Amazon
\r
14 * FreeRTOS name, please do so in a fair use way that does not cause confusion.
\r
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 * http://www.FreeRTOS.org
\r
24 * http://aws.amazon.com/freertos
\r
26 * 1 tab == 4 spaces!
\r
29 /*-----------------------------------------------------------
\r
30 * Simple parallel port IO routines.
\r
31 *-----------------------------------------------------------*/
\r
33 /* Kernel includes. */
\r
34 #include "FreeRTOS.h"
\r
37 /* Fujitsu drivers/libraries. */
\r
38 #include "mb9bf506n.h"
\r
39 #include "system_mb9bf50x.h"
\r
41 /* Only the LEDs on one of the two seven segment displays are used. */
\r
42 #define partstMAX_LEDS 8
\r
44 /* The LEDs are controlled by bits 8 to 15 of the IO port. */
\r
45 #define partstLED_0_OFFSET 8
\r
47 /*-----------------------------------------------------------*/
\r
49 void vParTestInitialise( void )
\r
51 const unsigned short usGPIOState = 0xFF00U;
\r
53 /* Analog inputs are not used on the LED outputs. */
\r
54 FM3_GPIO->ADE = 0x00FF;
\r
56 /* LED seg1 to GPIO output (P18->P1F). */
\r
57 FM3_GPIO->DDR1 = 0xFF00;
\r
58 FM3_GPIO->PFR1 = 0x0000;
\r
60 /* LED seg2 to GPIO output (P30->P3F). */
\r
61 FM3_GPIO->DDR3 = 0xFF00;
\r
62 FM3_GPIO->PFR3 = 0x0000;
\r
64 /* Start with all LEDs off. */
\r
65 FM3_GPIO->PDOR3 = usGPIOState;
\r
66 FM3_GPIO->PDOR1 = usGPIOState;
\r
68 /*-----------------------------------------------------------*/
\r
70 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
\r
72 if( uxLED < partstMAX_LEDS )
\r
74 /* A critical section is used as the LEDs are also accessed from an
\r
76 taskENTER_CRITICAL();
\r
78 if( xValue == pdTRUE )
\r
80 FM3_GPIO->PDOR3 &= ~( 1UL << ( uxLED + partstLED_0_OFFSET ) );
\r
84 FM3_GPIO->PDOR3 |= ( 1UL << ( uxLED + partstLED_0_OFFSET ) );
\r
87 taskEXIT_CRITICAL();
\r
90 /*-----------------------------------------------------------*/
\r
92 void vParTestSetLEDFromISR( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
\r
94 unsigned portBASE_TYPE uxInterruptFlags;
\r
96 uxInterruptFlags = portSET_INTERRUPT_MASK_FROM_ISR();
\r
98 if( uxLED < partstMAX_LEDS )
\r
100 if( xValue == pdTRUE )
\r
102 FM3_GPIO->PDOR3 &= ~( 1UL << ( uxLED + partstLED_0_OFFSET ) );
\r
106 FM3_GPIO->PDOR3 |= ( 1UL << ( uxLED + partstLED_0_OFFSET ) );
\r
110 portCLEAR_INTERRUPT_MASK_FROM_ISR( uxInterruptFlags );
\r
112 /*-----------------------------------------------------------*/
\r
114 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
\r
116 if( uxLED < partstMAX_LEDS )
\r
118 /* A critical section is used as the LEDs are also accessed from an
\r
120 taskENTER_CRITICAL();
\r
122 if( ( FM3_GPIO->PDOR3 & ( 1UL << ( uxLED + partstLED_0_OFFSET ) ) ) != 0UL )
\r
124 FM3_GPIO->PDOR3 &= ~( 1UL << ( uxLED + partstLED_0_OFFSET ) );
\r
128 FM3_GPIO->PDOR3 |= ( 1UL << ( uxLED + partstLED_0_OFFSET ) );
\r
131 taskEXIT_CRITICAL();
\r
134 /*-----------------------------------------------------------*/
\r
136 long lParTestGetLEDState( unsigned long ulLED )
\r
138 long lReturn = pdFALSE;
\r
140 if( ulLED < partstMAX_LEDS )
\r
142 taskENTER_CRITICAL();
\r
144 if( ( FM3_GPIO->PDOR3 & ( 1UL << ( ulLED + partstLED_0_OFFSET ) ) ) == 0UL )
\r
149 taskEXIT_CRITICAL();
\r
154 /*-----------------------------------------------------------*/
\r