2 * FreeRTOS Kernel V10.0.0
\r
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software. If you wish to use our Amazon
\r
14 * FreeRTOS name, please do so in a fair use way that does not cause confusion.
\r
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 * http://www.FreeRTOS.org
\r
24 * http://aws.amazon.com/freertos
\r
26 * 1 tab == 4 spaces!
\r
29 /******************************************************************************
\r
30 * This project provides two demo applications. A simple blinky style project,
\r
31 * and a more comprehensive test and demo application. The
\r
32 * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to
\r
33 * select between the two. The simply blinky demo is implemented and described
\r
34 * in main_blinky.c. The more comprehensive test and demo application is
\r
35 * implemented and described in main_full.c.
\r
37 * This file implements the code that is not demo specific, including the
\r
38 * hardware setup and FreeRTOS hook functions.
\r
40 * This project does not provide an example of how to write an RTOS compatible
\r
41 * interrupt service routine (other than the tick interrupt itself), so this
\r
42 * file contains the function vAnExampleISR_C_Handler() as a dummy example (that
\r
43 * is not actually installed) that can be used as a reference. Also see the
\r
44 * file ExampleISR.s87, and the documentation page for this demo on the
\r
45 * FreeRTOS.org website for full instructions.
\r
47 * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON
\r
48 * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO
\r
49 * APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!
\r
53 /* Scheduler include files. */
\r
54 #include "FreeRTOS.h"
\r
58 /* Hardware includes. */
\r
59 #include "demo_specific_io.h"
\r
61 /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
\r
62 or 0 to run the more comprehensive test and demo application. */
\r
63 #define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0
\r
65 /*-----------------------------------------------------------*/
\r
68 * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
\r
69 * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.
\r
71 extern void main_blinky( void );
\r
72 extern void main_full( void );
\r
75 * This function is called from the C startup routine to setup the processor -
\r
76 * in particular the clock source.
\r
78 int __low_level_init(void);
\r
80 /* Prototypes for the standard FreeRTOS callback/hook functions implemented
\r
81 within this file. */
\r
82 void vApplicationMallocFailedHook( void );
\r
83 void vApplicationIdleHook( void );
\r
84 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
\r
85 void vApplicationTickHook( void );
\r
87 /*-----------------------------------------------------------*/
\r
89 /* This variable is not actually used, but provided to allow an example of how
\r
90 to write an ISR to be included in this file. */
\r
91 static SemaphoreHandle_t xSemaphore = NULL;
\r
93 /* RL78 Option Byte Definition. Watchdog disabled, LVI enabled, OCD interface
\r
95 __root __far const unsigned char OptionByte[] @ 0x00C0 =
\r
97 0x6eU, 0xffU, 0xe8U, 0x85U
\r
100 /* Security byte definition */
\r
101 __root __far const unsigned char ucSecurityCode[] @ 0x00C4 =
\r
103 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
\r
106 /*-----------------------------------------------------------*/
\r
110 /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
\r
112 #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1
\r
122 /*-----------------------------------------------------------*/
\r
124 void vAnExampleISR_C_Handler( void )
\r
127 * This demo does not include a functional interrupt service routine - so
\r
128 * this dummy handler (which is not actually installed) is provided as an
\r
129 * example of how an ISR that needs to cause a context switch needs to be
\r
130 * implemented. ISRs that do not cause a context switch have no special
\r
131 * requirements and can be written as per the compiler documentation.
\r
133 * This C function is called from a wrapper function that is implemented
\r
134 * in assembly code. See vANExampleISR_ASM_Wrapper() in ExampleISR.s87.
\r
135 * Also see the documentation page for this demo on the FreeRTOS.org website
\r
136 * for full instructions.
\r
138 short sHigherPriorityTaskWoken = pdFALSE;
\r
140 /* Handler code goes here...*/
\r
142 /* For purposes of demonstration, assume at some point the hander calls
\r
143 xSemaphoreGiveFromISR().*/
\r
144 xSemaphoreGiveFromISR( xSemaphore, &sHigherPriorityTaskWoken );
\r
146 /* If giving the semaphore unblocked a task, and the unblocked task has a
\r
147 priority higher than or equal to the currently running task, then
\r
148 sHigherPriorityTaskWoken will have been set to pdTRUE internally within the
\r
149 xSemaphoreGiveFromISR() function. Passing a pdTRUE value to
\r
150 portYIELD_FROM_ISR() will cause this interrupt to return directly to the
\r
151 higher priority unblocked task. */
\r
152 portYIELD_FROM_ISR( sHigherPriorityTaskWoken );
\r
154 /*-----------------------------------------------------------*/
\r
156 int __low_level_init(void)
\r
158 portDISABLE_INTERRUPTS();
\r
177 /* LED port initialization. */
\r
182 /*-----------------------------------------------------------*/
\r
184 void vApplicationMallocFailedHook( void )
\r
186 /* Called if a call to pvPortMalloc() fails because there is insufficient
\r
187 free memory available in the FreeRTOS heap. pvPortMalloc() is called
\r
188 internally by FreeRTOS API functions that create tasks, queues, software
\r
189 timers, and semaphores. The size of the FreeRTOS heap is set by the
\r
190 configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
\r
191 taskDISABLE_INTERRUPTS();
\r
194 /*-----------------------------------------------------------*/
\r
196 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
\r
198 ( void ) pcTaskName;
\r
201 /* Run time stack overflow checking is performed if
\r
202 configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
\r
203 function is called if a stack overflow is detected. */
\r
204 taskDISABLE_INTERRUPTS();
\r
207 /*-----------------------------------------------------------*/
\r
209 void vApplicationIdleHook( void )
\r
211 volatile size_t xFreeHeapSpace;
\r
213 /* This is just a trivial example of an idle hook. It is called on each
\r
214 cycle of the idle task. It must *NOT* attempt to block. In this case the
\r
215 idle task just queries the amount of FreeRTOS heap that remains. See the
\r
216 memory management section on the http://www.FreeRTOS.org web site for memory
\r
217 management options. If there is a lot of heap memory free then the
\r
218 configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up
\r
220 xFreeHeapSpace = xPortGetFreeHeapSize();
\r
222 /* Remove compiler warning about xFreeHeapSpace being set but never used. */
\r
223 ( void ) xFreeHeapSpace;
\r