mbed_rtx.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* mbed Microcontroller Library
  2. * Copyright (c) 2017 ARM Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MBED_MBED_RTX_H
  17. #define MBED_MBED_RTX_H
  18. #include <stdint.h>
  19. #ifndef INITIAL_SP
  20. #if (defined(TARGET_STM32L475VG) ||\
  21. defined(TARGET_STM32L476RG) ||\
  22. defined(TARGET_STM32L476JG) ||\
  23. defined(TARGET_STM32L476VG) ||\
  24. defined(TARGET_STM32L486RG))
  25. /* only GCC_ARM and IAR toolchains have the stack on SRAM2 */
  26. #if (((defined(__GNUC__) && !defined(__CC_ARM)) ||\
  27. defined(__IAR_SYSTEMS_ICC__ )) &&\
  28. defined(TWO_RAM_REGIONS))
  29. #define INITIAL_SP (0x10008000UL)
  30. #else
  31. #define INITIAL_SP (0x20018000UL)
  32. #endif /* toolchains */
  33. #elif (defined(TARGET_STM32F051R8) ||\
  34. defined(TARGET_STM32F100RB) ||\
  35. defined(TARGET_STM32L031K6) ||\
  36. defined(TARGET_STM32L053C8) ||\
  37. defined(TARGET_STM32L053R8))
  38. #define INITIAL_SP (0x20002000UL)
  39. #elif (defined(TARGET_STM32F303K8) ||\
  40. defined(TARGET_STM32F334C8) ||\
  41. defined(TARGET_STM32F334R8))
  42. #define INITIAL_SP (0x20003000UL)
  43. #elif (defined(TARGET_STM32F070RB) ||\
  44. defined(TARGET_STM32F072RB) ||\
  45. defined(TARGET_STM32F302R8))
  46. #define INITIAL_SP (0x20004000UL)
  47. #elif (defined(TARGET_STM32F103RB) ||\
  48. defined(TARGET_STM32F103C8) ||\
  49. defined(TARGET_STM32L072CZ) ||\
  50. defined(TARGET_STM32L073RZ) ||\
  51. defined(TARGET_STM32L0x2xZ))
  52. #define INITIAL_SP (0x20005000UL)
  53. #elif (defined(TARGET_STM32F091RC) ||\
  54. defined(TARGET_STM32F410RB) ||\
  55. defined(TARGET_STM32L151CBA)||\
  56. defined(TARGET_STM32L151CC) ||\
  57. defined(TARGET_STM32L151RC) ||\
  58. defined(TARGET_STM32L152RC))
  59. #define INITIAL_SP (0x20008000UL)
  60. #elif defined(TARGET_STM32F303VC)
  61. #define INITIAL_SP (0x2000A000UL)
  62. #elif defined(TARGET_STM32L443RC)
  63. #define INITIAL_SP (0x2000C000UL)
  64. #elif defined(TARGET_STM32L432KC) ||\
  65. defined (TARGET_STM32L433RC)
  66. #define INITIAL_SP (0x20010000UL)
  67. #elif (defined(TARGET_STM32F303RE) ||\
  68. defined(TARGET_STM32F303ZE) ||\
  69. defined(TARGET_STM32F401VC))
  70. #define INITIAL_SP (0x20010000UL)
  71. #elif defined(TARGET_STM32L152RE)
  72. #define INITIAL_SP (0x20014000UL)
  73. #elif (defined(TARGET_STM32F401RE) ||\
  74. defined(TARGET_STM32F401VE))
  75. #define INITIAL_SP (0x20018000UL)
  76. #elif (defined(TARGET_STM32F207ZG) ||\
  77. defined(TARGET_STM32F405RG) ||\
  78. defined(TARGET_STM32F407VG) ||\
  79. defined(TARGET_STM32F411RE) ||\
  80. defined(TARGET_STM32F446RE) ||\
  81. defined(TARGET_STM32F446VE) ||\
  82. defined(TARGET_STM32F446ZE))
  83. #define INITIAL_SP (0x20020000UL)
  84. #elif (defined(TARGET_STM32F429ZI) ||\
  85. defined(TARGET_STM32F437VG) ||\
  86. defined(TARGET_STM32F439VI) ||\
  87. defined(TARGET_STM32F439ZI))
  88. #define INITIAL_SP (0x20030000UL)
  89. #elif defined(TARGET_STM32F412ZG)
  90. #define INITIAL_SP (0x20040000UL)
  91. #elif (defined(TARGET_STM32F413ZH) ||\
  92. defined(TARGET_STM32F469NI) ||\
  93. defined(TARGET_STM32F746NG) ||\
  94. defined(TARGET_STM32F746ZG) ||\
  95. defined(TARGET_STM32F756ZG) ||\
  96. defined(TARGET_STM32L496AG) ||\
  97. defined(TARGET_STM32L496ZG))
  98. #define INITIAL_SP (0x20050000UL)
  99. #elif (defined(TARGET_STM32F767ZI) ||\
  100. defined(TARGET_STM32F769NI))
  101. #define INITIAL_SP (0x20080000UL)
  102. #else
  103. #error "INITIAL_SP is not defined for this target in the mbed_rtx.h file"
  104. #endif
  105. #endif // INITIAL_SP
  106. #if (defined(__GNUC__) && !defined(__CC_ARM) && !defined(__ARMCC_VERSION) && defined(TWO_RAM_REGIONS))
  107. extern uint32_t __StackLimit[];
  108. extern uint32_t __StackTop[];
  109. extern uint32_t __end__[];
  110. extern uint32_t __HeapLimit[];
  111. #define HEAP_START ((unsigned char*)__end__)
  112. #define HEAP_SIZE ((uint32_t)((uint32_t)__HeapLimit - (uint32_t)HEAP_START))
  113. #define ISR_STACK_START ((unsigned char*)__StackLimit)
  114. #define ISR_STACK_SIZE ((uint32_t)((uint32_t)__StackTop - (uint32_t)__StackLimit))
  115. #endif
  116. #endif // MBED_MBED_RTX_H