www.freertos.org

Dependents:   mbed_freeRTOS_send

Fork of FreeRTOS by Rohit Grover

Committer:
ser1516
Date:
Wed May 18 21:25:21 2016 +0000
Revision:
1:6db425da9b9e
Parent:
0:8e57f3e9cc89
queue implementada com accelarometro e pot a enviar para o can -  ainda nao testado

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 0:8e57f3e9cc89 1 /*
rgrover1 0:8e57f3e9cc89 2 FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
rgrover1 0:8e57f3e9cc89 3 All rights reserved
rgrover1 0:8e57f3e9cc89 4
rgrover1 0:8e57f3e9cc89 5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
rgrover1 0:8e57f3e9cc89 6
rgrover1 0:8e57f3e9cc89 7 ***************************************************************************
rgrover1 0:8e57f3e9cc89 8 * *
rgrover1 0:8e57f3e9cc89 9 * FreeRTOS provides completely free yet professionally developed, *
rgrover1 0:8e57f3e9cc89 10 * robust, strictly quality controlled, supported, and cross *
rgrover1 0:8e57f3e9cc89 11 * platform software that has become a de facto standard. *
rgrover1 0:8e57f3e9cc89 12 * *
rgrover1 0:8e57f3e9cc89 13 * Help yourself get started quickly and support the FreeRTOS *
rgrover1 0:8e57f3e9cc89 14 * project by purchasing a FreeRTOS tutorial book, reference *
rgrover1 0:8e57f3e9cc89 15 * manual, or both from: http://www.FreeRTOS.org/Documentation *
rgrover1 0:8e57f3e9cc89 16 * *
rgrover1 0:8e57f3e9cc89 17 * Thank you! *
rgrover1 0:8e57f3e9cc89 18 * *
rgrover1 0:8e57f3e9cc89 19 ***************************************************************************
rgrover1 0:8e57f3e9cc89 20
rgrover1 0:8e57f3e9cc89 21 This file is part of the FreeRTOS distribution.
rgrover1 0:8e57f3e9cc89 22
rgrover1 0:8e57f3e9cc89 23 FreeRTOS is free software; you can redistribute it and/or modify it under
rgrover1 0:8e57f3e9cc89 24 the terms of the GNU General Public License (version 2) as published by the
rgrover1 0:8e57f3e9cc89 25 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
rgrover1 0:8e57f3e9cc89 26
rgrover1 0:8e57f3e9cc89 27 >>! NOTE: The modification to the GPL is included to allow you to distribute
rgrover1 0:8e57f3e9cc89 28 >>! a combined work that includes FreeRTOS without being obliged to provide
rgrover1 0:8e57f3e9cc89 29 >>! the source code for proprietary components outside of the FreeRTOS
rgrover1 0:8e57f3e9cc89 30 >>! kernel.
rgrover1 0:8e57f3e9cc89 31
rgrover1 0:8e57f3e9cc89 32 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
rgrover1 0:8e57f3e9cc89 33 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
rgrover1 0:8e57f3e9cc89 34 FOR A PARTICULAR PURPOSE. Full license text is available from the following
rgrover1 0:8e57f3e9cc89 35 link: http://www.freertos.org/a00114.html
rgrover1 0:8e57f3e9cc89 36
rgrover1 0:8e57f3e9cc89 37 1 tab == 4 spaces!
rgrover1 0:8e57f3e9cc89 38
rgrover1 0:8e57f3e9cc89 39 ***************************************************************************
rgrover1 0:8e57f3e9cc89 40 * *
rgrover1 0:8e57f3e9cc89 41 * Having a problem? Start by reading the FAQ "My application does *
rgrover1 0:8e57f3e9cc89 42 * not run, what could be wrong?" *
rgrover1 0:8e57f3e9cc89 43 * *
rgrover1 0:8e57f3e9cc89 44 * http://www.FreeRTOS.org/FAQHelp.html *
rgrover1 0:8e57f3e9cc89 45 * *
rgrover1 0:8e57f3e9cc89 46 ***************************************************************************
rgrover1 0:8e57f3e9cc89 47
rgrover1 0:8e57f3e9cc89 48 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
rgrover1 0:8e57f3e9cc89 49 license and Real Time Engineers Ltd. contact details.
rgrover1 0:8e57f3e9cc89 50
rgrover1 0:8e57f3e9cc89 51 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
rgrover1 0:8e57f3e9cc89 52 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
rgrover1 0:8e57f3e9cc89 53 compatible FAT file system, and our tiny thread aware UDP/IP stack.
rgrover1 0:8e57f3e9cc89 54
rgrover1 0:8e57f3e9cc89 55 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
rgrover1 0:8e57f3e9cc89 56 Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
rgrover1 0:8e57f3e9cc89 57 licenses offer ticketed support, indemnification and middleware.
rgrover1 0:8e57f3e9cc89 58
rgrover1 0:8e57f3e9cc89 59 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
rgrover1 0:8e57f3e9cc89 60 engineered and independently SIL3 certified version for use in safety and
rgrover1 0:8e57f3e9cc89 61 mission critical applications that require provable dependability.
rgrover1 0:8e57f3e9cc89 62
rgrover1 0:8e57f3e9cc89 63 1 tab == 4 spaces!
rgrover1 0:8e57f3e9cc89 64 */
rgrover1 0:8e57f3e9cc89 65
rgrover1 0:8e57f3e9cc89 66
rgrover1 0:8e57f3e9cc89 67 /*
rgrover1 0:8e57f3e9cc89 68 * The simplest possible implementation of pvPortMalloc(). Note that this
rgrover1 0:8e57f3e9cc89 69 * implementation does NOT allow allocated memory to be freed again.
rgrover1 0:8e57f3e9cc89 70 *
rgrover1 0:8e57f3e9cc89 71 * See heap_2.c, heap_3.c and heap_4.c for alternative implementations, and the
rgrover1 0:8e57f3e9cc89 72 * memory management pages of http://www.FreeRTOS.org for more information.
rgrover1 0:8e57f3e9cc89 73 */
rgrover1 0:8e57f3e9cc89 74 #include <stdlib.h>
rgrover1 0:8e57f3e9cc89 75
rgrover1 0:8e57f3e9cc89 76 /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
rgrover1 0:8e57f3e9cc89 77 all the API functions to use the MPU wrappers. That should only be done when
rgrover1 0:8e57f3e9cc89 78 task.h is included from an application file. */
rgrover1 0:8e57f3e9cc89 79 #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
rgrover1 0:8e57f3e9cc89 80
rgrover1 0:8e57f3e9cc89 81 #include "FreeRTOS.h"
rgrover1 0:8e57f3e9cc89 82 #include "task.h"
rgrover1 0:8e57f3e9cc89 83
rgrover1 0:8e57f3e9cc89 84 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
rgrover1 0:8e57f3e9cc89 85
rgrover1 0:8e57f3e9cc89 86 /* A few bytes might be lost to byte aligning the heap start address. */
rgrover1 0:8e57f3e9cc89 87 #define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT )
rgrover1 0:8e57f3e9cc89 88
rgrover1 0:8e57f3e9cc89 89 /* Allocate the memory for the heap. */
rgrover1 0:8e57f3e9cc89 90 static unsigned char ucHeap[ configTOTAL_HEAP_SIZE ];
rgrover1 0:8e57f3e9cc89 91 static size_t xNextFreeByte = ( size_t ) 0;
rgrover1 0:8e57f3e9cc89 92
rgrover1 0:8e57f3e9cc89 93 /*-----------------------------------------------------------*/
rgrover1 0:8e57f3e9cc89 94
rgrover1 0:8e57f3e9cc89 95 void *pvPortMalloc( size_t xWantedSize )
rgrover1 0:8e57f3e9cc89 96 {
rgrover1 0:8e57f3e9cc89 97 void *pvReturn = NULL;
rgrover1 0:8e57f3e9cc89 98 static unsigned char *pucAlignedHeap = NULL;
rgrover1 0:8e57f3e9cc89 99
rgrover1 0:8e57f3e9cc89 100 /* Ensure that blocks are always aligned to the required number of bytes. */
rgrover1 0:8e57f3e9cc89 101 #if portBYTE_ALIGNMENT != 1
rgrover1 0:8e57f3e9cc89 102 if( xWantedSize & portBYTE_ALIGNMENT_MASK )
rgrover1 0:8e57f3e9cc89 103 {
rgrover1 0:8e57f3e9cc89 104 /* Byte alignment required. */
rgrover1 0:8e57f3e9cc89 105 xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
rgrover1 0:8e57f3e9cc89 106 }
rgrover1 0:8e57f3e9cc89 107 #endif
rgrover1 0:8e57f3e9cc89 108
rgrover1 0:8e57f3e9cc89 109 vTaskSuspendAll();
rgrover1 0:8e57f3e9cc89 110 {
rgrover1 0:8e57f3e9cc89 111 if( pucAlignedHeap == NULL )
rgrover1 0:8e57f3e9cc89 112 {
rgrover1 0:8e57f3e9cc89 113 /* Ensure the heap starts on a correctly aligned boundary. */
rgrover1 0:8e57f3e9cc89 114 pucAlignedHeap = ( unsigned char * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ( portPOINTER_SIZE_TYPE ) ~portBYTE_ALIGNMENT_MASK ) );
rgrover1 0:8e57f3e9cc89 115 }
rgrover1 0:8e57f3e9cc89 116
rgrover1 0:8e57f3e9cc89 117 /* Check there is enough room left for the allocation. */
rgrover1 0:8e57f3e9cc89 118 if( ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) &&
rgrover1 0:8e57f3e9cc89 119 ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) )/* Check for overflow. */
rgrover1 0:8e57f3e9cc89 120 {
rgrover1 0:8e57f3e9cc89 121 /* Return the next free byte then increment the index past this
rgrover1 0:8e57f3e9cc89 122 block. */
rgrover1 0:8e57f3e9cc89 123 pvReturn = pucAlignedHeap + xNextFreeByte;
rgrover1 0:8e57f3e9cc89 124 xNextFreeByte += xWantedSize;
rgrover1 0:8e57f3e9cc89 125 }
rgrover1 0:8e57f3e9cc89 126
rgrover1 0:8e57f3e9cc89 127 traceMALLOC( pvReturn, xWantedSize );
rgrover1 0:8e57f3e9cc89 128 }
rgrover1 0:8e57f3e9cc89 129 xTaskResumeAll();
rgrover1 0:8e57f3e9cc89 130
rgrover1 0:8e57f3e9cc89 131 #if( configUSE_MALLOC_FAILED_HOOK == 1 )
rgrover1 0:8e57f3e9cc89 132 {
rgrover1 0:8e57f3e9cc89 133 if( pvReturn == NULL )
rgrover1 0:8e57f3e9cc89 134 {
rgrover1 0:8e57f3e9cc89 135 extern void vApplicationMallocFailedHook( void );
rgrover1 0:8e57f3e9cc89 136 vApplicationMallocFailedHook();
rgrover1 0:8e57f3e9cc89 137 }
rgrover1 0:8e57f3e9cc89 138 }
rgrover1 0:8e57f3e9cc89 139 #endif
rgrover1 0:8e57f3e9cc89 140
rgrover1 0:8e57f3e9cc89 141 return pvReturn;
rgrover1 0:8e57f3e9cc89 142 }
rgrover1 0:8e57f3e9cc89 143 /*-----------------------------------------------------------*/
rgrover1 0:8e57f3e9cc89 144
rgrover1 0:8e57f3e9cc89 145 void vPortFree( void *pv )
rgrover1 0:8e57f3e9cc89 146 {
rgrover1 0:8e57f3e9cc89 147 /* Memory cannot be freed using this scheme. See heap_2.c, heap_3.c and
rgrover1 0:8e57f3e9cc89 148 heap_4.c for alternative implementations, and the memory management pages of
rgrover1 0:8e57f3e9cc89 149 http://www.FreeRTOS.org for more information. */
rgrover1 0:8e57f3e9cc89 150 ( void ) pv;
rgrover1 0:8e57f3e9cc89 151
rgrover1 0:8e57f3e9cc89 152 /* Force an assert as it is invalid to call this function. */
rgrover1 0:8e57f3e9cc89 153 configASSERT( pv == NULL );
rgrover1 0:8e57f3e9cc89 154 }
rgrover1 0:8e57f3e9cc89 155 /*-----------------------------------------------------------*/
rgrover1 0:8e57f3e9cc89 156
rgrover1 0:8e57f3e9cc89 157 void vPortInitialiseBlocks( void )
rgrover1 0:8e57f3e9cc89 158 {
rgrover1 0:8e57f3e9cc89 159 /* Only required when static memory is not cleared. */
rgrover1 0:8e57f3e9cc89 160 xNextFreeByte = ( size_t ) 0;
rgrover1 0:8e57f3e9cc89 161 }
rgrover1 0:8e57f3e9cc89 162 /*-----------------------------------------------------------*/
rgrover1 0:8e57f3e9cc89 163
rgrover1 0:8e57f3e9cc89 164 size_t xPortGetFreeHeapSize( void )
rgrover1 0:8e57f3e9cc89 165 {
rgrover1 0:8e57f3e9cc89 166 return ( configADJUSTED_HEAP_SIZE - xNextFreeByte );
rgrover1 0:8e57f3e9cc89 167 }
rgrover1 0:8e57f3e9cc89 168
rgrover1 0:8e57f3e9cc89 169
rgrover1 0:8e57f3e9cc89 170