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