You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

201 lines
6.8 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32wbxx_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) 2019 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 __STM32WBxx_HAL_DEF
  22. #define __STM32WBxx_HAL_DEF
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "stm32wbxx.h"
  28. #include "Legacy/stm32_hal_legacy.h" /* Aliases file for old names compatibility */
  29. #include <stddef.h>
  30. /* Exported types ------------------------------------------------------------*/
  31. /**
  32. * @brief HAL Status structures definition
  33. */
  34. typedef enum
  35. {
  36. HAL_OK = 0x00,
  37. HAL_ERROR = 0x01,
  38. HAL_BUSY = 0x02,
  39. HAL_TIMEOUT = 0x03
  40. } HAL_StatusTypeDef;
  41. /**
  42. * @brief HAL Lock structures definition
  43. */
  44. typedef enum
  45. {
  46. HAL_UNLOCKED = 0x00,
  47. HAL_LOCKED = 0x01
  48. } HAL_LockTypeDef;
  49. /* Exported macros -----------------------------------------------------------*/
  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(0)
  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 = 0)
  75. #if (USE_RTOS == 1)
  76. /* Reserved for future use */
  77. #error " USE_RTOS should be 0 in the current HAL release "
  78. #else
  79. #define __HAL_LOCK(__HANDLE__) \
  80. do{ \
  81. if((__HANDLE__)->Lock == HAL_LOCKED) \
  82. { \
  83. return HAL_BUSY; \
  84. } \
  85. else \
  86. { \
  87. (__HANDLE__)->Lock = HAL_LOCKED; \
  88. } \
  89. }while (0)
  90. #define __HAL_UNLOCK(__HANDLE__) \
  91. do{ \
  92. (__HANDLE__)->Lock = HAL_UNLOCKED; \
  93. }while (0)
  94. #endif /* USE_RTOS */
  95. #if defined ( __GNUC__ )
  96. #ifndef __weak
  97. #define __weak __attribute__((weak))
  98. #endif /* __weak */
  99. #ifndef __packed
  100. #define __packed __attribute__((__packed__))
  101. #endif /* __packed */
  102. #endif /* __GNUC__ */
  103. /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
  104. /* GNU Compiler */
  105. #if defined (__GNUC__)
  106. #ifndef __ALIGN_END
  107. #define __ALIGN_END __attribute__ ((aligned (4)))
  108. #endif /* __ALIGN_END */
  109. #ifndef __ALIGN_BEGIN
  110. #define __ALIGN_BEGIN
  111. #endif /* __ALIGN_BEGIN */
  112. #else
  113. #ifndef __ALIGN_END
  114. #define __ALIGN_END
  115. #endif /* __ALIGN_END */
  116. #ifndef __ALIGN_BEGIN
  117. /* ARM Compiler */
  118. #if defined (__CC_ARM)
  119. #define __ALIGN_BEGIN __align(4)
  120. /* IAR Compiler */
  121. #elif defined (__ICCARM__)
  122. #define __ALIGN_BEGIN
  123. #endif /* __CC_ARM */
  124. #endif /* __ALIGN_BEGIN */
  125. #endif /* __GNUC__ */
  126. /**
  127. * @brief __RAM_FUNC definition
  128. */
  129. #if defined ( __CC_ARM )
  130. /* ARM Compiler
  131. ------------
  132. RAM functions are defined using the toolchain options.
  133. Functions that are executed in RAM should reside in a separate source module.
  134. Using the 'Options for File' dialog you can simply change the 'Code / Const'
  135. area of a module to a memory space in physical RAM.
  136. Available memory areas are declared in the 'Target' tab of the 'Options for Target'
  137. dialog.
  138. */
  139. #define __RAM_FUNC
  140. #elif defined ( __ICCARM__ )
  141. /* ICCARM Compiler
  142. ---------------
  143. RAM functions are defined using a specific toolchain keyword "__ramfunc".
  144. */
  145. #define __RAM_FUNC __ramfunc
  146. #elif defined ( __GNUC__ )
  147. /* GNU Compiler
  148. ------------
  149. RAM functions are defined using a specific toolchain attribute
  150. "__attribute__((section(".RamFunc")))".
  151. */
  152. #define __RAM_FUNC __attribute__((section(".RamFunc")))
  153. #endif
  154. /**
  155. * @brief __NOINLINE definition
  156. */
  157. #if defined ( __CC_ARM ) || defined ( __GNUC__ )
  158. /* ARM & GNUCompiler
  159. ----------------
  160. */
  161. #define __NOINLINE __attribute__ ( (noinline) )
  162. #elif defined ( __ICCARM__ )
  163. /* ICCARM Compiler
  164. ---------------
  165. */
  166. #define __NOINLINE _Pragma("optimize = no_inline")
  167. #endif
  168. #ifdef __cplusplus
  169. }
  170. #endif
  171. #endif /* ___STM32WBxx_HAL_DEF */
  172. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/