]> begriffs open source - freertos/blob - portable/template/portmacro.h
Sample FreeRTOSConfig.h and template port (#812)
[freertos] / portable / template / portmacro.h
1 /*
2  * FreeRTOS Kernel <DEVELOPMENT BRANCH>
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 #ifndef PORTMACRO_H
29 #define PORTMACRO_H
30
31 /*-----------------------------------------------------------
32  * Port specific definitions.
33  *
34  * The settings in this file configure FreeRTOS correctly for the
35  * given hardware and compiler.
36  *
37  * These settings should not be altered.
38  *-----------------------------------------------------------
39  */
40
41 /* Type definitions. */
42 #define portCHAR                 char
43 #define portFLOAT                float
44 #define portDOUBLE               double
45 #define portLONG                 long
46 #define portSHORT                int
47 #define portSTACK_TYPE           uint8_t
48 #define portBASE_TYPE            char
49
50 #define portSTACK_GROWTH         ( -1 )
51 #define portBYTE_ALIGNMENT       4
52 #define portPOINTER_SIZE_TYPE    size_t
53 typedef portSTACK_TYPE   StackType_t;
54 typedef signed char      BaseType_t;
55 typedef unsigned char    UBaseType_t;
56
57 #if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
58     typedef uint16_t     TickType_t;
59     #define portMAX_DELAY    ( TickType_t ) 0xffff
60 #elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
61     typedef uint32_t     TickType_t;
62     #define portMAX_DELAY    ( TickType_t ) 0xffffffffUL
63 #else
64     #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width.
65 #endif
66
67 /* Architecture specific optimisations. */
68 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
69     #define configUSE_PORT_OPTIMISED_TASK_SELECTION    1
70 #endif
71
72 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
73
74 /* Check the configuration. */
75     #if ( configMAX_PRIORITIES > 32 )
76         #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.
77     #endif
78
79 /* Store/clear the ready priorities in a bit map. */
80     #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities )    ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
81     #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities )     ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
82
83 /*-----------------------------------------------------------*/
84
85     #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) \
86     {                                                                    \
87         uxTopPriority = 0;                                               \
88     }                                                                    \
89     while( 0 )
90
91 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
92
93 #define portDISABLE_INTERRUPTS()   \
94     { /* Disable the interrupts */ \
95     }
96 #define portENABLE_INTERRUPTS()   \
97     { /* Enable the interrupts */ \
98     }
99
100 #define portENTER_CRITICAL()                                             \
101     { /* preserve current interrupt state and then disable interrupts */ \
102     }
103 #define portEXIT_CRITICAL()                              \
104     { /* restore previously preserved interrupt state */ \
105     }
106
107 extern void vPortYield( void );
108 #define portYIELD()                                           vPortYield()
109
110 /* Task function macros as described on the FreeRTOS.org WEB site. */
111 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters )    void vFunction( void * pvParameters )
112 #define portTASK_FUNCTION( vFunction, pvParameters )          void vFunction( void * pvParameters )
113
114 #endif /* PORTMACRO_H */