2 * FreeRTOS Kernel V10.4.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 * 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.
43 /* Standard includes. */
46 /* Scheduler includes. */
50 /* Demo application includes. */
53 /* Constants required to setup the LCD. */
56 /* Constants required to access the "LED's". The LED segments are turned on
57 and off to generate '*' characters. */
58 #define partstNUM_LEDS ( ( unsigned char ) 6 )
59 #define partstSEGMENTS_ON ( ( unsigned char ) 0x0f )
60 #define partstSEGMENTS_OFF ( ( unsigned char ) 0x00 )
62 /* The LED number of the real on board LED, rather than a simulated LED. */
63 #define partstON_BOARD_LED ( ( unsigned portBASE_TYPE ) 10 )
64 #define mainON_BOARD_LED_BIT ( ( unsigned char ) 0x01 )
66 /* The LCD segments used to generate the '*' characters for LED's 0 to 5. */
67 unsigned char * const ucRHSSegments[ partstNUM_LEDS ] = { ( unsigned char * )0xa4,
68 ( unsigned char * )0xa2,
69 ( unsigned char * )0xa0,
70 ( unsigned char * )0x9e,
71 ( unsigned char * )0x9c,
72 ( unsigned char * )0x9a };
74 unsigned char * const ucLHSSegments[ partstNUM_LEDS ] = { ( unsigned char * )0xa3,
75 ( unsigned char * )0xa1,
76 ( unsigned char * )0x9f,
77 ( unsigned char * )0x9d,
78 ( unsigned char * )0x9b,
79 ( unsigned char * )0x99 };
82 * Toggle the single genuine built in LED.
84 static void prvToggleOnBoardLED( void );
86 /*-----------------------------------------------------------*/
88 void vParTestInitialise( void )
90 /* Initialise the LCD hardware. */
92 /* Used for the onboard LED. */
95 // Setup Basic Timer for LCD operation
96 BTCTL = (LCD_DIV_64+0x23);
98 // Setup port functions
105 /* Initialise all segments to off. */
106 LCDM1 = partstSEGMENTS_OFF;
107 LCDM2 = partstSEGMENTS_OFF;
108 LCDM3 = partstSEGMENTS_OFF;
109 LCDM4 = partstSEGMENTS_OFF;
110 LCDM5 = partstSEGMENTS_OFF;
111 LCDM6 = partstSEGMENTS_OFF;
112 LCDM7 = partstSEGMENTS_OFF;
113 LCDM8 = partstSEGMENTS_OFF;
114 LCDM9 = partstSEGMENTS_OFF;
115 LCDM10 = partstSEGMENTS_OFF;
116 LCDM11 = partstSEGMENTS_OFF;
117 LCDM12 = partstSEGMENTS_OFF;
118 LCDM13 = partstSEGMENTS_OFF;
119 LCDM14 = partstSEGMENTS_OFF;
120 LCDM15 = partstSEGMENTS_OFF;
121 LCDM16 = partstSEGMENTS_OFF;
122 LCDM17 = partstSEGMENTS_OFF;
123 LCDM18 = partstSEGMENTS_OFF;
124 LCDM19 = partstSEGMENTS_OFF;
125 LCDM20 = partstSEGMENTS_OFF;
127 /* Setup LCD control. */
128 LCDCTL = (LCDSG0_7|LCD4MUX|LCDON);
130 /*-----------------------------------------------------------*/
132 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
134 /* Set or clear the output [in this case show or hide the '*' character. */
135 if( uxLED < ( portBASE_TYPE ) partstNUM_LEDS )
141 /* Turn on the segments required to show the '*'. */
142 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
143 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
147 /* Turn off all the segments. */
148 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
149 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
155 /*-----------------------------------------------------------*/
157 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
159 if( uxLED < ( portBASE_TYPE ) partstNUM_LEDS )
163 /* If the '*' is already showing - hide it. If it is not already
164 showing then show it. */
165 if( *( ucRHSSegments[ uxLED ] ) )
167 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
168 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
172 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
173 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
180 if( uxLED == partstON_BOARD_LED )
182 /* The request related to the genuine on board LED. */
183 prvToggleOnBoardLED();
187 /*-----------------------------------------------------------*/
189 static void prvToggleOnBoardLED( void )
191 static unsigned short sState = pdFALSE;
193 /* Toggle the state of the single genuine on board LED. */
196 P1OUT |= mainON_BOARD_LED_BIT;
200 P1OUT &= ~mainON_BOARD_LED_BIT;
205 /*-----------------------------------------------------------*/