portmacro.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * FreeRTOS Kernel V10.4.6
  3. * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  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. /*-----------------------------------------------------------
  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 rt_ubase_t
  49. #define portBASE_TYPE rt_base_t
  50. typedef portSTACK_TYPE StackType_t;
  51. typedef rt_base_t BaseType_t;
  52. typedef rt_ubase_t UBaseType_t;
  53. typedef rt_tick_t TickType_t;
  54. #define portMAX_DELAY ( TickType_t ) RT_TICK_MAX
  55. struct rt_semaphore_wrapper
  56. {
  57. struct rt_semaphore sem;
  58. rt_uint16_t max_value;
  59. };
  60. /*-----------------------------------------------------------*/
  61. /* Architecture specifics. */
  62. #define portTICK_PERIOD_MS ((TickType_t) (1000 / configTICK_RATE_HZ))
  63. #define portBYTE_ALIGNMENT RT_ALIGN_SIZE
  64. #define portPOINTER_SIZE_TYPE rt_size_t
  65. /*-----------------------------------------------------------*/
  66. /* Scheduler utilities. */
  67. #define portYIELD() rt_thread_yield()
  68. #define portYIELD_FROM_ISR( x ) rt_thread_yield()
  69. /*-----------------------------------------------------------*/
  70. /* Critical section management. */
  71. extern void vPortEnterCritical( void );
  72. extern void vPortExitCritical( void );
  73. #define portSET_INTERRUPT_MASK_FROM_ISR() rt_hw_interrupt_disable()
  74. #define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) rt_hw_interrupt_enable( x )
  75. #define portDISABLE_INTERRUPTS() vPortEnterCritical()
  76. #define portENABLE_INTERRUPTS() vPortExitCritical()
  77. #define portENTER_CRITICAL() vPortEnterCritical()
  78. #define portEXIT_CRITICAL() vPortExitCritical()
  79. /*-----------------------------------------------------------*/
  80. #define FREERTOS_PRIORITY_TO_RTTHREAD(priority) ( configMAX_PRIORITIES - 1 - ( priority ) )
  81. #define RTTHREAD_PRIORITY_TO_FREERTOS(priority) ( RT_THREAD_PRIORITY_MAX - 1 - ( priority ) )
  82. /* Use this macro to calculate the buffer size when allocating a queue statically
  83. * To ensure the buffer can fit the desired number of messages
  84. */
  85. #define QUEUE_BUFFER_SIZE( uxQueueLength, uxItemSize ) ( ( RT_ALIGN( uxItemSize, RT_ALIGN_SIZE ) + sizeof( void * ) ) * uxQueueLength )
  86. BaseType_t rt_err_to_freertos(rt_err_t rt_err);
  87. #ifdef __cplusplus
  88. }
  89. #endif
  90. #endif /* PORTMACRO_H */