]> begriffs open source - cmsis-freertos/blob - Source/portable/CCS/ARM_Cortex-R4/portmacro.h
Merge branch 'develop'
[cmsis-freertos] / Source / portable / CCS / ARM_Cortex-R4 / portmacro.h
1 /*
2  * FreeRTOS Kernel V10.4.6
3  * Copyright (C) 2021 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * SPDX-License-Identifier: MIT
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy of
8  * this software and associated documentation files (the "Software"), to deal in
9  * the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11  * the Software, and to permit persons to whom the Software is furnished to do so,
12  * subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  * https://www.FreeRTOS.org
25  * https://github.com/FreeRTOS
26  *
27  */
28
29 #ifndef __PORTMACRO_H__
30 #define __PORTMACRO_H__
31
32 /*-----------------------------------------------------------
33  * Port specific definitions.
34  *
35  * The settings in this file configure FreeRTOS correctly for the
36  * given hardware and compiler.
37  *
38  * These settings should not be altered.
39  *-----------------------------------------------------------
40  */
41
42 /* Type definitions. */
43 #define portCHAR        char
44 #define portFLOAT       float
45 #define portDOUBLE      double
46 #define portLONG        long
47 #define portSHORT       short
48 #define portSTACK_TYPE  uint32_t
49 #define portBASE_TYPE   long
50
51 typedef portSTACK_TYPE StackType_t;
52 typedef long BaseType_t;
53 typedef unsigned long UBaseType_t;
54
55 #if (configUSE_16_BIT_TICKS == 1)
56     typedef uint16_t TickType_t;
57     #define portMAX_DELAY (TickType_t) 0xFFFF
58 #else
59     typedef uint32_t TickType_t;
60     #define portMAX_DELAY (TickType_t) 0xFFFFFFFFF
61
62         /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
63         not need to be guarded with a critical section. */
64         #define portTICK_TYPE_IS_ATOMIC 1
65 #endif
66
67
68 /* Architecture specifics. */
69 #define portSTACK_GROWTH    (-1)
70 #define portTICK_PERIOD_MS    ((TickType_t) 1000 / configTICK_RATE_HZ)
71 #define portBYTE_ALIGNMENT  8
72
73 /* Critical section handling. */
74 extern void vPortEnterCritical(void);
75 extern void vPortExitCritical(void);
76 #define portENTER_CRITICAL()            vPortEnterCritical()
77 #define portEXIT_CRITICAL()                     vPortExitCritical()
78 #define portDISABLE_INTERRUPTS()        asm( " CPSID I" )
79 #define portENABLE_INTERRUPTS()         asm( " CPSIE I" )
80
81 /* Scheduler utilities. */
82 #pragma SWI_ALIAS( vPortYield, 0 )
83 extern void vPortYield( void );
84 #define portYIELD()                     vPortYield()
85 #define portSYS_SSIR1_REG                       ( * ( ( volatile uint32_t * ) 0xFFFFFFB0 ) )
86 #define portSYS_SSIR1_SSKEY                     ( 0x7500UL )
87 #define portYIELD_WITHIN_API()          { portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY;  asm( " DSB " ); asm( " ISB " ); }
88 #define portYIELD_FROM_ISR( x )         do { if( x != pdFALSE ) { portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY;  ( void ) portSYS_SSIR1_REG; } } while( 0 )
89
90 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
91         #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
92 #endif
93
94 /* Architecture specific optimisations. */
95 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
96
97         /* Check the configuration. */
98         #if( configMAX_PRIORITIES > 32 )
99                 #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.
100         #endif
101
102         /* Store/clear the ready priorities in a bit map. */
103         #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
104         #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
105
106         /*-----------------------------------------------------------*/
107
108         #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - __clz( ( uxReadyPriorities ) ) )
109
110 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
111
112
113 /* Task function macros as described on the FreeRTOS.org WEB site. */
114 #define portTASK_FUNCTION(vFunction, pvParameters)       void vFunction(void *pvParameters)
115 #define portTASK_FUNCTION_PROTO(vFunction, pvParameters) void vFunction(void *pvParameters)
116
117 #endif /* __PORTMACRO_H__ */
118