]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/portmacro.h
35ea9bd615ba20de39bbffd9583941759c8e4ff9
[freertos] / FreeRTOS / Source / portable / CCS / ARM_Cortex-R4 / portmacro.h
1 /*\r
2  * FreeRTOS Kernel V10.1.1\r
3  * Copyright (C) 2018 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 /*-----------------------------------------------------------\r
32  * Port specific definitions.\r
33  *\r
34  * The settings in this file configure FreeRTOS correctly for the\r
35  * given hardware and compiler.\r
36  *\r
37  * These settings should not be altered.\r
38  *-----------------------------------------------------------\r
39  */\r
40 \r
41 /* Type definitions. */\r
42 #define portCHAR        char\r
43 #define portFLOAT       float\r
44 #define portDOUBLE      double\r
45 #define portLONG        long\r
46 #define portSHORT       short\r
47 #define portSTACK_TYPE  uint32_t\r
48 #define portBASE_TYPE   long\r
49 \r
50 typedef portSTACK_TYPE StackType_t;\r
51 typedef long BaseType_t;\r
52 typedef unsigned long UBaseType_t;\r
53 \r
54 #if (configUSE_16_BIT_TICKS == 1)\r
55     typedef uint16_t TickType_t;\r
56     #define portMAX_DELAY (TickType_t) 0xFFFF\r
57 #else\r
58     typedef uint32_t TickType_t;\r
59     #define portMAX_DELAY (TickType_t) 0xFFFFFFFFF\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 #endif\r
65 \r
66 \r
67 /* Architecture 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 /* Critical section handling. */\r
73 extern void vPortEnterCritical(void);\r
74 extern void vPortExitCritical(void);\r
75 #define portENTER_CRITICAL()            vPortEnterCritical()\r
76 #define portEXIT_CRITICAL()                     vPortExitCritical()\r
77 #define portDISABLE_INTERRUPTS()        asm( " CPSID I" )\r
78 #define portENABLE_INTERRUPTS()         asm( " CPSIE I" )\r
79 \r
80 /* Scheduler utilities. */\r
81 #pragma SWI_ALIAS( vPortYield, 0 )\r
82 extern void vPortYield( void );\r
83 #define portYIELD()                     vPortYield()\r
84 #define portSYS_SSIR1_REG                       ( * ( ( volatile uint32_t * ) 0xFFFFFFB0 ) )\r
85 #define portSYS_SSIR1_SSKEY                     ( 0x7500UL )\r
86 #define portYIELD_WITHIN_API()          { portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY;  asm( " DSB " ); asm( " ISB " ); }\r
87 #define portYIELD_FROM_ISR( x )         if( x != pdFALSE ){ portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY;  ( void ) portSYS_SSIR1_REG; }\r
88 \r
89 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION\r
90         #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1\r
91 #endif\r
92 \r
93 /* Architecture specific optimisations. */\r
94 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1\r
95 \r
96         /* Check the configuration. */\r
97         #if( configMAX_PRIORITIES > 32 )\r
98                 #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.\r
99         #endif\r
100 \r
101         /* Store/clear the ready priorities in a bit map. */\r
102         #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )\r
103         #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )\r
104 \r
105         /*-----------------------------------------------------------*/\r
106 \r
107         #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - __clz( ( uxReadyPriorities ) ) )\r
108 \r
109 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
110 \r
111 \r
112 /* Task function macros as described on the FreeRTOS.org WEB site. */\r
113 #define portTASK_FUNCTION(vFunction, pvParameters)       void vFunction(void *pvParameters)\r
114 #define portTASK_FUNCTION_PROTO(vFunction, pvParameters) void vFunction(void *pvParameters)\r
115 \r
116 #endif /* __PORTMACRO_H__ */\r
117 \r