portmacro.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * FreeRTOS Kernel V10.4.3
  3. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  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. /* IAR includes. */
  30. #ifdef __ICCARM__
  31. #include <intrinsics.h>
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /*-----------------------------------------------------------
  36. * Port specific definitions.
  37. *
  38. * The settings in this file configure FreeRTOS correctly for the given hardware
  39. * and compiler.
  40. *
  41. * These settings should not be altered.
  42. *-----------------------------------------------------------
  43. */
  44. /* Type definitions. */
  45. #define portCHAR char
  46. #define portFLOAT float
  47. #define portDOUBLE double
  48. #define portLONG long
  49. #define portSHORT short
  50. #define portSTACK_TYPE uint32_t
  51. #define portBASE_TYPE long
  52. typedef portSTACK_TYPE StackType_t;
  53. typedef long BaseType_t;
  54. typedef unsigned long UBaseType_t;
  55. typedef uint32_t TickType_t;
  56. #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
  57. /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
  58. not need to be guarded with a critical section. */
  59. #define portTICK_TYPE_IS_ATOMIC 1
  60. /*-----------------------------------------------------------*/
  61. /* Hardware specifics. */
  62. #define portSTACK_GROWTH ( -1 )
  63. #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
  64. #define portBYTE_ALIGNMENT 64
  65. /*-----------------------------------------------------------*/
  66. /* Task utilities. */
  67. /* Called at the end of an ISR that can cause a context switch. */
  68. #define portEND_SWITCHING_ISR( xSwitchRequired )\
  69. { \
  70. extern uint32_t ulPortYieldRequired; \
  71. \
  72. if( xSwitchRequired != pdFALSE ) \
  73. { \
  74. ulPortYieldRequired = pdTRUE; \
  75. } \
  76. }
  77. #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
  78. #define portYIELD() __asm volatile ( "SWI 0" ); __ISB()
  79. /*-----------------------------------------------------------
  80. * Critical section control
  81. *----------------------------------------------------------*/
  82. extern void vPortEnterCritical( void );
  83. extern void vPortExitCritical( void );
  84. extern uint32_t ulPortSetInterruptMask( void );
  85. extern void vPortClearInterruptMask( uint32_t ulNewMaskValue );
  86. #define portENTER_CRITICAL() vPortEnterCritical();
  87. #define portEXIT_CRITICAL() vPortExitCritical();
  88. #define portDISABLE_INTERRUPTS() __disable_irq(); __DSB(); __ISB() /* No priority mask register so global disable is used. */
  89. #define portENABLE_INTERRUPTS() __enable_irq()
  90. #define portSET_INTERRUPT_MASK_FROM_ISR() __get_interrupt_state(); __disable_irq() /* No priority mask register so global disable is used. */
  91. #define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) __set_interrupt_state(x)
  92. /*-----------------------------------------------------------*/
  93. /* Task function macros as described on the FreeRTOS.org WEB site. These are
  94. not required for this port but included in case common demo code that uses these
  95. macros is used. */
  96. #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
  97. #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
  98. /* Prototype of the FreeRTOS tick handler. This must be installed as the
  99. handler for whichever peripheral is used to generate the RTOS tick. */
  100. void FreeRTOS_Tick_Handler( void );
  101. /* Any task that uses the floating point unit MUST call vPortTaskUsesFPU()
  102. before any floating point instructions are executed. */
  103. void vPortTaskUsesFPU( void );
  104. #define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU()
  105. /* Architecture specific optimisations. */
  106. #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
  107. #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
  108. #endif
  109. #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
  110. /* Store/clear the ready priorities in a bit map. */
  111. #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
  112. #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
  113. /*-----------------------------------------------------------*/
  114. #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - __CLZ( uxReadyPriorities ) )
  115. #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
  116. #define portNOP() __asm volatile( "NOP" )
  117. #ifdef __cplusplus
  118. } /* extern C */
  119. #endif
  120. /* Suppress warnings that are generated by the IAR tools, but cannot be
  121. fixed in the source code because to do so would cause other compilers to
  122. generate warnings. */
  123. #pragma diag_suppress=Pe191
  124. #pragma diag_suppress=Pa082
  125. #endif /* __ICCARM__ */
  126. #endif /* PORTMACRO_H */