1 |
581 |
jeremybenn |
/*
|
2 |
|
|
FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.
|
3 |
|
|
|
4 |
|
|
***************************************************************************
|
5 |
|
|
* *
|
6 |
|
|
* If you are: *
|
7 |
|
|
* *
|
8 |
|
|
* + New to FreeRTOS, *
|
9 |
|
|
* + Wanting to learn FreeRTOS or multitasking in general quickly *
|
10 |
|
|
* + Looking for basic training, *
|
11 |
|
|
* + Wanting to improve your FreeRTOS skills and productivity *
|
12 |
|
|
* *
|
13 |
|
|
* then take a look at the FreeRTOS books - available as PDF or paperback *
|
14 |
|
|
* *
|
15 |
|
|
* "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
|
16 |
|
|
* http://www.FreeRTOS.org/Documentation *
|
17 |
|
|
* *
|
18 |
|
|
* A pdf reference manual is also available. Both are usually delivered *
|
19 |
|
|
* to your inbox within 20 minutes to two hours when purchased between 8am *
|
20 |
|
|
* and 8pm GMT (although please allow up to 24 hours in case of *
|
21 |
|
|
* exceptional circumstances). Thank you for your support! *
|
22 |
|
|
* *
|
23 |
|
|
***************************************************************************
|
24 |
|
|
|
25 |
|
|
This file is part of the FreeRTOS distribution.
|
26 |
|
|
|
27 |
|
|
FreeRTOS is free software; you can redistribute it and/or modify it under
|
28 |
|
|
the terms of the GNU General Public License (version 2) as published by the
|
29 |
|
|
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
30 |
|
|
***NOTE*** The exception to the GPL is included to allow you to distribute
|
31 |
|
|
a combined work that includes FreeRTOS without being obliged to provide the
|
32 |
|
|
source code for proprietary components outside of the FreeRTOS kernel.
|
33 |
|
|
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
34 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
35 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
36 |
|
|
more details. You should have received a copy of the GNU General Public
|
37 |
|
|
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
38 |
|
|
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
39 |
|
|
by writing to Richard Barry, contact details for whom are available on the
|
40 |
|
|
FreeRTOS WEB site.
|
41 |
|
|
|
42 |
|
|
1 tab == 4 spaces!
|
43 |
|
|
|
44 |
|
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
45 |
|
|
contact details.
|
46 |
|
|
|
47 |
|
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
48 |
|
|
critical systems.
|
49 |
|
|
|
50 |
|
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
51 |
|
|
licensing and training services.
|
52 |
|
|
*/
|
53 |
|
|
|
54 |
|
|
/*
|
55 |
|
|
* This demo application creates eight co-routines and four tasks (five
|
56 |
|
|
* including the idle task). The co-routines execute as part of the idle task
|
57 |
|
|
* hook. The application is limited in size to allow its compilation using
|
58 |
|
|
* the KickStart version of the IAR compiler.
|
59 |
|
|
*
|
60 |
|
|
* Six of the created co-routines are the standard 'co-routine flash'
|
61 |
|
|
* co-routines contained within the Demo/Common/Minimal/crflash.c file and
|
62 |
|
|
* documented on the FreeRTOS.org WEB site.
|
63 |
|
|
*
|
64 |
|
|
* The 'LCD Task' waits on a message queue for messages informing it what and
|
65 |
|
|
* where to display text. This is the only task that accesses the LCD
|
66 |
|
|
* so mutual exclusion is guaranteed.
|
67 |
|
|
*
|
68 |
|
|
* The 'LCD Message Task' periodically sends strings to the LCD Task using
|
69 |
|
|
* the message queue. The strings are rotated to form a short message and
|
70 |
|
|
* are written to the top row of the LCD.
|
71 |
|
|
*
|
72 |
|
|
* The 'ADC Co-routine' periodically reads the ADC input that is connected to
|
73 |
|
|
* the light sensor, forms a short message from the value, and then sends this
|
74 |
|
|
* message to the LCD Task using the same message queue. The ADC readings are
|
75 |
|
|
* displayed on the bottom row of the LCD.
|
76 |
|
|
*
|
77 |
|
|
* The eighth co-routine and final task control the transmission and reception
|
78 |
|
|
* of a string to UART 0. The co-routine periodically sends the first
|
79 |
|
|
* character of the string to the UART, with the UART's TxEnd interrupt being
|
80 |
|
|
* used to transmit the remaining characters. The UART's RxEnd interrupt
|
81 |
|
|
* receives the characters and places them on a queue to be processed by the
|
82 |
|
|
* 'COMs Rx' task. An error is latched should an unexpected character be
|
83 |
|
|
* received, or any character be received out of sequence.
|
84 |
|
|
*
|
85 |
|
|
* A loopback connector is required to ensure that each character transmitted
|
86 |
|
|
* on the UART is also received on the same UART. For test purposes the UART
|
87 |
|
|
* FIFO's are not utalised in order to maximise the interrupt overhead. Also
|
88 |
|
|
* a pseudo random interval is used between the start of each transmission in
|
89 |
|
|
* order that the resultant interrupts are more randomly distributed and
|
90 |
|
|
* therefore more likely to highlight any problems.
|
91 |
|
|
*
|
92 |
|
|
* The flash co-routines control LED's zero to four. LED five is toggled each
|
93 |
|
|
* time the string is transmitted on the UART. LED six is toggled each time
|
94 |
|
|
* the string is CORRECTLY received on the UART. LED seven is latched on
|
95 |
|
|
* should an error be detected in any task or co-routine.
|
96 |
|
|
*
|
97 |
|
|
* In addition the idle task makes repetitive calls to
|
98 |
|
|
* vSetAndCheckRegisters(). This simply loads the general purpose registers
|
99 |
|
|
* with a known value, then checks each register to ensure the held value is
|
100 |
|
|
* still correct. As a low priority task this checking routine is likely to
|
101 |
|
|
* get repeatedly swapped in and out. A register being found to contain an
|
102 |
|
|
* incorrect value is therefore indicative of an error in the task switching
|
103 |
|
|
* mechanism.
|
104 |
|
|
*
|
105 |
|
|
*/
|
106 |
|
|
|
107 |
|
|
/* standard include files. */
|
108 |
|
|
#include <stdio.h>
|
109 |
|
|
|
110 |
|
|
/* Scheduler include files. */
|
111 |
|
|
#include "FreeRTOS.h"
|
112 |
|
|
#include "task.h"
|
113 |
|
|
#include "queue.h"
|
114 |
|
|
#include "croutine.h"
|
115 |
|
|
|
116 |
|
|
/* Demo application include files. */
|
117 |
|
|
#include "partest.h"
|
118 |
|
|
#include "crflash.h"
|
119 |
|
|
#include "commstest.h"
|
120 |
|
|
|
121 |
|
|
/* Library include files. */
|
122 |
|
|
#include "DriverLib.h"
|
123 |
|
|
|
124 |
|
|
/* The time to delay between writing each character to the LCD. */
|
125 |
|
|
#define mainCHAR_WRITE_DELAY ( 2 / portTICK_RATE_MS )
|
126 |
|
|
|
127 |
|
|
/* The time to delay between writing each string to the LCD. */
|
128 |
|
|
#define mainSTRING_WRITE_DELAY ( 400 / portTICK_RATE_MS )
|
129 |
|
|
|
130 |
|
|
#define mainADC_DELAY ( 200 / portTICK_RATE_MS )
|
131 |
|
|
|
132 |
|
|
/* The number of flash co-routines to create. */
|
133 |
|
|
#define mainNUM_FLASH_CO_ROUTINES ( 5 )
|
134 |
|
|
|
135 |
|
|
/* The length of the queue used to send messages to the LCD task. */
|
136 |
|
|
#define mainLCD_QUEUE_LEN ( 3 )
|
137 |
|
|
|
138 |
|
|
/* The priority of the co-routine used to initiate the transmission of the
|
139 |
|
|
string on UART 0. */
|
140 |
|
|
#define mainTX_CO_ROUTINE_PRIORITY ( 1 )
|
141 |
|
|
#define mainADC_CO_ROUTINE_PRIORITY ( 2 )
|
142 |
|
|
|
143 |
|
|
/* Only one of each co-routine is created so its index is not important. */
|
144 |
|
|
#define mainTX_CO_ROUTINE_INDEX ( 0 )
|
145 |
|
|
#define mainADC_CO_ROUTINE_INDEX ( 0 )
|
146 |
|
|
|
147 |
|
|
/* The task priorities. */
|
148 |
|
|
#define mainLCD_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
149 |
|
|
#define mainMSG_TASK_PRIORITY ( mainLCD_TASK_PRIORITY - 1 )
|
150 |
|
|
#define mainCOMMS_RX_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
151 |
|
|
|
152 |
|
|
/* The LCD had two rows. */
|
153 |
|
|
#define mainTOP_ROW 0
|
154 |
|
|
#define mainBOTTOM_ROW 1
|
155 |
|
|
|
156 |
|
|
/* Dimension for the buffer into which the ADC value string is written. */
|
157 |
|
|
#define mainMAX_ADC_STRING_LEN 20
|
158 |
|
|
|
159 |
|
|
/* The LED that is lit should an error be detected in any of the tasks or
|
160 |
|
|
co-routines. */
|
161 |
|
|
#define mainFAIL_LED ( 7 )
|
162 |
|
|
|
163 |
|
|
/*-----------------------------------------------------------*/
|
164 |
|
|
|
165 |
|
|
/*
|
166 |
|
|
* The task that displays text on the LCD.
|
167 |
|
|
*/
|
168 |
|
|
static void prvLCDTask( void * pvParameters );
|
169 |
|
|
|
170 |
|
|
/*
|
171 |
|
|
* The task that sends messages to be displayed on the top row of the LCD.
|
172 |
|
|
*/
|
173 |
|
|
static void prvLCDMessageTask( void * pvParameters );
|
174 |
|
|
|
175 |
|
|
/*
|
176 |
|
|
* The co-routine that reads the ADC and sends messages for display on the
|
177 |
|
|
* bottom row of the LCD.
|
178 |
|
|
*/
|
179 |
|
|
static void prvADCCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex );
|
180 |
|
|
|
181 |
|
|
/*
|
182 |
|
|
* Function to simply set a known value into the general purpose registers
|
183 |
|
|
* then read them back to ensure they remain set correctly. An incorrect value
|
184 |
|
|
* being indicative of an error in the task switching mechanism.
|
185 |
|
|
*/
|
186 |
|
|
extern void vSetAndCheckRegisters( void );
|
187 |
|
|
|
188 |
|
|
/*
|
189 |
|
|
* Latch the LED that indicates that an error has occurred.
|
190 |
|
|
*/
|
191 |
|
|
void vSetErrorLED( void );
|
192 |
|
|
|
193 |
|
|
/*
|
194 |
|
|
* Thread safe write to the PDC.
|
195 |
|
|
*/
|
196 |
|
|
static void prvPDCWrite( char cAddress, char cData );
|
197 |
|
|
|
198 |
|
|
/*
|
199 |
|
|
* Sets up the hardware used by the demo.
|
200 |
|
|
*/
|
201 |
|
|
static void prvSetupHardware( void );
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
/*-----------------------------------------------------------*/
|
205 |
|
|
|
206 |
|
|
/* The structure that is passed on the LCD message queue. */
|
207 |
|
|
typedef struct
|
208 |
|
|
{
|
209 |
|
|
char **ppcMessageToDisplay; /*<< Points to a char* pointing to the message to display. */
|
210 |
|
|
portBASE_TYPE xRow; /*<< The row on which the message should be displayed. */
|
211 |
|
|
} xLCDMessage;
|
212 |
|
|
|
213 |
|
|
/* Error flag set to pdFAIL if an error is encountered in the tasks/co-routines
|
214 |
|
|
defined within this file. */
|
215 |
|
|
unsigned portBASE_TYPE uxErrorStatus = pdPASS;
|
216 |
|
|
|
217 |
|
|
/* The queue used to transmit messages to the LCD task. */
|
218 |
|
|
static xQueueHandle xLCDQueue;
|
219 |
|
|
|
220 |
|
|
/*-----------------------------------------------------------*/
|
221 |
|
|
|
222 |
|
|
/*
|
223 |
|
|
* Setup the hardware, create the tasks/co-routines, then start the scheduler.
|
224 |
|
|
*/
|
225 |
|
|
void main( void )
|
226 |
|
|
{
|
227 |
|
|
/* Create the queue used by tasks wanting to write to the LCD. */
|
228 |
|
|
xLCDQueue = xQueueCreate( mainLCD_QUEUE_LEN, sizeof( xLCDMessage ) );
|
229 |
|
|
|
230 |
|
|
/* Setup the ports used by the demo and the clock. */
|
231 |
|
|
prvSetupHardware();
|
232 |
|
|
|
233 |
|
|
/* Create the co-routines that flash the LED's. */
|
234 |
|
|
vStartFlashCoRoutines( mainNUM_FLASH_CO_ROUTINES );
|
235 |
|
|
|
236 |
|
|
/* Create the co-routine that initiates the transmission of characters
|
237 |
|
|
on the UART and the task that receives them, as described at the top of
|
238 |
|
|
this file. */
|
239 |
|
|
xCoRoutineCreate( vSerialTxCoRoutine, mainTX_CO_ROUTINE_PRIORITY, mainTX_CO_ROUTINE_INDEX );
|
240 |
|
|
xTaskCreate( vCommsRxTask, "CMS", configMINIMAL_STACK_SIZE, NULL, mainCOMMS_RX_TASK_PRIORITY, NULL );
|
241 |
|
|
|
242 |
|
|
/* Create the task that waits for messages to display on the LCD, plus the
|
243 |
|
|
task and co-routine that send messages for display (as described at the top
|
244 |
|
|
of this file. */
|
245 |
|
|
xTaskCreate( prvLCDTask, "LCD", configMINIMAL_STACK_SIZE, ( void * ) &xLCDQueue, mainLCD_TASK_PRIORITY, NULL );
|
246 |
|
|
xTaskCreate( prvLCDMessageTask, "MSG", configMINIMAL_STACK_SIZE, ( void * ) &xLCDQueue, mainMSG_TASK_PRIORITY, NULL );
|
247 |
|
|
xCoRoutineCreate( prvADCCoRoutine, mainADC_CO_ROUTINE_PRIORITY, mainADC_CO_ROUTINE_INDEX );
|
248 |
|
|
|
249 |
|
|
/* Start the scheduler running the tasks and co-routines just created. */
|
250 |
|
|
vTaskStartScheduler();
|
251 |
|
|
|
252 |
|
|
/* Should not get here unless we did not have enough memory to start the
|
253 |
|
|
scheduler. */
|
254 |
|
|
for( ;; );
|
255 |
|
|
}
|
256 |
|
|
/*-----------------------------------------------------------*/
|
257 |
|
|
|
258 |
|
|
static void prvLCDMessageTask( void * pvParameters )
|
259 |
|
|
{
|
260 |
|
|
/* The strings that are written to the LCD. */
|
261 |
|
|
char *pcStringsToDisplay[] = {
|
262 |
|
|
"IAR ",
|
263 |
|
|
"Stellaris ",
|
264 |
|
|
"Demo ",
|
265 |
|
|
"www.FreeRTOS.org",
|
266 |
|
|
""
|
267 |
|
|
};
|
268 |
|
|
|
269 |
|
|
xQueueHandle *pxLCDQueue;
|
270 |
|
|
xLCDMessage xMessageToSend;
|
271 |
|
|
portBASE_TYPE xIndex = 0;
|
272 |
|
|
|
273 |
|
|
/* To test the parameter passing mechanism, the queue on which messages are
|
274 |
|
|
posted is passed in as a parameter even though it is available as a file
|
275 |
|
|
scope variable anyway. */
|
276 |
|
|
pxLCDQueue = ( xQueueHandle * ) pvParameters;
|
277 |
|
|
|
278 |
|
|
for( ;; )
|
279 |
|
|
{
|
280 |
|
|
/* Wait until it is time to move onto the next string. */
|
281 |
|
|
vTaskDelay( mainSTRING_WRITE_DELAY );
|
282 |
|
|
|
283 |
|
|
/* Create the message object to send to the LCD task. */
|
284 |
|
|
xMessageToSend.ppcMessageToDisplay = &pcStringsToDisplay[ xIndex ];
|
285 |
|
|
xMessageToSend.xRow = mainTOP_ROW;
|
286 |
|
|
|
287 |
|
|
/* Post the message to be displayed. */
|
288 |
|
|
if( !xQueueSend( *pxLCDQueue, ( void * ) &xMessageToSend, 0 ) )
|
289 |
|
|
{
|
290 |
|
|
uxErrorStatus = pdFAIL;
|
291 |
|
|
}
|
292 |
|
|
|
293 |
|
|
/* Move onto the next message, wrapping when necessary. */
|
294 |
|
|
xIndex++;
|
295 |
|
|
if( *( pcStringsToDisplay[ xIndex ] ) == 0x00 )
|
296 |
|
|
{
|
297 |
|
|
xIndex = 0;
|
298 |
|
|
|
299 |
|
|
/* Delay longer before going back to the start of the messages. */
|
300 |
|
|
vTaskDelay( mainSTRING_WRITE_DELAY * 2 );
|
301 |
|
|
}
|
302 |
|
|
}
|
303 |
|
|
}
|
304 |
|
|
/*-----------------------------------------------------------*/
|
305 |
|
|
|
306 |
|
|
void prvLCDTask( void * pvParameters )
|
307 |
|
|
{
|
308 |
|
|
unsigned portBASE_TYPE uxIndex;
|
309 |
|
|
xQueueHandle *pxLCDQueue;
|
310 |
|
|
xLCDMessage xReceivedMessage;
|
311 |
|
|
char *pcString;
|
312 |
|
|
const unsigned char ucCFGData[] = {
|
313 |
|
|
0x30, /* Set data bus to 8-bits. */
|
314 |
|
|
0x30,
|
315 |
|
|
0x30,
|
316 |
|
|
0x3C, /* Number of lines/font. */
|
317 |
|
|
0x08, /* Display off. */
|
318 |
|
|
0x01, /* Display clear. */
|
319 |
|
|
0x06, /* Entry mode [cursor dir][shift]. */
|
320 |
|
|
0x0C /* Display on [display on][curson on][blinking on]. */
|
321 |
|
|
};
|
322 |
|
|
|
323 |
|
|
/* To test the parameter passing mechanism, the queue on which messages are
|
324 |
|
|
received is passed in as a parameter even though it is available as a file
|
325 |
|
|
scope variable anyway. */
|
326 |
|
|
pxLCDQueue = ( xQueueHandle * ) pvParameters;
|
327 |
|
|
|
328 |
|
|
/* Configure the LCD. */
|
329 |
|
|
uxIndex = 0;
|
330 |
|
|
while( uxIndex < sizeof( ucCFGData ) )
|
331 |
|
|
{
|
332 |
|
|
prvPDCWrite( PDC_LCD_CSR, ucCFGData[ uxIndex ] );
|
333 |
|
|
uxIndex++;
|
334 |
|
|
vTaskDelay( mainCHAR_WRITE_DELAY );
|
335 |
|
|
}
|
336 |
|
|
|
337 |
|
|
/* Turn the LCD Backlight on. */
|
338 |
|
|
prvPDCWrite( PDC_CSR, 0x01 );
|
339 |
|
|
|
340 |
|
|
/* Clear display. */
|
341 |
|
|
vTaskDelay( mainCHAR_WRITE_DELAY );
|
342 |
|
|
prvPDCWrite( PDC_LCD_CSR, LCD_CLEAR );
|
343 |
|
|
|
344 |
|
|
uxIndex = 0;
|
345 |
|
|
for( ;; )
|
346 |
|
|
{
|
347 |
|
|
/* Wait for a message to arrive. */
|
348 |
|
|
if( xQueueReceive( *pxLCDQueue, &xReceivedMessage, portMAX_DELAY ) )
|
349 |
|
|
{
|
350 |
|
|
/* Which row does the received message say to write to? */
|
351 |
|
|
PDCLCDSetPos( 0, xReceivedMessage.xRow );
|
352 |
|
|
|
353 |
|
|
/* Where is the string we are going to display? */
|
354 |
|
|
pcString = *xReceivedMessage.ppcMessageToDisplay;
|
355 |
|
|
|
356 |
|
|
while( *pcString )
|
357 |
|
|
{
|
358 |
|
|
/* Don't write out the string too quickly as LCD's are usually
|
359 |
|
|
pretty slow devices. */
|
360 |
|
|
vTaskDelay( mainCHAR_WRITE_DELAY );
|
361 |
|
|
prvPDCWrite( PDC_LCD_RAM, *pcString );
|
362 |
|
|
pcString++;
|
363 |
|
|
}
|
364 |
|
|
}
|
365 |
|
|
}
|
366 |
|
|
}
|
367 |
|
|
/*-----------------------------------------------------------*/
|
368 |
|
|
|
369 |
|
|
static void prvADCCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )
|
370 |
|
|
{
|
371 |
|
|
static unsigned long ulADCValue;
|
372 |
|
|
static char cMessageBuffer[ mainMAX_ADC_STRING_LEN ];
|
373 |
|
|
static char *pcMessage;
|
374 |
|
|
static xLCDMessage xMessageToSend;
|
375 |
|
|
|
376 |
|
|
/* Co-routines MUST start with a call to crSTART(). */
|
377 |
|
|
crSTART( xHandle );
|
378 |
|
|
|
379 |
|
|
for( ;; )
|
380 |
|
|
{
|
381 |
|
|
/* Start an ADC conversion. */
|
382 |
|
|
ADCProcessorTrigger( ADC_BASE, 0 );
|
383 |
|
|
|
384 |
|
|
/* Simply delay - when we unblock the result should be available */
|
385 |
|
|
crDELAY( xHandle, mainADC_DELAY );
|
386 |
|
|
|
387 |
|
|
/* Get the ADC result. */
|
388 |
|
|
ADCSequenceDataGet( ADC_BASE, 0, &ulADCValue );
|
389 |
|
|
|
390 |
|
|
/* Create a string with the result. */
|
391 |
|
|
sprintf( cMessageBuffer, "ADC = %d ", ulADCValue );
|
392 |
|
|
pcMessage = cMessageBuffer;
|
393 |
|
|
|
394 |
|
|
/* Configure the message we are going to send for display. */
|
395 |
|
|
xMessageToSend.ppcMessageToDisplay = ( char** ) &pcMessage;
|
396 |
|
|
xMessageToSend.xRow = mainBOTTOM_ROW;
|
397 |
|
|
|
398 |
|
|
/* Send the string to the LCD task for display. We are sending
|
399 |
|
|
on a task queue so do not have the option to block. */
|
400 |
|
|
if( !xQueueSend( xLCDQueue, ( void * ) &xMessageToSend, 0 ) )
|
401 |
|
|
{
|
402 |
|
|
uxErrorStatus = pdFAIL;
|
403 |
|
|
}
|
404 |
|
|
}
|
405 |
|
|
|
406 |
|
|
/* Co-routines MUST end with a call to crEND(). */
|
407 |
|
|
crEND();
|
408 |
|
|
}
|
409 |
|
|
/*-----------------------------------------------------------*/
|
410 |
|
|
|
411 |
|
|
static void prvSetupHardware( void )
|
412 |
|
|
{
|
413 |
|
|
/* Setup the PLL. */
|
414 |
|
|
SysCtlClockSet( SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ );
|
415 |
|
|
|
416 |
|
|
/* Initialise the hardware used to talk to the LCD, LED's and UART. */
|
417 |
|
|
PDCInit();
|
418 |
|
|
vParTestInitialise();
|
419 |
|
|
vSerialInit();
|
420 |
|
|
|
421 |
|
|
/* The ADC is used to read the light sensor. */
|
422 |
|
|
SysCtlPeripheralEnable( SYSCTL_PERIPH_ADC );
|
423 |
|
|
ADCSequenceConfigure( ADC_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
|
424 |
|
|
ADCSequenceStepConfigure( ADC_BASE, 0, 0, ADC_CTL_CH0 | ADC_CTL_END );
|
425 |
|
|
ADCSequenceEnable( ADC_BASE, 0 );
|
426 |
|
|
|
427 |
|
|
}
|
428 |
|
|
/*-----------------------------------------------------------*/
|
429 |
|
|
|
430 |
|
|
static void prvPDCWrite( char cAddress, char cData )
|
431 |
|
|
{
|
432 |
|
|
vTaskSuspendAll();
|
433 |
|
|
{
|
434 |
|
|
PDCWrite( cAddress, cData );
|
435 |
|
|
}
|
436 |
|
|
xTaskResumeAll();
|
437 |
|
|
}
|
438 |
|
|
/*-----------------------------------------------------------*/
|
439 |
|
|
|
440 |
|
|
void vSetErrorLED( void )
|
441 |
|
|
{
|
442 |
|
|
vParTestSetLED( mainFAIL_LED, pdTRUE );
|
443 |
|
|
}
|
444 |
|
|
/*-----------------------------------------------------------*/
|
445 |
|
|
|
446 |
|
|
void vApplicationIdleHook( void )
|
447 |
|
|
{
|
448 |
|
|
/* The co-routines are executed in the idle task using the idle task
|
449 |
|
|
hook. */
|
450 |
|
|
for( ;; )
|
451 |
|
|
{
|
452 |
|
|
/* Schedule the co-routines. */
|
453 |
|
|
vCoRoutineSchedule();
|
454 |
|
|
|
455 |
|
|
/* Run the register check function between each co-routine. */
|
456 |
|
|
vSetAndCheckRegisters();
|
457 |
|
|
|
458 |
|
|
/* See if the comms task and co-routine has found any errors. */
|
459 |
|
|
if( uxGetCommsStatus() != pdPASS )
|
460 |
|
|
{
|
461 |
|
|
vParTestSetLED( mainFAIL_LED, pdTRUE );
|
462 |
|
|
}
|
463 |
|
|
}
|
464 |
|
|
}
|
465 |
|
|
/*-----------------------------------------------------------*/
|