1 /* 2 * FreeRTOS Kernel V10.6.2 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 41 /*----------------------------------------------------------- 42 * Port specific definitions. 43 * 44 * The settings in this file configure FreeRTOS correctly for the 45 * given hardware and compiler. 46 * 47 * These settings should not be altered. 48 *----------------------------------------------------------- 49 */ 50 51 /* Type definitions. */ 52 #define portCHAR char 53 #define portFLOAT float 54 #define portDOUBLE double 55 #define portLONG long 56 #define portSHORT short 57 #define portSTACK_TYPE unsigned long 58 #define portBASE_TYPE long 59 #define portPOINTER_SIZE_TYPE intptr_t 60 61 typedef portSTACK_TYPE StackType_t; 62 typedef long BaseType_t; 63 typedef unsigned long UBaseType_t; 64 65 typedef unsigned long TickType_t; 66 #define portMAX_DELAY ( TickType_t ) ULONG_MAX 67 68 #define portTICK_TYPE_IS_ATOMIC 1 69 70 /*-----------------------------------------------------------*/ 71 72 /* Architecture specifics. */ 73 #define portSTACK_GROWTH ( -1 ) 74 #define portHAS_STACK_OVERFLOW_CHECKING ( 1 ) 75 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) 76 #define portTICK_RATE_MICROSECONDS ( ( TickType_t ) 1000000 / configTICK_RATE_HZ ) 77 #define portBYTE_ALIGNMENT 8 78 /*-----------------------------------------------------------*/ 79 80 /* Scheduler utilities. */ 81 extern void vPortYield( void ); 82 83 #define portYIELD() vPortYield() 84 85 #define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) vPortYield() 86 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) 87 /*-----------------------------------------------------------*/ 88 89 /* Critical section management. */ 90 extern void vPortDisableInterrupts( void ); 91 extern void vPortEnableInterrupts( void ); 92 #define portSET_INTERRUPT_MASK() ( vPortDisableInterrupts() ) 93 #define portCLEAR_INTERRUPT_MASK() ( vPortEnableInterrupts() ) 94 95 extern UBaseType_t xPortSetInterruptMask( void ); 96 extern void vPortClearInterruptMask( UBaseType_t xMask ); 97 98 extern void vPortEnterCritical( void ); 99 extern void vPortExitCritical( void ); 100 #define portSET_INTERRUPT_MASK_FROM_ISR() xPortSetInterruptMask() 101 #define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x) 102 #define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK() 103 #define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK() 104 #define portENTER_CRITICAL() vPortEnterCritical() 105 #define portEXIT_CRITICAL() vPortExitCritical() 106 107 /*-----------------------------------------------------------*/ 108 109 extern void vPortThreadDying( void *pxTaskToDelete, volatile BaseType_t *pxPendYield ); 110 extern void vPortCancelThread( void *pxTaskToDelete ); 111 #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortThreadDying( ( pvTaskToDelete ), ( pxPendYield ) ) 112 #define portCLEAN_UP_TCB( pxTCB ) vPortCancelThread( pxTCB ) 113 /*-----------------------------------------------------------*/ 114 115 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) __attribute__( ( noreturn ) ) 116 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) 117 /*-----------------------------------------------------------*/ 118 119 /* 120 * Tasks run in their own pthreads and context switches between them 121 * are always a full memory barrier. ISRs are emulated as signals 122 * which also imply a full memory barrier. 123 * 124 * Thus, only a compilier barrier is needed to prevent the compiler 125 * reordering. 126 */ 127 #define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) 128 129 extern unsigned long ulPortGetRunTime( void ); 130 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* no-op */ 131 #define portGET_RUN_TIME_COUNTER_VALUE() ulPortGetRunTime() 132 133 /* *INDENT-OFF* */ 134 #ifdef __cplusplus 135 } 136 #endif 137 /* *INDENT-ON* */ 138 139 #endif /* PORTMACRO_H */ 140