2 * FreeRTOS Kernel V11.2.0
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * SPDX-License-Identifier: MIT
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:
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
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.
24 * https://www.FreeRTOS.org
25 * https://github.com/FreeRTOS
38 /*-----------------------------------------------------------
39 * Port specific definitions.
41 * The settings in this file configure FreeRTOS correctly for the given hardware
44 * These settings should not be altered.
45 *-----------------------------------------------------------
48 /* Type definitions. */
50 #define portFLOAT float
51 #define portDOUBLE double
53 #define portSHORT short
54 #define portSTACK_TYPE uint32_t
55 #define portBASE_TYPE long
57 typedef portSTACK_TYPE StackType_t;
58 typedef long BaseType_t;
59 typedef unsigned long UBaseType_t;
61 typedef uint32_t TickType_t;
62 #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
64 /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
65 * not need to be guarded with a critical section. */
66 #define portTICK_TYPE_IS_ATOMIC 1
68 /*-----------------------------------------------------------*/
70 /* Hardware specifics. */
71 #define portSTACK_GROWTH ( -1 )
72 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
73 #define portBYTE_ALIGNMENT 8
75 /*-----------------------------------------------------------*/
79 /* Called at the end of an ISR that can cause a context switch. */
80 #define portEND_SWITCHING_ISR( xSwitchRequired ) \
82 extern volatile uint32_t ulPortYieldRequired; \
84 if( xSwitchRequired != pdFALSE ) \
86 ulPortYieldRequired = pdTRUE; \
90 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
92 void vPortYield( void );
94 #define portYIELD() vPortYield();
96 /*-----------------------------------------------------------*/
99 * Critical section management.
102 extern void vPortEnterCritical( void );
103 extern void vPortExitCritical( void );
104 extern void vPortEnableInterrupts( void );
105 extern void vPortDisableInterrupts( void );
106 extern uint32_t ulPortSetInterruptMaskFromISR( void );
108 /* In the absence of a priority mask register, these functions and macros
109 * globally enable and disable interrupts. */
110 #define portENTER_CRITICAL() vPortEnterCritical();
111 #define portEXIT_CRITICAL() vPortExitCritical();
112 #define portENABLE_INTERRUPTS() vPortEnableInterrupts();
113 #define portDISABLE_INTERRUPTS() vPortDisableInterrupts();
114 #define portSET_INTERRUPT_MASK_FROM_ISR() ulPortSetInterruptMaskFromISR();
115 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) do { if( x == 0 ) portENABLE_INTERRUPTS(); } while( 0 )
117 /*-----------------------------------------------------------*/
119 /* Task function macros as described on the FreeRTOS.org WEB site. These are
120 * not required for this port but included in case common demo code that uses these
122 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
123 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
125 /* Tickless idle/low power functionality. */
126 #ifndef portSUPPRESS_TICKS_AND_SLEEP
127 extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );
128 #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime )
131 /* Prototype of the FreeRTOS tick handler. This must be installed as the
132 * handler for whichever peripheral is used to generate the RTOS tick. */
133 void FreeRTOS_Tick_Handler( void );
136 * @brief Returns the number of leading zeros in a 32 bit variable.
138 * @param[in] ulBitmap 32-Bit number to count leading zeros in.
140 * @return The number of leading zeros in ulBitmap.
142 UBaseType_t ulPortCountLeadingZeros( UBaseType_t ulBitmap );
144 /* If configUSE_TASK_FPU_SUPPORT is set to 1 (or left undefined) then tasks are
145 * created without an FPU context and must call vPortTaskUsesFPU() to give
146 * themselves an FPU context before using any FPU instructions. If
147 * configUSE_TASK_FPU_SUPPORT is set to 2 then all tasks will have an FPU
148 * context by default. */
149 #if ( configUSE_TASK_FPU_SUPPORT != 2 )
150 void vPortTaskUsesFPU( void );
152 /* Each task has an FPU context already, so define this function as a
154 #define vPortTaskUsesFPU()
156 #define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU()
158 #define portLOWEST_INTERRUPT_PRIORITY ( ( ( uint32_t ) configUNIQUE_INTERRUPT_PRIORITIES ) - 1UL )
159 #define portLOWEST_USABLE_INTERRUPT_PRIORITY ( portLOWEST_INTERRUPT_PRIORITY - 1UL )
161 /* Architecture specific optimisations. */
162 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
163 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
166 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
168 /* Store, clear and get the ready priorities in a bit map. */
169 #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
170 #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
171 #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - ulPortCountLeadingZeros( ( uxTopReadyPriority ) ) )
173 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
175 #define portNOP() __asm volatile ( "NOP" )
176 #define portINLINE __inline
177 #define portMEMORY_BARRIER() __asm volatile ( "" ::: "memory" )
185 #endif /* PORTMACRO_H */