stm32l5xx_hal_def.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /**
  2. ******************************************************************************
  3. * @file stm32l5xx_hal_def.h
  4. * @author MCD Application Team
  5. * @brief This file contains HAL common defines, enumeration, macros and
  6. * structures definitions.
  7. *
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * Copyright (c) 2019 STMicroelectronics.
  12. * All rights reserved.
  13. *
  14. * This software is licensed under terms that can be found in the LICENSE file
  15. * in the root directory of this software component.
  16. * If no LICENSE file comes with this software, it is provided AS-IS.
  17. *
  18. ******************************************************************************
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef STM32L5xx_HAL_DEF_H
  22. #define STM32L5xx_HAL_DEF_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  28. #include <arm_cmse.h>
  29. #endif
  30. #include "stm32l5xx.h"
  31. #include "Legacy/stm32_hal_legacy.h" /* Aliases file for old names compatibility */
  32. #include <stddef.h>
  33. /* Exported types ------------------------------------------------------------*/
  34. /**
  35. * @brief HAL Status structures definition
  36. */
  37. typedef enum
  38. {
  39. HAL_OK = 0x00,
  40. HAL_ERROR = 0x01,
  41. HAL_BUSY = 0x02,
  42. HAL_TIMEOUT = 0x03
  43. } HAL_StatusTypeDef;
  44. /**
  45. * @brief HAL Lock structures definition
  46. */
  47. typedef enum
  48. {
  49. HAL_UNLOCKED = 0x00,
  50. HAL_LOCKED = 0x01
  51. } HAL_LockTypeDef;
  52. /* Exported macros -----------------------------------------------------------*/
  53. #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */
  54. #define HAL_MAX_DELAY 0xFFFFFFFFU
  55. #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT))
  56. #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
  57. #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
  58. do{ \
  59. (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
  60. (__DMA_HANDLE__).Parent = (__HANDLE__); \
  61. } while(0)
  62. /** @brief Reset the Handle's State field.
  63. * @param __HANDLE__ specifies the Peripheral Handle.
  64. * @note This macro can be used for the following purpose:
  65. * - When the Handle is declared as local variable; before passing it as parameter
  66. * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
  67. * to set to 0 the Handle's "State" field.
  68. * Otherwise, "State" field may have any random value and the first time the function
  69. * HAL_PPP_Init() is called, the low level hardware initialization will be missed
  70. * (i.e. HAL_PPP_MspInit() will not be executed).
  71. * - When there is a need to reconfigure the low level hardware: instead of calling
  72. * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
  73. * In this later function, when the Handle's "State" field is set to 0, it will execute the function
  74. * HAL_PPP_MspInit() which will reconfigure the low level hardware.
  75. * @retval None
  76. */
  77. #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0)
  78. #if (USE_RTOS == 1)
  79. /* Reserved for future use */
  80. #error " USE_RTOS should be 0 in the current HAL release "
  81. #else
  82. #define __HAL_LOCK(__HANDLE__) \
  83. do{ \
  84. if((__HANDLE__)->Lock == HAL_LOCKED) \
  85. { \
  86. return HAL_BUSY; \
  87. } \
  88. else \
  89. { \
  90. (__HANDLE__)->Lock = HAL_LOCKED; \
  91. } \
  92. }while (0)
  93. #define __HAL_UNLOCK(__HANDLE__) \
  94. do{ \
  95. (__HANDLE__)->Lock = HAL_UNLOCKED; \
  96. }while (0)
  97. #endif /* USE_RTOS */
  98. #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
  99. #ifndef __weak
  100. #define __weak __attribute__((weak))
  101. #endif
  102. #ifndef __packed
  103. #define __packed __attribute__((packed))
  104. #endif
  105. #elif defined (__GNUC__) /* GNU Compiler */
  106. #ifndef __weak
  107. #define __weak __attribute__((weak))
  108. #endif /* __weak */
  109. #ifndef __packed
  110. #define __packed __attribute__((__packed__))
  111. #endif /* __packed */
  112. #endif /* __GNUC__ */
  113. /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
  114. #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
  115. #ifndef __ALIGN_BEGIN
  116. #define __ALIGN_BEGIN
  117. #endif
  118. #ifndef __ALIGN_END
  119. #define __ALIGN_END __attribute__((aligned (4)))
  120. #endif
  121. #elif defined (__GNUC__) /* GNU Compiler */
  122. #ifndef __ALIGN_END
  123. #define __ALIGN_END __attribute__((aligned (4)))
  124. #endif /* __ALIGN_END */
  125. #ifndef __ALIGN_BEGIN
  126. #define __ALIGN_BEGIN
  127. #endif /* __ALIGN_BEGIN */
  128. #else
  129. #ifndef __ALIGN_END
  130. #define __ALIGN_END
  131. #endif /* __ALIGN_END */
  132. #ifndef __ALIGN_BEGIN
  133. #if defined (__ICCARM__) /* IAR Compiler */
  134. #define __ALIGN_BEGIN
  135. #endif /* __ICCARM__ */
  136. #endif /* __ALIGN_BEGIN */
  137. #endif /* __GNUC__ */
  138. /**
  139. * @brief __RAM_FUNC definition
  140. */
  141. #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  142. /* ARM Compiler V6
  143. ---------------
  144. RAM functions are defined using the toolchain options.
  145. Functions that are executed in RAM should reside in a separate source module.
  146. Using the 'Options for File' dialog you can simply change the 'Code / Const'
  147. area of a module to a memory space in physical RAM.
  148. Available memory areas are declared in the 'Target' tab of the 'Options for Target'
  149. dialog.
  150. */
  151. #define __RAM_FUNC
  152. #elif defined (__ICCARM__)
  153. /* ICCARM Compiler
  154. ---------------
  155. RAM functions are defined using a specific toolchain keyword "__ramfunc".
  156. */
  157. #define __RAM_FUNC __ramfunc
  158. #elif defined (__GNUC__)
  159. /* GNU Compiler
  160. ------------
  161. RAM functions are defined using a specific toolchain attribute
  162. "__attribute__((section(".RamFunc")))".
  163. */
  164. #define __RAM_FUNC __attribute__((section(".RamFunc")))
  165. #endif
  166. /**
  167. * @brief __NOINLINE definition
  168. */
  169. #if (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined (__GNUC__)
  170. /* ARM V6 & GNU Compiler
  171. ---------------------
  172. */
  173. #define __NOINLINE __attribute__((noinline))
  174. #elif defined (__ICCARM__)
  175. /* ICCARM Compiler
  176. ---------------
  177. */
  178. #define __NOINLINE _Pragma("optimize = no_inline")
  179. #endif
  180. #ifdef __cplusplus
  181. }
  182. #endif
  183. #endif /* STM32L5xx_HAL_DEF_H */