]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/ThirdParty/GCC/Wiced_CY/portmacro.h
Remove the FreeRTOS-IoT-Libraries from FreeRTOS-Plus as it was an old copy with a...
[freertos] / FreeRTOS / Source / portable / ThirdParty / GCC / Wiced_CY / portmacro.h
1 /*\r
2  * FreeRTOS Kernel V10.2.0\r
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 #ifndef PORTMACRO_H\r
29 #define PORTMACRO_H\r
30 \r
31 #ifdef __cplusplus\r
32         extern "C" {\r
33 #endif\r
34 \r
35 /*-----------------------------------------------------------\r
36  * Port specific definitions.\r
37  *\r
38  * The settings in this file configure FreeRTOS correctly for the given hardware\r
39  * and compiler.\r
40  *\r
41  * These settings should not be altered.\r
42  *-----------------------------------------------------------\r
43  */\r
44 \r
45 /* Type definitions. */\r
46 #define portCHAR                char\r
47 #define portFLOAT               float\r
48 #define portDOUBLE              double\r
49 #define portLONG                long\r
50 #define portSHORT               short\r
51 #define portSTACK_TYPE  uint32_t\r
52 #define portBASE_TYPE   long\r
53 \r
54 typedef portSTACK_TYPE StackType_t;\r
55 typedef long BaseType_t;\r
56 typedef unsigned long UBaseType_t;\r
57 \r
58 typedef uint32_t TickType_t;\r
59 #define portMAX_DELAY ( TickType_t ) 0xffffffffUL\r
60 \r
61 /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do\r
62 not need to be guarded with a critical section. */\r
63 #define portTICK_TYPE_IS_ATOMIC 1\r
64 \r
65 /*-----------------------------------------------------------*/\r
66 \r
67 /* Hardware specifics. */\r
68 #define portSTACK_GROWTH                        ( -1 )\r
69 #define portTICK_PERIOD_MS                      ( ( TickType_t ) 1000 / configTICK_RATE_HZ )\r
70 #define portBYTE_ALIGNMENT                      8\r
71 \r
72 /*-----------------------------------------------------------*/\r
73 \r
74 /* Task utilities. */\r
75 \r
76 /* Called at the end of an ISR that can cause a context switch. */\r
77 #define portEND_SWITCHING_ISR( xSwitchRequired )\\r
78 {                                                                                               \\r
79 extern volatile uint32_t ulPortYieldRequired;   \\r
80                                                                                                 \\r
81         if( xSwitchRequired != pdFALSE )                        \\r
82         {                                                                                       \\r
83                 ulPortYieldRequired = pdTRUE;                   \\r
84         }                                                                                       \\r
85 }\r
86 \r
87 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )\r
88 #define portYIELD() __asm volatile ( "SWI 0             \n"                             \\r
89                                                                          "ISB             " );\r
90 \r
91 \r
92 /*-----------------------------------------------------------\r
93  * Critical section control\r
94  *----------------------------------------------------------*/\r
95 \r
96 extern void vPortEnterCritical( void );\r
97 extern void vPortExitCritical( void );\r
98 extern uint32_t ulPortSetInterruptMask( void );\r
99 extern void vPortClearInterruptMask( uint32_t ulNewMaskValue );\r
100 extern void vPortInstallFreeRTOSVectorTable( void );\r
101 \r
102 /* The I bit within the CPSR. */\r
103 #define portINTERRUPT_ENABLE_BIT        ( 1 << 7 )\r
104 \r
105 /* In the absence of a priority mask register, these functions and macros\r
106 globally enable and disable interrupts. */\r
107 #define portENTER_CRITICAL()            vPortEnterCritical();\r
108 #define portEXIT_CRITICAL()                     vPortExitCritical();\r
109 #define portENABLE_INTERRUPTS()         __asm volatile ( "CPSIE i       \n"     );\r
110 #define portDISABLE_INTERRUPTS()        __asm volatile ( "CPSID i       \n"             \\r
111                                                                                                          "DSB           \n"             \\r
112                                                                                                          "ISB             " );\r
113 \r
114 __attribute__( ( always_inline ) ) static __inline uint32_t portINLINE_SET_INTERRUPT_MASK_FROM_ISR( void )\r
115 {\r
116 volatile uint32_t ulCPSR;\r
117 \r
118         __asm volatile ( "MRS %0, CPSR" : "=r" (ulCPSR) );\r
119         ulCPSR &= portINTERRUPT_ENABLE_BIT;\r
120         portDISABLE_INTERRUPTS();\r
121         return ulCPSR;\r
122 }\r
123 \r
124 #define portSET_INTERRUPT_MASK_FROM_ISR() portINLINE_SET_INTERRUPT_MASK_FROM_ISR()\r
125 #define portCLEAR_INTERRUPT_MASK_FROM_ISR(x)    if( x == 0 ) portENABLE_INTERRUPTS()\r
126 \r
127 /*-----------------------------------------------------------*/\r
128 \r
129 /* Task function macros as described on the FreeRTOS.org WEB site.  These are\r
130 not required for this port but included in case common demo code that uses these\r
131 macros is used. */\r
132 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters )      void vFunction( void *pvParameters )\r
133 #define portTASK_FUNCTION( vFunction, pvParameters )    void vFunction( void *pvParameters )\r
134 \r
135 /* Tickless idle/low power functionality. */\r
136 #ifndef portSUPPRESS_TICKS_AND_SLEEP\r
137         extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );\r
138         #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime )\r
139 #endif\r
140 \r
141 /* Prototype of the FreeRTOS tick handler.  This must be installed as the\r
142 handler for whichever peripheral is used to generate the RTOS tick. */\r
143 void FreeRTOS_Tick_Handler( void );\r
144 \r
145 /* Any task that uses the floating point unit MUST call vPortTaskUsesFPU()\r
146 before any floating point instructions are executed. */\r
147 void vPortTaskUsesFPU( void );\r
148 #define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU()\r
149 \r
150 #define portLOWEST_INTERRUPT_PRIORITY ( ( ( uint32_t ) configUNIQUE_INTERRUPT_PRIORITIES ) - 1UL )\r
151 #define portLOWEST_USABLE_INTERRUPT_PRIORITY ( portLOWEST_INTERRUPT_PRIORITY - 1UL )\r
152 \r
153 /* Architecture specific optimisations. */\r
154 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION\r
155         #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1\r
156 #endif\r
157 \r
158 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1\r
159 \r
160         /* Store/clear the ready priorities in a bit map. */\r
161         #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )\r
162         #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )\r
163 \r
164         /*-----------------------------------------------------------*/\r
165 \r
166         #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - ( uint32_t ) __builtin_clz( uxReadyPriorities ) )\r
167 \r
168 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
169 \r
170 #define portNOP() __asm volatile( "NOP" )\r
171 #define portINLINE __inline\r
172 \r
173 #ifdef __cplusplus\r
174         } /* extern C */\r
175 #endif\r
176 \r
177 \r
178 #endif /* PORTMACRO_H */\r
179 \r