stm32wbxx.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /**
  2. ******************************************************************************
  3. * @file stm32wbxx.h
  4. * @author MCD Application Team
  5. * @brief CMSIS STM32WBxx Device Peripheral Access Layer Header File.
  6. *
  7. * The file is the unique include file that the application programmer
  8. * is using in the C source code, usually in main.c. This file contains:
  9. * - Configuration section that allows to select:
  10. * - The STM32WBxx device used in the target application
  11. * - To use or not the peripheral's drivers in application code(i.e.
  12. * code will be based on direct access to peripheral's registers
  13. * rather than drivers API), this option is controlled by
  14. * "#define USE_HAL_DRIVER"
  15. *
  16. ******************************************************************************
  17. * @attention
  18. *
  19. * Copyright (c) 2019-2021 STMicroelectronics.
  20. * All rights reserved.
  21. *
  22. * This software is licensed under terms that can be found in the LICENSE file
  23. * in the root directory of this software component.
  24. * If no LICENSE file comes with this software, it is provided AS-IS.
  25. *
  26. ******************************************************************************
  27. */
  28. /** @addtogroup CMSIS
  29. * @{
  30. */
  31. /** @addtogroup stm32wbxx
  32. * @{
  33. */
  34. #ifndef __STM32WBxx_H
  35. #define __STM32WBxx_H
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif /* __cplusplus */
  39. /** @addtogroup Library_configuration_section
  40. * @{
  41. */
  42. /**
  43. * @brief STM32 Family
  44. */
  45. #if !defined (STM32WB)
  46. #define STM32WB
  47. #endif /* STM32WB */
  48. /* Tip: To avoid modifying this file each time you need to switch between these
  49. devices, you can define the device in your toolchain compiler preprocessor.
  50. */
  51. #if !defined (USE_HAL_DRIVER)
  52. /**
  53. * @brief Comment the line below if you will not use the peripherals drivers.
  54. In this case, these drivers will not be included and the application code will
  55. be based on direct access to peripherals registers
  56. */
  57. /*#define USE_HAL_DRIVER */
  58. #endif /* USE_HAL_DRIVER */
  59. /**
  60. * @brief CMSIS Device version number
  61. */
  62. #define __STM32WBxx_CMSIS_VERSION_MAIN (0x01U) /*!< [31:24] main version */
  63. #define __STM32WBxx_CMSIS_VERSION_SUB1 (0x0CU) /*!< [23:16] sub1 version */
  64. #define __STM32WBxx_CMSIS_VERSION_SUB2 (0x02U) /*!< [15:8] sub2 version */
  65. #define __STM32WBxx_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */
  66. #define __STM32WBxx_CMSIS_DEVICE_VERSION ((__STM32WBxx_CMSIS_VERSION_MAIN << 24)\
  67. |(__STM32WBxx_CMSIS_VERSION_SUB1 << 16)\
  68. |(__STM32WBxx_CMSIS_VERSION_SUB2 << 8 )\
  69. |(__STM32WBxx_CMSIS_VERSION_RC))
  70. /**
  71. * @}
  72. */
  73. /** @addtogroup Device_Included
  74. * @{
  75. */
  76. #if defined(STM32WB55xx)
  77. #include "stm32wb55xx.h"
  78. #elif defined(STM32WB5Mxx)
  79. #include "stm32wb5mxx.h"
  80. #elif defined(STM32WB50xx)
  81. #include "stm32wb50xx.h"
  82. #elif defined(STM32WB35xx)
  83. #include "stm32wb35xx.h"
  84. #elif defined(STM32WB30xx)
  85. #include "stm32wb30xx.h"
  86. #elif defined(STM32WB15xx)
  87. #include "stm32wb15xx.h"
  88. #elif defined(STM32WB10xx)
  89. #include "stm32wb10xx.h"
  90. #elif defined(STM32WB1Mxx)
  91. #include "stm32wb1mxx.h"
  92. #else
  93. #error "Please select first the target STM32WBxx device used in your application, for instance xxx (in stm32wbxx.h file)"
  94. #endif
  95. /**
  96. * @}
  97. */
  98. /** @addtogroup Exported_types
  99. * @{
  100. */
  101. typedef enum
  102. {
  103. RESET = 0,
  104. SET = !RESET
  105. } FlagStatus, ITStatus;
  106. typedef enum
  107. {
  108. DISABLE = 0,
  109. ENABLE = !DISABLE
  110. } FunctionalState;
  111. #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
  112. typedef enum
  113. {
  114. SUCCESS = 0,
  115. ERROR = !SUCCESS
  116. } ErrorStatus;
  117. /**
  118. * @}
  119. */
  120. /** @addtogroup Exported_macros
  121. * @{
  122. */
  123. #define SET_BIT(REG, BIT) ((REG) |= (BIT))
  124. #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
  125. #define READ_BIT(REG, BIT) ((REG) & (BIT))
  126. #define CLEAR_REG(REG) ((REG) = (0x0))
  127. #define WRITE_REG(REG, VAL) ((REG) = (VAL))
  128. #define READ_REG(REG) ((REG))
  129. #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
  130. /* Use of CMSIS compiler intrinsics for register exclusive access */
  131. /* Atomic 32-bit register access macro to set one or several bits */
  132. #define ATOMIC_SET_BIT(REG, BIT) \
  133. do { \
  134. uint32_t val; \
  135. do { \
  136. val = __LDREXW((__IO uint32_t *)&(REG)) | (BIT); \
  137. } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
  138. } while(0)
  139. /* Atomic 32-bit register access macro to clear one or several bits */
  140. #define ATOMIC_CLEAR_BIT(REG, BIT) \
  141. do { \
  142. uint32_t val; \
  143. do { \
  144. val = __LDREXW((__IO uint32_t *)&(REG)) & ~(BIT); \
  145. } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
  146. } while(0)
  147. /* Atomic 32-bit register access macro to clear and set one or several bits */
  148. #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \
  149. do { \
  150. uint32_t val; \
  151. do { \
  152. val = (__LDREXW((__IO uint32_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
  153. } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
  154. } while(0)
  155. /* Atomic 16-bit register access macro to set one or several bits */
  156. #define ATOMIC_SETH_BIT(REG, BIT) \
  157. do { \
  158. uint16_t val; \
  159. do { \
  160. val = __LDREXH((__IO uint16_t *)&(REG)) | (BIT); \
  161. } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
  162. } while(0)
  163. /* Atomic 16-bit register access macro to clear one or several bits */
  164. #define ATOMIC_CLEARH_BIT(REG, BIT) \
  165. do { \
  166. uint16_t val; \
  167. do { \
  168. val = __LDREXH((__IO uint16_t *)&(REG)) & ~(BIT); \
  169. } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
  170. } while(0)
  171. /* Atomic 16-bit register access macro to clear and set one or several bits */
  172. #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) \
  173. do { \
  174. uint16_t val; \
  175. do { \
  176. val = (__LDREXH((__IO uint16_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
  177. } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
  178. } while(0)
  179. #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
  180. /**
  181. * @}
  182. */
  183. #if defined (USE_HAL_DRIVER)
  184. #include "stm32wbxx_hal.h"
  185. #endif /* USE_HAL_DRIVER */
  186. #ifdef __cplusplus
  187. }
  188. #endif /* __cplusplus */
  189. #endif /* __STM32WBxx_H */
  190. /**
  191. * @}
  192. */
  193. /**
  194. * @}
  195. */