2 FreeRTOS V9.0.1 - Copyright (C) 2017 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
70 /******************************************************************************
\r
71 * This project provides two demo applications. A simple blinky style project,
\r
72 * and a more comprehensive test and demo application. The
\r
73 * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to
\r
74 * select between the two. The simply blinky demo is implemented and described
\r
75 * in main_blinky.c. The more comprehensive test and demo application is
\r
76 * implemented and described in main_full.c.
\r
78 * This file implements the code that is not demo specific, including the
\r
79 * hardware setup and standard FreeRTOS hook functions.
\r
81 * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON
\r
82 * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO
\r
83 * APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!
\r
87 /* Scheduler include files. */
\r
88 #include "FreeRTOS.h"
\r
92 /* Library includes. */
\r
96 /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
\r
97 or 0 to run the more comprehensive test and demo application. */
\r
98 #define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 1
\r
100 /*-----------------------------------------------------------*/
\r
103 * Configure the hardware as necessary to run this demo.
\r
105 static void prvSetupHardware( void );
\r
108 * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
\r
109 * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.
\r
111 #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1
\r
112 extern void main_blinky( void );
\r
114 extern void main_full( void );
\r
115 #endif /* #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 */
\r
117 /* Prototypes for the standard FreeRTOS callback/hook functions implemented
\r
118 within this file. */
\r
119 void vApplicationMallocFailedHook( void );
\r
120 void vApplicationIdleHook( void );
\r
121 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
\r
122 void vApplicationTickHook( void );
\r
124 /*-----------------------------------------------------------*/
\r
128 /* Configure the hardware ready to run the demo. */
\r
129 prvSetupHardware();
\r
131 /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
\r
133 #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
\r
145 /*-----------------------------------------------------------*/
\r
147 static void prvSetupHardware( void )
\r
152 /*-----------------------------------------------------------*/
\r
154 void vApplicationMallocFailedHook( void )
\r
156 /* Called if a call to pvPortMalloc() fails because there is insufficient
\r
157 free memory available in the FreeRTOS heap. pvPortMalloc() is called
\r
158 internally by FreeRTOS API functions that create tasks, queues, software
\r
159 timers, and semaphores. The size of the FreeRTOS heap is set by the
\r
160 configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
\r
162 /* Force an assert. */
\r
163 configASSERT( ( volatile void * ) NULL );
\r
165 /*-----------------------------------------------------------*/
\r
167 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
\r
169 ( void ) pcTaskName;
\r
172 /* Run time stack overflow checking is performed if
\r
173 configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
\r
174 function is called if a stack overflow is detected. */
\r
176 /* Force an assert. */
\r
177 configASSERT( ( volatile void * ) NULL );
\r
179 /*-----------------------------------------------------------*/
\r
181 void vApplicationIdleHook( void )
\r
183 volatile size_t xFreeHeapSpace;
\r
185 /* This is just a trivial example of an idle hook. It is called on each
\r
186 cycle of the idle task. It must *NOT* attempt to block. In this case the
\r
187 idle task just queries the amount of FreeRTOS heap that remains. See the
\r
188 memory management section on the http://www.FreeRTOS.org web site for memory
\r
189 management options. If there is a lot of heap memory free then the
\r
190 configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up
\r
192 xFreeHeapSpace = xPortGetFreeHeapSize();
\r
194 /* Remove compiler warning about xFreeHeapSpace being set but never used. */
\r
195 ( void ) xFreeHeapSpace;
\r
197 /*-----------------------------------------------------------*/
\r
199 void vApplicationTickHook( void )
\r
201 #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )
\r
203 extern void vFullDemoTickHook( void );
\r
205 /* The full demo includes some tests that execute in an interrupt
\r
206 context, and the tick hook is used for this purpose. */
\r
207 vFullDemoTickHook();
\r
211 /*-----------------------------------------------------------*/
\r
238 * \brief Getting Started Application.
\r
240 * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
\r
242 * \asf_license_start
\r
246 * Redistribution and use in source and binary forms, with or without
\r
247 * modification, are permitted provided that the following conditions are met:
\r
249 * 1. Redistributions of source code must retain the above copyright notice,
\r
250 * this list of conditions and the following disclaimer.
\r
252 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
253 * this list of conditions and the following disclaimer in the documentation
\r
254 * and/or other materials provided with the distribution.
\r
256 * 3. The name of Atmel may not be used to endorse or promote products derived
\r
257 * from this software without specific prior written permission.
\r
259 * 4. This software may only be redistributed and used in connection with an
\r
260 * Atmel microcontroller product.
\r
262 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
\r
263 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
264 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
265 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
\r
266 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
267 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
\r
268 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
269 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
\r
270 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
\r
271 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
272 * POSSIBILITY OF SUCH DAMAGE.
\r
274 * \asf_license_stop
\r
279 * \mainpage Getting Started Application
\r
283 * The Getting Started example will help new users get familiar with Atmel's
\r
284 * SAM family of microcontrollers. This basic application shows the startup
\r
285 * sequence of a chip and how to use its core peripherals.
\r
287 * \section Requirements
\r
289 * This package can be used with SAM evaluation kits.
\r
291 * \section Description
\r
293 * The demonstration program makes the LED(s) on the board blink at a fixed rate.
\r
294 * This rate is generated by using Time tick timer. The blinking can be stopped
\r
295 * using the push button.
\r
299 * -# Build the program and download it inside the evaluation board.
\r
300 * -# On the computer, open and configure a terminal application
\r
301 * (e.g. HyperTerminal on Microsoft Windows) with these settings:
\r
306 * - No flow control
\r
307 * -# Start the application.
\r
308 * -# The LED(s) should start blinking on the board. In the terminal window, the
\r
309 * following text should appear (values depend on the board and chip used):
\r
311 -- Getting Started Example xxx --
\r
313 -- Compiled: xxx xx xxxx xx:xx:xx --
\r
315 * -# Pressing and release button 1 should make one LED stop & restart
\r
317 * -# If the button 2 available, pressing button 2 should make the other LED
\r
318 * stop & restart blinking.
\r
322 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
\r
325 #include "FreeRTOS.h"
\r
329 #include "stdio_serial.h"
\r
330 #include "conf_board.h"
\r
331 #include "conf_clock.h"
\r
333 /** IRQ priority for PIO (The lower the value, the greater the priority) */
\r
334 // [main_def_pio_irq_prior]
\r
335 #define IRQ_PRIOR_PIO 0
\r
336 // [main_def_pio_irq_prior]
\r
338 /** LED0 blink time, LED1 blink half this time, in ms */
\r
339 #define BLINK_PERIOD 1000
\r
341 #define STRING_EOL "\r"
\r
342 #define STRING_HEADER "-- Getting Started Example --\r\n" \
\r
343 "-- "BOARD_NAME" --\r\n" \
\r
344 "-- Compiled: "__DATE__" "__TIME__" --"STRING_EOL
\r
346 /** LED0 blinking control. */
\r
347 // [main_var_led0_control]
\r
348 volatile bool g_b_led0_active = true;
\r
349 // [main_var_led0_control]
\r
352 /** LED1 blinking control. */
\r
353 // [main_var_led1_control]
\r
354 volatile bool g_b_led1_active = true;
\r
355 // [main_var_led1_control]
\r
358 /** Global g_ul_ms_ticks in milliseconds since start of application */
\r
359 // [main_var_ticks]
\r
360 volatile uint32_t g_ul_ms_ticks = 0;
\r
361 // [main_var_ticks]
\r
372 /* Prototypes for the standard FreeRTOS callback/hook functions implemented
\r
373 within this file. */
\r
374 void vApplicationMallocFailedHook( void );
\r
375 void vApplicationIdleHook( void );
\r
376 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
\r
377 void vApplicationTickHook( void );
\r
381 * \brief Process Buttons Events
\r
383 * Change active states of LEDs when corresponding button events happened.
\r
385 static void ProcessButtonEvt(uint8_t uc_button)
\r
387 // [main_button1_evnt_process]
\r
388 if (uc_button == 0) {
\r
389 g_b_led0_active = !g_b_led0_active;
\r
390 if (!g_b_led0_active) {
\r
391 ioport_set_pin_level(LED0_GPIO, IOPORT_PIN_LEVEL_HIGH);
\r
394 // [main_button1_evnt_process]
\r
397 // [main_button2_evnt_process]
\r
398 g_b_led1_active = !g_b_led1_active;
\r
400 /* Enable LED#2 and TC if they were enabled */
\r
401 if (g_b_led1_active) {
\r
402 ioport_set_pin_level(LED1_GPIO, IOPORT_PIN_LEVEL_LOW);
\r
405 /* Disable LED#2 and TC if they were disabled */
\r
407 ioport_set_pin_level(LED1_GPIO, IOPORT_PIN_LEVEL_HIGH);
\r
410 // [main_button2_evnt_process]
\r
416 * \brief Handler for System Tick interrupt.
\r
418 * Process System Tick Event
\r
419 * Increments the g_ul_ms_ticks counter.
\r
421 // [main_systick_handler]
\r
422 void _SysTick_Handler(void)
\r
426 // [main_systick_handler]
\r
429 * \brief Handler for Button 1 rising edge interrupt.
\r
431 * Handle process led1 status change.
\r
433 // [main_button1_handler]
\r
434 static void Button1_Handler(uint32_t id, uint32_t mask)
\r
436 if (PIN_PUSHBUTTON_1_ID == id && PIN_PUSHBUTTON_1_MASK == mask) {
\r
437 ProcessButtonEvt(0);
\r
440 // [main_button1_handler]
\r
442 #ifndef BOARD_NO_PUSHBUTTON_2
\r
444 * \brief Handler for Button 2 falling edge interrupt.
\r
446 * Handle process led2 status change.
\r
448 // [main_button2_handler]
\r
449 static void Button2_Handler(uint32_t id, uint32_t mask)
\r
451 if (PIN_PUSHBUTTON_2_ID == id && PIN_PUSHBUTTON_2_MASK == mask) {
\r
452 ProcessButtonEvt(1);
\r
455 // [main_button2_handler]
\r
459 * \brief Configure the Pushbuttons
\r
461 * Configure the PIO as inputs and generate corresponding interrupt when
\r
462 * pressed or released.
\r
464 static void configure_buttons(void)
\r
466 // [main_button1_configure]
\r
467 /* Configure Pushbutton 1 */
\r
468 pmc_enable_periph_clk(PIN_PUSHBUTTON_1_ID);
\r
469 pio_set_debounce_filter(PIN_PUSHBUTTON_1_PIO, PIN_PUSHBUTTON_1_MASK, 10);
\r
470 /* Interrupt on rising edge */
\r
471 pio_handler_set(PIN_PUSHBUTTON_1_PIO, PIN_PUSHBUTTON_1_ID,
\r
472 PIN_PUSHBUTTON_1_MASK, PIN_PUSHBUTTON_1_ATTR, Button1_Handler);
\r
473 NVIC_EnableIRQ((IRQn_Type) PIN_PUSHBUTTON_1_ID);
\r
474 pio_handler_set_priority(PIN_PUSHBUTTON_1_PIO,
\r
475 (IRQn_Type) PIN_PUSHBUTTON_1_ID, IRQ_PRIOR_PIO);
\r
476 pio_enable_interrupt(PIN_PUSHBUTTON_1_PIO, PIN_PUSHBUTTON_1_MASK);
\r
477 // [main_button1_configure]
\r
478 #ifndef BOARD_NO_PUSHBUTTON_2
\r
479 // [main_button2_configure]
\r
480 /* Configure Pushbutton 2 */
\r
481 pmc_enable_periph_clk(PIN_PUSHBUTTON_2_ID);
\r
482 pio_set_debounce_filter(PIN_PUSHBUTTON_2_PIO, PIN_PUSHBUTTON_2_MASK, 10);
\r
483 /* Interrupt on falling edge */
\r
484 pio_handler_set(PIN_PUSHBUTTON_2_PIO, PIN_PUSHBUTTON_2_ID,
\r
485 PIN_PUSHBUTTON_2_MASK, PIN_PUSHBUTTON_2_ATTR, Button2_Handler);
\r
486 NVIC_EnableIRQ((IRQn_Type) PIN_PUSHBUTTON_2_ID);
\r
487 pio_handler_set_priority(PIN_PUSHBUTTON_2_PIO,
\r
488 (IRQn_Type) PIN_PUSHBUTTON_2_ID, IRQ_PRIOR_PIO);
\r
489 pio_enable_interrupt(PIN_PUSHBUTTON_2_PIO, PIN_PUSHBUTTON_2_MASK);
\r
490 // [main_button2_configure]
\r
495 * Interrupt handler for TC0 interrupt. Toggles the state of LED\#2.
\r
497 // [main_tc0_handler]
\r
498 #ifndef BOARD_NO_LED_1
\r
499 void TC0_Handler(void)
\r
501 volatile uint32_t ul_dummy;
\r
503 /* Clear status bit to acknowledge interrupt */
\r
504 ul_dummy = tc_get_status(TC0, 0);
\r
506 /* Avoid compiler warning */
\r
510 /** Toggle LED state. */
\r
511 ioport_toggle_pin_level(LED1_GPIO);
\r
516 // [main_tc0_handler]
\r
519 * Configure Timer Counter 0 to generate an interrupt every 250ms.
\r
521 // [main_tc_configure]
\r
522 static void configure_tc(void)
\r
525 uint32_t ul_tcclks;
\r
526 uint32_t ul_sysclk = sysclk_get_cpu_hz();
\r
528 /* Configure PMC */
\r
529 pmc_enable_periph_clk(ID_TC0);
\r
531 /* Enable PCK output */
\r
532 pmc_disable_pck(PMC_PCK_3);
\r
533 pmc_switch_pck_to_sclk(PMC_PCK_3, PMC_PCK_PRES_CLK_1);
\r
534 pmc_enable_pck(PMC_PCK_3);
\r
537 /** Configure TC for a 4Hz frequency and trigger on RC compare. */
\r
538 tc_find_mck_divisor(4, ul_sysclk, &ul_div, &ul_tcclks, ul_sysclk);
\r
539 tc_init(TC0, 0, ul_tcclks | TC_CMR_CPCTRG);
\r
540 tc_write_rc(TC0, 0, (ul_sysclk / ul_div) / 4);
\r
542 /* Configure and enable interrupt on RC compare */
\r
543 NVIC_EnableIRQ((IRQn_Type) ID_TC0);
\r
544 tc_enable_interrupt(TC0, 0, TC_IER_CPCS);
\r
547 /** Start the counter if LED1 is enabled. */
\r
548 if (g_b_led1_active) {
\r
556 // [main_tc_configure]
\r
559 * Configure UART console.
\r
561 // [main_console_configure]
\r
562 static void configure_console(void)
\r
564 const usart_serial_options_t uart_serial_options = {
\r
565 .baudrate = CONF_UART_BAUDRATE,
\r
566 #ifdef CONF_UART_CHAR_LENGTH
\r
567 .charlength = CONF_UART_CHAR_LENGTH,
\r
569 .paritytype = CONF_UART_PARITY,
\r
570 #ifdef CONF_UART_STOP_BITS
\r
571 .stopbits = CONF_UART_STOP_BITS,
\r
575 /* Configure console UART. */
\r
576 sysclk_enable_peripheral_clock(CONSOLE_UART_ID);
\r
577 stdio_serial_init(CONF_UART, &uart_serial_options);
\r
580 // [main_console_configure]
\r
583 * \brief Wait for the given number of milliseconds (using the g_ul_ms_ticks
\r
584 * generated by the SAM's microcontrollers's system tick).
\r
586 * \param ul_dly_ticks Delay to wait for, in milliseconds.
\r
589 static void mdelay(uint32_t ul_dly_ticks)
\r
591 uint32_t ul_cur_ticks;
\r
593 ul_cur_ticks = g_ul_ms_ticks;
\r
594 while ((g_ul_ms_ticks - ul_cur_ticks) < ul_dly_ticks);
\r
599 * \brief getting-started Application entry point.
\r
601 * \return Unused (ANSI-C compatibility).
\r
606 //! [main_step_sys_init]
\r
607 /* Initialize the SAM system */
\r
610 //! [main_step_sys_init]
\r
612 #ifndef BOARD_NO_PUSHBUTTON_2
\r
613 #if (SAMV71 || SAMV70 || SAMS70 || SAME70)
\r
614 if (GPIO_PUSH_BUTTON_2 == PIO_PB12_IDX) {
\r
615 matrix_set_system_io(matrix_get_system_io() | CCFG_SYSIO_SYSIO12);
\r
617 ioport_set_pin_dir(GPIO_PUSH_BUTTON_2, IOPORT_DIR_INPUT);
\r
618 ioport_set_pin_mode(GPIO_PUSH_BUTTON_2, GPIO_PUSH_BUTTON_2_FLAGS);
\r
619 ioport_set_pin_sense_mode(GPIO_PUSH_BUTTON_2, GPIO_PUSH_BUTTON_2_SENSE);
\r
622 //! [main_step_console_init]
\r
623 /* Initialize the console uart */
\r
624 configure_console();
\r
625 //! [main_step_console_init]
\r
627 /* Output example information */
\r
628 puts(STRING_HEADER);
\r
630 /* Configure systick for 1 ms */
\r
631 puts("Configure system tick to get 1ms tick period.\r");
\r
632 //! [main_step_systick_init]
\r
633 if (SysTick_Config(sysclk_get_cpu_hz() / 1000)) {
\r
634 puts("-F- Systick configuration error\r");
\r
637 //! [main_step_systick_init]
\r
639 #ifndef BOARD_NO_LED_1
\r
640 puts("Configure TC.\r");
\r
641 //! [main_step_tc_init]
\r
643 //! [main_step_tc_init]
\r
646 puts("Configure buttons with debouncing.\r");
\r
647 //! [main_step_btn_init]
\r
648 configure_buttons();
\r
649 //! [main_step_btn_init]
\r
651 printf("Press %s to Start/Stop the %s blinking.\r\n",
\r
652 PUSHBUTTON_1_NAME, LED_0_NAME);
\r
654 #ifndef BOARD_NO_PUSHBUTTON_2
\r
655 printf("Press %s to Start/Stop the %s blinking.\r\n",
\r
656 PUSHBUTTON_2_NAME, LED_1_NAME);
\r
659 //! [main_step_loop]
\r
661 /* Wait for LED to be active */
\r
662 while (!g_b_led0_active);
\r
664 /* Toggle LED state if active */
\r
665 if (g_b_led0_active) {
\r
666 ioport_toggle_pin_level(LED0_GPIO);
\r
670 /* Wait for 500ms */
\r
673 //! [main_step_loop]
\r
684 void vApplicationMallocFailedHook( void )
\r
686 /* Called if a call to pvPortMalloc() fails because there is insufficient
\r
687 free memory available in the FreeRTOS heap. pvPortMalloc() is called
\r
688 internally by FreeRTOS API functions that create tasks, queues, software
\r
689 timers, and semaphores. The size of the FreeRTOS heap is set by the
\r
690 configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
\r
692 /* Force an assert. */
\r
693 configASSERT( ( volatile void * ) NULL );
\r
695 /*-----------------------------------------------------------*/
\r
697 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
\r
699 ( void ) pcTaskName;
\r
702 /* Run time stack overflow checking is performed if
\r
703 configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
\r
704 function is called if a stack overflow is detected. */
\r
706 /* Force an assert. */
\r
707 configASSERT( ( volatile void * ) NULL );
\r
709 /*-----------------------------------------------------------*/
\r
711 void vApplicationIdleHook( void )
\r
713 volatile size_t xFreeHeapSpace;
\r
715 /* This is just a trivial example of an idle hook. It is called on each
\r
716 cycle of the idle task. It must *NOT* attempt to block. In this case the
\r
717 idle task just queries the amount of FreeRTOS heap that remains. See the
\r
718 memory management section on the http://www.FreeRTOS.org web site for memory
\r
719 management options. If there is a lot of heap memory free then the
\r
720 configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up
\r
722 xFreeHeapSpace = xPortGetFreeHeapSize();
\r
724 /* Remove compiler warning about xFreeHeapSpace being set but never used. */
\r
725 ( void ) xFreeHeapSpace;
\r
727 /*-----------------------------------------------------------*/
\r
729 void vApplicationTickHook( void )
\r
732 /*-----------------------------------------------------------*/
\r