Rohit Grover / FreeRTOS

Dependents:   Nucleo freertos_test FreeRTOS_test freertos_bluetooth ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers portmacro.h Source File

portmacro.h

00001 /*
00002     FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. 
00003     All rights reserved
00004 
00005     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
00006 
00007     ***************************************************************************
00008      *                                                                       *
00009      *    FreeRTOS provides completely free yet professionally developed,    *
00010      *    robust, strictly quality controlled, supported, and cross          *
00011      *    platform software that has become a de facto standard.             *
00012      *                                                                       *
00013      *    Help yourself get started quickly and support the FreeRTOS         *
00014      *    project by purchasing a FreeRTOS tutorial book, reference          *
00015      *    manual, or both from: http://www.FreeRTOS.org/Documentation        *
00016      *                                                                       *
00017      *    Thank you!                                                         *
00018      *                                                                       *
00019     ***************************************************************************
00020 
00021     This file is part of the FreeRTOS distribution.
00022 
00023     FreeRTOS is free software; you can redistribute it and/or modify it under
00024     the terms of the GNU General Public License (version 2) as published by the
00025     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
00026 
00027     >>! NOTE: The modification to the GPL is included to allow you to distribute
00028     >>! a combined work that includes FreeRTOS without being obliged to provide
00029     >>! the source code for proprietary components outside of the FreeRTOS
00030     >>! kernel.
00031 
00032     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
00033     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00034     FOR A PARTICULAR PURPOSE.  Full license text is available from the following
00035     link: http://www.freertos.org/a00114.html
00036 
00037     1 tab == 4 spaces!
00038 
00039     ***************************************************************************
00040      *                                                                       *
00041      *    Having a problem?  Start by reading the FAQ "My application does   *
00042      *    not run, what could be wrong?"                                     *
00043      *                                                                       *
00044      *    http://www.FreeRTOS.org/FAQHelp.html                               *
00045      *                                                                       *
00046     ***************************************************************************
00047 
00048     http://www.FreeRTOS.org - Documentation, books, training, latest versions,
00049     license and Real Time Engineers Ltd. contact details.
00050 
00051     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
00052     including FreeRTOS+Trace - an indispensable productivity tool, a DOS
00053     compatible FAT file system, and our tiny thread aware UDP/IP stack.
00054 
00055     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
00056     Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS
00057     licenses offer ticketed support, indemnification and middleware.
00058 
00059     http://www.SafeRTOS.com - High Integrity Systems also provide a safety
00060     engineered and independently SIL3 certified version for use in safety and
00061     mission critical applications that require provable dependability.
00062 
00063     1 tab == 4 spaces!
00064 */
00065 
00066 
00067 #ifndef PORTMACRO_H
00068 #define PORTMACRO_H
00069 
00070 #ifdef __cplusplus
00071 extern "C" {
00072 #endif
00073 
00074 /*-----------------------------------------------------------
00075  * Port specific definitions.
00076  *
00077  * The settings in this file configure FreeRTOS correctly for the
00078  * given hardware and compiler.
00079  *
00080  * These settings should not be altered.
00081  *-----------------------------------------------------------
00082  */
00083 
00084 /* Type definitions. */
00085 #define portCHAR        char
00086 #define portFLOAT       float
00087 #define portDOUBLE      double
00088 #define portLONG        long
00089 #define portSHORT       short
00090 #define portSTACK_TYPE  unsigned portLONG
00091 #define portBASE_TYPE   long
00092 
00093 #if( configUSE_16_BIT_TICKS == 1 )
00094     typedef unsigned portSHORT portTickType;
00095     #define portMAX_DELAY ( portTickType ) 0xffff
00096 #else
00097     typedef unsigned portLONG portTickType;
00098     #define portMAX_DELAY ( portTickType ) 0xffffffff
00099 #endif
00100 /*-----------------------------------------------------------*/
00101 
00102 /* Architecture specifics. */
00103 #define portSTACK_GROWTH            ( -1 )
00104 #define portTICK_RATE_MS            ( ( portTickType ) 1000 / configTICK_RATE_HZ )
00105 #define portBYTE_ALIGNMENT          8
00106 /*-----------------------------------------------------------*/
00107 
00108 /* Scheduler utilities. */
00109 extern void vPortYield( void );
00110 #define portNVIC_INT_CTRL_REG       ( * ( ( volatile unsigned long * ) 0xe000ed04 ) )
00111 #define portNVIC_PENDSVSET_BIT      ( 1UL << 28UL )
00112 #define portYIELD()                 vPortYield()
00113 #define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT
00114 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
00115 /*-----------------------------------------------------------*/
00116 
00117 /* Critical section management. */
00118 extern unsigned long ulPortSetInterruptMask( void );
00119 extern void vPortClearInterruptMask( unsigned long ulNewMask );
00120 extern void vPortEnterCritical( void );
00121 extern void vPortExitCritical( void );
00122 
00123 #define portDISABLE_INTERRUPTS()                ulPortSetInterruptMask()
00124 #define portENABLE_INTERRUPTS()                 vPortClearInterruptMask( 0 )
00125 #define portENTER_CRITICAL()                    vPortEnterCritical()
00126 #define portEXIT_CRITICAL()                     vPortExitCritical()
00127 #define portSET_INTERRUPT_MASK_FROM_ISR()       ulPortSetInterruptMask()
00128 #define portCLEAR_INTERRUPT_MASK_FROM_ISR(x)    vPortClearInterruptMask(x)
00129 /*-----------------------------------------------------------*/
00130 
00131 /* Tickless idle/low power functionality. */
00132 #ifndef portSUPPRESS_TICKS_AND_SLEEP
00133     extern void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime );
00134     #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime )
00135 #endif
00136 /*-----------------------------------------------------------*/
00137 
00138 /* Port specific optimisations. */
00139 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
00140 
00141     /* Check the configuration. */
00142     #if( configMAX_PRIORITIES > 32 )
00143         #error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32.  It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.
00144     #endif
00145 
00146     /* Store/clear the ready priorities in a bit map. */
00147     #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
00148     #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
00149 
00150     /*-----------------------------------------------------------*/
00151 
00152     #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - __clz( ( uxReadyPriorities ) ) )
00153 
00154 #endif /* taskRECORD_READY_PRIORITY */
00155 /*-----------------------------------------------------------*/
00156 
00157 /* Task function macros as described on the FreeRTOS.org WEB site.  These are
00158 not necessary for to use this port.  They are defined so the common demo files
00159 (which build with all the ports) will build. */
00160 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
00161 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
00162 /*-----------------------------------------------------------*/
00163 
00164 #ifdef configASSERT
00165     void vPortValidateInterruptPriority( void );
00166     #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID()  vPortValidateInterruptPriority()
00167 #endif
00168 
00169 /* portNOP() is not required by this port. */
00170 #define portNOP()
00171 
00172 #ifdef __cplusplus
00173 }
00174 #endif
00175 
00176 #endif /* PORTMACRO_H */
00177