portmacro.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. #include <avr/wdt.h>
  43. /* Type definitions. */
  44. #define portCHAR char
  45. #define portFLOAT float
  46. #define portDOUBLE double
  47. #define portLONG long
  48. #define portSHORT int
  49. typedef uint8_t StackType_t;
  50. typedef int8_t BaseType_t;
  51. typedef uint8_t 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. #endif
  59. /*-----------------------------------------------------------*/
  60. /* Critical section management. */
  61. #define portENTER_CRITICAL() __asm__ __volatile__ ( \
  62. "in __tmp_reg__, __SREG__" "\n\t" \
  63. "cli" "\n\t" \
  64. "push __tmp_reg__" "\n\t" \
  65. ::: "memory" \
  66. )
  67. #define portEXIT_CRITICAL() __asm__ __volatile__ ( \
  68. "pop __tmp_reg__" "\n\t" \
  69. "out __SREG__, __tmp_reg__" "\n\t" \
  70. ::: "memory" \
  71. )
  72. #define portDISABLE_INTERRUPTS() __asm__ __volatile__ ( "cli" ::: "memory")
  73. #define portENABLE_INTERRUPTS() __asm__ __volatile__ ( "sei" ::: "memory")
  74. /*-----------------------------------------------------------*/
  75. /* Architecture specifics. */
  76. /* System Tick - Scheduler timer
  77. * Prefer to use the enhanced Watchdog Timer, but also Timer0 is ok.
  78. */
  79. #if defined(WDIE) && defined(WDIF) /* If Enhanced WDT with interrupt capability is available */
  80. #define portUSE_WDTO WDTO_15MS /* use the Watchdog Timer for xTaskIncrementTick */
  81. /* Watchdog period options: WDTO_15MS
  82. WDTO_30MS
  83. WDTO_60MS
  84. WDTO_120MS
  85. WDTO_250MS
  86. WDTO_500MS
  87. WDTO_1S
  88. WDTO_2S
  89. */
  90. #else
  91. #define portUSE_TIMER0 /* use the 8-bit Timer0 for xTaskIncrementTick */
  92. #endif
  93. #define portSTACK_GROWTH ( -1 )
  94. /* Timing for the scheduler.
  95. * Watchdog Timer is 128kHz nominal,
  96. * but 120 kHz at 5V DC and 25 degrees is actually more accurate,
  97. * from data sheet.
  98. */
  99. #if defined( portUSE_WDTO )
  100. #define portTICK_PERIOD_MS ( (TickType_t) _BV( portUSE_WDTO + 4 ) )
  101. #else
  102. #define portTICK_PERIOD_MS ( (TickType_t) 1000 / configTICK_RATE_HZ )
  103. #endif
  104. #define portBYTE_ALIGNMENT 1
  105. #define portNOP() __asm__ __volatile__ ( "nop" );
  106. /*-----------------------------------------------------------*/
  107. /* Kernel utilities. */
  108. extern void vPortYield( void ) __attribute__ ( ( naked ) );
  109. #define portYIELD() vPortYield()
  110. extern void vPortYieldFromISR( void ) __attribute__ ( ( naked ) );
  111. #define portYIELD_FROM_ISR() vPortYieldFromISR()
  112. /*-----------------------------------------------------------*/
  113. #if defined(__AVR_3_BYTE_PC__)
  114. /* Task function macros as described on the FreeRTOS.org WEB site. */
  115. /* Add .lowtext tag from the avr linker script avr6.x for ATmega2560 and ATmega2561
  116. * to make sure functions are loaded in low memory.
  117. */
  118. #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) __attribute__ ((section (".lowtext")))
  119. #else
  120. #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
  121. #endif
  122. #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
  123. #ifdef __cplusplus
  124. }
  125. #endif
  126. #endif /* PORTMACRO_H */