FreeRTOS v_8.2.1 for LPC1768

Dependents:   frtos_v_8_bluetooth frtos_v_8_pololu frtos_v_8_Final

Committer:
JoaoJardim
Date:
Mon Dec 10 10:04:09 2018 +0000
Revision:
1:2f4de0d9dc8b
Parent:
0:91ad48ad5687
Same implementation as freertos_bluetooth at this time, but with FreeRTOS v_8.2.1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:91ad48ad5687 1 /*
dflet 0:91ad48ad5687 2 FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd.
dflet 0:91ad48ad5687 3 All rights reserved
dflet 0:91ad48ad5687 4
dflet 0:91ad48ad5687 5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
dflet 0:91ad48ad5687 6
dflet 0:91ad48ad5687 7 This file is part of the FreeRTOS distribution.
dflet 0:91ad48ad5687 8
dflet 0:91ad48ad5687 9 FreeRTOS is free software; you can redistribute it and/or modify it under
dflet 0:91ad48ad5687 10 the terms of the GNU General Public License (version 2) as published by the
dflet 0:91ad48ad5687 11 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
dflet 0:91ad48ad5687 12
dflet 0:91ad48ad5687 13 ***************************************************************************
dflet 0:91ad48ad5687 14 >>! NOTE: The modification to the GPL is included to allow you to !<<
dflet 0:91ad48ad5687 15 >>! distribute a combined work that includes FreeRTOS without being !<<
dflet 0:91ad48ad5687 16 >>! obliged to provide the source code for proprietary components !<<
dflet 0:91ad48ad5687 17 >>! outside of the FreeRTOS kernel. !<<
dflet 0:91ad48ad5687 18 ***************************************************************************
dflet 0:91ad48ad5687 19
dflet 0:91ad48ad5687 20 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
dflet 0:91ad48ad5687 21 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dflet 0:91ad48ad5687 22 FOR A PARTICULAR PURPOSE. Full license text is available on the following
dflet 0:91ad48ad5687 23 link: http://www.freertos.org/a00114.html
dflet 0:91ad48ad5687 24
dflet 0:91ad48ad5687 25 ***************************************************************************
dflet 0:91ad48ad5687 26 * *
dflet 0:91ad48ad5687 27 * FreeRTOS provides completely free yet professionally developed, *
dflet 0:91ad48ad5687 28 * robust, strictly quality controlled, supported, and cross *
dflet 0:91ad48ad5687 29 * platform software that is more than just the market leader, it *
dflet 0:91ad48ad5687 30 * is the industry's de facto standard. *
dflet 0:91ad48ad5687 31 * *
dflet 0:91ad48ad5687 32 * Help yourself get started quickly while simultaneously helping *
dflet 0:91ad48ad5687 33 * to support the FreeRTOS project by purchasing a FreeRTOS *
dflet 0:91ad48ad5687 34 * tutorial book, reference manual, or both: *
dflet 0:91ad48ad5687 35 * http://www.FreeRTOS.org/Documentation *
dflet 0:91ad48ad5687 36 * *
dflet 0:91ad48ad5687 37 ***************************************************************************
dflet 0:91ad48ad5687 38
dflet 0:91ad48ad5687 39 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
dflet 0:91ad48ad5687 40 the FAQ page "My application does not run, what could be wrong?". Have you
dflet 0:91ad48ad5687 41 defined configASSERT()?
dflet 0:91ad48ad5687 42
dflet 0:91ad48ad5687 43 http://www.FreeRTOS.org/support - In return for receiving this top quality
dflet 0:91ad48ad5687 44 embedded software for free we request you assist our global community by
dflet 0:91ad48ad5687 45 participating in the support forum.
dflet 0:91ad48ad5687 46
dflet 0:91ad48ad5687 47 http://www.FreeRTOS.org/training - Investing in training allows your team to
dflet 0:91ad48ad5687 48 be as productive as possible as early as possible. Now you can receive
dflet 0:91ad48ad5687 49 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
dflet 0:91ad48ad5687 50 Ltd, and the world's leading authority on the world's leading RTOS.
dflet 0:91ad48ad5687 51
dflet 0:91ad48ad5687 52 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
dflet 0:91ad48ad5687 53 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
dflet 0:91ad48ad5687 54 compatible FAT file system, and our tiny thread aware UDP/IP stack.
dflet 0:91ad48ad5687 55
dflet 0:91ad48ad5687 56 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
dflet 0:91ad48ad5687 57 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
dflet 0:91ad48ad5687 58
dflet 0:91ad48ad5687 59 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
dflet 0:91ad48ad5687 60 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
dflet 0:91ad48ad5687 61 licenses offer ticketed support, indemnification and commercial middleware.
dflet 0:91ad48ad5687 62
dflet 0:91ad48ad5687 63 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
dflet 0:91ad48ad5687 64 engineered and independently SIL3 certified version for use in safety and
dflet 0:91ad48ad5687 65 mission critical applications that require provable dependability.
dflet 0:91ad48ad5687 66
dflet 0:91ad48ad5687 67 1 tab == 4 spaces!
dflet 0:91ad48ad5687 68 */
dflet 0:91ad48ad5687 69
dflet 0:91ad48ad5687 70 #ifndef STACK_MACROS_H
dflet 0:91ad48ad5687 71 #define STACK_MACROS_H
dflet 0:91ad48ad5687 72
dflet 0:91ad48ad5687 73 /*
dflet 0:91ad48ad5687 74 * Call the stack overflow hook function if the stack of the task being swapped
dflet 0:91ad48ad5687 75 * out is currently overflowed, or looks like it might have overflowed in the
dflet 0:91ad48ad5687 76 * past.
dflet 0:91ad48ad5687 77 *
dflet 0:91ad48ad5687 78 * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check
dflet 0:91ad48ad5687 79 * the current stack state only - comparing the current top of stack value to
dflet 0:91ad48ad5687 80 * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1
dflet 0:91ad48ad5687 81 * will also cause the last few stack bytes to be checked to ensure the value
dflet 0:91ad48ad5687 82 * to which the bytes were set when the task was created have not been
dflet 0:91ad48ad5687 83 * overwritten. Note this second test does not guarantee that an overflowed
dflet 0:91ad48ad5687 84 * stack will always be recognised.
dflet 0:91ad48ad5687 85 */
dflet 0:91ad48ad5687 86
dflet 0:91ad48ad5687 87 /*-----------------------------------------------------------*/
dflet 0:91ad48ad5687 88
dflet 0:91ad48ad5687 89 #if( configCHECK_FOR_STACK_OVERFLOW == 0 )
dflet 0:91ad48ad5687 90
dflet 0:91ad48ad5687 91 /* FreeRTOSConfig.h is not set to check for stack overflows. */
dflet 0:91ad48ad5687 92 #define taskFIRST_CHECK_FOR_STACK_OVERFLOW()
dflet 0:91ad48ad5687 93 #define taskSECOND_CHECK_FOR_STACK_OVERFLOW()
dflet 0:91ad48ad5687 94
dflet 0:91ad48ad5687 95 #endif /* configCHECK_FOR_STACK_OVERFLOW == 0 */
dflet 0:91ad48ad5687 96 /*-----------------------------------------------------------*/
dflet 0:91ad48ad5687 97
dflet 0:91ad48ad5687 98 #if( configCHECK_FOR_STACK_OVERFLOW == 1 )
dflet 0:91ad48ad5687 99
dflet 0:91ad48ad5687 100 /* FreeRTOSConfig.h is only set to use the first method of
dflet 0:91ad48ad5687 101 overflow checking. */
dflet 0:91ad48ad5687 102 #define taskSECOND_CHECK_FOR_STACK_OVERFLOW()
dflet 0:91ad48ad5687 103
dflet 0:91ad48ad5687 104 #endif
dflet 0:91ad48ad5687 105 /*-----------------------------------------------------------*/
dflet 0:91ad48ad5687 106
dflet 0:91ad48ad5687 107 #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH < 0 ) )
dflet 0:91ad48ad5687 108
dflet 0:91ad48ad5687 109 /* Only the current stack state is to be checked. */
dflet 0:91ad48ad5687 110 #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \
dflet 0:91ad48ad5687 111 { \
dflet 0:91ad48ad5687 112 /* Is the currently saved stack pointer within the stack limit? */ \
dflet 0:91ad48ad5687 113 if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \
dflet 0:91ad48ad5687 114 { \
dflet 0:91ad48ad5687 115 vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
dflet 0:91ad48ad5687 116 } \
dflet 0:91ad48ad5687 117 }
dflet 0:91ad48ad5687 118
dflet 0:91ad48ad5687 119 #endif /* configCHECK_FOR_STACK_OVERFLOW > 0 */
dflet 0:91ad48ad5687 120 /*-----------------------------------------------------------*/
dflet 0:91ad48ad5687 121
dflet 0:91ad48ad5687 122 #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH > 0 ) )
dflet 0:91ad48ad5687 123
dflet 0:91ad48ad5687 124 /* Only the current stack state is to be checked. */
dflet 0:91ad48ad5687 125 #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \
dflet 0:91ad48ad5687 126 { \
dflet 0:91ad48ad5687 127 \
dflet 0:91ad48ad5687 128 /* Is the currently saved stack pointer within the stack limit? */ \
dflet 0:91ad48ad5687 129 if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \
dflet 0:91ad48ad5687 130 { \
dflet 0:91ad48ad5687 131 vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
dflet 0:91ad48ad5687 132 } \
dflet 0:91ad48ad5687 133 }
dflet 0:91ad48ad5687 134
dflet 0:91ad48ad5687 135 #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
dflet 0:91ad48ad5687 136 /*-----------------------------------------------------------*/
dflet 0:91ad48ad5687 137
dflet 0:91ad48ad5687 138 #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) )
dflet 0:91ad48ad5687 139
dflet 0:91ad48ad5687 140 #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \
dflet 0:91ad48ad5687 141 { \
dflet 0:91ad48ad5687 142 static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
dflet 0:91ad48ad5687 143 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
dflet 0:91ad48ad5687 144 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
dflet 0:91ad48ad5687 145 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
dflet 0:91ad48ad5687 146 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \
dflet 0:91ad48ad5687 147 \
dflet 0:91ad48ad5687 148 \
dflet 0:91ad48ad5687 149 /* Has the extremity of the task stack ever been written over? */ \
dflet 0:91ad48ad5687 150 if( memcmp( ( void * ) pxCurrentTCB->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \
dflet 0:91ad48ad5687 151 { \
dflet 0:91ad48ad5687 152 vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
dflet 0:91ad48ad5687 153 } \
dflet 0:91ad48ad5687 154 }
dflet 0:91ad48ad5687 155
dflet 0:91ad48ad5687 156 #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
dflet 0:91ad48ad5687 157 /*-----------------------------------------------------------*/
dflet 0:91ad48ad5687 158
dflet 0:91ad48ad5687 159 #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) )
dflet 0:91ad48ad5687 160
dflet 0:91ad48ad5687 161 #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \
dflet 0:91ad48ad5687 162 { \
dflet 0:91ad48ad5687 163 int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \
dflet 0:91ad48ad5687 164 static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
dflet 0:91ad48ad5687 165 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
dflet 0:91ad48ad5687 166 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
dflet 0:91ad48ad5687 167 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
dflet 0:91ad48ad5687 168 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \
dflet 0:91ad48ad5687 169 \
dflet 0:91ad48ad5687 170 \
dflet 0:91ad48ad5687 171 pcEndOfStack -= sizeof( ucExpectedStackBytes ); \
dflet 0:91ad48ad5687 172 \
dflet 0:91ad48ad5687 173 /* Has the extremity of the task stack ever been written over? */ \
dflet 0:91ad48ad5687 174 if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \
dflet 0:91ad48ad5687 175 { \
dflet 0:91ad48ad5687 176 vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
dflet 0:91ad48ad5687 177 } \
dflet 0:91ad48ad5687 178 }
dflet 0:91ad48ad5687 179
dflet 0:91ad48ad5687 180 #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
dflet 0:91ad48ad5687 181 /*-----------------------------------------------------------*/
dflet 0:91ad48ad5687 182
dflet 0:91ad48ad5687 183 #endif /* STACK_MACROS_H */
dflet 0:91ad48ad5687 184
dflet 0:91ad48ad5687 185