]> git.sur5r.net Git - freertos/blob - Source/portable/GCC/ARM_CM3/portmacro.h
3732a0e708f95cd254e87e2ba0a8be8e1724c777
[freertos] / Source / portable / GCC / ARM_CM3 / portmacro.h
1 /*\r
2         FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry.\r
3 \r
4         This file is part of the FreeRTOS.org distribution.\r
5 \r
6         FreeRTOS.org is free software; you can redistribute it and/or modify\r
7         it under the terms of the GNU General Public License as published by\r
8         the Free Software Foundation; either version 2 of the License, or\r
9         (at your option) any later version.\r
10 \r
11         FreeRTOS.org is distributed in the hope that it will be useful,\r
12         but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14         GNU General Public License for more details.\r
15 \r
16         You should have received a copy of the GNU General Public License\r
17         along with FreeRTOS.org; if not, write to the Free Software\r
18         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
19 \r
20         A special exception to the GPL can be applied should you wish to distribute\r
21         a combined work that includes FreeRTOS.org, without being obliged to provide\r
22         the source code for any proprietary components.  See the licensing section \r
23         of http://www.FreeRTOS.org for full details of how and when the exception\r
24         can be applied.\r
25 \r
26         ***************************************************************************\r
27         See http://www.FreeRTOS.org for documentation, latest information, license \r
28         and contact details.  Please ensure to read the configuration and relevant \r
29         port sections of the online documentation.\r
30 \r
31         Also see http://www.SafeRTOS.com a version that has been certified for use\r
32         in safety critical systems, plus commercial licensing, development and\r
33         support options.\r
34         ***************************************************************************\r
35 */\r
36 \r
37 /*\r
38         Change from V4.4.0:\r
39 \r
40         + Introduced usage of configKERNEL_INTERRUPT_PRIORITY macro to set the\r
41           interrupt priority used by the kernel.\r
42 */\r
43 \r
44 #ifndef PORTMACRO_H\r
45 #define PORTMACRO_H\r
46 \r
47 #ifdef __cplusplus\r
48 extern "C" {\r
49 #endif\r
50 \r
51 /*-----------------------------------------------------------\r
52  * Port specific definitions.  \r
53  *\r
54  * The settings in this file configure FreeRTOS correctly for the\r
55  * given hardware and compiler.\r
56  *\r
57  * These settings should not be altered.\r
58  *-----------------------------------------------------------\r
59  */\r
60 \r
61 /* Type definitions. */\r
62 #define portCHAR                char\r
63 #define portFLOAT               float\r
64 #define portDOUBLE              double\r
65 #define portLONG                long\r
66 #define portSHORT               short\r
67 #define portSTACK_TYPE  unsigned portLONG\r
68 #define portBASE_TYPE   long\r
69 \r
70 #if( configUSE_16_BIT_TICKS == 1 )\r
71         typedef unsigned portSHORT portTickType;\r
72         #define portMAX_DELAY ( portTickType ) 0xffff\r
73 #else\r
74         typedef unsigned portLONG portTickType;\r
75         #define portMAX_DELAY ( portTickType ) 0xffffffff\r
76 #endif\r
77 /*-----------------------------------------------------------*/ \r
78 \r
79 /* Architecture specifics. */\r
80 #define portSTACK_GROWTH                        ( -1 )\r
81 #define portTICK_RATE_MS                        ( ( portTickType ) 1000 / configTICK_RATE_HZ )          \r
82 #define portBYTE_ALIGNMENT                      4\r
83 /*-----------------------------------------------------------*/ \r
84 \r
85 \r
86 /* Scheduler utilities. */\r
87 extern void vPortYieldFromISR( void );\r
88 \r
89 #define portYIELD()                                     vPortYieldFromISR()\r
90 \r
91 #define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) vPortYieldFromISR()\r
92 /*-----------------------------------------------------------*/\r
93 \r
94 \r
95 /* Critical section management. */\r
96 \r
97 #define vPortSetInterruptMask()                                                 \\r
98         __asm volatile                                                                          \\r
99         (                                                                                                       \\r
100                 "       push { r0 }                                                             \n"     \\r
101                 "       ldr r0, =ulKernelPriority                               \n"     \\r
102                 "       ldr r0, [r0]                                                    \n"     \\r
103                 "       msr basepri, r0                                                 \n" \\r
104                 "       pop { r0 }                                                              "       \\r
105         )\r
106         \r
107 /*-----------------------------------------------------------*/\r
108 \r
109 #define vPortClearInterruptMask()                                               \\r
110         __asm volatile                                                                          \\r
111         (                                                                                                       \\r
112                 "       push { r0 }                                                             \n"     \\r
113                 "       mov r0, #0                                                              \n"     \\r
114                 "       msr basepri, r0                                                 \n"     \\r
115                 "       pop      { r0 }                                                         "       \\r
116         )\r
117 \r
118 /*-----------------------------------------------------------*/\r
119 \r
120 \r
121 extern void vPortEnterCritical( void );\r
122 extern void vPortExitCritical( void );\r
123 \r
124 #define portDISABLE_INTERRUPTS()        vPortSetInterruptMask();\r
125 #define portENABLE_INTERRUPTS()         vPortClearInterruptMask();\r
126 #define portENTER_CRITICAL()            vPortEnterCritical()\r
127 #define portEXIT_CRITICAL()                     vPortExitCritical()\r
128 /*-----------------------------------------------------------*/\r
129 \r
130 /* Task function macros as described on the FreeRTOS.org WEB site. */\r
131 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
132 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
133 \r
134 #define inline\r
135 #define portNOP()\r
136 \r
137 #ifdef __cplusplus\r
138 }\r
139 #endif\r
140 \r
141 #endif /* PORTMACRO_H */\r
142 \r