stm32f3xx_hal_def.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_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) 2016 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 __STM32F3xx_HAL_DEF
  22. #define __STM32F3xx_HAL_DEF
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "stm32f3xx.h"
  28. #include "Legacy/stm32_hal_legacy.h"
  29. #include <stddef.h>
  30. /* Exported types ------------------------------------------------------------*/
  31. /**
  32. * @brief HAL Status structures definition
  33. */
  34. typedef enum
  35. {
  36. HAL_OK = 0x00U,
  37. HAL_ERROR = 0x01U,
  38. HAL_BUSY = 0x02U,
  39. HAL_TIMEOUT = 0x03
  40. } HAL_StatusTypeDef;
  41. /**
  42. * @brief HAL Lock structures definition
  43. */
  44. typedef enum
  45. {
  46. HAL_UNLOCKED = 0x00U,
  47. HAL_LOCKED = 0x01
  48. } HAL_LockTypeDef;
  49. /* Exported macro ------------------------------------------------------------*/
  50. #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */
  51. #define HAL_MAX_DELAY 0xFFFFFFFFU
  52. #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == BIT)
  53. #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
  54. #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \
  55. do{ \
  56. (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \
  57. (__DMA_HANDLE_).Parent = (__HANDLE__); \
  58. } while(0U)
  59. /** @brief Reset the Handle's State field.
  60. * @param __HANDLE__ specifies the Peripheral Handle.
  61. * @note This macro can be used for the following purpose:
  62. * - When the Handle is declared as local variable; before passing it as parameter
  63. * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
  64. * to set to 0 the Handle's "State" field.
  65. * Otherwise, "State" field may have any random value and the first time the function
  66. * HAL_PPP_Init() is called, the low level hardware initialization will be missed
  67. * (i.e. HAL_PPP_MspInit() will not be executed).
  68. * - When there is a need to reconfigure the low level hardware: instead of calling
  69. * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
  70. * In this later function, when the Handle's "State" field is set to 0, it will execute the function
  71. * HAL_PPP_MspInit() which will reconfigure the low level hardware.
  72. * @retval None
  73. */
  74. #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
  75. #if (USE_RTOS == 1U)
  76. #error " USE_RTOS should be 0 in the current HAL release "
  77. #else
  78. #define __HAL_LOCK(__HANDLE__) \
  79. do{ \
  80. if((__HANDLE__)->Lock == HAL_LOCKED) \
  81. { \
  82. return HAL_BUSY; \
  83. } \
  84. else \
  85. { \
  86. (__HANDLE__)->Lock = HAL_LOCKED; \
  87. } \
  88. }while (0U)
  89. #define __HAL_UNLOCK(__HANDLE__) \
  90. do{ \
  91. (__HANDLE__)->Lock = HAL_UNLOCKED; \
  92. }while (0U)
  93. #endif /* USE_RTOS */
  94. #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
  95. #ifndef __weak
  96. #define __weak __attribute__((weak))
  97. #endif
  98. #ifndef __packed
  99. #define __packed __attribute__((packed))
  100. #endif
  101. #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
  102. #ifndef __weak
  103. #define __weak __attribute__((weak))
  104. #endif /* __weak */
  105. #ifndef __packed
  106. #define __packed __attribute__((__packed__))
  107. #endif /* __packed */
  108. #endif /* __GNUC__ */
  109. /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
  110. #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
  111. #ifndef __ALIGN_BEGIN
  112. #define __ALIGN_BEGIN
  113. #endif
  114. #ifndef __ALIGN_END
  115. #define __ALIGN_END __attribute__ ((aligned (4)))
  116. #endif
  117. #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
  118. #ifndef __ALIGN_END
  119. #define __ALIGN_END __attribute__ ((aligned (4)))
  120. #endif /* __ALIGN_END */
  121. #ifndef __ALIGN_BEGIN
  122. #define __ALIGN_BEGIN
  123. #endif /* __ALIGN_BEGIN */
  124. #else
  125. #ifndef __ALIGN_END
  126. #define __ALIGN_END
  127. #endif /* __ALIGN_END */
  128. #ifndef __ALIGN_BEGIN
  129. #if defined (__CC_ARM) /* ARM Compiler V5*/
  130. #define __ALIGN_BEGIN __align(4)
  131. #elif defined (__ICCARM__) /* IAR Compiler */
  132. #define __ALIGN_BEGIN
  133. #endif /* __CC_ARM */
  134. #endif /* __ALIGN_BEGIN */
  135. #endif /* __GNUC__ */
  136. /**
  137. * @brief __NOINLINE definition
  138. */
  139. #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ )
  140. /* ARM V4/V5 and V6 & GNU Compiler
  141. -------------------------------
  142. */
  143. #define __NOINLINE __attribute__ ( (noinline) )
  144. #elif defined ( __ICCARM__ )
  145. /* ICCARM Compiler
  146. ---------------
  147. */
  148. #define __NOINLINE _Pragma("optimize = no_inline")
  149. #endif
  150. #ifdef __cplusplus
  151. }
  152. #endif
  153. #endif /* ___STM32F3xx_HAL_DEF */
  154. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/