2 FreeRTOS V7.2.0 - Copyright (C) 2012 Real Time Engineers Ltd.
\r
5 ***************************************************************************
\r
7 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
8 * Complete, revised, and edited pdf reference manuals are also *
\r
11 * Purchasing FreeRTOS documentation will not only help you, by *
\r
12 * ensuring you get running as quickly as possible and with an *
\r
13 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
14 * the FreeRTOS project to continue with its mission of providing *
\r
15 * professional grade, cross platform, de facto standard solutions *
\r
16 * for microcontrollers - completely free of charge! *
\r
18 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
20 * Thank you for using FreeRTOS, and thank you for your support! *
\r
22 ***************************************************************************
\r
25 This file is part of the FreeRTOS distribution.
\r
27 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
28 the terms of the GNU General Public License (version 2) as published by the
\r
29 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
30 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
31 distribute a combined work that includes FreeRTOS without being obliged to
\r
32 provide the source code for proprietary components outside of the FreeRTOS
\r
33 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
34 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
35 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
36 more details. You should have received a copy of the GNU General Public
\r
37 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
38 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
39 by writing to Richard Barry, contact details for whom are available on the
\r
44 ***************************************************************************
\r
46 * Having a problem? Start by reading the FAQ "My application does *
\r
47 * not run, what could be wrong? *
\r
49 * http://www.FreeRTOS.org/FAQHelp.html *
\r
51 ***************************************************************************
\r
54 http://www.FreeRTOS.org - Documentation, training, latest information,
\r
55 license and contact details.
\r
57 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
58 including FreeRTOS+Trace - an indispensable productivity tool.
\r
60 Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
\r
61 the code with commercial support, indemnification, and middleware, under
\r
62 the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
\r
63 provide a safety engineered and independently SIL3 certified version under
\r
64 the SafeRTOS brand: http://www.SafeRTOS.com.
\r
68 * The documentation page for this demo available on http://www.FreeRTOS.org
\r
69 * documents the hardware configuration required to run this demo. It also
\r
70 * provides more information on the expected demo application behaviour.
\r
72 * main() creates all the demo application tasks, then starts the scheduler.
\r
73 * A lot of the created tasks are from the pool of "standard demo" tasks. The
\r
74 * web documentation provides more details of the standard demo tasks, which
\r
75 * provide no particular functionality but do provide good examples of how to
\r
76 * use the FreeRTOS API.
\r
78 * In addition to the standard demo tasks, the following tasks, interrupts and
\r
79 * tests are defined and/or created within this file:
\r
81 * "LCD" task - The LCD task is a 'gatekeeper' task. It is the only task that
\r
82 * is permitted to access the LCD and therefore ensures access to the LCD is
\r
83 * always serialised and there are no mutual exclusion issues. When a task or
\r
84 * an interrupt wants to write to the LCD, it does not access the LCD directly
\r
85 * but instead sends the message to the LCD task. The LCD task then performs
\r
86 * the actual LCD output. This mechanism also allows interrupts to, in effect,
\r
87 * write to the LCD by sending messages to the LCD task.
\r
89 * The LCD task is also a demonstration of a 'controller' task design pattern.
\r
90 * Some tasks do not actually send a string to the LCD task directly, but
\r
91 * instead send a command that is interpreted by the LCD task. In a normal
\r
92 * application these commands can be control values or set points, in this
\r
93 * simple example the commands just result in messages being displayed on the
\r
96 * "Button Poll" task - This task polls the state of the 'up' key on the
\r
97 * joystick input device. It uses the vTaskDelay() API function to control
\r
98 * the poll rate to ensure debouncing is not necessary and that the task does
\r
99 * not use all the available CPU processing time.
\r
101 * Button Interrupt and run time stats display - The select button on the
\r
102 * joystick input device is configured to generate an external interrupt. The
\r
103 * handler for this interrupt sends a message to LCD task, which interprets the
\r
104 * message to mean, firstly write a message to the LCD, and secondly, generate
\r
105 * a table of run time statistics. The run time statistics are displayed as a
\r
106 * table that contains information on how much processing time each task has
\r
107 * been allocated since the application started to execute. This information
\r
108 * is provided both as an absolute time, and as a percentage of the total run
\r
109 * time. The information is displayed in the terminal IO window of the IAR
\r
110 * embedded workbench. The online documentation for this demo shows a screen
\r
111 * shot demonstrating where the run time stats can be viewed.
\r
113 * Idle Hook - The idle hook is a function that is called on each iteration of
\r
114 * the idle task. In this case it is used to place the processor into a low
\r
115 * power mode. Note however that this application is implemented using standard
\r
116 * components, and is therefore not optimised for low power operation. Lower
\r
117 * power consumption would be achieved by converting polling tasks into event
\r
118 * driven tasks, and slowing the tick interrupt frequency.
\r
120 * "Check" function called from the tick hook - The tick hook is called during
\r
121 * each tick interrupt. It is called from an interrupt context so must execute
\r
122 * quickly, not attempt to block, and not call any FreeRTOS API functions that
\r
123 * do not end in "FromISR". In this case the tick hook executes a 'check'
\r
124 * function. This only executes every five seconds. Its main function is to
\r
125 * check that all the standard demo tasks are still operational. Each time it
\r
126 * executes it sends a status code to the LCD task. The LCD task interprets the
\r
127 * code and displays an appropriate message - which will be PASS if no tasks
\r
128 * have reported any errors, or a message stating which task has reported an
\r
131 * "Reg test" tasks - These fill the registers with known values, then check
\r
132 * that each register still contains its expected value. Each task uses
\r
133 * different values. The tasks run with very low priority so get preempted
\r
134 * very frequently. A check variable is incremented on each iteration of the
\r
135 * test loop. A register containing an unexpected value is indicative of an
\r
136 * error in the context switching mechanism and will result in a branch to a
\r
137 * null loop - which in turn will prevent the check variable from incrementing
\r
138 * any further and allow the check task (described a above) to determine that an
\r
139 * error has occurred. The nature of the reg test tasks necessitates that they
\r
140 * are written in assembly code.
\r
142 * *NOTE 1* vApplicationSetupTimerInterrupt() is called by the kernel to let
\r
143 * the application set up a timer to generate the tick interrupt. In this
\r
144 * example a timer A0 is used for this purpose.
\r
148 /* Standard includes. */
\r
151 /* FreeRTOS includes. */
\r
152 #include "FreeRTOS.h"
\r
156 /* Hardware includes. */
\r
157 #include "msp430.h"
\r
158 #include "hal_MSP-EXP430F5438.h"
\r
160 /* Standard demo includes. */
\r
161 #include "ParTest.h"
\r
162 #include "dynamic.h"
\r
163 #include "comtest2.h"
\r
164 #include "GenQTest.h"
\r
166 /* Codes sent within messages to the LCD task so the LCD task can interpret
\r
167 exactly what the message it just received was. These are sent in the
\r
168 cMessageID member of the message structure (defined below). */
\r
169 #define mainMESSAGE_BUTTON_UP ( 1 )
\r
170 #define mainMESSAGE_BUTTON_SEL ( 2 )
\r
171 #define mainMESSAGE_STATUS ( 3 )
\r
173 /* When the cMessageID member of the message sent to the LCD task is
\r
174 mainMESSAGE_STATUS then these definitions are sent in the ulMessageValue member
\r
175 of the same message and indicate what the status actually is. */
\r
176 #define mainERROR_DYNAMIC_TASKS ( pdPASS + 1 )
\r
177 #define mainERROR_COM_TEST ( pdPASS + 2 )
\r
178 #define mainERROR_GEN_QUEUE_TEST ( pdPASS + 3 )
\r
179 #define mainERROR_REG_TEST ( pdPASS + 4 )
\r
181 /* The length of the queue (the number of items the queue can hold) that is used
\r
182 to send messages from tasks and interrupts the the LCD task. */
\r
183 #define mainQUEUE_LENGTH ( 5 )
\r
185 /* Priorities used by the test and demo tasks. */
\r
186 #define mainLCD_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
187 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
188 #define mainGENERIC_QUEUE_TEST_PRIORITY ( tskIDLE_PRIORITY )
\r
190 /* The LED used by the comtest tasks. See the comtest.c file for more
\r
192 #define mainCOM_TEST_LED ( 1 )
\r
194 /* The baud rate used by the comtest tasks described at the top of this file. */
\r
195 #define mainCOM_TEST_BAUD_RATE ( 38400 )
\r
197 /* The maximum number of lines of text that can be displayed on the LCD. */
\r
198 #define mainMAX_LCD_LINES ( 8 )
\r
200 /* Just used to ensure parameters are passed into tasks correctly. */
\r
201 #define mainTASK_PARAMETER_CHECK_VALUE ( ( void * ) 0xDEAD )
\r
202 /*-----------------------------------------------------------*/
\r
205 * The reg test tasks as described at the top of this file.
\r
207 extern void vRegTest1Task( void *pvParameters );
\r
208 extern void vRegTest2Task( void *pvParameters );
\r
211 * Configures clocks, LCD, port pints, etc. necessary to execute this demo.
\r
213 static void prvSetupHardware( void );
\r
216 * Definition of the LCD/controller task described in the comments at the top
\r
219 static void prvLCDTask( void *pvParameters );
\r
222 * Definition of the button poll task described in the comments at the top of
\r
225 static void prvButtonPollTask( void *pvParameters );
\r
228 * Converts a status message value into an appropriate string for display on
\r
229 * the LCD. The string is written to pcBuffer.
\r
231 static void prvGenerateStatusMessage( char *pcBuffer, long lStatusValue );
\r
233 /*-----------------------------------------------------------*/
\r
235 /* Variables that are incremented on each iteration of the reg test tasks -
\r
236 provided the tasks have not reported any errors. The check task inspects these
\r
237 variables to ensure they are still incrementing as expected. If a variable
\r
238 stops incrementing then it is likely that its associate task has stalled. */
\r
239 volatile unsigned short usRegTest1Counter = 0, usRegTest2Counter = 0;
\r
241 /* The handle of the queue used to send messages from tasks and interrupts to
\r
243 static xQueueHandle xLCDQueue = NULL;
\r
245 /* The definition of each message sent from tasks and interrupts to the LCD
\r
249 char cMessageID; /* << States what the message is. */
\r
250 unsigned long ulMessageValue; /* << States the message value (can be an integer, string pointer, etc. depending on the value of cMessageID). */
\r
253 /*-----------------------------------------------------------*/
\r
255 /* The linker script can be used to test the FreeRTOS ports use of 20bit
\r
256 addresses by locating all code in high memory. The following pragma ensures
\r
257 that main remains in low memory when that is done. The ISR_CODE segment is used
\r
258 for convenience as ISR functions are always placed in low memory. */
\r
259 #pragma location="ISR_CODE"
\r
262 /* Configure the peripherals used by this demo application. This includes
\r
263 configuring the joystick input select button to generate interrupts. */
\r
264 prvSetupHardware();
\r
266 /* Create the queue used by tasks and interrupts to send strings to the LCD
\r
268 xLCDQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( xQueueMessage ) );
\r
270 /* If the queue could not be created then don't create any tasks that might
\r
271 attempt to use the queue. */
\r
272 if( xLCDQueue != NULL )
\r
274 /* Add the created queue to the queue registry so it can be viewed in
\r
275 the IAR FreeRTOS state viewer plug-in. */
\r
276 vQueueAddToRegistry( xLCDQueue, "LCDQueue" );
\r
278 /* Create the standard demo tasks. */
\r
279 vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
\r
280 vStartDynamicPriorityTasks();
\r
281 vStartGenericQueueTasks( mainGENERIC_QUEUE_TEST_PRIORITY );
\r
283 /* Create the LCD, button poll and register test tasks, as described at
\r
284 the top of this file. */
\r
285 xTaskCreate( prvLCDTask, ( signed char * ) "LCD", configMINIMAL_STACK_SIZE * 2, mainTASK_PARAMETER_CHECK_VALUE, mainLCD_TASK_PRIORITY, NULL );
\r
286 xTaskCreate( prvButtonPollTask, ( signed char * ) "BPoll", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
\r
287 xTaskCreate( vRegTest1Task, ( signed char * ) "Reg1", configMINIMAL_STACK_SIZE, NULL, 0, NULL );
\r
288 xTaskCreate( vRegTest2Task, ( signed char * ) "Reg2", configMINIMAL_STACK_SIZE, NULL, 0, NULL );
\r
290 /* Start the scheduler. */
\r
291 vTaskStartScheduler();
\r
294 /* If all is well then this line will never be reached. If it is reached
\r
295 then it is likely that there was insufficient (FreeRTOS) heap memory space
\r
296 to create the idle task. This may have been trapped by the malloc() failed
\r
297 hook function, if one is configured. */
\r
300 /*-----------------------------------------------------------*/
\r
302 static void prvLCDTask( void *pvParameters )
\r
304 xQueueMessage xReceivedMessage;
\r
306 /* Buffer into which strings are formatted and placed ready for display on the
\r
307 LCD. Note this is a static variable to prevent it being allocated on the task
\r
308 stack, which is too small to hold such a variable. The stack size is configured
\r
309 when the task is created. */
\r
310 static char cBuffer[ 512 ];
\r
311 unsigned char ucLine = 1;
\r
314 /* This function is the only function that uses printf(). If printf() is
\r
315 used from any other function then some sort of mutual exclusion on stdout
\r
318 This is also the only function that is permitted to access the LCD.
\r
320 First print out the number of bytes that remain in the FreeRTOS heap. This
\r
321 can be viewed in the terminal IO window within the IAR Embedded Workbench. */
\r
322 printf( "%d bytes of heap space remain unallocated\n", ( int ) xPortGetFreeHeapSize() );
\r
324 /* Just as a test of the port, and for no functional reason, check the task
\r
325 parameter contains its expected value. */
\r
326 if( pvParameters != mainTASK_PARAMETER_CHECK_VALUE )
\r
328 halLcdPrintLine( "Invalid parameter", ucLine, OVERWRITE_TEXT );
\r
334 /* Wait for a message to be received. Using portMAX_DELAY as the block
\r
335 time will result in an indefinite wait provided INCLUDE_vTaskSuspend is
\r
336 set to 1 in FreeRTOSConfig.h, therefore there is no need to check the
\r
337 function return value and the function will only return when a value
\r
338 has been received. */
\r
339 xQueueReceive( xLCDQueue, &xReceivedMessage, portMAX_DELAY );
\r
341 /* Clear the LCD if no room remains for any more text output. */
\r
342 if( ucLine > mainMAX_LCD_LINES )
\r
344 halLcdClearScreen();
\r
348 /* What is this message? What does it contain? */
\r
349 switch( xReceivedMessage.cMessageID )
\r
351 case mainMESSAGE_BUTTON_UP : /* The button poll task has just
\r
352 informed this task that the up
\r
353 button on the joystick input has
\r
354 been pressed or released. */
\r
355 sprintf( cBuffer, "Button up = %d", ( int ) xReceivedMessage.ulMessageValue );
\r
358 case mainMESSAGE_BUTTON_SEL : /* The select button interrupt
\r
359 just informed this task that the
\r
360 select button was pressed.
\r
361 Generate a table of task run time
\r
362 statistics and output this to
\r
363 the terminal IO window in the IAR
\r
364 embedded workbench. */
\r
365 printf( "\nTask\t Abs Time\t %%Time\n*****************************************" );
\r
366 vTaskGetRunTimeStats( ( signed char * ) cBuffer );
\r
369 /* Also print out a message to
\r
370 the LCD - in this case the
\r
371 pointer to the string to print
\r
372 is sent directly in the
\r
373 ulMessageValue member of the
\r
374 message. This just demonstrates
\r
375 a different communication
\r
377 sprintf( cBuffer, "%s", ( char * ) xReceivedMessage.ulMessageValue );
\r
380 case mainMESSAGE_STATUS : /* The tick interrupt hook
\r
381 function has just informed this
\r
382 task of the system status.
\r
383 Generate a string in accordance
\r
384 with the status value. */
\r
385 prvGenerateStatusMessage( cBuffer, xReceivedMessage.ulMessageValue );
\r
388 default : sprintf( cBuffer, "Unknown message" );
\r
392 /* Output the message that was placed into the cBuffer array within the
\r
393 switch statement above, then move onto the next line ready for the next
\r
394 message to arrive on the queue. */
\r
395 halLcdPrintLine( cBuffer, ucLine, OVERWRITE_TEXT );
\r
399 /*-----------------------------------------------------------*/
\r
401 static void prvGenerateStatusMessage( char *pcBuffer, long lStatusValue )
\r
403 /* Just a utility function to convert a status value into a meaningful
\r
404 string for output onto the LCD. */
\r
405 switch( lStatusValue )
\r
407 case pdPASS : sprintf( pcBuffer, "Status = PASS" );
\r
409 case mainERROR_DYNAMIC_TASKS : sprintf( pcBuffer, "Err: Dynamic tsks" );
\r
411 case mainERROR_COM_TEST : sprintf( pcBuffer, "Err: COM test" );
\r
413 case mainERROR_GEN_QUEUE_TEST : sprintf( pcBuffer, "Error: Gen Q test" );
\r
415 case mainERROR_REG_TEST : sprintf( pcBuffer, "Error: Reg test" );
\r
417 default : sprintf( pcBuffer, "Unknown status" );
\r
421 /*-----------------------------------------------------------*/
\r
423 static void prvButtonPollTask( void *pvParameters )
\r
425 unsigned char ucLastState = pdFALSE, ucState;
\r
426 xQueueMessage xMessage;
\r
428 /* This tasks performs the button polling functionality as described at the
\r
429 top of this file. */
\r
432 /* Check the button state. */
\r
433 ucState = ( halButtonsPressed() & BUTTON_UP );
\r
437 /* The button was pressed. */
\r
441 if( ucState != ucLastState )
\r
443 /* The state has changed, send a message to the LCD task. */
\r
444 xMessage.cMessageID = mainMESSAGE_BUTTON_UP;
\r
445 xMessage.ulMessageValue = ( unsigned long ) ucState;
\r
446 ucLastState = ucState;
\r
447 xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );
\r
450 /* Block for 10 milliseconds so this task does not utilise all the CPU
\r
451 time and debouncing of the button is not necessary. */
\r
452 vTaskDelay( 10 / portTICK_RATE_MS );
\r
455 /*-----------------------------------------------------------*/
\r
457 static void prvSetupHardware( void )
\r
461 LFXT_Start( XT1DRIVE_0 );
\r
462 hal430SetSystemClock( configCPU_CLOCK_HZ, configLFXT_CLOCK_HZ );
\r
464 halButtonsInit( BUTTON_ALL );
\r
465 halButtonsInterruptEnable( BUTTON_SELECT );
\r
467 /* Initialise the LCD, but note that the backlight is not used as the
\r
468 library function uses timer A0 to modulate the backlight, and this file
\r
469 defines vApplicationSetupTimerInterrupt() to also use timer A0 to generate
\r
470 the tick interrupt. If the backlight is required, then change either the
\r
471 halLCD library or vApplicationSetupTimerInterrupt() to use a different
\r
472 timer. Timer A1 is used for the run time stats time base6. */
\r
474 halLcdSetContrast( 100 );
\r
475 halLcdClearScreen();
\r
477 halLcdPrintLine( " www.FreeRTOS.org", 0, OVERWRITE_TEXT );
\r
479 /*-----------------------------------------------------------*/
\r
481 void vApplicationTickHook( void )
\r
483 static unsigned short usLastRegTest1Counter = 0, usLastRegTest2Counter = 0;
\r
484 static unsigned long ulCounter = 0;
\r
485 static const unsigned long ulCheckFrequency = 5000UL / portTICK_RATE_MS;
\r
486 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
\r
488 /* Define the status message that is sent to the LCD task. By default the
\r
490 static xQueueMessage xStatusMessage = { mainMESSAGE_STATUS, pdPASS };
\r
492 /* This is called from within the tick interrupt and performs the 'check'
\r
493 functionality as described in the comments at the top of this file.
\r
495 Is it time to perform the 'check' functionality again? */
\r
497 if( ulCounter >= ulCheckFrequency )
\r
499 /* See if the standard demo tasks are executing as expected, changing
\r
500 the message that is sent to the LCD task from PASS to an error code if
\r
501 any tasks set reports an error. */
\r
502 if( xAreComTestTasksStillRunning() != pdPASS )
\r
504 xStatusMessage.ulMessageValue = mainERROR_COM_TEST;
\r
507 if( xAreDynamicPriorityTasksStillRunning() != pdPASS )
\r
509 xStatusMessage.ulMessageValue = mainERROR_DYNAMIC_TASKS;
\r
512 if( xAreGenericQueueTasksStillRunning() != pdPASS )
\r
514 xStatusMessage.ulMessageValue = mainERROR_GEN_QUEUE_TEST;
\r
517 /* Check the reg test tasks are still cycling. They will stop
\r
518 incrementing their loop counters if they encounter an error. */
\r
519 if( usRegTest1Counter == usLastRegTest1Counter )
\r
521 xStatusMessage.ulMessageValue = mainERROR_REG_TEST;
\r
524 if( usRegTest2Counter == usLastRegTest2Counter )
\r
526 xStatusMessage.ulMessageValue = mainERROR_REG_TEST;
\r
529 usLastRegTest1Counter = usRegTest1Counter;
\r
530 usLastRegTest2Counter = usRegTest2Counter;
\r
532 /* As this is the tick hook the lHigherPriorityTaskWoken parameter is not
\r
533 needed (a context switch is going to be performed anyway), but it must
\r
534 still be provided. */
\r
535 xQueueSendFromISR( xLCDQueue, &xStatusMessage, &xHigherPriorityTaskWoken );
\r
539 /* Just periodically toggle an LED to show that the tick interrupt is
\r
540 running. Note that this access LED_PORT_OUT in a non-atomic way, so tasks
\r
541 that access the same port must do so from a critical section. */
\r
542 if( ( ulCounter & 0xff ) == 0 )
\r
544 if( ( LED_PORT_OUT & LED_1 ) == 0 )
\r
546 LED_PORT_OUT |= LED_1;
\r
550 LED_PORT_OUT &= ~LED_1;
\r
554 /*-----------------------------------------------------------*/
\r
556 #pragma vector=PORT2_VECTOR
\r
557 __interrupt static void prvSelectButtonInterrupt(void)
\r
559 /* Define the message sent to the LCD task from this interrupt. */
\r
560 static const xQueueMessage xMessage = { mainMESSAGE_BUTTON_SEL, ( unsigned long ) "Select Interrupt" };
\r
561 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
\r
563 /* This is the interrupt handler for the joystick select button input.
\r
564 The button has been pushed, write a message to the LCD via the LCD task. */
\r
565 xQueueSendFromISR( xLCDQueue, &xMessage, &xHigherPriorityTaskWoken );
\r
569 /* If writing to xLCDQueue caused a task to unblock, and the unblocked task
\r
570 has a priority equal to or above the task that this interrupt interrupted,
\r
571 then lHigherPriorityTaskWoken will have been set to pdTRUE internally within
\r
572 xQueuesendFromISR(), and portEND_SWITCHING_ISR() will ensure that this
\r
573 interrupt returns directly to the higher priority unblocked task. */
\r
574 portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
\r
576 /*-----------------------------------------------------------*/
\r
578 /* The MSP430X port uses this callback function to configure its tick interrupt.
\r
579 This allows the application to choose the tick interrupt source.
\r
580 configTICK_VECTOR must also be set in FreeRTOSConfig.h to the correct
\r
581 interrupt vector for the chosen tick interrupt source. This implementation of
\r
582 vApplicationSetupTimerInterrupt() generates the tick from timer A0, so in this
\r
583 case configTICK_VECTOR is set to TIMER0_A0_VECTOR. */
\r
584 void vApplicationSetupTimerInterrupt( void )
\r
586 const unsigned short usACLK_Frequency_Hz = 32768;
\r
588 /* Ensure the timer is stopped. */
\r
591 /* Run the timer from the ACLK. */
\r
594 /* Clear everything to start with. */
\r
597 /* Set the compare match value according to the tick rate we want. */
\r
598 TA0CCR0 = usACLK_Frequency_Hz / configTICK_RATE_HZ;
\r
600 /* Enable the interrupts. */
\r
603 /* Start up clean. */
\r
609 /*-----------------------------------------------------------*/
\r
611 void vApplicationIdleHook( void )
\r
613 /* Called on each iteration of the idle task. In this case the idle task
\r
614 just enters a low power mode. */
\r
615 __bis_SR_register( LPM3_bits + GIE );
\r
617 /*-----------------------------------------------------------*/
\r
619 void vApplicationMallocFailedHook( void )
\r
621 /* Called if a call to pvPortMalloc() fails because there is insufficient
\r
622 free memory available in the FreeRTOS heap. pvPortMalloc() is called
\r
623 internally by FreeRTOS API functions that create tasks, queues or
\r
625 taskDISABLE_INTERRUPTS();
\r
628 /*-----------------------------------------------------------*/
\r
630 void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )
\r
633 ( void ) pcTaskName;
\r
635 /* Run time stack overflow checking is performed if
\r
636 configconfigCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
\r
637 function is called if a stack overflow is detected. */
\r
638 taskDISABLE_INTERRUPTS();
\r
641 /*-----------------------------------------------------------*/
\r