portmacro.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /*-----------------------------------------------------------
  33. * Port specific definitions.
  34. *
  35. * The settings in this file configure FreeRTOS correctly for the
  36. * given hardware and compiler.
  37. *
  38. * These settings should not be altered.
  39. *-----------------------------------------------------------
  40. */
  41. /* Type definitions. */
  42. #define portCHAR char
  43. #define portFLOAT float
  44. #define portDOUBLE double
  45. #define portLONG long
  46. #define portSHORT short
  47. #define portSTACK_TYPE uint32_t
  48. #define portBASE_TYPE long
  49. typedef portSTACK_TYPE StackType_t;
  50. typedef long BaseType_t;
  51. typedef unsigned long UBaseType_t;
  52. #if ( configUSE_16_BIT_TICKS == 1 )
  53. typedef uint16_t TickType_t;
  54. #define portMAX_DELAY ( TickType_t ) 0xffff
  55. #else
  56. typedef uint32_t TickType_t;
  57. #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
  58. /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
  59. * not need to be guarded with a critical section. */
  60. #define portTICK_TYPE_IS_ATOMIC 1
  61. #endif
  62. /*-----------------------------------------------------------*/
  63. /* Architecture specifics. */
  64. #define portSTACK_GROWTH ( -1 )
  65. #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
  66. #define portBYTE_ALIGNMENT 8
  67. #define portDONT_DISCARD __attribute__( ( used ) )
  68. /*-----------------------------------------------------------*/
  69. /* Scheduler utilities. */
  70. extern void vPortYield( void );
  71. #define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
  72. #define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
  73. #define portYIELD() vPortYield()
  74. #define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT
  75. #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
  76. /*-----------------------------------------------------------*/
  77. /* Critical section management. */
  78. extern void vPortEnterCritical( void );
  79. extern void vPortExitCritical( void );
  80. extern uint32_t ulSetInterruptMaskFromISR( void ) __attribute__( ( naked ) );
  81. extern void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__( ( naked ) );
  82. #define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR()
  83. #define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) vClearInterruptMaskFromISR( x )
  84. #define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" )
  85. #define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" )
  86. #define portENTER_CRITICAL() vPortEnterCritical()
  87. #define portEXIT_CRITICAL() vPortExitCritical()
  88. /*-----------------------------------------------------------*/
  89. /* Tickless idle/low power functionality. */
  90. #ifndef portSUPPRESS_TICKS_AND_SLEEP
  91. extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );
  92. #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime )
  93. #endif
  94. /*-----------------------------------------------------------*/
  95. /* Task function macros as described on the FreeRTOS.org WEB site. */
  96. #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
  97. #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
  98. #define portNOP()
  99. #define portMEMORY_BARRIER() __asm volatile ( "" ::: "memory" )
  100. #ifdef __cplusplus
  101. }
  102. #endif
  103. #endif /* PORTMACRO_H */