2 * FreeRTOS Kernel V10.1.1
3 * Copyright (C) 2018 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 * Characters on the LCD are used to simulate LED's. In this case the 'ParTest'
30 * is really operating on the LCD display.
31 *-----------------------------------------------------------*/
34 * This demo is configured to execute on the ES449 prototyping board from
35 * SoftBaugh. The ES449 has a built in LCD display and a single built in user
36 * LED. Therefore, in place of flashing an LED, the 'flash' and 'check' tasks
37 * toggle '*' characters on the LCD. The left most '*' represents LED 0, the
40 * There is a single genuine on board LED referenced as LED 10.
44 /* Scheduler includes. */
48 /* Demo application includes. */
51 /* Constants required to setup the LCD. */
54 /* Constants required to access the "LED's". The LED segments are turned on
55 and off to generate '*' characters. */
56 #define partstNUM_LEDS ( ( unsigned char ) 6 )
57 #define partstSEGMENTS_ON ( ( unsigned char ) 0x0f )
58 #define partstSEGMENTS_OFF ( ( unsigned char ) 0x00 )
60 /* The LED number of the real on board LED, rather than a simulated LED. */
61 #define partstON_BOARD_LED ( ( unsigned portBASE_TYPE ) 10 )
62 #define mainON_BOARD_LED_BIT ( ( unsigned char ) 0x01 )
64 /* The LCD segments used to generate the '*' characters for LED's 0 to 5. */
65 unsigned char * const ucRHSSegments[ partstNUM_LEDS ] = { ( unsigned char * )0xa4,
66 ( unsigned char * )0xa2,
67 ( unsigned char * )0xa0,
68 ( unsigned char * )0x9e,
69 ( unsigned char * )0x9c,
70 ( unsigned char * )0x9a };
72 unsigned char * const ucLHSSegments[ partstNUM_LEDS ] = { ( unsigned char * )0xa3,
73 ( unsigned char * )0xa1,
74 ( unsigned char * )0x9f,
75 ( unsigned char * )0x9d,
76 ( unsigned char * )0x9b,
77 ( unsigned char * )0x99 };
80 * Toggle the single genuine built in LED.
82 static void prvToggleOnBoardLED( void );
84 /*-----------------------------------------------------------*/
86 void vParTestInitialise( void )
88 /* Initialise the LCD hardware. */
90 /* Used for the onboard LED. */
93 // Setup Basic Timer for LCD operation
94 BTCTL = (LCD_DIV_64+0x23);
96 // Setup port functions
103 /* Initialise all segments to off. */
104 LCDM1 = partstSEGMENTS_OFF;
105 LCDM2 = partstSEGMENTS_OFF;
106 LCDM3 = partstSEGMENTS_OFF;
107 LCDM4 = partstSEGMENTS_OFF;
108 LCDM5 = partstSEGMENTS_OFF;
109 LCDM6 = partstSEGMENTS_OFF;
110 LCDM7 = partstSEGMENTS_OFF;
111 LCDM8 = partstSEGMENTS_OFF;
112 LCDM9 = partstSEGMENTS_OFF;
113 LCDM10 = partstSEGMENTS_OFF;
114 LCDM11 = partstSEGMENTS_OFF;
115 LCDM12 = partstSEGMENTS_OFF;
116 LCDM13 = partstSEGMENTS_OFF;
117 LCDM14 = partstSEGMENTS_OFF;
118 LCDM15 = partstSEGMENTS_OFF;
119 LCDM16 = partstSEGMENTS_OFF;
120 LCDM17 = partstSEGMENTS_OFF;
121 LCDM18 = partstSEGMENTS_OFF;
122 LCDM19 = partstSEGMENTS_OFF;
123 LCDM20 = partstSEGMENTS_OFF;
125 /* Setup LCD control. */
126 LCDCTL = (LCDSG0_7|LCD4MUX|LCDON);
128 /*-----------------------------------------------------------*/
130 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
132 /* Set or clear the output [in this case show or hide the '*' character. */
133 if( uxLED < ( portBASE_TYPE ) partstNUM_LEDS )
139 /* Turn on the segments required to show the '*'. */
140 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
141 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
145 /* Turn off all the segments. */
146 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
147 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
153 /*-----------------------------------------------------------*/
155 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
157 if( uxLED < ( portBASE_TYPE ) partstNUM_LEDS )
161 /* If the '*' is already showing - hide it. If it is not already
162 showing then show it. */
163 if( *( ucRHSSegments[ uxLED ] ) )
165 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
166 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
170 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
171 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
178 if( uxLED == partstON_BOARD_LED )
180 /* The request related to the genuine on board LED. */
181 prvToggleOnBoardLED();
185 /*-----------------------------------------------------------*/
187 static void prvToggleOnBoardLED( void )
189 static unsigned short sState = pdFALSE;
191 /* Toggle the state of the single genuine on board LED. */
194 P1OUT |= mainON_BOARD_LED_BIT;
198 P1OUT &= ~mainON_BOARD_LED_BIT;
203 /*-----------------------------------------------------------*/