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
45 /* Scheduler includes. */
\r
46 #include "FreeRTOS.h"
\r
49 /* Demo application includes. */
\r
50 #include "partest.h"
\r
52 /* Constants required to setup the LCD. */
\r
53 #define LCD_DIV_64 5
\r
55 /* Constants required to access the "LED's". The LED segments are turned on
\r
56 and off to generate '*' characters. */
\r
57 #define partstNUM_LEDS ( ( unsigned char ) 6 )
\r
58 #define partstSEGMENTS_ON ( ( unsigned char ) 0x0f )
\r
59 #define partstSEGMENTS_OFF ( ( unsigned char ) 0x00 )
\r
61 /* The LED number of the real on board LED, rather than a simulated LED. */
\r
62 #define partstON_BOARD_LED ( ( unsigned portBASE_TYPE ) 10 )
\r
63 #define mainON_BOARD_LED_BIT ( ( unsigned char ) 0x01 )
\r
65 /* The LCD segments used to generate the '*' characters for LED's 0 to 5. */
\r
66 unsigned char * const ucRHSSegments[ partstNUM_LEDS ] = { ( unsigned char * )0xa4,
\r
67 ( unsigned char * )0xa2,
\r
68 ( unsigned char * )0xa0,
\r
69 ( unsigned char * )0x9e,
\r
70 ( unsigned char * )0x9c,
\r
71 ( unsigned char * )0x9a };
\r
73 unsigned char * const ucLHSSegments[ partstNUM_LEDS ] = { ( unsigned char * )0xa3,
\r
74 ( unsigned char * )0xa1,
\r
75 ( unsigned char * )0x9f,
\r
76 ( unsigned char * )0x9d,
\r
77 ( unsigned char * )0x9b,
\r
78 ( unsigned char * )0x99 };
\r
81 * Toggle the single genuine built in LED.
\r
83 static void prvToggleOnBoardLED( void );
\r
85 /*-----------------------------------------------------------*/
\r
87 void vParTestInitialise( void )
\r
89 /* Initialise the LCD hardware. */
\r
91 /* Used for the onboard LED. */
\r
94 // Setup Basic Timer for LCD operation
\r
95 BTCTL = (LCD_DIV_64+0x23);
\r
97 // Setup port functions
\r
104 /* Initialise all segments to off. */
\r
105 LCDM1 = partstSEGMENTS_OFF;
\r
106 LCDM2 = partstSEGMENTS_OFF;
\r
107 LCDM3 = partstSEGMENTS_OFF;
\r
108 LCDM4 = partstSEGMENTS_OFF;
\r
109 LCDM5 = partstSEGMENTS_OFF;
\r
110 LCDM6 = partstSEGMENTS_OFF;
\r
111 LCDM7 = partstSEGMENTS_OFF;
\r
112 LCDM8 = partstSEGMENTS_OFF;
\r
113 LCDM9 = partstSEGMENTS_OFF;
\r
114 LCDM10 = partstSEGMENTS_OFF;
\r
115 LCDM11 = partstSEGMENTS_OFF;
\r
116 LCDM12 = partstSEGMENTS_OFF;
\r
117 LCDM13 = partstSEGMENTS_OFF;
\r
118 LCDM14 = partstSEGMENTS_OFF;
\r
119 LCDM15 = partstSEGMENTS_OFF;
\r
120 LCDM16 = partstSEGMENTS_OFF;
\r
121 LCDM17 = partstSEGMENTS_OFF;
\r
122 LCDM18 = partstSEGMENTS_OFF;
\r
123 LCDM19 = partstSEGMENTS_OFF;
\r
124 LCDM20 = partstSEGMENTS_OFF;
\r
126 /* Setup LCD control. */
\r
127 LCDCTL = (LCDSG0_7|LCD4MUX|LCDON);
\r
129 /*-----------------------------------------------------------*/
\r
131 void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
\r
133 /* Set or clear the output [in this case show or hide the '*' character. */
\r
134 if( uxLED < ( portBASE_TYPE ) partstNUM_LEDS )
\r
140 /* Turn on the segments required to show the '*'. */
\r
141 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
\r
142 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
\r
146 /* Turn off all the segments. */
\r
147 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
\r
148 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
\r
154 /*-----------------------------------------------------------*/
\r
156 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
\r
158 if( uxLED < ( portBASE_TYPE ) partstNUM_LEDS )
\r
162 /* If the '*' is already showing - hide it. If it is not already
\r
163 showing then show it. */
\r
164 if( *( ucRHSSegments[ uxLED ] ) )
\r
166 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
\r
167 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_OFF;
\r
171 *( ucRHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
\r
172 *( ucLHSSegments[ uxLED ] ) = partstSEGMENTS_ON;
\r
179 if( uxLED == partstON_BOARD_LED )
\r
181 /* The request related to the genuine on board LED. */
\r
182 prvToggleOnBoardLED();
\r
186 /*-----------------------------------------------------------*/
\r
188 static void prvToggleOnBoardLED( void )
\r
190 static unsigned short sState = pdFALSE;
\r
192 /* Toggle the state of the single genuine on board LED. */
\r
195 P1OUT |= mainON_BOARD_LED_BIT;
\r
199 P1OUT &= ~mainON_BOARD_LED_BIT;
\r
204 /*-----------------------------------------------------------*/
\r