2 FreeRTOS V8.2.0 - Copyright (C) 2015 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 This file is part of the FreeRTOS distribution.
\r
9 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
10 the terms of the GNU General Public License (version 2) as published by the
\r
11 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
\r
13 ***************************************************************************
\r
14 >>! NOTE: The modification to the GPL is included to allow you to !<<
\r
15 >>! distribute a combined work that includes FreeRTOS without being !<<
\r
16 >>! obliged to provide the source code for proprietary components !<<
\r
17 >>! outside of the FreeRTOS kernel. !<<
\r
18 ***************************************************************************
\r
20 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
21 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
22 FOR A PARTICULAR PURPOSE. Full license text is available on the following
\r
23 link: http://www.freertos.org/a00114.html
\r
25 ***************************************************************************
\r
27 * FreeRTOS provides completely free yet professionally developed, *
\r
28 * robust, strictly quality controlled, supported, and cross *
\r
29 * platform software that is more than just the market leader, it *
\r
30 * is the industry's de facto standard. *
\r
32 * Help yourself get started quickly while simultaneously helping *
\r
33 * to support the FreeRTOS project by purchasing a FreeRTOS *
\r
34 * tutorial book, reference manual, or both: *
\r
35 * http://www.FreeRTOS.org/Documentation *
\r
37 ***************************************************************************
\r
39 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
\r
40 the FAQ page "My application does not run, what could be wrong?". Have you
\r
41 defined configASSERT()?
\r
43 http://www.FreeRTOS.org/support - In return for receiving this top quality
\r
44 embedded software for free we request you assist our global community by
\r
45 participating in the support forum.
\r
47 http://www.FreeRTOS.org/training - Investing in training allows your team to
\r
48 be as productive as possible as early as possible. Now you can receive
\r
49 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
\r
50 Ltd, and the world's leading authority on the world's leading RTOS.
\r
52 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
53 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
54 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
56 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
\r
57 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
\r
59 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
\r
60 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
61 licenses offer ticketed support, indemnification and commercial middleware.
\r
63 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
64 engineered and independently SIL3 certified version for use in safety and
\r
65 mission critical applications that require provable dependability.
\r
71 * The documentation page for this demo available on http://www.FreeRTOS.org
\r
72 * documents the hardware configuration required to run this demo. It also
\r
73 * provides more information on the expected demo application behaviour.
\r
75 * main() creates all the demo application tasks, then starts the scheduler.
\r
76 * A lot of the created tasks are from the pool of "standard demo" tasks. The
\r
77 * web documentation provides more details of the standard demo tasks, which
\r
78 * provide no particular functionality but do provide good examples of how to
\r
79 * use the FreeRTOS API.
\r
81 * In addition to the standard demo tasks, the following tasks, interrupts and
\r
82 * tests are defined and/or created within this file:
\r
84 * "LCD" task - The LCD task is a 'gatekeeper' task. It is the only task that
\r
85 * is permitted to access the LCD and therefore ensures access to the LCD is
\r
86 * always serialised and there are no mutual exclusion issues. When a task or
\r
87 * an interrupt wants to write to the LCD, it does not access the LCD directly
\r
88 * but instead sends the message to the LCD task. The LCD task then performs
\r
89 * the actual LCD output. This mechanism also allows interrupts to, in effect,
\r
90 * write to the LCD by sending messages to the LCD task.
\r
92 * The LCD task is also a demonstration of a 'controller' task design pattern.
\r
93 * Some tasks do not actually send a string to the LCD task directly, but
\r
94 * instead send a command that is interpreted by the LCD task. In a normal
\r
95 * application these commands can be control values or set points, in this
\r
96 * simple example the commands just result in messages being displayed on the
\r
99 * "Button Poll" task - This task polls the state of the 'up' key on the
\r
100 * joystick input device. It uses the vTaskDelay() API function to control
\r
101 * the poll rate to ensure debouncing is not necessary and that the task does
\r
102 * not use all the available CPU processing time.
\r
104 * Button Interrupt and run time stats display - The select button on the
\r
105 * joystick input device is configured to generate an external interrupt. The
\r
106 * handler for this interrupt sends a message to LCD task, which interprets the
\r
107 * message to mean, firstly write a message to the LCD, and secondly, generate
\r
108 * a table of run time statistics. The run time statistics are displayed as a
\r
109 * table that contains information on how much processing time each task has
\r
110 * been allocated since the application started to execute. This information
\r
111 * is provided both as an absolute time, and as a percentage of the total run
\r
112 * time. The information is displayed in the terminal IO window of the IAR
\r
113 * embedded workbench. The online documentation for this demo shows a screen
\r
114 * shot demonstrating where the run time stats can be viewed.
\r
116 * Idle Hook - The idle hook is a function that is called on each iteration of
\r
117 * the idle task. In this case it is used to place the processor into a low
\r
118 * power mode. Note however that this application is implemented using standard
\r
119 * components, and is therefore not optimised for low power operation. Lower
\r
120 * power consumption would be achieved by converting polling tasks into event
\r
121 * driven tasks, and slowing the tick interrupt frequency.
\r
123 * "Check" function called from the tick hook - The tick hook is called during
\r
124 * each tick interrupt. It is called from an interrupt context so must execute
\r
125 * quickly, not attempt to block, and not call any FreeRTOS API functions that
\r
126 * do not end in "FromISR". In this case the tick hook executes a 'check'
\r
127 * function. This only executes every five seconds. Its main function is to
\r
128 * check that all the standard demo tasks are still operational. Each time it
\r
129 * executes it sends a status code to the LCD task. The LCD task interprets the
\r
130 * code and displays an appropriate message - which will be PASS if no tasks
\r
131 * have reported any errors, or a message stating which task has reported an
\r
134 * "Reg test" tasks - These fill the registers with known values, then check
\r
135 * that each register still contains its expected value. Each task uses
\r
136 * different values. The tasks run with very low priority so get preempted
\r
137 * very frequently. A check variable is incremented on each iteration of the
\r
138 * test loop. A register containing an unexpected value is indicative of an
\r
139 * error in the context switching mechanism and will result in a branch to a
\r
140 * null loop - which in turn will prevent the check variable from incrementing
\r
141 * any further and allow the check task (described a above) to determine that an
\r
142 * error has occurred. The nature of the reg test tasks necessitates that they
\r
143 * are written in assembly code.
\r
145 * *NOTE 1* vApplicationSetupTimerInterrupt() is called by the kernel to let
\r
146 * the application set up a timer to generate the tick interrupt. In this
\r
147 * example a timer A0 is used for this purpose.
\r
151 /* Standard includes. */
\r
154 /* FreeRTOS includes. */
\r
155 #include "FreeRTOS.h"
\r
159 /* Hardware includes. */
\r
160 #include "msp430.h"
\r
161 #include "hal_MSP-EXP430F5438.h"
\r
163 /* Standard demo includes. */
\r
164 #include "ParTest.h"
\r
165 #include "dynamic.h"
\r
166 #include "comtest2.h"
\r
167 #include "GenQTest.h"
\r
169 /* Codes sent within messages to the LCD task so the LCD task can interpret
\r
170 exactly what the message it just received was. These are sent in the
\r
171 cMessageID member of the message structure (defined below). */
\r
172 #define mainMESSAGE_BUTTON_UP ( 1 )
\r
173 #define mainMESSAGE_BUTTON_SEL ( 2 )
\r
174 #define mainMESSAGE_STATUS ( 3 )
\r
176 /* When the cMessageID member of the message sent to the LCD task is
\r
177 mainMESSAGE_STATUS then these definitions are sent in the ulMessageValue member
\r
178 of the same message and indicate what the status actually is. */
\r
179 #define mainERROR_DYNAMIC_TASKS ( pdPASS + 1 )
\r
180 #define mainERROR_COM_TEST ( pdPASS + 2 )
\r
181 #define mainERROR_GEN_QUEUE_TEST ( pdPASS + 3 )
\r
182 #define mainERROR_REG_TEST ( pdPASS + 4 )
\r
184 /* The length of the queue (the number of items the queue can hold) that is used
\r
185 to send messages from tasks and interrupts the the LCD task. */
\r
186 #define mainQUEUE_LENGTH ( 5 )
\r
188 /* Priorities used by the test and demo tasks. */
\r
189 #define mainLCD_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
190 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
191 #define mainGENERIC_QUEUE_TEST_PRIORITY ( tskIDLE_PRIORITY )
\r
193 /* The LED used by the comtest tasks. See the comtest.c file for more
\r
195 #define mainCOM_TEST_LED ( 1 )
\r
197 /* The baud rate used by the comtest tasks described at the top of this file. */
\r
198 #define mainCOM_TEST_BAUD_RATE ( 38400 )
\r
200 /* The maximum number of lines of text that can be displayed on the LCD. */
\r
201 #define mainMAX_LCD_LINES ( 8 )
\r
203 /* Just used to ensure parameters are passed into tasks correctly. */
\r
204 #define mainTASK_PARAMETER_CHECK_VALUE ( ( void * ) 0xDEAD )
\r
205 /*-----------------------------------------------------------*/
\r
208 * The reg test tasks as described at the top of this file.
\r
210 extern void vRegTest1Task( void *pvParameters );
\r
211 extern void vRegTest2Task( void *pvParameters );
\r
214 * Configures clocks, LCD, port pints, etc. necessary to execute this demo.
\r
216 static void prvSetupHardware( void );
\r
219 * Definition of the LCD/controller task described in the comments at the top
\r
222 static void prvLCDTask( void *pvParameters );
\r
225 * Definition of the button poll task described in the comments at the top of
\r
228 static void prvButtonPollTask( void *pvParameters );
\r
231 * Converts a status message value into an appropriate string for display on
\r
232 * the LCD. The string is written to pcBuffer.
\r
234 static void prvGenerateStatusMessage( char *pcBuffer, long lStatusValue );
\r
236 /*-----------------------------------------------------------*/
\r
238 /* Variables that are incremented on each iteration of the reg test tasks -
\r
239 provided the tasks have not reported any errors. The check task inspects these
\r
240 variables to ensure they are still incrementing as expected. If a variable
\r
241 stops incrementing then it is likely that its associate task has stalled. */
\r
242 volatile unsigned short usRegTest1Counter = 0, usRegTest2Counter = 0;
\r
244 /* The handle of the queue used to send messages from tasks and interrupts to
\r
246 static QueueHandle_t xLCDQueue = NULL;
\r
248 /* The definition of each message sent from tasks and interrupts to the LCD
\r
252 char cMessageID; /* << States what the message is. */
\r
253 unsigned long ulMessageValue; /* << States the message value (can be an integer, string pointer, etc. depending on the value of cMessageID). */
\r
256 /*-----------------------------------------------------------*/
\r
258 /* The linker script can be used to test the FreeRTOS ports use of 20bit
\r
259 addresses by locating all code in high memory. The following pragma ensures
\r
260 that main remains in low memory when that is done. The ISR_CODE segment is used
\r
261 for convenience as ISR functions are always placed in low memory. */
\r
262 #pragma location="ISR_CODE"
\r
265 /* Configure the peripherals used by this demo application. This includes
\r
266 configuring the joystick input select button to generate interrupts. */
\r
267 prvSetupHardware();
\r
269 /* Create the queue used by tasks and interrupts to send strings to the LCD
\r
271 xLCDQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( xQueueMessage ) );
\r
273 /* If the queue could not be created then don't create any tasks that might
\r
274 attempt to use the queue. */
\r
275 if( xLCDQueue != NULL )
\r
277 /* Add the created queue to the queue registry so it can be viewed in
\r
278 the IAR FreeRTOS state viewer plug-in. */
\r
279 vQueueAddToRegistry( xLCDQueue, "LCDQueue" );
\r
281 /* Create the standard demo tasks. */
\r
282 vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
\r
283 vStartDynamicPriorityTasks();
\r
284 vStartGenericQueueTasks( mainGENERIC_QUEUE_TEST_PRIORITY );
\r
286 /* Create the LCD, button poll and register test tasks, as described at
\r
287 the top of this file. */
\r
288 xTaskCreate( prvLCDTask, "LCD", configMINIMAL_STACK_SIZE * 2, mainTASK_PARAMETER_CHECK_VALUE, mainLCD_TASK_PRIORITY, NULL );
\r
289 xTaskCreate( prvButtonPollTask, "BPoll", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
\r
290 xTaskCreate( vRegTest1Task, "Reg1", configMINIMAL_STACK_SIZE, NULL, 0, NULL );
\r
291 xTaskCreate( vRegTest2Task, "Reg2", configMINIMAL_STACK_SIZE, NULL, 0, NULL );
\r
293 /* Start the scheduler. */
\r
294 vTaskStartScheduler();
\r
297 /* If all is well then this line will never be reached. If it is reached
\r
298 then it is likely that there was insufficient (FreeRTOS) heap memory space
\r
299 to create the idle task. This may have been trapped by the malloc() failed
\r
300 hook function, if one is configured. */
\r
303 /*-----------------------------------------------------------*/
\r
305 static void prvLCDTask( void *pvParameters )
\r
307 xQueueMessage xReceivedMessage;
\r
309 /* Buffer into which strings are formatted and placed ready for display on the
\r
310 LCD. Note this is a static variable to prevent it being allocated on the task
\r
311 stack, which is too small to hold such a variable. The stack size is configured
\r
312 when the task is created. */
\r
313 static char cBuffer[ 512 ];
\r
314 unsigned char ucLine = 1;
\r
317 /* This function is the only function that uses printf(). If printf() is
\r
318 used from any other function then some sort of mutual exclusion on stdout
\r
321 This is also the only function that is permitted to access the LCD.
\r
323 First print out the number of bytes that remain in the FreeRTOS heap. This
\r
324 can be viewed in the terminal IO window within the IAR Embedded Workbench. */
\r
325 printf( "%d bytes of heap space remain unallocated\n", ( int ) xPortGetFreeHeapSize() );
\r
327 /* Just as a test of the port, and for no functional reason, check the task
\r
328 parameter contains its expected value. */
\r
329 if( pvParameters != mainTASK_PARAMETER_CHECK_VALUE )
\r
331 halLcdPrintLine( "Invalid parameter", ucLine, OVERWRITE_TEXT );
\r
337 /* Wait for a message to be received. Using portMAX_DELAY as the block
\r
338 time will result in an indefinite wait provided INCLUDE_vTaskSuspend is
\r
339 set to 1 in FreeRTOSConfig.h, therefore there is no need to check the
\r
340 function return value and the function will only return when a value
\r
341 has been received. */
\r
342 xQueueReceive( xLCDQueue, &xReceivedMessage, portMAX_DELAY );
\r
344 /* Clear the LCD if no room remains for any more text output. */
\r
345 if( ucLine > mainMAX_LCD_LINES )
\r
347 halLcdClearScreen();
\r
351 /* What is this message? What does it contain? */
\r
352 switch( xReceivedMessage.cMessageID )
\r
354 case mainMESSAGE_BUTTON_UP : /* The button poll task has just
\r
355 informed this task that the up
\r
356 button on the joystick input has
\r
357 been pressed or released. */
\r
358 sprintf( cBuffer, "Button up = %d", ( int ) xReceivedMessage.ulMessageValue );
\r
361 case mainMESSAGE_BUTTON_SEL : /* The select button interrupt
\r
362 just informed this task that the
\r
363 select button was pressed.
\r
364 Generate a table of task run time
\r
365 statistics and output this to
\r
366 the terminal IO window in the IAR
\r
367 embedded workbench. */
\r
368 printf( "\nTask\t Abs Time\t %%Time\n*****************************************" );
\r
369 vTaskGetRunTimeStats( cBuffer );
\r
372 /* Also print out a message to
\r
373 the LCD - in this case the
\r
374 pointer to the string to print
\r
375 is sent directly in the
\r
376 ulMessageValue member of the
\r
377 message. This just demonstrates
\r
378 a different communication
\r
380 sprintf( cBuffer, "%s", ( char * ) xReceivedMessage.ulMessageValue );
\r
383 case mainMESSAGE_STATUS : /* The tick interrupt hook
\r
384 function has just informed this
\r
385 task of the system status.
\r
386 Generate a string in accordance
\r
387 with the status value. */
\r
388 prvGenerateStatusMessage( cBuffer, xReceivedMessage.ulMessageValue );
\r
391 default : sprintf( cBuffer, "Unknown message" );
\r
395 /* Output the message that was placed into the cBuffer array within the
\r
396 switch statement above, then move onto the next line ready for the next
\r
397 message to arrive on the queue. */
\r
398 halLcdPrintLine( cBuffer, ucLine, OVERWRITE_TEXT );
\r
402 /*-----------------------------------------------------------*/
\r
404 static void prvGenerateStatusMessage( char *pcBuffer, long lStatusValue )
\r
406 /* Just a utility function to convert a status value into a meaningful
\r
407 string for output onto the LCD. */
\r
408 switch( lStatusValue )
\r
410 case pdPASS : sprintf( pcBuffer, "Status = PASS" );
\r
412 case mainERROR_DYNAMIC_TASKS : sprintf( pcBuffer, "Err: Dynamic tsks" );
\r
414 case mainERROR_COM_TEST : sprintf( pcBuffer, "Err: COM test" );
\r
416 case mainERROR_GEN_QUEUE_TEST : sprintf( pcBuffer, "Error: Gen Q test" );
\r
418 case mainERROR_REG_TEST : sprintf( pcBuffer, "Error: Reg test" );
\r
420 default : sprintf( pcBuffer, "Unknown status" );
\r
424 /*-----------------------------------------------------------*/
\r
426 static void prvButtonPollTask( void *pvParameters )
\r
428 unsigned char ucLastState = pdFALSE, ucState;
\r
429 xQueueMessage xMessage;
\r
431 /* This tasks performs the button polling functionality as described at the
\r
432 top of this file. */
\r
435 /* Check the button state. */
\r
436 ucState = ( halButtonsPressed() & BUTTON_UP );
\r
440 /* The button was pressed. */
\r
444 if( ucState != ucLastState )
\r
446 /* The state has changed, send a message to the LCD task. */
\r
447 xMessage.cMessageID = mainMESSAGE_BUTTON_UP;
\r
448 xMessage.ulMessageValue = ( unsigned long ) ucState;
\r
449 ucLastState = ucState;
\r
450 xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );
\r
453 /* Block for 10 milliseconds so this task does not utilise all the CPU
\r
454 time and debouncing of the button is not necessary. */
\r
455 vTaskDelay( 10 / portTICK_PERIOD_MS );
\r
458 /*-----------------------------------------------------------*/
\r
460 static void prvSetupHardware( void )
\r
464 LFXT_Start( XT1DRIVE_0 );
\r
465 hal430SetSystemClock( configCPU_CLOCK_HZ, configLFXT_CLOCK_HZ );
\r
467 halButtonsInit( BUTTON_ALL );
\r
468 halButtonsInterruptEnable( BUTTON_SELECT );
\r
470 /* Initialise the LCD, but note that the backlight is not used as the
\r
471 library function uses timer A0 to modulate the backlight, and this file
\r
472 defines vApplicationSetupTimerInterrupt() to also use timer A0 to generate
\r
473 the tick interrupt. If the backlight is required, then change either the
\r
474 halLCD library or vApplicationSetupTimerInterrupt() to use a different
\r
475 timer. Timer A1 is used for the run time stats time base6. */
\r
477 halLcdSetContrast( 100 );
\r
478 halLcdClearScreen();
\r
480 halLcdPrintLine( " www.FreeRTOS.org", 0, OVERWRITE_TEXT );
\r
482 /*-----------------------------------------------------------*/
\r
484 void vApplicationTickHook( void )
\r
486 static unsigned short usLastRegTest1Counter = 0, usLastRegTest2Counter = 0;
\r
487 static unsigned long ulCounter = 0;
\r
488 static const unsigned long ulCheckFrequency = 5000UL / portTICK_PERIOD_MS;
\r
489 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
\r
491 /* Define the status message that is sent to the LCD task. By default the
\r
493 static xQueueMessage xStatusMessage = { mainMESSAGE_STATUS, pdPASS };
\r
495 /* This is called from within the tick interrupt and performs the 'check'
\r
496 functionality as described in the comments at the top of this file.
\r
498 Is it time to perform the 'check' functionality again? */
\r
500 if( ulCounter >= ulCheckFrequency )
\r
502 /* See if the standard demo tasks are executing as expected, changing
\r
503 the message that is sent to the LCD task from PASS to an error code if
\r
504 any tasks set reports an error. */
\r
505 if( xAreComTestTasksStillRunning() != pdPASS )
\r
507 xStatusMessage.ulMessageValue = mainERROR_COM_TEST;
\r
510 if( xAreDynamicPriorityTasksStillRunning() != pdPASS )
\r
512 xStatusMessage.ulMessageValue = mainERROR_DYNAMIC_TASKS;
\r
515 if( xAreGenericQueueTasksStillRunning() != pdPASS )
\r
517 xStatusMessage.ulMessageValue = mainERROR_GEN_QUEUE_TEST;
\r
520 /* Check the reg test tasks are still cycling. They will stop
\r
521 incrementing their loop counters if they encounter an error. */
\r
522 if( usRegTest1Counter == usLastRegTest1Counter )
\r
524 xStatusMessage.ulMessageValue = mainERROR_REG_TEST;
\r
527 if( usRegTest2Counter == usLastRegTest2Counter )
\r
529 xStatusMessage.ulMessageValue = mainERROR_REG_TEST;
\r
532 usLastRegTest1Counter = usRegTest1Counter;
\r
533 usLastRegTest2Counter = usRegTest2Counter;
\r
535 /* As this is the tick hook the lHigherPriorityTaskWoken parameter is not
\r
536 needed (a context switch is going to be performed anyway), but it must
\r
537 still be provided. */
\r
538 xQueueSendFromISR( xLCDQueue, &xStatusMessage, &xHigherPriorityTaskWoken );
\r
542 /* Just periodically toggle an LED to show that the tick interrupt is
\r
543 running. Note that this access LED_PORT_OUT in a non-atomic way, so tasks
\r
544 that access the same port must do so from a critical section. */
\r
545 if( ( ulCounter & 0xff ) == 0 )
\r
547 if( ( LED_PORT_OUT & LED_1 ) == 0 )
\r
549 LED_PORT_OUT |= LED_1;
\r
553 LED_PORT_OUT &= ~LED_1;
\r
557 /*-----------------------------------------------------------*/
\r
559 #pragma vector=PORT2_VECTOR
\r
560 __interrupt static void prvSelectButtonInterrupt(void)
\r
562 /* Define the message sent to the LCD task from this interrupt. */
\r
563 static const xQueueMessage xMessage = { mainMESSAGE_BUTTON_SEL, ( unsigned long ) "Select Interrupt" };
\r
564 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
\r
566 /* This is the interrupt handler for the joystick select button input.
\r
567 The button has been pushed, write a message to the LCD via the LCD task. */
\r
568 xQueueSendFromISR( xLCDQueue, &xMessage, &xHigherPriorityTaskWoken );
\r
572 /* If writing to xLCDQueue caused a task to unblock, and the unblocked task
\r
573 has a priority equal to or above the task that this interrupt interrupted,
\r
574 then lHigherPriorityTaskWoken will have been set to pdTRUE internally within
\r
575 xQueuesendFromISR(), and portEND_SWITCHING_ISR() will ensure that this
\r
576 interrupt returns directly to the higher priority unblocked task. */
\r
577 portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
\r
579 /*-----------------------------------------------------------*/
\r
581 /* The MSP430X port uses this callback function to configure its tick interrupt.
\r
582 This allows the application to choose the tick interrupt source.
\r
583 configTICK_VECTOR must also be set in FreeRTOSConfig.h to the correct
\r
584 interrupt vector for the chosen tick interrupt source. This implementation of
\r
585 vApplicationSetupTimerInterrupt() generates the tick from timer A0, so in this
\r
586 case configTICK_VECTOR is set to TIMER0_A0_VECTOR. */
\r
587 void vApplicationSetupTimerInterrupt( void )
\r
589 const unsigned short usACLK_Frequency_Hz = 32768;
\r
591 /* Ensure the timer is stopped. */
\r
594 /* Run the timer from the ACLK. */
\r
597 /* Clear everything to start with. */
\r
600 /* Set the compare match value according to the tick rate we want. */
\r
601 TA0CCR0 = usACLK_Frequency_Hz / configTICK_RATE_HZ;
\r
603 /* Enable the interrupts. */
\r
606 /* Start up clean. */
\r
612 /*-----------------------------------------------------------*/
\r
614 void vApplicationIdleHook( void )
\r
616 /* Called on each iteration of the idle task. In this case the idle task
\r
617 just enters a low power mode. */
\r
618 __bis_SR_register( LPM3_bits + GIE );
\r
620 /*-----------------------------------------------------------*/
\r
622 void vApplicationMallocFailedHook( void )
\r
624 /* Called if a call to pvPortMalloc() fails because there is insufficient
\r
625 free memory available in the FreeRTOS heap. pvPortMalloc() is called
\r
626 internally by FreeRTOS API functions that create tasks, queues or
\r
628 taskDISABLE_INTERRUPTS();
\r
631 /*-----------------------------------------------------------*/
\r
633 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
\r
636 ( void ) pcTaskName;
\r
638 /* Run time stack overflow checking is performed if
\r
639 configconfigCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
\r
640 function is called if a stack overflow is detected. */
\r
641 taskDISABLE_INTERRUPTS();
\r
644 /*-----------------------------------------------------------*/
\r