portmacro.h 4.8 KB

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