stm32f1xx_hal_def.h 6.8 KB

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