]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/IAR/RX100/portmacro.h
Update to MIT licensed FreeRTOS V10.0.0 - see https://www.freertos.org/History.txt
[freertos] / FreeRTOS / Source / portable / IAR / RX100 / portmacro.h
1 /*\r
2  * FreeRTOS Kernel V10.0.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. If you wish to use our Amazon\r
14  * FreeRTOS name, please do so in a fair use way that does not cause confusion.\r
15  *\r
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
22  *\r
23  * http://www.FreeRTOS.org\r
24  * http://aws.amazon.com/freertos\r
25  *\r
26  * 1 tab == 4 spaces!\r
27  */\r
28 \r
29 \r
30 #ifndef PORTMACRO_H\r
31 #define PORTMACRO_H\r
32 \r
33 #include <intrinsics.h>\r
34 \r
35 #ifdef __cplusplus\r
36 extern "C" {\r
37 #endif\r
38 \r
39 /* Hardware specifics. */\r
40 #include "machine.h"\r
41 \r
42 /*-----------------------------------------------------------\r
43  * Port specific definitions.\r
44  *\r
45  * The settings in this file configure FreeRTOS correctly for the\r
46  * given hardware and compiler.\r
47  *\r
48  * These settings should not be altered.\r
49  *-----------------------------------------------------------\r
50  */\r
51 \r
52 /* Type definitions - these are a bit legacy and not really used now, other than\r
53 portSTACK_TYPE and portBASE_TYPE. */\r
54 #define portCHAR                char\r
55 #define portFLOAT               float\r
56 #define portDOUBLE              double\r
57 #define portLONG                long\r
58 #define portSHORT               short\r
59 #define portSTACK_TYPE  uint32_t\r
60 #define portBASE_TYPE   long\r
61 \r
62 typedef portSTACK_TYPE StackType_t;\r
63 typedef long BaseType_t;\r
64 typedef unsigned long UBaseType_t;\r
65 \r
66 \r
67 #if( configUSE_16_BIT_TICKS == 1 )\r
68         typedef uint16_t TickType_t;\r
69         #define portMAX_DELAY ( TickType_t ) 0xffff\r
70 #else\r
71         typedef uint32_t TickType_t;\r
72         #define portMAX_DELAY ( TickType_t ) 0xffffffffUL\r
73 \r
74         /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do\r
75         not need to be guarded with a critical section. */\r
76         #define portTICK_TYPE_IS_ATOMIC 1\r
77 #endif\r
78 /*-----------------------------------------------------------*/\r
79 \r
80 /* Hardware specifics. */\r
81 #define portBYTE_ALIGNMENT                      8       /* Could make four, according to manual. */\r
82 #define portSTACK_GROWTH                        -1\r
83 #define portTICK_PERIOD_MS                      ( ( TickType_t ) 1000 / configTICK_RATE_HZ )\r
84 #define portNOP()                                       __no_operation()\r
85 \r
86 #define portYIELD()                                             \\r
87         __asm volatile                                          \\r
88         (                                                                       \\r
89                 "MOV.L #0x872E0, R15            \n"     \\r
90                 "MOV.B #1, [R15]                        \n"     \\r
91                 "MOV.L [R15], R15                       \n"     \\r
92                 ::: "R15"                                               \\r
93         )\r
94 \r
95 #define portYIELD_FROM_ISR( x ) if( ( x ) != pdFALSE ) { portYIELD(); }\r
96 \r
97 /* These macros should not be called directly, but through the\r
98 taskENTER_CRITICAL() and taskEXIT_CRITICAL() macros.  An extra check is\r
99 performed if configASSERT() is defined to ensure an assertion handler does not\r
100 inadvertently attempt to lower the IPL when the call to assert was triggered\r
101 because the IPL value was found to be above     configMAX_SYSCALL_INTERRUPT_PRIORITY\r
102 when an ISR safe FreeRTOS API function was executed.  ISR safe FreeRTOS API\r
103 functions are those that end in FromISR.  FreeRTOS maintains a separate\r
104 interrupt API to ensure API function and interrupt entry is as fast and as\r
105 simple as possible. */\r
106 #define portENABLE_INTERRUPTS()         __set_interrupt_level( ( uint8_t ) 0 )\r
107 #ifdef configASSERT\r
108         #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() configASSERT( ( __get_interrupt_level() <= configMAX_SYSCALL_INTERRUPT_PRIORITY ) )\r
109         #define portDISABLE_INTERRUPTS()        if( __get_interrupt_level() < configMAX_SYSCALL_INTERRUPT_PRIORITY ) __set_interrupt_level( ( uint8_t ) configMAX_SYSCALL_INTERRUPT_PRIORITY )\r
110 #else\r
111         #define portDISABLE_INTERRUPTS()        __set_interrupt_level( ( uint8_t ) configMAX_SYSCALL_INTERRUPT_PRIORITY )\r
112 #endif\r
113 \r
114 /* Critical nesting counts are stored in the TCB. */\r
115 #define portCRITICAL_NESTING_IN_TCB ( 1 )\r
116 \r
117 /* The critical nesting functions defined within tasks.c. */\r
118 extern void vTaskEnterCritical( void );\r
119 extern void vTaskExitCritical( void );\r
120 #define portENTER_CRITICAL()    vTaskEnterCritical()\r
121 #define portEXIT_CRITICAL()             vTaskExitCritical()\r
122 \r
123 /* As this port allows interrupt nesting... */\r
124 #define portSET_INTERRUPT_MASK_FROM_ISR() __get_interrupt_level(); portDISABLE_INTERRUPTS()\r
125 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ) __set_interrupt_level( ( uint8_t ) ( uxSavedInterruptStatus ) )\r
126 \r
127 /* Tickless idle/low power functionality. */\r
128 #if configUSE_TICKLESS_IDLE == 1\r
129         #ifndef portSUPPRESS_TICKS_AND_SLEEP\r
130                 extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );\r
131                 #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime )\r
132         #endif\r
133 #endif\r
134 \r
135 /*-----------------------------------------------------------*/\r
136 \r
137 /* Task function macros as described on the FreeRTOS.org WEB site. */\r
138 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
139 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
140 \r
141 /* Prevent warnings of undefined behaviour: the order of volatile accesses is\r
142 undefined - all warnings have been manually checked and are not an issue, and\r
143 the warnings cannot be prevent by code changes without undesirable effects. */\r
144 #pragma diag_suppress=Pa082\r
145 \r
146 #ifdef __cplusplus\r
147 }\r
148 #endif\r
149 \r
150 #endif /* PORTMACRO_H */\r
151 \r