uc-sdk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
portmacro.h
Go to the documentation of this file.
1 /*
2  FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd.
3  All rights reserved
4 
5  VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
6 
7  ***************************************************************************
8  * *
9  * FreeRTOS provides completely free yet professionally developed, *
10  * robust, strictly quality controlled, supported, and cross *
11  * platform software that has become a de facto standard. *
12  * *
13  * Help yourself get started quickly and support the FreeRTOS *
14  * project by purchasing a FreeRTOS tutorial book, reference *
15  * manual, or both from: http://www.FreeRTOS.org/Documentation *
16  * *
17  * Thank you! *
18  * *
19  ***************************************************************************
20 
21  This file is part of the FreeRTOS distribution.
22 
23  FreeRTOS is free software; you can redistribute it and/or modify it under
24  the terms of the GNU General Public License (version 2) as published by the
25  Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
26 
27  >>! NOTE: The modification to the GPL is included to allow you to distribute
28  >>! a combined work that includes FreeRTOS without being obliged to provide
29  >>! the source code for proprietary components outside of the FreeRTOS
30  >>! kernel.
31 
32  FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
33  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
34  FOR A PARTICULAR PURPOSE. Full license text is available from the following
35  link: http://www.freertos.org/a00114.html
36 
37  1 tab == 4 spaces!
38 
39  ***************************************************************************
40  * *
41  * Having a problem? Start by reading the FAQ "My application does *
42  * not run, what could be wrong?" *
43  * *
44  * http://www.FreeRTOS.org/FAQHelp.html *
45  * *
46  ***************************************************************************
47 
48  http://www.FreeRTOS.org - Documentation, books, training, latest versions,
49  license and Real Time Engineers Ltd. contact details.
50 
51  http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
52  including FreeRTOS+Trace - an indispensable productivity tool, a DOS
53  compatible FAT file system, and our tiny thread aware UDP/IP stack.
54 
55  http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
56  Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
57  licenses offer ticketed support, indemnification and middleware.
58 
59  http://www.SafeRTOS.com - High Integrity Systems also provide a safety
60  engineered and independently SIL3 certified version for use in safety and
61  mission critical applications that require provable dependability.
62 
63  1 tab == 4 spaces!
64 */
65 
66 
67 #ifndef PORTMACRO_H
68 #define PORTMACRO_H
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
74 /*-----------------------------------------------------------
75  * Port specific definitions.
76  *
77  * The settings in this file configure FreeRTOS correctly for the
78  * given hardware and compiler.
79  *
80  * These settings should not be altered.
81  *-----------------------------------------------------------
82  */
83 
84 /* Type definitions. */
85 #define portCHAR char
86 #define portFLOAT float
87 #define portDOUBLE double
88 #define portLONG long
89 #define portSHORT short
90 #define portSTACK_TYPE unsigned portLONG
91 #define portBASE_TYPE long
92 
93 #if( configUSE_16_BIT_TICKS == 1 )
94  typedef unsigned portSHORT portTickType;
95  #define portMAX_DELAY ( portTickType ) 0xffff
96 #else
97  typedef unsigned portLONG portTickType;
98  #define portMAX_DELAY ( portTickType ) 0xffffffff
99 #endif
100 /*-----------------------------------------------------------*/
101 
102 /* Architecture specifics. */
103 #define portSTACK_GROWTH ( -1 )
104 #define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
105 #define portBYTE_ALIGNMENT 8
106 /*-----------------------------------------------------------*/
107 
108 
109 /* Scheduler utilities. */
110 extern void vPortYield( void );
111 #define portNVIC_INT_CTRL_REG ( * ( ( volatile unsigned long * ) 0xe000ed04 ) )
112 #define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
113 #define portYIELD() vPortYield()
114 #define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT
115 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
116 /*-----------------------------------------------------------*/
117 
118 /* Critical section management. */
119 extern void vPortEnterCritical( void );
120 extern void vPortExitCritical( void );
121 extern unsigned long ulPortSetInterruptMask( void );
122 extern void vPortClearInterruptMask( unsigned long ulNewMaskValue );
123 #define portSET_INTERRUPT_MASK_FROM_ISR() ulPortSetInterruptMask()
124 #define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x)
125 #define portDISABLE_INTERRUPTS() ulPortSetInterruptMask()
126 #define portENABLE_INTERRUPTS() vPortClearInterruptMask(0)
127 #define portENTER_CRITICAL() vPortEnterCritical()
128 #define portEXIT_CRITICAL() vPortExitCritical()
129 /*-----------------------------------------------------------*/
130 
131 /* Task function macros as described on the FreeRTOS.org WEB site. These are
132 not necessary for to use this port. They are defined so the common demo files
133 (which build with all the ports) will build. */
134 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
135 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
136 /*-----------------------------------------------------------*/
137 
138 /* Tickless idle/low power functionality. */
139 #ifndef portSUPPRESS_TICKS_AND_SLEEP
140  extern void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime );
141  #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime )
142 #endif
143 /*-----------------------------------------------------------*/
144 
145 /* Architecture specific optimisations. */
146 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
147 
148  /* Generic helper function. */
149  __attribute__( ( always_inline ) ) static inline unsigned char ucPortCountLeadingZeros( unsigned long ulBitmap )
150  {
151  unsigned char ucReturn;
152 
153  __asm volatile ( "clz %0, %1" : "=r" ( ucReturn ) : "r" ( ulBitmap ) );
154  return ucReturn;
155  }
156 
157  /* Check the configuration. */
158  #if( configMAX_PRIORITIES > 32 )
159  #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.
160  #endif
161 
162  /* Store/clear the ready priorities in a bit map. */
163  #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
164  #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
165 
166  /*-----------------------------------------------------------*/
167 
168  #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - ucPortCountLeadingZeros( ( uxReadyPriorities ) ) )
169 
170 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
171 
172 /*-----------------------------------------------------------*/
173 
174 #ifdef configASSERT
175  void vPortValidateInterruptPriority( void );
176  #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority()
177 #endif
178 
179 /* portNOP() is not required by this port. */
180 #define portNOP()
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 #endif /* PORTMACRO_H */
187