1 /* 2 * FreeRTOS Kernel V11.1.0 3 * Copyright 2020 Cambridge Consultants Ltd. 4 * 5 * SPDX-License-Identifier: MIT 6 * 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: 13 * 14 * The above copyright notice and this permission notice shall be included in all 15 * copies or substantial portions of the Software. 16 * 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. 23 * 24 * https://www.FreeRTOS.org 25 * https://github.com/FreeRTOS 26 * 27 */ 28 29 30 #ifndef PORTMACRO_H 31 #define PORTMACRO_H 32 33 /* *INDENT-OFF* */ 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 /* *INDENT-ON* */ 38 39 #include <limits.h> 40 #include <stdint.h> 41 42 /*----------------------------------------------------------- 43 * Port specific definitions. 44 * 45 * The settings in this file configure FreeRTOS correctly for the 46 * given hardware and compiler. 47 * 48 * These settings should not be altered. 49 *----------------------------------------------------------- 50 */ 51 52 /* Type definitions. */ 53 #define portCHAR char 54 #define portFLOAT float 55 #define portDOUBLE double 56 #define portLONG long 57 #define portSHORT short 58 #define portSTACK_TYPE unsigned long 59 #define portBASE_TYPE long 60 #define portPOINTER_SIZE_TYPE intptr_t 61 62 typedef portSTACK_TYPE StackType_t; 63 typedef long BaseType_t; 64 typedef unsigned long UBaseType_t; 65 66 typedef unsigned long TickType_t; 67 #define portMAX_DELAY ( ( TickType_t ) ULONG_MAX ) 68 69 #define portTICK_TYPE_IS_ATOMIC 1 70 71 /*-----------------------------------------------------------*/ 72 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 /*-----------------------------------------------------------*/ 80 81 /* Scheduler utilities. */ 82 extern void vPortYield( void ); 83 84 #define portYIELD() vPortYield() 85 86 #define portEND_SWITCHING_ISR( xSwitchRequired ) \ 87 do \ 88 { \ 89 if( xSwitchRequired != pdFALSE ) \ 90 { \ 91 traceISR_EXIT_TO_SCHEDULER(); \ 92 vPortYield(); \ 93 } \ 94 else \ 95 { \ 96 traceISR_EXIT(); \ 97 } \ 98 } while( 0 ) 99 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) 100 /*-----------------------------------------------------------*/ 101 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() ) 107 108 extern UBaseType_t xPortSetInterruptMask( void ); 109 extern void vPortClearInterruptMask( UBaseType_t xMask ); 110 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() 119 120 /*-----------------------------------------------------------*/ 121 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 /*-----------------------------------------------------------*/ 128 129 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) __attribute__( ( noreturn ) ) 130 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) 131 /*-----------------------------------------------------------*/ 132 133 /* 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. 137 * 138 * Thus, only a compilier barrier is needed to prevent the compiler 139 * reordering. 140 */ 141 #define portMEMORY_BARRIER() __asm volatile ( "" ::: "memory" ) 142 143 extern uint32_t ulPortGetRunTime( void ); 144 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* no-op */ 145 #define portGET_RUN_TIME_COUNTER_VALUE() ulPortGetRunTime() 146 147 /* *INDENT-OFF* */ 148 #ifdef __cplusplus 149 } 150 #endif 151 /* *INDENT-ON* */ 152 153 #endif /* PORTMACRO_H */ 154