2 * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 * Copyright 2020 Cambridge Consultants Ltd.
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
42 /*-----------------------------------------------------------
43 * Port specific definitions.
45 * The settings in this file configure FreeRTOS correctly for the
46 * given hardware and compiler.
48 * These settings should not be altered.
49 *-----------------------------------------------------------
52 /* Type definitions. */
54 #define portFLOAT float
55 #define portDOUBLE double
57 #define portSHORT short
58 #define portSTACK_TYPE unsigned long
59 #define portBASE_TYPE long
60 #define portPOINTER_SIZE_TYPE intptr_t
62 typedef portSTACK_TYPE StackType_t;
63 typedef long BaseType_t;
64 typedef unsigned long UBaseType_t;
66 typedef unsigned long TickType_t;
67 #define portMAX_DELAY ( ( TickType_t ) ULONG_MAX )
69 #define portTICK_TYPE_IS_ATOMIC 1
71 /*-----------------------------------------------------------*/
73 /* Architecture specifics. */
74 #define portSTACK_GROWTH ( -1 )
75 #define portHAS_STACK_OVERFLOW_CHECKING ( 1 )
76 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
77 #define portTICK_RATE_MICROSECONDS ( ( TickType_t ) 1000000 / configTICK_RATE_HZ )
78 #define portBYTE_ALIGNMENT 8
79 /*-----------------------------------------------------------*/
81 /* Scheduler utilities. */
82 extern void vPortYield( void );
84 #define portYIELD() vPortYield()
86 #define portEND_SWITCHING_ISR( xSwitchRequired ) \
89 if( xSwitchRequired != pdFALSE ) \
91 traceISR_EXIT_TO_SCHEDULER(); \
99 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
100 /*-----------------------------------------------------------*/
102 /* Critical section management. */
103 extern void vPortDisableInterrupts( void );
104 extern void vPortEnableInterrupts( void );
105 #define portSET_INTERRUPT_MASK() ( vPortDisableInterrupts() )
106 #define portCLEAR_INTERRUPT_MASK() ( vPortEnableInterrupts() )
108 extern UBaseType_t xPortSetInterruptMask( void );
109 extern void vPortClearInterruptMask( UBaseType_t xMask );
111 extern void vPortEnterCritical( void );
112 extern void vPortExitCritical( void );
113 #define portSET_INTERRUPT_MASK_FROM_ISR() xPortSetInterruptMask()
114 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) vPortClearInterruptMask( x )
115 #define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK()
116 #define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK()
117 #define portENTER_CRITICAL() vPortEnterCritical()
118 #define portEXIT_CRITICAL() vPortExitCritical()
120 /*-----------------------------------------------------------*/
122 extern void vPortThreadDying( void * pxTaskToDelete,
123 volatile BaseType_t * pxPendYield );
124 extern void vPortCancelThread( void * pxTaskToDelete );
125 #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortThreadDying( ( pvTaskToDelete ), ( pxPendYield ) )
126 #define portCLEAN_UP_TCB( pxTCB ) vPortCancelThread( pxTCB )
127 /*-----------------------------------------------------------*/
129 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) __attribute__( ( noreturn ) )
130 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
131 /*-----------------------------------------------------------*/
134 * Tasks run in their own pthreads and context switches between them
135 * are always a full memory barrier. ISRs are emulated as signals
136 * which also imply a full memory barrier.
138 * Thus, only a compiler barrier is needed to prevent the compiler
141 #define portMEMORY_BARRIER() __asm volatile ( "" ::: "memory" )
143 extern uint32_t ulPortGetRunTime( void );
144 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* no-op */
145 #define portGET_RUN_TIME_COUNTER_VALUE() ulPortGetRunTime()
153 #endif /* PORTMACRO_H */