2 * FreeRTOS SMP Kernel V202110.00
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * https://www.FreeRTOS.org
23 * https://github.com/FreeRTOS
34 /*-----------------------------------------------------------
35 * Port specific definitions.
37 * The settings in this file configure FreeRTOS correctly for the given hardware
40 * These settings should not be altered.
41 *-----------------------------------------------------------
44 /* Type definitions. */
46 #define portFLOAT float
47 #define portDOUBLE double
49 #define portSHORT short
50 #define portSTACK_TYPE uint32_t
51 #define portBASE_TYPE long
53 typedef portSTACK_TYPE StackType_t;
54 typedef long BaseType_t;
55 typedef unsigned long UBaseType_t;
58 #if( configUSE_16_BIT_TICKS == 1 )
59 typedef uint16_t TickType_t;
60 #define portMAX_DELAY ( TickType_t ) 0xffff
62 typedef uint32_t TickType_t;
63 #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
65 /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
66 not need to be guarded with a critical section. */
67 #define portTICK_TYPE_IS_ATOMIC 1
69 /*-----------------------------------------------------------*/
71 /* Hardware specifics. */
72 #define portSTACK_GROWTH ( -1 )
73 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
74 #define portBYTE_ALIGNMENT 8
76 /*-----------------------------------------------------------*/
80 /* Called at the end of an ISR that can cause a context switch. */
81 #define portEND_SWITCHING_ISR( xSwitchRequired )\
83 extern uint32_t ulPortYieldRequired; \
85 if( xSwitchRequired != pdFALSE ) \
87 ulPortYieldRequired = pdTRUE; \
91 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
92 #define portYIELD() __asm( "SWI 0" );
95 /*-----------------------------------------------------------
96 * Critical section control
97 *----------------------------------------------------------*/
99 extern void vPortEnterCritical( void );
100 extern void vPortExitCritical( void );
101 extern uint32_t ulPortSetInterruptMask( void );
102 extern void vPortClearInterruptMask( uint32_t ulNewMaskValue );
104 /* These macros do not globally disable/enable interrupts. They do mask off
105 interrupts that have a priority below configMAX_API_CALL_INTERRUPT_PRIORITY. */
106 #define portENTER_CRITICAL() vPortEnterCritical();
107 #define portEXIT_CRITICAL() vPortExitCritical();
108 #define portDISABLE_INTERRUPTS() ulPortSetInterruptMask()
109 #define portENABLE_INTERRUPTS() vPortClearInterruptMask( 0 )
110 #define portSET_INTERRUPT_MASK_FROM_ISR() ulPortSetInterruptMask()
111 #define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x)
113 /*-----------------------------------------------------------*/
115 /* Task function macros as described on the FreeRTOS.org WEB site. These are
116 not required for this port but included in case common demo code that uses these
118 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
119 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
121 /* Prototype of the FreeRTOS tick handler. This must be installed as the
122 handler for whichever peripheral is used to generate the RTOS tick. */
123 void FreeRTOS_Tick_Handler( void );
125 /* Any task that uses the floating point unit MUST call vPortTaskUsesFPU()
126 before any floating point instructions are executed. */
127 void vPortTaskUsesFPU( void );
128 #define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU()
130 #define portLOWEST_INTERRUPT_PRIORITY ( ( ( uint32_t ) configUNIQUE_INTERRUPT_PRIORITIES ) - 1UL )
131 #define portLOWEST_USABLE_INTERRUPT_PRIORITY ( portLOWEST_INTERRUPT_PRIORITY - 1UL )
133 /* Architecture specific optimisations. */
134 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
135 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
138 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
140 /* Store/clear the ready priorities in a bit map. */
141 #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
142 #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
144 /*-----------------------------------------------------------*/
146 #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - __clz( uxReadyPriorities ) )
148 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
151 void vPortValidateInterruptPriority( void );
152 #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority()
155 #define portNOP() __nop()
161 #endif /* PORTMACRO_H */