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 * Characters on the LCD are used to simulate LED's. In this case the 'ParTest'
\r
31 * is really operating on the LCD display.
\r
32 *-----------------------------------------------------------*/
\r
35 * This demo is configured to execute on the ES449 prototyping board from
\r
36 * SoftBaugh. The ES449 has a built in LCD display and a single built in user
\r
37 * LED. Therefore, in place of flashing an LED, the 'flash' and 'check' tasks
\r
38 * toggle '*' characters on the LCD. The left most '*' represents LED 0, the
\r
41 * There is a single genuine on board LED referenced as LED 10.
\r
44 /* Standard includes. */
\r
47 /* Scheduler includes. */
\r
48 #include "FreeRTOS.h"
\r
51 /* Demo application includes. */
\r
52 #include "partest.h"
\r
54 /* Constants required to setup the LCD. */
\r
55 #define LCD_DIV_64 5
\r
57 /* Constants required to access the "LED's". The LED segments are turned on
\r
58 and off to generate '*' characters. */
\r
59 #define partstNUM_LEDS ( ( unsigned char ) 6 )
\r
60 #define partstSEGMENTS_ON ( ( unsigned char ) 0x0f )
\r
61 #define partstSEGMENTS_OFF ( ( unsigned char ) 0x00 )
\r
63 /* The LED number of the real on board LED, rather than a simulated LED. */
\r
64 #define partstON_BOARD_LED ( ( unsigned portBASE_TYPE ) 10 )
\r
65 #define mainON_BOARD_LED_BIT ( ( unsigned char ) 0x01 )
\r
67 /* The LCD segments used to generate the '*' characters for LED's 0 to 5. */
\r
68 unsigned char * const ucRHSSegments[ partstNUM_LEDS ] = { ( unsigned char * )0xa4,
\r
69 ( unsigned char * )0xa2,
\r
70 ( unsigned char * )0xa0,
\r
71 ( unsigned char * )0x9e,
\r
72 ( unsigned char * )0x9c,
\r
73 ( unsigned char * )0x9a };
\r
75 unsigned char * const ucLHSSegments[ partstNUM_LEDS ] = { ( unsigned char * )0xa3,
\r
76 ( unsigned char * )0xa1,
\r
77 ( unsigned char * )0x9f,
\r
78 ( unsigned char * )0x9d,
\r
79 ( unsigned char * )0x9b,
\r
80 ( unsigned char * )0x99 };
\r
83 * Toggle the single genuine built in LED.
\r
85 static void prvToggleOnBoardLED( void );
\r
87 /*-----------------------------------------------------------*/
\r
89 void vParTestInitialise( void )
\r
91 /* Initialise the LCD hardware. */
\r
93 /* Used for the onboard LED. */
\r
96 // Setup Basic Timer for LCD operation
\r
97 BTCTL = (LCD_DIV_64+0x23);
\r
99 // Setup port functions
\r
106 /* Initialise all segments to off. */
\r
107 LCDM1 = partstSEGMENTS_OFF;
\r
108 LCDM2 = partstSEGMENTS_OFF;
\r
109 LCDM3 = partstSEGMENTS_OFF;
\r
110 LCDM4 = partstSEGMENTS_OFF;
\r
111 LCDM5 = partstSEGMENTS_OFF;
\r
112 LCDM6 = partstSEGMENTS_OFF;
\r
113 LCDM7 = partstSEGMENTS_OFF;
\r
114 LCDM8 = partstSEGMENTS_OFF;
\r
115 LCDM9 = partstSEGMENTS_OFF;
\r
116 LCDM10 = partstSEGMENTS_OFF;
\r
117 LCDM11 = partstSEGMENTS_OFF;
\r
118 LCDM12 = partstSEGMENTS_OFF;
\r
119 LCDM13 = partstSEGMENTS_OFF;
\r
120 LCDM14 = partstSEGMENTS_OFF;
\r
121 LCDM15 = partstSEGMENTS_OFF;
\r
122 LCDM16 = partstSEGMENTS_OFF;
\r
123 LCDM17 = partstSEGMENTS_OFF;
\r
124 LCDM18 = partstSEGMENTS_OFF;
\r
125 LCDM19 = partstSEGMENTS_OFF;
\r
126 LCDM20 = partstSEGMENTS_OFF;
\r
128 /* Setup LCD control. */
\r
129 LCDCTL = (LCDSG0_7|LCD4MUX|LCDON);
\r
131 /*-----------------------------------------------------------*/
\r
133 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
\r
135 /* Set or clear the output [in this case show or hide the '*' character. */
\r
136 if( uxLED < ( portBASE_TYPE ) partstNUM_LEDS )
\r
142 /* Turn on the segments required to show the '*'. */
\r
143 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
\r
144 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
\r
148 /* Turn off all the segments. */
\r
149 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
\r
150 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
\r
156 /*-----------------------------------------------------------*/
\r
158 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
\r
160 if( uxLED < ( portBASE_TYPE ) partstNUM_LEDS )
\r
164 /* If the '*' is already showing - hide it. If it is not already
\r
165 showing then show it. */
\r
166 if( *( ucRHSSegments[ uxLED ] ) )
\r
168 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
\r
169 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
\r
173 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
\r
174 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
\r
181 if( uxLED == partstON_BOARD_LED )
\r
183 /* The request related to the genuine on board LED. */
\r
184 prvToggleOnBoardLED();
\r
188 /*-----------------------------------------------------------*/
\r
190 static void prvToggleOnBoardLED( void )
\r
192 static unsigned short sState = pdFALSE;
\r
194 /* Toggle the state of the single genuine on board LED. */
\r
197 P1OUT |= mainON_BOARD_LED_BIT;
\r
201 P1OUT &= ~mainON_BOARD_LED_BIT;
\r
206 /*-----------------------------------------------------------*/
\r