]> begriffs open source - freertos/blob - portable/IAR/MSP430/portmacro.h
Update copyright year from 2020 to 2021
[freertos] / portable / IAR / MSP430 / portmacro.h
1 /*\r
2  * FreeRTOS Kernel <DEVELOPMENT BRANCH>\r
3  * Copyright (C) 2021 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  * https://www.FreeRTOS.org\r
23  * https://github.com/FreeRTOS\r
24  *\r
25  */\r
26 \r
27 #ifndef PORTMACRO_H\r
28 #define PORTMACRO_H\r
29 \r
30 /*-----------------------------------------------------------\r
31  * Port specific definitions.\r
32  *\r
33  * The settings in this file configure FreeRTOS correctly for the\r
34  * given hardware and compiler.\r
35  *\r
36  * These settings should not be altered.\r
37  *-----------------------------------------------------------\r
38  */\r
39 \r
40 /* Type definitions. */\r
41 #define portCHAR                char\r
42 #define portFLOAT               float\r
43 #define portDOUBLE              double\r
44 #define portLONG                long\r
45 #define portSHORT               int\r
46 #define portSTACK_TYPE  uint16_t\r
47 #define portBASE_TYPE   short\r
48 \r
49 typedef portSTACK_TYPE StackType_t;\r
50 typedef short BaseType_t;\r
51 typedef unsigned short UBaseType_t;\r
52 \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 ) 0xffffffffUL\r
60 #endif\r
61 \r
62 /*-----------------------------------------------------------*/\r
63 \r
64 /* Interrupt control macros. */\r
65 #define portDISABLE_INTERRUPTS()        _DINT(); _NOP()\r
66 #define portENABLE_INTERRUPTS()         _EINT(); _NOP()\r
67 /*-----------------------------------------------------------*/\r
68 \r
69 /* Critical section control macros. */\r
70 #define portNO_CRITICAL_SECTION_NESTING         ( ( uint16_t ) 0 )\r
71 \r
72 #define portENTER_CRITICAL()                                                                                                    \\r
73 {                                                                                                                                                               \\r
74 extern volatile uint16_t usCriticalNesting;                                                     \\r
75                                                                                                                                                                 \\r
76         portDISABLE_INTERRUPTS();                                                                                                       \\r
77                                                                                                                                                                 \\r
78         /* Now interrupts are disabled usCriticalNesting can be accessed */                     \\r
79         /* directly.  Increment ulCriticalNesting to keep a count of how many */        \\r
80         /* times portENTER_CRITICAL() has been called. */                                                       \\r
81         usCriticalNesting++;                                                                                                            \\r
82 }\r
83 \r
84 #define portEXIT_CRITICAL()                                                                                                             \\r
85 {                                                                                                                                                               \\r
86 extern volatile uint16_t usCriticalNesting;                                                     \\r
87                                                                                                                                                                 \\r
88         if( usCriticalNesting > portNO_CRITICAL_SECTION_NESTING )                                       \\r
89         {                                                                                                                                                       \\r
90                 /* Decrement the nesting count as we are leaving a critical section. */ \\r
91                 usCriticalNesting--;                                                                                                    \\r
92                                                                                                                                                                 \\r
93                 /* If the nesting level has reached zero then interrupts should be */   \\r
94                 /* re-enabled. */                                                                                                               \\r
95                 if( usCriticalNesting == portNO_CRITICAL_SECTION_NESTING )                              \\r
96                 {                                                                                                                                               \\r
97                         portENABLE_INTERRUPTS();                                                                                        \\r
98                 }                                                                                                                                               \\r
99         }                                                                                                                                                       \\r
100 }\r
101 /*-----------------------------------------------------------*/\r
102 \r
103 /* Task utilities. */\r
104 \r
105 /*\r
106  * Manual context switch called by portYIELD or taskYIELD.\r
107  */\r
108 extern void vPortYield( void );\r
109 #define portYIELD() vPortYield()\r
110 /*-----------------------------------------------------------*/\r
111 \r
112 /* Hardware specifics. */\r
113 #define portBYTE_ALIGNMENT                      2\r
114 #define portSTACK_GROWTH                        ( -1 )\r
115 #define portTICK_PERIOD_MS                      ( ( TickType_t ) 1000 / configTICK_RATE_HZ )\r
116 #define portNOP()\r
117 #define portPOINTER_SIZE_TYPE           uint16_t\r
118 /*-----------------------------------------------------------*/\r
119 \r
120 /* Task function macros as described on the FreeRTOS.org WEB site. */\r
121 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
122 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
123 \r
124 #if configINTERRUPT_EXAMPLE_METHOD == 2\r
125 \r
126 extern void vTaskSwitchContext( void );\r
127 #define portYIELD_FROM_ISR( x ) do { if( x ) vTaskSwitchContext(); } while( 0 )\r
128 \r
129 #endif\r
130 \r
131 #endif /* PORTMACRO_H */\r
132 \r