portmacro.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * FreeRTOS Kernel V10.4.3
  3. * Copyright 2020 Cambridge Consultants Ltd.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. * this software and associated documentation files (the "Software"), to deal in
  7. * the Software without restriction, including without limitation the rights to
  8. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9. * the Software, and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  17. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  18. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  19. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * https://www.FreeRTOS.org
  23. * https://github.com/FreeRTOS
  24. *
  25. * 1 tab == 4 spaces!
  26. */
  27. #ifndef PORTMACRO_H
  28. #define PORTMACRO_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #include <limits.h>
  33. /*-----------------------------------------------------------
  34. * Port specific definitions.
  35. *
  36. * The settings in this file configure FreeRTOS correctly for the
  37. * given hardware and compiler.
  38. *
  39. * These settings should not be altered.
  40. *-----------------------------------------------------------
  41. */
  42. /* Type definitions. */
  43. #define portCHAR char
  44. #define portFLOAT float
  45. #define portDOUBLE double
  46. #define portLONG long
  47. #define portSHORT short
  48. #define portSTACK_TYPE unsigned long
  49. #define portBASE_TYPE long
  50. #define portPOINTER_SIZE_TYPE intptr_t
  51. typedef portSTACK_TYPE StackType_t;
  52. typedef long BaseType_t;
  53. typedef unsigned long UBaseType_t;
  54. typedef unsigned long TickType_t;
  55. #define portMAX_DELAY ( TickType_t ) ULONG_MAX
  56. #define portTICK_TYPE_IS_ATOMIC 1
  57. /*-----------------------------------------------------------*/
  58. /* Architecture specifics. */
  59. #define portSTACK_GROWTH ( -1 )
  60. #define portHAS_STACK_OVERFLOW_CHECKING ( 1 )
  61. #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
  62. #define portTICK_RATE_MICROSECONDS ( ( portTickType ) 1000000 / configTICK_RATE_HZ )
  63. #define portBYTE_ALIGNMENT 8
  64. /*-----------------------------------------------------------*/
  65. /* Scheduler utilities. */
  66. extern void vPortYield( void );
  67. #define portYIELD() vPortYield()
  68. #define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) vPortYield()
  69. #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
  70. /*-----------------------------------------------------------*/
  71. /* Critical section management. */
  72. extern void vPortDisableInterrupts( void );
  73. extern void vPortEnableInterrupts( void );
  74. #define portSET_INTERRUPT_MASK() ( vPortDisableInterrupts() )
  75. #define portCLEAR_INTERRUPT_MASK() ( vPortEnableInterrupts() )
  76. extern portBASE_TYPE xPortSetInterruptMask( void );
  77. extern void vPortClearInterruptMask( portBASE_TYPE xMask );
  78. extern void vPortEnterCritical( void );
  79. extern void vPortExitCritical( void );
  80. #define portSET_INTERRUPT_MASK_FROM_ISR() xPortSetInterruptMask()
  81. #define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x)
  82. #define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK()
  83. #define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK()
  84. #define portENTER_CRITICAL() vPortEnterCritical()
  85. #define portEXIT_CRITICAL() vPortExitCritical()
  86. /*-----------------------------------------------------------*/
  87. extern void vPortThreadDying( void *pxTaskToDelete, volatile BaseType_t *pxPendYield );
  88. extern void vPortCancelThread( void *pxTaskToDelete );
  89. #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortThreadDying( ( pvTaskToDelete ), ( pxPendYield ) )
  90. #define portCLEAN_UP_TCB( pxTCB ) vPortCancelThread( pxTCB )
  91. /*-----------------------------------------------------------*/
  92. #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
  93. #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
  94. /*-----------------------------------------------------------*/
  95. /*
  96. * Tasks run in their own pthreads and context switches between them
  97. * are always a full memory barrier. ISRs are emulated as signals
  98. * which also imply a full memory barrier.
  99. *
  100. * Thus, only a compilier barrier is needed to prevent the compiler
  101. * reordering.
  102. */
  103. #define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" )
  104. extern unsigned long ulPortGetRunTime( void );
  105. #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* no-op */
  106. #define portGET_RUN_TIME_COUNTER_VALUE() ulPortGetRunTime()
  107. #ifdef __cplusplus
  108. }
  109. #endif
  110. #endif /* PORTMACRO_H */