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.
 
 
 

8018 lines
442 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32wbxx_ll_adc.h
  4. * @author MCD Application Team
  5. * @brief Header file of ADC LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32WBxx_LL_ADC_H
  21. #define STM32WBxx_LL_ADC_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32wbxx.h"
  27. /** @addtogroup STM32WBxx_LL_Driver
  28. * @{
  29. */
  30. #if defined (ADC1)
  31. /** @defgroup ADC_LL ADC
  32. * @{
  33. */
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /* Private constants ---------------------------------------------------------*/
  37. /** @defgroup ADC_LL_Private_Constants ADC Private Constants
  38. * @{
  39. */
  40. /* Internal mask for ADC group regular sequencer: */
  41. /* To select into literal LL_ADC_REG_RANK_x the relevant bits for: */
  42. /* - sequencer register offset */
  43. /* - sequencer rank bits position into the selected register */
  44. /* Internal register offset for ADC group regular sequencer configuration */
  45. /* (offset placed into a spare area of literal definition) */
  46. #if defined (ADC_SUPPORT_2_5_MSPS)
  47. /* No register ADC_SQRx on this ADC peripheral version */
  48. #else
  49. #define ADC_SQR1_REGOFFSET (0x00000000UL)
  50. #define ADC_SQR2_REGOFFSET (0x00000100UL)
  51. #define ADC_SQR3_REGOFFSET (0x00000200UL)
  52. #define ADC_SQR4_REGOFFSET (0x00000300UL)
  53. #define ADC_REG_SQRX_REGOFFSET_MASK (ADC_SQR1_REGOFFSET | ADC_SQR2_REGOFFSET | ADC_SQR3_REGOFFSET | ADC_SQR4_REGOFFSET)
  54. #define ADC_SQRX_REGOFFSET_POS (8UL) /* Position of bits ADC_SQRx_REGOFFSET in ADC_REG_SQRX_REGOFFSET_MASK */
  55. #endif /* ADC_SUPPORT_2_5_MSPS */
  56. #define ADC_REG_RANK_ID_SQRX_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  57. /* Definition of ADC group regular sequencer bits information to be inserted */
  58. /* into ADC group regular sequencer ranks literals definition. */
  59. #if defined (ADC_SUPPORT_2_5_MSPS)
  60. #define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ( 0UL) /* Value equivalent to bitfield "ADC_CHSELR_SQ1" position in register */
  61. #define ADC_REG_RANK_2_SQRX_BITOFFSET_POS ( 4UL) /* Value equivalent to bitfield "ADC_CHSELR_SQ2" position in register */
  62. #define ADC_REG_RANK_3_SQRX_BITOFFSET_POS ( 8UL) /* Value equivalent to bitfield "ADC_CHSELR_SQ3" position in register */
  63. #define ADC_REG_RANK_4_SQRX_BITOFFSET_POS (12UL) /* Value equivalent to bitfield "ADC_CHSELR_SQ4" position in register */
  64. #define ADC_REG_RANK_5_SQRX_BITOFFSET_POS (16UL) /* Value equivalent to bitfield "ADC_CHSELR_SQ5" position in register */
  65. #define ADC_REG_RANK_6_SQRX_BITOFFSET_POS (20UL) /* Value equivalent to bitfield "ADC_CHSELR_SQ6" position in register */
  66. #define ADC_REG_RANK_7_SQRX_BITOFFSET_POS (24UL) /* Value equivalent to bitfield "ADC_CHSELR_SQ7" position in register */
  67. #define ADC_REG_RANK_8_SQRX_BITOFFSET_POS (28UL) /* Value equivalent to bitfield "ADC_CHSELR_SQ8" position in register */
  68. #else
  69. #define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ( 6UL) /* Value equivalent to bitfield "ADC_SQR1_SQ1" position in register */
  70. #define ADC_REG_RANK_2_SQRX_BITOFFSET_POS (12UL) /* Value equivalent to bitfield "ADC_SQR1_SQ2" position in register */
  71. #define ADC_REG_RANK_3_SQRX_BITOFFSET_POS (18UL) /* Value equivalent to bitfield "ADC_SQR1_SQ3" position in register */
  72. #define ADC_REG_RANK_4_SQRX_BITOFFSET_POS (24UL) /* Value equivalent to bitfield "ADC_SQR1_SQ4" position in register */
  73. #define ADC_REG_RANK_5_SQRX_BITOFFSET_POS ( 0UL) /* Value equivalent to bitfield "ADC_SQR2_SQ5" position in register */
  74. #define ADC_REG_RANK_6_SQRX_BITOFFSET_POS ( 6UL) /* Value equivalent to bitfield "ADC_SQR2_SQ6" position in register */
  75. #define ADC_REG_RANK_7_SQRX_BITOFFSET_POS (12UL) /* Value equivalent to bitfield "ADC_SQR2_SQ7" position in register */
  76. #define ADC_REG_RANK_8_SQRX_BITOFFSET_POS (18UL) /* Value equivalent to bitfield "ADC_SQR2_SQ8" position in register */
  77. #define ADC_REG_RANK_9_SQRX_BITOFFSET_POS (24UL) /* Value equivalent to bitfield "ADC_SQR2_SQ9" position in register */
  78. #define ADC_REG_RANK_10_SQRX_BITOFFSET_POS ( 0UL) /* Value equivalent to bitfield "ADC_SQR3_SQ10" position in register */
  79. #define ADC_REG_RANK_11_SQRX_BITOFFSET_POS ( 6UL) /* Value equivalent to bitfield "ADC_SQR3_SQ11" position in register */
  80. #define ADC_REG_RANK_12_SQRX_BITOFFSET_POS (12UL) /* Value equivalent to bitfield "ADC_SQR3_SQ12" position in register */
  81. #define ADC_REG_RANK_13_SQRX_BITOFFSET_POS (18UL) /* Value equivalent to bitfield "ADC_SQR3_SQ13" position in register */
  82. #define ADC_REG_RANK_14_SQRX_BITOFFSET_POS (24UL) /* Value equivalent to bitfield "ADC_SQR3_SQ14" position in register */
  83. #define ADC_REG_RANK_15_SQRX_BITOFFSET_POS ( 0UL) /* Value equivalent to bitfield "ADC_SQR4_SQ15" position in register */
  84. #define ADC_REG_RANK_16_SQRX_BITOFFSET_POS ( 6UL) /* Value equivalent to bitfield "ADC_SQR4_SQ16" position in register */
  85. #endif /* ADC_SUPPORT_2_5_MSPS */
  86. /* Internal mask for ADC group injected sequencer: */
  87. /* To select into literal LL_ADC_INJ_RANK_x the relevant bits for: */
  88. /* - data register offset */
  89. /* - sequencer rank bits position into the selected register */
  90. /* Internal register offset for ADC group injected data register */
  91. /* (offset placed into a spare area of literal definition) */
  92. #define ADC_JDR1_REGOFFSET (0x00000000UL)
  93. #define ADC_JDR2_REGOFFSET (0x00000100UL)
  94. #define ADC_JDR3_REGOFFSET (0x00000200UL)
  95. #define ADC_JDR4_REGOFFSET (0x00000300UL)
  96. #define ADC_INJ_JDRX_REGOFFSET_MASK (ADC_JDR1_REGOFFSET | ADC_JDR2_REGOFFSET | ADC_JDR3_REGOFFSET | ADC_JDR4_REGOFFSET)
  97. #define ADC_INJ_RANK_ID_JSQR_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  98. #define ADC_JDRX_REGOFFSET_POS (8UL) /* Position of bits ADC_JDRx_REGOFFSET in ADC_INJ_JDRX_REGOFFSET_MASK */
  99. /* Definition of ADC group injected sequencer bits information to be inserted */
  100. /* into ADC group injected sequencer ranks literals definition. */
  101. #define ADC_INJ_RANK_1_JSQR_BITOFFSET_POS ( 8UL) /* Value equivalent to bitfield "ADC_JSQR_JSQ1" position in register */
  102. #define ADC_INJ_RANK_2_JSQR_BITOFFSET_POS (14UL) /* Value equivalent to bitfield "ADC_JSQR_JSQ2" position in register */
  103. #define ADC_INJ_RANK_3_JSQR_BITOFFSET_POS (20UL) /* Value equivalent to bitfield "ADC_JSQR_JSQ3" position in register */
  104. #define ADC_INJ_RANK_4_JSQR_BITOFFSET_POS (26UL) /* Value equivalent to bitfield "ADC_JSQR_JSQ4" position in register */
  105. /* Internal mask for ADC group regular trigger: */
  106. /* To select into literal LL_ADC_REG_TRIG_x the relevant bits for: */
  107. /* - regular trigger source */
  108. /* - regular trigger edge */
  109. #define ADC_REG_TRIG_EXT_EDGE_DEFAULT (ADC_CFGR_EXTEN_0) /* Trigger edge set to rising edge (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value) */
  110. /* Mask containing trigger source masks for each of possible */
  111. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  112. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  113. #define ADC_REG_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTSEL) << (4U * 0UL)) | \
  114. ((ADC_CFGR_EXTSEL) << (4U * 1UL)) | \
  115. ((ADC_CFGR_EXTSEL) << (4U * 2UL)) | \
  116. ((ADC_CFGR_EXTSEL) << (4U * 3UL)) )
  117. /* Mask containing trigger edge masks for each of possible */
  118. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  119. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  120. #define ADC_REG_TRIG_EDGE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTEN) << (4U * 0UL)) | \
  121. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 1UL)) | \
  122. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 2UL)) | \
  123. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 3UL)) )
  124. /* Definition of ADC group regular trigger bits information. */
  125. #define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS ( 6UL) /* Value equivalent to bitfield "ADC_CFGR_EXTSEL" position in register */
  126. #define ADC_REG_TRIG_EXTEN_BITOFFSET_POS (10UL) /* Value equivalent to bitfield "ADC_CFGR_EXTEN" position in register */
  127. /* Internal mask for ADC group injected trigger: */
  128. /* To select into literal LL_ADC_INJ_TRIG_x the relevant bits for: */
  129. /* - injected trigger source */
  130. /* - injected trigger edge */
  131. #define ADC_INJ_TRIG_EXT_EDGE_DEFAULT (ADC_JSQR_JEXTEN_0) /* Trigger edge set to rising edge (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value) */
  132. /* Mask containing trigger source masks for each of possible */
  133. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  134. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  135. #define ADC_INJ_TRIG_SOURCE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTSEL) << (4U * 0UL)) | \
  136. ((ADC_JSQR_JEXTSEL) << (4U * 1UL)) | \
  137. ((ADC_JSQR_JEXTSEL) << (4U * 2UL)) | \
  138. ((ADC_JSQR_JEXTSEL) << (4U * 3UL)) )
  139. /* Mask containing trigger edge masks for each of possible */
  140. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  141. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  142. #define ADC_INJ_TRIG_EDGE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTEN) << (4U * 0UL)) | \
  143. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 1UL)) | \
  144. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 2UL)) | \
  145. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 3UL)) )
  146. /* Definition of ADC group injected trigger bits information. */
  147. #define ADC_INJ_TRIG_EXTSEL_BITOFFSET_POS ( 2UL) /* Value equivalent to bitfield "ADC_JSQR_JEXTSEL" position in register */
  148. #define ADC_INJ_TRIG_EXTEN_BITOFFSET_POS ( 6UL) /* Value equivalent to bitfield "ADC_JSQR_JEXTEN" position in register */
  149. /* Internal mask for ADC channel: */
  150. /* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
  151. /* - channel identifier defined by number */
  152. /* - channel identifier defined by bitfield */
  153. /* - channel differentiation between external channels (connected to */
  154. /* GPIO pins) and internal channels (connected to internal paths) */
  155. /* - channel sampling time defined by SMPRx register offset */
  156. /* and SMPx bits positions into SMPRx register */
  157. #define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CFGR_AWD1CH)
  158. #if defined (ADC_SUPPORT_2_5_MSPS)
  159. #define ADC_CHANNEL_ID_BITFIELD_MASK (ADC_CHSELR_CHSEL)
  160. #else
  161. #define ADC_CHANNEL_ID_BITFIELD_MASK (ADC_AWD2CR_AWD2CH)
  162. #endif
  163. #define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS (26UL)/* Value equivalent to bitfield "ADC_CHANNEL_ID_NUMBER_MASK" position in register */
  164. #if defined(ADC_SUPPORT_2_5_MSPS)
  165. #define ADC_CHANNEL_ID_NUMBER_MASK_SEQ (ADC_CHSELR_SQ1 << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) /* Value equivalent to ADC_CHANNEL_ID_NUMBER_MASK with reduced range: on this STM32 serie, ADC group regular sequencer, if set to mode "fully configurable", can contain channels with a restricted channel number. Refer to function @ref LL_ADC_REG_SetSequencerConfigurable(). */
  166. #endif
  167. #define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_BITFIELD_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  168. /* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
  169. #define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 (0x0000001FUL) /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> [Position of bitfield "ADC_CHANNEL_NUMBER_MASK" in register]) */
  170. /* Channel differentiation between external and internal channels */
  171. #define ADC_CHANNEL_ID_INTERNAL_CH (0x80000000UL) /* Marker of internal channel */
  172. #define ADC_CHANNEL_ID_INTERNAL_CH_2 (0x00080000UL) /* Marker of internal channel for other ADC instances, in case of different ADC internal channels mapped on same channel number on different ADC instances */
  173. #define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH | ADC_CHANNEL_ID_INTERNAL_CH_2)
  174. /* Internal register offset for ADC channel sampling time configuration */
  175. /* (offset placed into a spare area of literal definition) */
  176. #define ADC_SMPR1_REGOFFSET (0x00000000UL)
  177. #define ADC_SMPR2_REGOFFSET (0x02000000UL)
  178. #define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET)
  179. #define ADC_SMPRX_REGOFFSET_POS (25UL) /* Position of bits ADC_SMPRx_REGOFFSET in ADC_CHANNEL_SMPRX_REGOFFSET_MASK */
  180. #define ADC_CHANNEL_SMPx_BITOFFSET_MASK (0x01F00000UL)
  181. #define ADC_CHANNEL_SMPx_BITOFFSET_POS (20UL) /* Value equivalent to bitfield "ADC_CHANNEL_SMPx_BITOFFSET_MASK" position in register */
  182. /* Definition of channels ID number information to be inserted into */
  183. /* channels literals definition. */
  184. #define ADC_CHANNEL_0_NUMBER (0x00000000UL)
  185. #define ADC_CHANNEL_1_NUMBER ( ADC_CFGR_AWD1CH_0)
  186. #define ADC_CHANNEL_2_NUMBER ( ADC_CFGR_AWD1CH_1 )
  187. #define ADC_CHANNEL_3_NUMBER ( ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  188. #define ADC_CHANNEL_4_NUMBER ( ADC_CFGR_AWD1CH_2 )
  189. #define ADC_CHANNEL_5_NUMBER ( ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_0)
  190. #define ADC_CHANNEL_6_NUMBER ( ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 )
  191. #define ADC_CHANNEL_7_NUMBER ( ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  192. #define ADC_CHANNEL_8_NUMBER ( ADC_CFGR_AWD1CH_3 )
  193. #define ADC_CHANNEL_9_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_0)
  194. #define ADC_CHANNEL_10_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_1 )
  195. #define ADC_CHANNEL_11_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  196. #define ADC_CHANNEL_12_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 )
  197. #define ADC_CHANNEL_13_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_0)
  198. #define ADC_CHANNEL_14_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 )
  199. #define ADC_CHANNEL_15_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0)
  200. #define ADC_CHANNEL_16_NUMBER (ADC_CFGR_AWD1CH_4 )
  201. #define ADC_CHANNEL_17_NUMBER (ADC_CFGR_AWD1CH_4 | ADC_CFGR_AWD1CH_0)
  202. #define ADC_CHANNEL_18_NUMBER (ADC_CFGR_AWD1CH_4 | ADC_CFGR_AWD1CH_1 )
  203. /* Definition of channels ID bitfield information to be inserted into */
  204. /* channels literals definition. */
  205. #if defined (ADC_SUPPORT_2_5_MSPS)
  206. #define ADC_CHANNEL_0_BITFIELD (ADC_CHSELR_CHSEL0)
  207. #define ADC_CHANNEL_1_BITFIELD (ADC_CHSELR_CHSEL1)
  208. #define ADC_CHANNEL_2_BITFIELD (ADC_CHSELR_CHSEL2)
  209. #define ADC_CHANNEL_3_BITFIELD (ADC_CHSELR_CHSEL3)
  210. #define ADC_CHANNEL_4_BITFIELD (ADC_CHSELR_CHSEL4)
  211. #define ADC_CHANNEL_5_BITFIELD (ADC_CHSELR_CHSEL5)
  212. #define ADC_CHANNEL_6_BITFIELD (ADC_CHSELR_CHSEL6)
  213. #define ADC_CHANNEL_7_BITFIELD (ADC_CHSELR_CHSEL7)
  214. #define ADC_CHANNEL_8_BITFIELD (ADC_CHSELR_CHSEL8)
  215. #define ADC_CHANNEL_9_BITFIELD (ADC_CHSELR_CHSEL9)
  216. #define ADC_CHANNEL_10_BITFIELD (ADC_CHSELR_CHSEL10)
  217. #define ADC_CHANNEL_11_BITFIELD (ADC_CHSELR_CHSEL11)
  218. #define ADC_CHANNEL_12_BITFIELD (ADC_CHSELR_CHSEL12)
  219. #define ADC_CHANNEL_13_BITFIELD (ADC_CHSELR_CHSEL13)
  220. #define ADC_CHANNEL_14_BITFIELD (ADC_CHSELR_CHSEL14)
  221. #define ADC_CHANNEL_15_BITFIELD (ADC_CHSELR_CHSEL15)
  222. #define ADC_CHANNEL_16_BITFIELD (ADC_CHSELR_CHSEL16)
  223. #define ADC_CHANNEL_17_BITFIELD (ADC_CHSELR_CHSEL17)
  224. #define ADC_CHANNEL_18_BITFIELD (ADC_CHSELR_CHSEL18)
  225. #else
  226. #define ADC_CHANNEL_0_BITFIELD (ADC_AWD2CR_AWD2CH_0)
  227. #define ADC_CHANNEL_1_BITFIELD (ADC_AWD2CR_AWD2CH_1)
  228. #define ADC_CHANNEL_2_BITFIELD (ADC_AWD2CR_AWD2CH_2)
  229. #define ADC_CHANNEL_3_BITFIELD (ADC_AWD2CR_AWD2CH_3)
  230. #define ADC_CHANNEL_4_BITFIELD (ADC_AWD2CR_AWD2CH_4)
  231. #define ADC_CHANNEL_5_BITFIELD (ADC_AWD2CR_AWD2CH_5)
  232. #define ADC_CHANNEL_6_BITFIELD (ADC_AWD2CR_AWD2CH_6)
  233. #define ADC_CHANNEL_7_BITFIELD (ADC_AWD2CR_AWD2CH_7)
  234. #define ADC_CHANNEL_8_BITFIELD (ADC_AWD2CR_AWD2CH_8)
  235. #define ADC_CHANNEL_9_BITFIELD (ADC_AWD2CR_AWD2CH_9)
  236. #define ADC_CHANNEL_10_BITFIELD (ADC_AWD2CR_AWD2CH_10)
  237. #define ADC_CHANNEL_11_BITFIELD (ADC_AWD2CR_AWD2CH_11)
  238. #define ADC_CHANNEL_12_BITFIELD (ADC_AWD2CR_AWD2CH_12)
  239. #define ADC_CHANNEL_13_BITFIELD (ADC_AWD2CR_AWD2CH_13)
  240. #define ADC_CHANNEL_14_BITFIELD (ADC_AWD2CR_AWD2CH_14)
  241. #define ADC_CHANNEL_15_BITFIELD (ADC_AWD2CR_AWD2CH_15)
  242. #define ADC_CHANNEL_16_BITFIELD (ADC_AWD2CR_AWD2CH_16)
  243. #define ADC_CHANNEL_17_BITFIELD (ADC_AWD2CR_AWD2CH_17)
  244. #define ADC_CHANNEL_18_BITFIELD (ADC_AWD2CR_AWD2CH_18)
  245. #endif
  246. /* Definition of channels sampling time information to be inserted into */
  247. /* channels literals definition. */
  248. #define ADC_CHANNEL_0_SMP (ADC_SMPR1_REGOFFSET | (( 0UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP0" position in register */
  249. #define ADC_CHANNEL_1_SMP (ADC_SMPR1_REGOFFSET | (( 3UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP1" position in register */
  250. #define ADC_CHANNEL_2_SMP (ADC_SMPR1_REGOFFSET | (( 6UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP2" position in register */
  251. #define ADC_CHANNEL_3_SMP (ADC_SMPR1_REGOFFSET | (( 9UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP3" position in register */
  252. #define ADC_CHANNEL_4_SMP (ADC_SMPR1_REGOFFSET | ((12UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP4" position in register */
  253. #define ADC_CHANNEL_5_SMP (ADC_SMPR1_REGOFFSET | ((15UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP5" position in register */
  254. #define ADC_CHANNEL_6_SMP (ADC_SMPR1_REGOFFSET | ((18UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP6" position in register */
  255. #define ADC_CHANNEL_7_SMP (ADC_SMPR1_REGOFFSET | ((21UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP7" position in register */
  256. #define ADC_CHANNEL_8_SMP (ADC_SMPR1_REGOFFSET | ((24UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP8" position in register */
  257. #define ADC_CHANNEL_9_SMP (ADC_SMPR1_REGOFFSET | ((27UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP9" position in register */
  258. #define ADC_CHANNEL_10_SMP (ADC_SMPR2_REGOFFSET | (( 0UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP10" position in register */
  259. #define ADC_CHANNEL_11_SMP (ADC_SMPR2_REGOFFSET | (( 3UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP11" position in register */
  260. #define ADC_CHANNEL_12_SMP (ADC_SMPR2_REGOFFSET | (( 6UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP12" position in register */
  261. #define ADC_CHANNEL_13_SMP (ADC_SMPR2_REGOFFSET | (( 9UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP13" position in register */
  262. #define ADC_CHANNEL_14_SMP (ADC_SMPR2_REGOFFSET | ((12UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP14" position in register */
  263. #define ADC_CHANNEL_15_SMP (ADC_SMPR2_REGOFFSET | ((15UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP15" position in register */
  264. #define ADC_CHANNEL_16_SMP (ADC_SMPR2_REGOFFSET | ((18UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP16" position in register */
  265. #define ADC_CHANNEL_17_SMP (ADC_SMPR2_REGOFFSET | ((21UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP17" position in register */
  266. #define ADC_CHANNEL_18_SMP (ADC_SMPR2_REGOFFSET | ((24UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP18" position in register */
  267. #if defined(ADC_SUPPORT_2_5_MSPS)
  268. /* Internal mask for ADC channel sampling time: */
  269. /* To select into literals LL_ADC_SAMPLINGTIME_x */
  270. /* the relevant bits for: */
  271. /* (concatenation of multiple bits used in register SMPR) */
  272. /* - ADC channels sampling time: setting channel wise, to map each channel */
  273. /* on one of the common sampling time available. */
  274. /* - ADC channels common sampling time: set a sampling time into one of the */
  275. /* common sampling time available. */
  276. #define ADC_SAMPLING_TIME_CH_MASK (ADC_CHANNEL_ID_BITFIELD_MASK << ADC_SMPR_SMPSEL0_BITOFFSET_POS)
  277. #define ADC_SAMPLING_TIME_SMP_MASK (ADC_SMPR_SMP2 | ADC_SMPR_SMP1)
  278. #define ADC_SAMPLING_TIME_SMP_SHIFT_MASK (ADC_SMPR_SMP2_BITOFFSET_POS | ADC_SMPR_SMP1_BITOFFSET_POS)
  279. #endif
  280. /* Internal mask for ADC mode single or differential ended: */
  281. /* To select into literals LL_ADC_SINGLE_ENDED or LL_ADC_SINGLE_DIFFERENTIAL */
  282. /* the relevant bits for: */
  283. /* (concatenation of multiple bits used in different registers) */
  284. /* - ADC calibration: calibration start, calibration factor get or set */
  285. /* - ADC channels: set each ADC channel ending mode */
  286. #define ADC_SINGLEDIFF_CALIB_START_MASK (ADC_CR_ADCALDIF)
  287. #define ADC_SINGLEDIFF_CALIB_FACTOR_MASK (ADC_CALFACT_CALFACT_D | ADC_CALFACT_CALFACT_S)
  288. #define ADC_SINGLEDIFF_CHANNEL_MASK (ADC_CHANNEL_ID_BITFIELD_MASK) /* Equivalent to ADC_DIFSEL_DIFSEL */
  289. #define ADC_SINGLEDIFF_CHANNEL_SHIFT_MASK (ADC_CALFACT_CALFACT_S_4 | ADC_CALFACT_CALFACT_S_3) /* Bits chosen to perform of shift when single mode is selected, shift value out of channels bits range. */
  290. #define ADC_SINGLEDIFF_CALIB_F_BIT_D_MASK (0x00010000UL) /* Selection of 1 bit to discriminate differential mode: mask of bit */
  291. #define ADC_SINGLEDIFF_CALIB_F_BIT_D_POS (16UL) /* Selection of 1 bit to discriminate differential mode: position of bit */
  292. #define ADC_SINGLEDIFF_CALIB_F_BIT_D_SHIFT4 (ADC_SINGLEDIFF_CALIB_F_BIT_D_POS - 4UL) /* Shift of bit ADC_SINGLEDIFF_CALIB_F_BIT_D to position to perform a shift of 4 ranks */
  293. /* Internal mask for ADC analog watchdog: */
  294. /* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
  295. /* (concatenation of multiple bits used in different analog watchdogs, */
  296. /* (feature of several watchdogs not available on all STM32 families)). */
  297. /* - analog watchdog 1: monitored channel defined by number, */
  298. /* selection of ADC group (ADC groups regular and-or injected). */
  299. /* - analog watchdog 2 and 3: monitored channel defined by bitfield, no */
  300. /* selection on groups. */
  301. /* Internal register offset for ADC analog watchdog channel configuration */
  302. #define ADC_AWD_CR1_REGOFFSET (0x00000000UL)
  303. #define ADC_AWD_CR2_REGOFFSET (0x00100000UL)
  304. #define ADC_AWD_CR3_REGOFFSET (0x00200000UL)
  305. /* Register offset gap between AWD1 and AWD2-AWD3 configuration registers */
  306. /* (Set separately as ADC_AWD_CRX_REGOFFSET to spare 32 bits space */
  307. #define ADC_AWD_CR12_REGOFFSETGAP_MASK (ADC_AWD2CR_AWD2CH_0)
  308. #define ADC_AWD_CR12_REGOFFSETGAP_VAL (0x00000024UL)
  309. #define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET | ADC_AWD_CR2_REGOFFSET | ADC_AWD_CR3_REGOFFSET)
  310. #define ADC_AWD_CRX_REGOFFSET_BITOFFSET_POS (20UL)
  311. #if defined (ADC_SUPPORT_2_5_MSPS)
  312. #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CFGR1_AWD1CH | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL)
  313. #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK)
  314. #else
  315. #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CFGR_AWD1CH | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL)
  316. #define ADC_AWD_CR23_CHANNEL_MASK (ADC_AWD2CR_AWD2CH)
  317. #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR23_CHANNEL_MASK)
  318. #endif
  319. #define ADC_AWD_CRX_REGOFFSET_POS (20UL) /* Position of bits ADC_AWD_CRx_REGOFFSET in ADC_AWD_CRX_REGOFFSET_MASK */
  320. /* Internal register offset for ADC analog watchdog threshold configuration */
  321. #define ADC_AWD_TR1_REGOFFSET (ADC_AWD_CR1_REGOFFSET)
  322. #define ADC_AWD_TR2_REGOFFSET (ADC_AWD_CR2_REGOFFSET)
  323. #define ADC_AWD_TR3_REGOFFSET (ADC_AWD_CR3_REGOFFSET)
  324. #define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_REGOFFSET | ADC_AWD_TR2_REGOFFSET | ADC_AWD_TR3_REGOFFSET)
  325. #define ADC_AWD_TRX_REGOFFSET_POS (ADC_AWD_CRX_REGOFFSET_POS) /* Position of bits ADC_SQRx_REGOFFSET in ADC_AWD_TRX_REGOFFSET_MASK */
  326. #define ADC_AWD_TRX_BIT_HIGH_MASK (0x00010000UL) /* Selection of 1 bit to discriminate threshold high: mask of bit */
  327. #define ADC_AWD_TRX_BIT_HIGH_POS (16UL) /* Selection of 1 bit to discriminate threshold high: position of bit */
  328. #define ADC_AWD_TRX_BIT_HIGH_SHIFT4 (ADC_AWD_TRX_BIT_HIGH_POS - 4UL) /* Shift of bit ADC_AWD_TRX_BIT_HIGH to position to perform a shift of 4 ranks */
  329. /* Internal mask for ADC offset: */
  330. /* Internal register offset for ADC offset number configuration */
  331. #define ADC_OFR1_REGOFFSET (0x00000000UL)
  332. #define ADC_OFR2_REGOFFSET (0x00000001UL)
  333. #define ADC_OFR3_REGOFFSET (0x00000002UL)
  334. #define ADC_OFR4_REGOFFSET (0x00000003UL)
  335. #define ADC_OFRx_REGOFFSET_MASK (ADC_OFR1_REGOFFSET | ADC_OFR2_REGOFFSET | ADC_OFR3_REGOFFSET | ADC_OFR4_REGOFFSET)
  336. /* ADC registers bits positions */
  337. #if defined (ADC_SUPPORT_2_5_MSPS)
  338. #define ADC_CFGR1_RES_BITOFFSET_POS ( 3UL) /* Value equivalent to bitfield "ADC_CFGR1_RES" position in register */
  339. #define ADC_CFGR1_AWDSGL_BITOFFSET_POS (22UL) /* Value equivalent to bitfield "ADC_CFGR1_AWDSGL" position in register */
  340. #define ADC_TR1_HT1_BITOFFSET_POS (16UL) /* Value equivalent to bitfield "ADC_TR1_HT1" position in register */
  341. #define ADC_CHSELR_CHSEL0_BITOFFSET_POS ( 0UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL0" position in register */
  342. #define ADC_CHSELR_CHSEL1_BITOFFSET_POS ( 1UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL1" position in register */
  343. #define ADC_CHSELR_CHSEL2_BITOFFSET_POS ( 2UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL2" position in register */
  344. #define ADC_CHSELR_CHSEL3_BITOFFSET_POS ( 3UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL3" position in register */
  345. #define ADC_CHSELR_CHSEL4_BITOFFSET_POS ( 4UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL4" position in register */
  346. #define ADC_CHSELR_CHSEL5_BITOFFSET_POS ( 5UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL5" position in register */
  347. #define ADC_CHSELR_CHSEL6_BITOFFSET_POS ( 6UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL6" position in register */
  348. #define ADC_CHSELR_CHSEL7_BITOFFSET_POS ( 7UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL7" position in register */
  349. #define ADC_CHSELR_CHSEL8_BITOFFSET_POS ( 8UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL8" position in register */
  350. #define ADC_CHSELR_CHSEL9_BITOFFSET_POS ( 9UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL9" position in register */
  351. #define ADC_CHSELR_CHSEL10_BITOFFSET_POS (10UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL10" position in register */
  352. #define ADC_CHSELR_CHSEL11_BITOFFSET_POS (11UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL11" position in register */
  353. #define ADC_CHSELR_CHSEL12_BITOFFSET_POS (12UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL12" position in register */
  354. #define ADC_CHSELR_CHSEL13_BITOFFSET_POS (13UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL13" position in register */
  355. #define ADC_CHSELR_CHSEL14_BITOFFSET_POS (14UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL14" position in register */
  356. #define ADC_CHSELR_CHSEL15_BITOFFSET_POS (15UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL15" position in register */
  357. #define ADC_CHSELR_CHSEL16_BITOFFSET_POS (16UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL16" position in register */
  358. #define ADC_CHSELR_CHSEL17_BITOFFSET_POS (17UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL17" position in register */
  359. #define ADC_CHSELR_CHSEL18_BITOFFSET_POS (18UL) /* Value equivalent to bitfield "ADC_CHSELR_CHSEL18" position in register */
  360. #define ADC_SMPR_SMP1_BITOFFSET_POS ( 0UL) /* Value equivalent to bitfield "ADC_SMPR_SMP1" position in register */
  361. #define ADC_SMPR_SMP2_BITOFFSET_POS ( 4UL) /* Value equivalent to bitfield "ADC_SMPR_SMP2" position in register */
  362. #define ADC_SMPR_SMPSEL0_BITOFFSET_POS ( 8UL) /* Value equivalent to bitfield "ADC_SMPR_SMPSEL0" position in register */
  363. #define ADC_CFGR_RES_BITOFFSET_POS ADC_CFGR1_RES_BITOFFSET_POS
  364. #define ADC_CFGR_AWDSGL_BITOFFSET_POS ADC_CFGR1_AWDSGL_BITOFFSET_POS
  365. #else
  366. #define ADC_CFGR_RES_BITOFFSET_POS ( 3UL) /* Value equivalent to bitfield "ADC_CFGR_RES" position in register */
  367. #define ADC_CFGR_AWD1SGL_BITOFFSET_POS (22UL) /* Value equivalent to bitfield "ADC_CFGR_AWD1SGL" position in register */
  368. #define ADC_CFGR_AWD1EN_BITOFFSET_POS (23UL) /* Value equivalent to bitfield "ADC_CFGR_AWD1EN" position in register */
  369. #define ADC_CFGR_JAWD1EN_BITOFFSET_POS (24UL) /* Value equivalent to bitfield "ADC_CFGR_JAWD1EN" position in register */
  370. #define ADC_TR1_HT1_BITOFFSET_POS (16UL) /* Value equivalent to bitfield "ADC_TR1_HT1" position in register */
  371. #endif
  372. /* ADC registers bits groups */
  373. #if defined (ADC_SUPPORT_2_5_MSPS)
  374. #define ADC_CR_BITS_PROPERTY_RS (ADC_CR_ADCAL | ADC_CR_ADSTP | ADC_CR_ADSTART | ADC_CR_ADDIS | ADC_CR_ADEN) /* ADC register CR bits with HW property "rs": Software can read as well as set this bit. Writing '0' has no effect on the bit value. */
  375. #else
  376. #define ADC_CR_BITS_PROPERTY_RS (ADC_CR_ADCAL | ADC_CR_JADSTP | ADC_CR_ADSTP | ADC_CR_JADSTART | ADC_CR_ADSTART | ADC_CR_ADDIS | ADC_CR_ADEN) /* ADC register CR bits with HW property "rs": Software can read as well as set this bit. Writing '0' has no effect on the bit value. */
  377. #endif
  378. /* ADC internal channels related definitions */
  379. /* Internal voltage reference VrefInt */
  380. #define VREFINT_CAL_ADDR ((uint16_t*) (0x1FFF75AAUL)) /* Internal voltage reference, address of parameter VREFINT: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.6 V (tolerance: +-10 mV). */
  381. #define VREFINT_CAL_VREF (3600UL) /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
  382. /* Temperature sensor */
  383. #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) (0x1FFF75A8UL)) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32WB, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
  384. #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) (0x1FFF75CAUL)) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32WB, temperature sensor ADC raw data acquired at temperature 130 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
  385. #define TEMPSENSOR_CAL1_TEMP (30L) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  386. #define TEMPSENSOR_CAL2_TEMP (130L) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  387. #define TEMPSENSOR_CAL_VREFANALOG (3000UL) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
  388. /**
  389. * @}
  390. */
  391. /* Private macros ------------------------------------------------------------*/
  392. /** @defgroup ADC_LL_Private_Macros ADC Private Macros
  393. * @{
  394. */
  395. /**
  396. * @brief Driver macro reserved for internal use: set a pointer to
  397. * a register from a register basis from which an offset
  398. * is applied.
  399. * @param __REG__ Register basis from which the offset is applied.
  400. * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
  401. * @retval Pointer to register address
  402. */
  403. #define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
  404. ((__IO uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2UL))))
  405. /**
  406. * @}
  407. */
  408. /* Exported types ------------------------------------------------------------*/
  409. #if defined(USE_FULL_LL_DRIVER)
  410. /** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
  411. * @{
  412. */
  413. /**
  414. * @brief Structure definition of some features of ADC common parameters
  415. * and multimode
  416. * (all ADC instances belonging to the same ADC common instance).
  417. * @note The setting of these parameters by function @ref LL_ADC_CommonInit()
  418. * is conditioned to ADC instances state (all ADC instances
  419. * sharing the same ADC common instance):
  420. * All ADC instances sharing the same ADC common instance must be
  421. * disabled.
  422. */
  423. typedef struct
  424. {
  425. uint32_t CommonClock; /*!< Set parameter common to several ADC: Clock source and prescaler.
  426. This parameter can be a value of @ref ADC_LL_EC_COMMON_CLOCK_SOURCE
  427. @note On this STM32 serie, if ADC group injected is used, some
  428. clock ratio constraints between ADC clock and AHB clock
  429. must be respected. Refer to reference manual.
  430. This feature can be modified afterwards using unitary function @ref LL_ADC_SetCommonClock(). */
  431. } LL_ADC_CommonInitTypeDef;
  432. /**
  433. * @brief Structure definition of some features of ADC instance.
  434. * @note These parameters have an impact on ADC scope: ADC instance.
  435. * Affects both group regular and group injected (availability
  436. * of ADC group injected depends on STM32 families).
  437. * Refer to corresponding unitary functions into
  438. * @ref ADC_LL_EF_Configuration_ADC_Instance .
  439. * @note The setting of these parameters by function @ref LL_ADC_Init()
  440. * is conditioned to ADC state:
  441. * ADC instance must be disabled.
  442. * This condition is applied to all ADC features, for efficiency
  443. * and compatibility over all STM32 families. However, the different
  444. * features can be set under different ADC state conditions
  445. * (setting possible with ADC enabled without conversion on going,
  446. * ADC enabled with conversion on going, ...)
  447. * Each feature can be updated afterwards with a unitary function
  448. * and potentially with ADC in a different state than disabled,
  449. * refer to description of each function for setting
  450. * conditioned to ADC state.
  451. */
  452. typedef struct
  453. {
  454. #if defined (ADC_SUPPORT_2_5_MSPS)
  455. uint32_t Clock; /*!< Set ADC instance clock source and prescaler.
  456. This parameter can be a value of @ref ADC_LL_EC_CLOCK_SOURCE
  457. @note On this STM32 serie, this parameter has some clock ratio constraints:
  458. ADC clock synchronous (from PCLK) with prescaler 1 must be enabled only if PCLK has a 50% duty clock cycle
  459. (APB prescaler configured inside the RCC must be bypassed and the system clock must by 50% duty cycle).
  460. This feature can be modified afterwards using unitary function @ref LL_ADC_SetClock().
  461. For more details, refer to description of this function. */
  462. #endif
  463. uint32_t Resolution; /*!< Set ADC resolution.
  464. This parameter can be a value of @ref ADC_LL_EC_RESOLUTION
  465. This feature can be modified afterwards using unitary function @ref LL_ADC_SetResolution(). */
  466. uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
  467. This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
  468. This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
  469. uint32_t LowPowerMode; /*!< Set ADC low power mode.
  470. This parameter can be a value of @ref ADC_LL_EC_LP_MODE
  471. This feature can be modified afterwards using unitary function @ref LL_ADC_SetLowPowerMode(). */
  472. } LL_ADC_InitTypeDef;
  473. /**
  474. * @brief Structure definition of some features of ADC group regular.
  475. * @note These parameters have an impact on ADC scope: ADC group regular.
  476. * Refer to corresponding unitary functions into
  477. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  478. * (functions with prefix "REG").
  479. * @note The setting of these parameters by function @ref LL_ADC_REG_Init()
  480. * is conditioned to ADC state:
  481. * ADC instance must be disabled.
  482. * This condition is applied to all ADC features, for efficiency
  483. * and compatibility over all STM32 families. However, the different
  484. * features can be set under different ADC state conditions
  485. * (setting possible with ADC enabled without conversion on going,
  486. * ADC enabled with conversion on going, ...)
  487. * Each feature can be updated afterwards with a unitary function
  488. * and potentially with ADC in a different state than disabled,
  489. * refer to description of each function for setting
  490. * conditioned to ADC state.
  491. */
  492. typedef struct
  493. {
  494. uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or from external peripheral (timer event, external interrupt line).
  495. This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
  496. @note On this STM32 serie, setting trigger source to external trigger also set trigger polarity to rising edge
  497. (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value).
  498. In case of need to modify trigger edge, use function @ref LL_ADC_REG_SetTriggerEdge().
  499. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
  500. uint32_t SequencerLength; /*!< Set ADC group regular sequencer length.
  501. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_SCAN_LENGTH
  502. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerLength(). */
  503. uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  504. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
  505. @note This parameter has an effect only if group regular sequencer is enabled
  506. (scan length of 2 ranks or more).
  507. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
  508. uint32_t ContinuousMode; /*!< Set ADC continuous conversion mode on ADC group regular, whether ADC conversions are performed in single mode (one conversion per trigger) or in continuous mode (after the first trigger, following conversions launched successively automatically).
  509. This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
  510. Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
  511. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
  512. uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
  513. This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
  514. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
  515. uint32_t Overrun; /*!< Set ADC group regular behavior in case of overrun:
  516. data preserved or overwritten.
  517. This parameter can be a value of @ref ADC_LL_EC_REG_OVR_DATA_BEHAVIOR
  518. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetOverrun(). */
  519. } LL_ADC_REG_InitTypeDef;
  520. #if defined (ADC_SUPPORT_2_5_MSPS)
  521. /* Feature "ADC group injected" not available on ADC peripheral of this STM32WB device */
  522. #else
  523. /**
  524. * @brief Structure definition of some features of ADC group injected.
  525. * @note These parameters have an impact on ADC scope: ADC group injected.
  526. * Refer to corresponding unitary functions into
  527. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  528. * (functions with prefix "INJ").
  529. * @note The setting of these parameters by function @ref LL_ADC_INJ_Init()
  530. * is conditioned to ADC state:
  531. * ADC instance must be disabled.
  532. * This condition is applied to all ADC features, for efficiency
  533. * and compatibility over all STM32 families. However, the different
  534. * features can be set under different ADC state conditions
  535. * (setting possible with ADC enabled without conversion on going,
  536. * ADC enabled with conversion on going, ...)
  537. * Each feature can be updated afterwards with a unitary function
  538. * and potentially with ADC in a different state than disabled,
  539. * refer to description of each function for setting
  540. * conditioned to ADC state.
  541. */
  542. typedef struct
  543. {
  544. uint32_t TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start) or from external peripheral (timer event, external interrupt line).
  545. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIGGER_SOURCE
  546. @note On this STM32 serie, setting trigger source to external trigger also set trigger polarity to rising edge
  547. (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value).
  548. In case of need to modify trigger edge, use function @ref LL_ADC_INJ_SetTriggerEdge().
  549. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTriggerSource(). */
  550. uint32_t SequencerLength; /*!< Set ADC group injected sequencer length.
  551. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_SCAN_LENGTH
  552. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerLength(). */
  553. uint32_t SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  554. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_DISCONT_MODE
  555. @note This parameter has an effect only if group injected sequencer is enabled
  556. (scan length of 2 ranks or more).
  557. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerDiscont(). */
  558. uint32_t TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group regular.
  559. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIG_AUTO
  560. Note: This parameter must be set to set to independent trigger if injected trigger source is set to an external trigger.
  561. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTrigAuto(). */
  562. } LL_ADC_INJ_InitTypeDef;
  563. #endif /* ADC_SUPPORT_2_5_MSPS */
  564. /**
  565. * @}
  566. */
  567. #endif /* USE_FULL_LL_DRIVER */
  568. /* Exported constants --------------------------------------------------------*/
  569. /** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
  570. * @{
  571. */
  572. /** @defgroup ADC_LL_EC_FLAG ADC flags
  573. * @brief Flags defines which can be used with LL_ADC_ReadReg function
  574. * @{
  575. */
  576. #define LL_ADC_FLAG_ADRDY ADC_ISR_ADRDY /*!< ADC flag ADC instance ready */
  577. #if defined(ADC_SUPPORT_2_5_MSPS)
  578. #define LL_ADC_FLAG_CCRDY ADC_ISR_CCRDY /*!< ADC flag ADC channel configuration ready */
  579. #else
  580. #endif
  581. #define LL_ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC flag ADC group regular end of unitary conversion */
  582. #define LL_ADC_FLAG_EOS ADC_ISR_EOS /*!< ADC flag ADC group regular end of sequence conversions */
  583. #define LL_ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC flag ADC group regular overrun */
  584. #define LL_ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC flag ADC group regular end of sampling phase */
  585. #define LL_ADC_FLAG_JEOC ADC_ISR_JEOC /*!< ADC flag ADC group injected end of unitary conversion */
  586. #define LL_ADC_FLAG_JEOS ADC_ISR_JEOS /*!< ADC flag ADC group injected end of sequence conversions */
  587. #define LL_ADC_FLAG_JQOVF ADC_ISR_JQOVF /*!< ADC flag ADC group injected contexts queue overflow */
  588. #define LL_ADC_FLAG_AWD1 ADC_ISR_AWD1 /*!< ADC flag ADC analog watchdog 1 */
  589. #define LL_ADC_FLAG_AWD2 ADC_ISR_AWD2 /*!< ADC flag ADC analog watchdog 2 */
  590. #define LL_ADC_FLAG_AWD3 ADC_ISR_AWD3 /*!< ADC flag ADC analog watchdog 3 */
  591. #if defined(ADC_SUPPORT_2_5_MSPS)
  592. #define LL_ADC_FLAG_EOCAL ADC_ISR_EOCAL /*!< ADC flag end of calibration */
  593. #endif
  594. /**
  595. * @}
  596. */
  597. /** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
  598. * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
  599. * @{
  600. */
  601. #define LL_ADC_IT_ADRDY ADC_IER_ADRDYIE /*!< ADC interruption ADC instance ready */
  602. #if defined(ADC_SUPPORT_2_5_MSPS)
  603. #define LL_ADC_IT_CCRDY ADC_IER_CCRDYIE /*!< ADC interruption channel configuration ready */
  604. #else
  605. #endif
  606. #define LL_ADC_IT_EOC ADC_IER_EOCIE /*!< ADC interruption ADC group regular end of unitary conversion */
  607. #define LL_ADC_IT_EOS ADC_IER_EOSIE /*!< ADC interruption ADC group regular end of sequence conversions */
  608. #define LL_ADC_IT_OVR ADC_IER_OVRIE /*!< ADC interruption ADC group regular overrun */
  609. #define LL_ADC_IT_EOSMP ADC_IER_EOSMPIE /*!< ADC interruption ADC group regular end of sampling phase */
  610. #define LL_ADC_IT_JEOC ADC_IER_JEOCIE /*!< ADC interruption ADC group injected end of unitary conversion */
  611. #define LL_ADC_IT_JEOS ADC_IER_JEOSIE /*!< ADC interruption ADC group injected end of sequence conversions */
  612. #define LL_ADC_IT_JQOVF ADC_IER_JQOVFIE /*!< ADC interruption ADC group injected contexts queue overflow */
  613. #define LL_ADC_IT_AWD1 ADC_IER_AWD1IE /*!< ADC interruption ADC analog watchdog 1 */
  614. #define LL_ADC_IT_AWD2 ADC_IER_AWD2IE /*!< ADC interruption ADC analog watchdog 2 */
  615. #define LL_ADC_IT_AWD3 ADC_IER_AWD3IE /*!< ADC interruption ADC analog watchdog 3 */
  616. #if defined(ADC_SUPPORT_2_5_MSPS)
  617. #define LL_ADC_IT_EOCAL ADC_IER_EOCALIE /*!< ADC interruption ADC end of calibration */
  618. #endif
  619. /**
  620. * @}
  621. */
  622. /** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
  623. * @{
  624. */
  625. /* List of ADC registers intended to be used (most commonly) with */
  626. /* DMA transfer. */
  627. /* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
  628. #define LL_ADC_DMA_REG_REGULAR_DATA (0x00000000UL) /* ADC group regular conversion data register (corresponding to register DR) to be used with ADC configured in independent mode. Without DMA transfer, register accessed by LL function @ref LL_ADC_REG_ReadConversionData32() and other functions @ref LL_ADC_REG_ReadConversionDatax() */
  629. /**
  630. * @}
  631. */
  632. /** @defgroup ADC_LL_EC_COMMON_CLOCK_SOURCE ADC common - Clock source
  633. * @{
  634. */
  635. #if !defined (ADC_SUPPORT_2_5_MSPS)
  636. #define LL_ADC_CLOCK_SYNC_PCLK_DIV1 (ADC_CCR_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock without prescaler */
  637. #define LL_ADC_CLOCK_SYNC_PCLK_DIV2 (ADC_CCR_CKMODE_1 ) /*!< ADC synchronous clock derived from AHB clock with prescaler division by 2 */
  638. #define LL_ADC_CLOCK_SYNC_PCLK_DIV4 (ADC_CCR_CKMODE_1 | ADC_CCR_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock with prescaler division by 4 */
  639. #endif
  640. #define LL_ADC_CLOCK_ASYNC_DIV1 (0x00000000UL) /*!< ADC asynchronous clock without prescaler */
  641. #define LL_ADC_CLOCK_ASYNC_DIV2 (ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 2 */
  642. #define LL_ADC_CLOCK_ASYNC_DIV4 (ADC_CCR_PRESC_1 ) /*!< ADC asynchronous clock with prescaler division by 4 */
  643. #define LL_ADC_CLOCK_ASYNC_DIV6 (ADC_CCR_PRESC_1 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 6 */
  644. #define LL_ADC_CLOCK_ASYNC_DIV8 (ADC_CCR_PRESC_2 ) /*!< ADC asynchronous clock with prescaler division by 8 */
  645. #define LL_ADC_CLOCK_ASYNC_DIV10 (ADC_CCR_PRESC_2 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 10 */
  646. #define LL_ADC_CLOCK_ASYNC_DIV12 (ADC_CCR_PRESC_2 | ADC_CCR_PRESC_1 ) /*!< ADC asynchronous clock with prescaler division by 12 */
  647. #define LL_ADC_CLOCK_ASYNC_DIV16 (ADC_CCR_PRESC_2 | ADC_CCR_PRESC_1 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 16 */
  648. #define LL_ADC_CLOCK_ASYNC_DIV32 (ADC_CCR_PRESC_3) /*!< ADC asynchronous clock with prescaler division by 32 */
  649. #define LL_ADC_CLOCK_ASYNC_DIV64 (ADC_CCR_PRESC_3 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 64 */
  650. #define LL_ADC_CLOCK_ASYNC_DIV128 (ADC_CCR_PRESC_3 | ADC_CCR_PRESC_1) /*!< ADC asynchronous clock with prescaler division by 128 */
  651. #define LL_ADC_CLOCK_ASYNC_DIV256 (ADC_CCR_PRESC_3 | ADC_CCR_PRESC_1 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 256 */
  652. /**
  653. * @}
  654. */
  655. /** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
  656. * @{
  657. */
  658. /* Note: Other measurement paths to internal channels may be available */
  659. /* (connections to other peripherals). */
  660. /* If they are not listed below, they do not require any specific */
  661. /* path enable. In this case, Access to measurement path is done */
  662. /* only by selecting the corresponding ADC internal channel. */
  663. #define LL_ADC_PATH_INTERNAL_NONE (0x00000000UL) /*!< ADC measurement paths all disabled */
  664. #define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CCR_VREFEN) /*!< ADC measurement path to internal channel VrefInt */
  665. #define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CCR_TSEN) /*!< ADC measurement path to internal channel temperature sensor */
  666. #define LL_ADC_PATH_INTERNAL_VBAT (ADC_CCR_VBATEN) /*!< ADC measurement path to internal channel Vbat */
  667. /**
  668. * @}
  669. */
  670. #if defined (ADC_SUPPORT_2_5_MSPS)
  671. /** @defgroup ADC_LL_EC_CLOCK_SOURCE ADC instance - Clock source
  672. * @{
  673. */
  674. #define LL_ADC_CLOCK_SYNC_PCLK_DIV4 (ADC_CFGR2_CKMODE_1) /*!< ADC synchronous clock derived from AHB clock divided by 4 */
  675. #define LL_ADC_CLOCK_SYNC_PCLK_DIV2 (ADC_CFGR2_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock divided by 2 */
  676. #define LL_ADC_CLOCK_SYNC_PCLK_DIV1 (ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock not divided */
  677. #define LL_ADC_CLOCK_ASYNC (0x00000000UL) /*!< ADC asynchronous clock. Asynchronous clock prescaler can be configured using function @ref LL_ADC_SetCommonClock(). */
  678. /**
  679. * @}
  680. */
  681. #endif
  682. /** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
  683. * @{
  684. */
  685. #define LL_ADC_RESOLUTION_12B (0x00000000UL) /*!< ADC resolution 12 bits */
  686. #define LL_ADC_RESOLUTION_10B ( ADC_CFGR_RES_0) /*!< ADC resolution 10 bits */
  687. #define LL_ADC_RESOLUTION_8B (ADC_CFGR_RES_1 ) /*!< ADC resolution 8 bits */
  688. #define LL_ADC_RESOLUTION_6B (ADC_CFGR_RES_1 | ADC_CFGR_RES_0) /*!< ADC resolution 6 bits */
  689. /**
  690. * @}
  691. */
  692. /** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
  693. * @{
  694. */
  695. #define LL_ADC_DATA_ALIGN_RIGHT (0x00000000UL) /*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
  696. #define LL_ADC_DATA_ALIGN_LEFT (ADC_CFGR_ALIGN) /*!< ADC conversion data alignment: left aligned (alignment on data register MSB bit 15)*/
  697. /**
  698. * @}
  699. */
  700. /** @defgroup ADC_LL_EC_LP_MODE ADC instance - Low power mode
  701. * @{
  702. */
  703. #define LL_ADC_LP_MODE_NONE (0x00000000UL) /*!< No ADC low power mode activated */
  704. #if defined (ADC_SUPPORT_2_5_MSPS)
  705. #define LL_ADC_LP_AUTOWAIT (ADC_CFGR1_WAIT) /*!< ADC low power mode auto delay: Dynamic low power mode, ADC conversions are performed only when necessary (when previous ADC conversion data is read). See description with function @ref LL_ADC_SetLowPowerMode(). */
  706. #define LL_ADC_LP_AUTOPOWEROFF (ADC_CFGR1_AUTOFF) /*!< ADC low power mode auto power-off: the ADC automatically powers-off after a ADC conversion and automatically wakes up when a new ADC conversion is triggered (with startup time between trigger and start of sampling). See description with function @ref LL_ADC_SetLowPowerMode(). */
  707. #define LL_ADC_LP_AUTOWAIT_AUTOPOWEROFF (ADC_CFGR1_WAIT | ADC_CFGR1_AUTOFF) /*!< ADC low power modes auto wait and auto power-off combined. See description with function @ref LL_ADC_SetLowPowerMode(). */
  708. #else
  709. #define LL_ADC_LP_AUTOWAIT (ADC_CFGR_AUTDLY) /*!< ADC low power mode auto delay: Dynamic low power mode, ADC conversions are performed only when necessary (when previous ADC conversion data is read). See description with function @ref LL_ADC_SetLowPowerMode(). */
  710. #endif
  711. /**
  712. * @}
  713. */
  714. /** @defgroup ADC_LL_EC_REG_TRIGGER_FREQ ADC group regular - Trigger frequency mode
  715. * @{
  716. */
  717. #define LL_ADC_TRIGGER_FREQ_HIGH (0x00000000UL) /*!< ADC trigger frequency mode set to high frequency. Note: ADC trigger frequency mode must be set to low frequency when a duration is exceeded before ADC conversion start trigger event (between ADC enable and ADC conversion start trigger event or between two ADC conversion start trigger event). Duration value: Refer to device datasheet, parameter "tIdle". */
  718. #define LL_ADC_TRIGGER_FREQ_LOW (ADC_CFGR2_LFTRIG) /*!< ADC trigger frequency mode set to low frequency. Note: ADC trigger frequency mode must be set to low frequency when a duration is exceeded before ADC conversion start trigger event (between ADC enable and ADC conversion start trigger event or between two ADC conversion start trigger event). Duration value: Refer to device datasheet, parameter "tIdle". */
  719. /**
  720. * @}
  721. */
  722. #if defined(ADC_SUPPORT_2_5_MSPS)
  723. /** @defgroup ADC_LL_EC_SAMPLINGTIME_COMMON ADC instance - Sampling time common to a group of channels
  724. * @{
  725. */
  726. #define LL_ADC_SAMPLINGTIME_COMMON_1 (ADC_SMPR_SMP1_BITOFFSET_POS) /*!< Set sampling time common to a group of channels: sampling time nb 1 */
  727. #define LL_ADC_SAMPLINGTIME_COMMON_2 (ADC_SMPR_SMP2_BITOFFSET_POS | ADC_SAMPLING_TIME_CH_MASK) /*!< Set sampling time common to a group of channels: sampling time nb 2 */
  728. /**
  729. * @}
  730. */
  731. #endif
  732. /** @defgroup ADC_LL_EC_OFFSET_NB ADC instance - Offset number
  733. * @{
  734. */
  735. #define LL_ADC_OFFSET_1 ADC_OFR1_REGOFFSET /*!< ADC offset number 1: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */
  736. #define LL_ADC_OFFSET_2 ADC_OFR2_REGOFFSET /*!< ADC offset number 2: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */
  737. #define LL_ADC_OFFSET_3 ADC_OFR3_REGOFFSET /*!< ADC offset number 3: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */
  738. #define LL_ADC_OFFSET_4 ADC_OFR4_REGOFFSET /*!< ADC offset number 4: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */
  739. /**
  740. * @}
  741. */
  742. /** @defgroup ADC_LL_EC_OFFSET_STATE ADC instance - Offset state
  743. * @{
  744. */
  745. #define LL_ADC_OFFSET_DISABLE (0x00000000UL) /*!< ADC offset disabled (among ADC selected offset number 1, 2, 3 or 4) */
  746. #define LL_ADC_OFFSET_ENABLE (ADC_OFR1_OFFSET1_EN) /*!< ADC offset enabled (among ADC selected offset number 1, 2, 3 or 4) */
  747. /**
  748. * @}
  749. */
  750. /** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
  751. * @{
  752. */
  753. #define LL_ADC_GROUP_REGULAR (0x00000001UL) /*!< ADC group regular (available on all STM32 devices) */
  754. #if !defined (ADC_SUPPORT_2_5_MSPS)
  755. #define LL_ADC_GROUP_INJECTED (0x00000002UL) /*!< ADC group injected (not available on all STM32 devices)*/
  756. #define LL_ADC_GROUP_REGULAR_INJECTED (0x00000003UL) /*!< ADC both groups regular and injected */
  757. #endif
  758. /**
  759. * @}
  760. */
  761. /** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
  762. * @{
  763. */
  764. #if defined (ADC_SUPPORT_2_5_MSPS)
  765. #define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 */
  766. #define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 */
  767. #define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 */
  768. #define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 */
  769. #define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 */
  770. #define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 */
  771. #define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 */
  772. #define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 */
  773. #define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 */
  774. #define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 */
  775. #define LL_ADC_CHANNEL_10 (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10 */
  776. #define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11 */
  777. #define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12 */
  778. #define LL_ADC_CHANNEL_13 (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN13 */
  779. #define LL_ADC_CHANNEL_14 (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN14 */
  780. #define LL_ADC_CHANNEL_15 (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN15 */
  781. #define LL_ADC_CHANNEL_16 (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN16 */
  782. #define LL_ADC_CHANNEL_17 (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN17 */
  783. #define LL_ADC_CHANNEL_18 (ADC_CHANNEL_18_NUMBER | ADC_CHANNEL_18_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN18 */
  784. #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_13 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. */
  785. #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_12 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. */
  786. #define LL_ADC_CHANNEL_VBAT (LL_ADC_CHANNEL_14 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/3 to have Vbat always below Vdda. */
  787. #else
  788. #define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_SMP | ADC_CHANNEL_0_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 */
  789. #define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_SMP | ADC_CHANNEL_1_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 */
  790. #define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_SMP | ADC_CHANNEL_2_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 */
  791. #define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_SMP | ADC_CHANNEL_3_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 */
  792. #define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_SMP | ADC_CHANNEL_4_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 */
  793. #define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_SMP | ADC_CHANNEL_5_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 */
  794. #define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_SMP | ADC_CHANNEL_6_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 */
  795. #define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_SMP | ADC_CHANNEL_7_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 */
  796. #define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_SMP | ADC_CHANNEL_8_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 */
  797. #define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_SMP | ADC_CHANNEL_9_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 */
  798. #define LL_ADC_CHANNEL_10 (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_SMP | ADC_CHANNEL_10_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10 */
  799. #define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_SMP | ADC_CHANNEL_11_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11 */
  800. #define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_SMP | ADC_CHANNEL_12_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12 */
  801. #define LL_ADC_CHANNEL_13 (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_SMP | ADC_CHANNEL_13_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN13 */
  802. #define LL_ADC_CHANNEL_14 (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_SMP | ADC_CHANNEL_14_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN14 */
  803. #define LL_ADC_CHANNEL_15 (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_SMP | ADC_CHANNEL_15_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN15 */
  804. #define LL_ADC_CHANNEL_16 (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_SMP | ADC_CHANNEL_16_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN16 */
  805. #define LL_ADC_CHANNEL_17 (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_SMP | ADC_CHANNEL_17_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN17 */
  806. #define LL_ADC_CHANNEL_18 (ADC_CHANNEL_18_NUMBER | ADC_CHANNEL_18_SMP | ADC_CHANNEL_18_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN18 */
  807. #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_0 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. */
  808. #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. */
  809. #define LL_ADC_CHANNEL_VBAT (LL_ADC_CHANNEL_18 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Vbat/2: Vbat voltage through a divider ladder of factor 1/2 to have Vbat always below Vdda. */
  810. #endif
  811. /**
  812. * @}
  813. */
  814. /** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source
  815. * @{
  816. */
  817. #if defined(ADC_SUPPORT_2_5_MSPS)
  818. #define LL_ADC_REG_TRIG_SOFTWARE (0x00000000UL) /*!< ADC group regular conversion trigger internal: SW start. */
  819. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO2 ( ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  820. #define LL_ADC_REG_TRIG_EXT_TIM1_CH4 ( ADC_CFGR1_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM1 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  821. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO ( ADC_CFGR1_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  822. #define LL_ADC_REG_TRIG_EXT_TIM2_CH4 ( ADC_CFGR1_EXTSEL_1 | ADC_CFGR1_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM2 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  823. #define LL_ADC_REG_TRIG_EXT_TIM2_CH3 (ADC_CFGR1_EXTSEL_2 | ADC_CFGR1_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM2 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  824. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CFGR1_EXTSEL_2 | ADC_CFGR1_EXTSEL_1 | ADC_CFGR1_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: external interrupt line 11. Trigger edge set to rising edge (default setting). */
  825. #else
  826. #define LL_ADC_REG_TRIG_SOFTWARE (0x00000000UL) /*!< ADC group regular conversion trigger internal: SW start. */
  827. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  828. #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO2 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM1 TRGO2. Trigger edge set to rising edge (default setting). */
  829. #define LL_ADC_REG_TRIG_EXT_TIM1_CH1 (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM1 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  830. #define LL_ADC_REG_TRIG_EXT_TIM1_CH2 (ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM1 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  831. #define LL_ADC_REG_TRIG_EXT_TIM1_CH3 (ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM1 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  832. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  833. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM2 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  834. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: external interrupt line 11. Trigger edge set to rising edge (default setting). */
  835. #endif
  836. /**
  837. * @}
  838. */
  839. /** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
  840. * @{
  841. */
  842. #define LL_ADC_REG_TRIG_EXT_RISING ( ADC_CFGR_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to rising edge */
  843. #define LL_ADC_REG_TRIG_EXT_FALLING (ADC_CFGR_EXTEN_1 ) /*!< ADC group regular conversion trigger polarity set to falling edge */
  844. #define LL_ADC_REG_TRIG_EXT_RISINGFALLING (ADC_CFGR_EXTEN_1 | ADC_CFGR_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to both rising and falling edges */
  845. /**
  846. * @}
  847. */
  848. /** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
  849. * @{
  850. */
  851. #define LL_ADC_REG_CONV_SINGLE (0x00000000UL) /*!< ADC conversions are performed in single mode: one conversion per trigger */
  852. #define LL_ADC_REG_CONV_CONTINUOUS (ADC_CFGR_CONT) /*!< ADC conversions are performed in continuous mode: after the first trigger, following conversions launched successively automatically */
  853. /**
  854. * @}
  855. */
  856. /** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer of ADC conversion data
  857. * @{
  858. */
  859. #define LL_ADC_REG_DMA_TRANSFER_NONE (0x00000000UL) /*!< ADC conversions are not transferred by DMA */
  860. #define LL_ADC_REG_DMA_TRANSFER_LIMITED ( ADC_CFGR_DMAEN) /*!< ADC conversion data are transferred by DMA, in limited mode (one shot mode): DMA transfer requests are stopped when number of DMA data transfers (number of ADC conversions) is reached. This ADC mode is intended to be used with DMA mode non-circular. */
  861. #define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CFGR_DMACFG | ADC_CFGR_DMAEN) /*!< ADC conversion data are transferred by DMA, in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions). This ADC mode is intended to be used with DMA mode circular. */
  862. /**
  863. * @}
  864. */
  865. /** @defgroup ADC_LL_EC_REG_OVR_DATA_BEHAVIOR ADC group regular - Overrun behavior on conversion data
  866. * @{
  867. */
  868. #define LL_ADC_REG_OVR_DATA_PRESERVED (0x00000000UL) /*!< ADC group regular behavior in case of overrun: data preserved */
  869. #define LL_ADC_REG_OVR_DATA_OVERWRITTEN (ADC_CFGR_OVRMOD) /*!< ADC group regular behavior in case of overrun: data overwritten */
  870. /**
  871. * @}
  872. */
  873. #if defined(ADC_SUPPORT_2_5_MSPS)
  874. /** @defgroup ADC_LL_EC_REG_SEQ_MODE ADC group regular - Sequencer configuration flexibility
  875. * @{
  876. */
  877. #define LL_ADC_REG_SEQ_FIXED (0x00000000UL) /*!< Sequencer configured to fully configurable: sequencer length and each rank affectation to a channel are configurable. Refer to description of function @ref LL_ADC_REG_SetSequencerLength(). */
  878. #define LL_ADC_REG_SEQ_CONFIGURABLE (ADC_CFGR1_CHSELRMOD) /*!< Sequencer configured to not fully configurable: sequencer length and each rank affectation to a channel are fixed by channel HW number. Refer to description of function @ref LL_ADC_REG_SetSequencerChannels(). */
  879. /**
  880. * @}
  881. */
  882. #endif
  883. /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_LENGTH ADC group regular - Sequencer scan length
  884. * @{
  885. */
  886. #if defined(ADC_SUPPORT_2_5_MSPS)
  887. #define LL_ADC_REG_SEQ_SCAN_DISABLE (ADC_CHSELR_SQ2) /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  888. #define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS (ADC_CHSELR_SQ3) /*!< ADC group regular sequencer enable with 2 ranks in the sequence */
  889. #define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS (ADC_CHSELR_SQ4) /*!< ADC group regular sequencer enable with 3 ranks in the sequence */
  890. #define LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS (ADC_CHSELR_SQ5) /*!< ADC group regular sequencer enable with 4 ranks in the sequence */
  891. #define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS (ADC_CHSELR_SQ6) /*!< ADC group regular sequencer enable with 5 ranks in the sequence */
  892. #define LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS (ADC_CHSELR_SQ7) /*!< ADC group regular sequencer enable with 6 ranks in the sequence */
  893. #define LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS (ADC_CHSELR_SQ8) /*!< ADC group regular sequencer enable with 7 ranks in the sequence */
  894. #define LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS (0x00000000UL) /*!< ADC group regular sequencer enable with 8 ranks in the sequence */
  895. #else
  896. #define LL_ADC_REG_SEQ_SCAN_DISABLE (0x00000000UL) /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  897. #define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS ( ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 2 ranks in the sequence */
  898. #define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS ( ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 3 ranks in the sequence */
  899. #define LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS ( ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 4 ranks in the sequence */
  900. #define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS ( ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 5 ranks in the sequence */
  901. #define LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 6 ranks in the sequence */
  902. #define LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 7 ranks in the sequence */
  903. #define LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 8 ranks in the sequence */
  904. #define LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (ADC_SQR1_L_3 ) /*!< ADC group regular sequencer enable with 9 ranks in the sequence */
  905. #define LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 10 ranks in the sequence */
  906. #define LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 11 ranks in the sequence */
  907. #define LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 12 ranks in the sequence */
  908. #define LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 13 ranks in the sequence */
  909. #define LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 14 ranks in the sequence */
  910. #define LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 15 ranks in the sequence */
  911. #define LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 16 ranks in the sequence */
  912. #endif
  913. /**
  914. * @}
  915. */
  916. #if defined(ADC_SUPPORT_2_5_MSPS)
  917. /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_DIRECTION ADC group regular - Sequencer scan direction
  918. * @{
  919. */
  920. #define LL_ADC_REG_SEQ_SCAN_DIR_FORWARD (0x00000000UL) /*!< On this STM32 serie, parameter relevant only is sequencer set to mode not fully configurable, refer to function @ref LL_ADC_REG_SetSequencerConfigurable(). ADC group regular sequencer scan direction forward: from lowest channel number to highest channel number (scan of all ranks, ADC conversion of ranks with channels enabled in sequencer). On some other STM32 families, this setting is not available and the default scan direction is forward. */
  921. #define LL_ADC_REG_SEQ_SCAN_DIR_BACKWARD (ADC_CFGR1_SCANDIR) /*!< On this STM32 serie, parameter relevant only is sequencer set to mode not fully configurable, refer to function @ref LL_ADC_REG_SetSequencerConfigurable(). ADC group regular sequencer scan direction backward: from highest channel number to lowest channel number (scan of all ranks, ADC conversion of ranks with channels enabled in sequencer) */
  922. /**
  923. * @}
  924. */
  925. #endif
  926. /** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
  927. * @{
  928. */
  929. #define LL_ADC_REG_SEQ_DISCONT_DISABLE (0x00000000UL) /*!< ADC group regular sequencer discontinuous mode disable */
  930. #if defined (ADC_SUPPORT_2_5_MSPS)
  931. #define LL_ADC_REG_SEQ_DISCONT_1RANK (ADC_CFGR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
  932. #else
  933. #define LL_ADC_REG_SEQ_DISCONT_1RANK ( ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
  934. #define LL_ADC_REG_SEQ_DISCONT_2RANKS ( ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enabled with sequence interruption every 2 ranks */
  935. #define LL_ADC_REG_SEQ_DISCONT_3RANKS ( ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 3 ranks */
  936. #define LL_ADC_REG_SEQ_DISCONT_4RANKS ( ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 4 ranks */
  937. #define LL_ADC_REG_SEQ_DISCONT_5RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 5 ranks */
  938. #define LL_ADC_REG_SEQ_DISCONT_6RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 6 ranks */
  939. #define LL_ADC_REG_SEQ_DISCONT_7RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 7 ranks */
  940. #define LL_ADC_REG_SEQ_DISCONT_8RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 8 ranks */
  941. #endif /* ADC_SUPPORT_2_5_MSPS */
  942. /**
  943. * @}
  944. */
  945. /** @defgroup ADC_LL_EC_REG_SEQ_RANKS ADC group regular - Sequencer ranks
  946. * @{
  947. */
  948. #if defined (ADC_SUPPORT_2_5_MSPS)
  949. #define LL_ADC_REG_RANK_1 (ADC_REG_RANK_1_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 1 */
  950. #define LL_ADC_REG_RANK_2 (ADC_REG_RANK_2_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 2 */
  951. #define LL_ADC_REG_RANK_3 (ADC_REG_RANK_3_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 3 */
  952. #define LL_ADC_REG_RANK_4 (ADC_REG_RANK_4_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 4 */
  953. #define LL_ADC_REG_RANK_5 (ADC_REG_RANK_5_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 5 */
  954. #define LL_ADC_REG_RANK_6 (ADC_REG_RANK_6_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 6 */
  955. #define LL_ADC_REG_RANK_7 (ADC_REG_RANK_7_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 7 */
  956. #define LL_ADC_REG_RANK_8 (ADC_REG_RANK_8_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 8 */
  957. #else
  958. #define LL_ADC_REG_RANK_1 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 1 */
  959. #define LL_ADC_REG_RANK_2 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_2_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 2 */
  960. #define LL_ADC_REG_RANK_3 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_3_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 3 */
  961. #define LL_ADC_REG_RANK_4 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_4_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 4 */
  962. #define LL_ADC_REG_RANK_5 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_5_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 5 */
  963. #define LL_ADC_REG_RANK_6 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_6_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 6 */
  964. #define LL_ADC_REG_RANK_7 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_7_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 7 */
  965. #define LL_ADC_REG_RANK_8 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_8_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 8 */
  966. #define LL_ADC_REG_RANK_9 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_9_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 9 */
  967. #define LL_ADC_REG_RANK_10 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_10_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 10 */
  968. #define LL_ADC_REG_RANK_11 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_11_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 11 */
  969. #define LL_ADC_REG_RANK_12 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_12_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 12 */
  970. #define LL_ADC_REG_RANK_13 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_13_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 13 */
  971. #define LL_ADC_REG_RANK_14 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_14_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 14 */
  972. #define LL_ADC_REG_RANK_15 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_15_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 15 */
  973. #define LL_ADC_REG_RANK_16 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_16_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 16 */
  974. #endif /* ADC_SUPPORT_2_5_MSPS */
  975. /**
  976. * @}
  977. */
  978. #if defined (ADC_SUPPORT_2_5_MSPS)
  979. /* Feature "ADC group injected" not available on ADC peripheral of this STM32WB device */
  980. #else
  981. /** @defgroup ADC_LL_EC_INJ_TRIGGER_SOURCE ADC group injected - Trigger source
  982. * @{
  983. */
  984. #define LL_ADC_INJ_TRIG_SOFTWARE (0x00000000UL) /*!< ADC group injected conversion trigger internal: SW start.. Trigger edge set to rising edge (default setting). */
  985. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
  986. #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM1 TRGO2. Trigger edge set to rising edge (default setting). */
  987. #define LL_ADC_INJ_TRIG_EXT_TIM1_CH4 (ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM1 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  988. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  989. #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM2 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  990. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: external interrupt line 15. Trigger edge set to rising edge (default setting). */
  991. /**
  992. * @}
  993. */
  994. /** @defgroup ADC_LL_EC_INJ_TRIGGER_EDGE ADC group injected - Trigger edge
  995. * @{
  996. */
  997. #define LL_ADC_INJ_TRIG_EXT_RISING ( ADC_JSQR_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to rising edge */
  998. #define LL_ADC_INJ_TRIG_EXT_FALLING (ADC_JSQR_JEXTEN_1 ) /*!< ADC group injected conversion trigger polarity set to falling edge */
  999. #define LL_ADC_INJ_TRIG_EXT_RISINGFALLING (ADC_JSQR_JEXTEN_1 | ADC_JSQR_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to both rising and falling edges */
  1000. /**
  1001. * @}
  1002. */
  1003. /** @defgroup ADC_LL_EC_INJ_TRIG_AUTO ADC group injected - Automatic trigger mode
  1004. * @{
  1005. */
  1006. #define LL_ADC_INJ_TRIG_INDEPENDENT (0x00000000UL) /*!< ADC group injected conversion trigger independent. Setting mandatory if ADC group injected injected trigger source is set to an external trigger. */
  1007. #define LL_ADC_INJ_TRIG_FROM_GRP_REGULAR (ADC_CFGR_JAUTO) /*!< ADC group injected conversion trigger from ADC group regular. Setting compliant only with group injected trigger source set to SW start, without any further action on ADC group injected conversion start or stop: in this case, ADC group injected is controlled only from ADC group regular. */
  1008. /**
  1009. * @}
  1010. */
  1011. /** @defgroup ADC_LL_EC_INJ_CONTEXT_QUEUE ADC group injected - Context queue mode
  1012. * @{
  1013. */
  1014. #define LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE (0x00000000UL) /* Group injected sequence context queue is enabled and can contain up to 2 contexts. When all contexts have been processed, the queue maintains the last context active perpetually. */
  1015. #define LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY (ADC_CFGR_JQM) /* Group injected sequence context queue is enabled and can contain up to 2 contexts. When all contexts have been processed, the queue is empty and injected group triggers are disabled. */
  1016. #define LL_ADC_INJ_QUEUE_DISABLE (ADC_CFGR_JQDIS) /* Group injected sequence context queue is disabled: only 1 sequence can be configured and is active perpetually. */
  1017. /**
  1018. * @}
  1019. */
  1020. /** @defgroup ADC_LL_EC_INJ_SEQ_SCAN_LENGTH ADC group injected - Sequencer scan length
  1021. * @{
  1022. */
  1023. #define LL_ADC_INJ_SEQ_SCAN_DISABLE (0x00000000UL) /*!< ADC group injected sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  1024. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS ( ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 2 ranks in the sequence */
  1025. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS (ADC_JSQR_JL_1 ) /*!< ADC group injected sequencer enable with 3 ranks in the sequence */
  1026. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS (ADC_JSQR_JL_1 | ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 4 ranks in the sequence */
  1027. /**
  1028. * @}
  1029. */
  1030. /** @defgroup ADC_LL_EC_INJ_SEQ_DISCONT_MODE ADC group injected - Sequencer discontinuous mode
  1031. * @{
  1032. */
  1033. #define LL_ADC_INJ_SEQ_DISCONT_DISABLE (0x00000000UL) /*!< ADC group injected sequencer discontinuous mode disable */
  1034. #define LL_ADC_INJ_SEQ_DISCONT_1RANK (ADC_CFGR_JDISCEN) /*!< ADC group injected sequencer discontinuous mode enable with sequence interruption every rank */
  1035. /**
  1036. * @}
  1037. */
  1038. /** @defgroup ADC_LL_EC_INJ_SEQ_RANKS ADC group injected - Sequencer ranks
  1039. * @{
  1040. */
  1041. #define LL_ADC_INJ_RANK_1 (ADC_JDR1_REGOFFSET | ADC_INJ_RANK_1_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 1 */
  1042. #define LL_ADC_INJ_RANK_2 (ADC_JDR2_REGOFFSET | ADC_INJ_RANK_2_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 2 */
  1043. #define LL_ADC_INJ_RANK_3 (ADC_JDR3_REGOFFSET | ADC_INJ_RANK_3_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 3 */
  1044. #define LL_ADC_INJ_RANK_4 (ADC_JDR4_REGOFFSET | ADC_INJ_RANK_4_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 4 */
  1045. /**
  1046. * @}
  1047. */
  1048. #endif /* ADC_SUPPORT_2_5_MSPS */
  1049. /** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time
  1050. * @{
  1051. */
  1052. #if defined (ADC_SUPPORT_2_5_MSPS)
  1053. #define LL_ADC_SAMPLINGTIME_1CYCLE_5 (0x00000000UL) /*!< Sampling time 1.5 ADC clock cycle */
  1054. #define LL_ADC_SAMPLINGTIME_3CYCLES_5 (ADC_SMPR_SMP1_0) /*!< Sampling time 3.5 ADC clock cycles */
  1055. #define LL_ADC_SAMPLINGTIME_7CYCLES_5 (ADC_SMPR_SMP1_1) /*!< Sampling time 7.5 ADC clock cycles */
  1056. #define LL_ADC_SAMPLINGTIME_12CYCLES_5 (ADC_SMPR_SMP1_1 | ADC_SMPR_SMP1_0) /*!< Sampling time 12.5 ADC clock cycles */
  1057. #define LL_ADC_SAMPLINGTIME_19CYCLES_5 (ADC_SMPR_SMP1_2) /*!< Sampling time 19.5 ADC clock cycles */
  1058. #define LL_ADC_SAMPLINGTIME_39CYCLES_5 (ADC_SMPR_SMP1_2 | ADC_SMPR_SMP1_0) /*!< Sampling time 39.5 ADC clock cycles */
  1059. #define LL_ADC_SAMPLINGTIME_79CYCLES_5 (ADC_SMPR_SMP1_2 | ADC_SMPR_SMP1_1) /*!< Sampling time 79.5 ADC clock cycles */
  1060. #define LL_ADC_SAMPLINGTIME_160CYCLES_5 (ADC_SMPR_SMP1_2 | ADC_SMPR_SMP1_1 | ADC_SMPR_SMP1_0) /*!< Sampling time 160.5 ADC clock cycles */
  1061. #else
  1062. #define LL_ADC_SAMPLINGTIME_2CYCLES_5 (0x00000000UL) /*!< Sampling time 2.5 ADC clock cycles */
  1063. #define LL_ADC_SAMPLINGTIME_6CYCLES_5 ( ADC_SMPR2_SMP10_0) /*!< Sampling time 6.5 ADC clock cycles */
  1064. #define LL_ADC_SAMPLINGTIME_12CYCLES_5 ( ADC_SMPR2_SMP10_1 ) /*!< Sampling time 12.5 ADC clock cycles */
  1065. #define LL_ADC_SAMPLINGTIME_24CYCLES_5 ( ADC_SMPR2_SMP10_1 | ADC_SMPR2_SMP10_0) /*!< Sampling time 24.5 ADC clock cycles */
  1066. #define LL_ADC_SAMPLINGTIME_47CYCLES_5 (ADC_SMPR2_SMP10_2 ) /*!< Sampling time 47.5 ADC clock cycles */
  1067. #define LL_ADC_SAMPLINGTIME_92CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_0) /*!< Sampling time 92.5 ADC clock cycles */
  1068. #define LL_ADC_SAMPLINGTIME_247CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_1 ) /*!< Sampling time 247.5 ADC clock cycles */
  1069. #define LL_ADC_SAMPLINGTIME_640CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_1 | ADC_SMPR2_SMP10_0) /*!< Sampling time 640.5 ADC clock cycles */
  1070. #endif
  1071. /**
  1072. * @}
  1073. */
  1074. /** @defgroup ADC_LL_EC_CHANNEL_SINGLE_DIFF_ENDING Channel - Single or differential ending
  1075. * @{
  1076. */
  1077. #if defined (ADC_SUPPORT_2_5_MSPS)
  1078. #define LL_ADC_SINGLE_ENDED (0x00000000UL) /*!< ADC channel ending set to single ended (literal also used to set calibration mode) */
  1079. #else
  1080. #define LL_ADC_SINGLE_ENDED ( ADC_CALFACT_CALFACT_S) /*!< ADC channel ending set to single ended (literal also used to set calibration mode) */
  1081. #define LL_ADC_DIFFERENTIAL_ENDED (ADC_CR_ADCALDIF | ADC_CALFACT_CALFACT_D) /*!< ADC channel ending set to differential (literal also used to set calibration mode) */
  1082. #define LL_ADC_BOTH_SINGLE_DIFF_ENDED (LL_ADC_SINGLE_ENDED | LL_ADC_DIFFERENTIAL_ENDED) /*!< ADC channel ending set to both single ended and differential (literal used only to set calibration factors) */
  1083. #endif
  1084. /**
  1085. * @}
  1086. */
  1087. /** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
  1088. * @{
  1089. */
  1090. #define LL_ADC_AWD1 (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
  1091. #if defined (ADC_SUPPORT_2_5_MSPS)
  1092. /* Feature "ADC analog watchdog 2 and 3" not available on ADC peripheral of this STM32WB device */
  1093. #else
  1094. #define LL_ADC_AWD2 (ADC_AWD_CR23_CHANNEL_MASK | ADC_AWD_CR2_REGOFFSET) /*!< ADC analog watchdog number 2 */
  1095. #define LL_ADC_AWD3 (ADC_AWD_CR23_CHANNEL_MASK | ADC_AWD_CR3_REGOFFSET) /*!< ADC analog watchdog number 3 */
  1096. #endif
  1097. /**
  1098. * @}
  1099. */
  1100. /** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
  1101. * @{
  1102. */
  1103. #if defined (ADC_SUPPORT_2_5_MSPS)
  1104. #define LL_ADC_AWD_DISABLE (0x00000000UL) /*!< ADC analog watchdog monitoring disabled */
  1105. #define LL_ADC_AWD_ALL_CHANNELS_REG ( ADC_CFGR1_AWD1EN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
  1106. #define LL_ADC_AWD_CHANNEL_0_REG ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group regular only */
  1107. #define LL_ADC_AWD_CHANNEL_1_REG ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group regular only */
  1108. #define LL_ADC_AWD_CHANNEL_2_REG ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group regular only */
  1109. #define LL_ADC_AWD_CHANNEL_3_REG ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group regular only */
  1110. #define LL_ADC_AWD_CHANNEL_4_REG ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group regular only */
  1111. #define LL_ADC_AWD_CHANNEL_5_REG ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group regular only */
  1112. #define LL_ADC_AWD_CHANNEL_6_REG ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group regular only */
  1113. #define LL_ADC_AWD_CHANNEL_7_REG ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group regular only */
  1114. #define LL_ADC_AWD_CHANNEL_8_REG ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group regular only */
  1115. #define LL_ADC_AWD_CHANNEL_9_REG ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group regular only */
  1116. #define LL_ADC_AWD_CHANNEL_10_REG ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group regular only */
  1117. #define LL_ADC_AWD_CHANNEL_11_REG ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group regular only */
  1118. #define LL_ADC_AWD_CHANNEL_12_REG ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group regular only */
  1119. #define LL_ADC_AWD_CHANNEL_13_REG ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group regular only */
  1120. #define LL_ADC_AWD_CHANNEL_14_REG ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group regular only */
  1121. #define LL_ADC_AWD_CHANNEL_15_REG ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group regular only */
  1122. #define LL_ADC_AWD_CHANNEL_16_REG ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group regular only */
  1123. #define LL_ADC_AWD_CHANNEL_17_REG ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group regular only */
  1124. #define LL_ADC_AWD_CHANNEL_18_REG ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group regular only */
  1125. #define LL_ADC_AWD_CH_VREFINT_REG ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group regular only */
  1126. #define LL_ADC_AWD_CH_TEMPSENSOR_REG ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group regular only */
  1127. #define LL_ADC_AWD_CH_VBAT_REG ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/3 to have Vbat always below Vdda, converted by group regular only */
  1128. #else
  1129. #define LL_ADC_AWD_DISABLE (0x00000000UL) /*!< ADC analog watchdog monitoring disabled */
  1130. #define LL_ADC_AWD_ALL_CHANNELS_REG (ADC_AWD_CR23_CHANNEL_MASK | ADC_CFGR_AWD1EN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
  1131. #define LL_ADC_AWD_ALL_CHANNELS_INJ (ADC_AWD_CR23_CHANNEL_MASK | ADC_CFGR_JAWD1EN ) /*!< ADC analog watchdog monitoring of all channels, converted by group injected only */
  1132. #define LL_ADC_AWD_ALL_CHANNELS_REG_INJ (ADC_AWD_CR23_CHANNEL_MASK | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN ) /*!< ADC analog watchdog monitoring of all channels, converted by either group regular or injected */
  1133. #define LL_ADC_AWD_CHANNEL_0_REG ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group regular only */
  1134. #define LL_ADC_AWD_CHANNEL_0_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group injected only */
  1135. #define LL_ADC_AWD_CHANNEL_0_REG_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by either group regular or injected */
  1136. #define LL_ADC_AWD_CHANNEL_1_REG ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group regular only */
  1137. #define LL_ADC_AWD_CHANNEL_1_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group injected only */
  1138. #define LL_ADC_AWD_CHANNEL_1_REG_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by either group regular or injected */
  1139. #define LL_ADC_AWD_CHANNEL_2_REG ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group regular only */
  1140. #define LL_ADC_AWD_CHANNEL_2_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group injected only */
  1141. #define LL_ADC_AWD_CHANNEL_2_REG_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by either group regular or injected */
  1142. #define LL_ADC_AWD_CHANNEL_3_REG ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group regular only */
  1143. #define LL_ADC_AWD_CHANNEL_3_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group injected only */
  1144. #define LL_ADC_AWD_CHANNEL_3_REG_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by either group regular or injected */
  1145. #define LL_ADC_AWD_CHANNEL_4_REG ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group regular only */
  1146. #define LL_ADC_AWD_CHANNEL_4_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group injected only */
  1147. #define LL_ADC_AWD_CHANNEL_4_REG_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by either group regular or injected */
  1148. #define LL_ADC_AWD_CHANNEL_5_REG ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group regular only */
  1149. #define LL_ADC_AWD_CHANNEL_5_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group injected only */
  1150. #define LL_ADC_AWD_CHANNEL_5_REG_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by either group regular or injected */
  1151. #define LL_ADC_AWD_CHANNEL_6_REG ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group regular only */
  1152. #define LL_ADC_AWD_CHANNEL_6_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group injected only */
  1153. #define LL_ADC_AWD_CHANNEL_6_REG_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by either group regular or injected */
  1154. #define LL_ADC_AWD_CHANNEL_7_REG ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group regular only */
  1155. #define LL_ADC_AWD_CHANNEL_7_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group injected only */
  1156. #define LL_ADC_AWD_CHANNEL_7_REG_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by either group regular or injected */
  1157. #define LL_ADC_AWD_CHANNEL_8_REG ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group regular only */
  1158. #define LL_ADC_AWD_CHANNEL_8_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group injected only */
  1159. #define LL_ADC_AWD_CHANNEL_8_REG_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by either group regular or injected */
  1160. #define LL_ADC_AWD_CHANNEL_9_REG ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group regular only */
  1161. #define LL_ADC_AWD_CHANNEL_9_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group injected only */
  1162. #define LL_ADC_AWD_CHANNEL_9_REG_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by either group regular or injected */
  1163. #define LL_ADC_AWD_CHANNEL_10_REG ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group regular only */
  1164. #define LL_ADC_AWD_CHANNEL_10_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group injected only */
  1165. #define LL_ADC_AWD_CHANNEL_10_REG_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by either group regular or injected */
  1166. #define LL_ADC_AWD_CHANNEL_11_REG ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group regular only */
  1167. #define LL_ADC_AWD_CHANNEL_11_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group injected only */
  1168. #define LL_ADC_AWD_CHANNEL_11_REG_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by either group regular or injected */
  1169. #define LL_ADC_AWD_CHANNEL_12_REG ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group regular only */
  1170. #define LL_ADC_AWD_CHANNEL_12_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group injected only */
  1171. #define LL_ADC_AWD_CHANNEL_12_REG_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by either group regular or injected */
  1172. #define LL_ADC_AWD_CHANNEL_13_REG ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group regular only */
  1173. #define LL_ADC_AWD_CHANNEL_13_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group injected only */
  1174. #define LL_ADC_AWD_CHANNEL_13_REG_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by either group regular or injected */
  1175. #define LL_ADC_AWD_CHANNEL_14_REG ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group regular only */
  1176. #define LL_ADC_AWD_CHANNEL_14_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group injected only */
  1177. #define LL_ADC_AWD_CHANNEL_14_REG_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by either group regular or injected */
  1178. #define LL_ADC_AWD_CHANNEL_15_REG ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group regular only */
  1179. #define LL_ADC_AWD_CHANNEL_15_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group injected only */
  1180. #define LL_ADC_AWD_CHANNEL_15_REG_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by either group regular or injected */
  1181. #define LL_ADC_AWD_CHANNEL_16_REG ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group regular only */
  1182. #define LL_ADC_AWD_CHANNEL_16_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group injected only */
  1183. #define LL_ADC_AWD_CHANNEL_16_REG_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by either group regular or injected */
  1184. #define LL_ADC_AWD_CHANNEL_17_REG ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group regular only */
  1185. #define LL_ADC_AWD_CHANNEL_17_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group injected only */
  1186. #define LL_ADC_AWD_CHANNEL_17_REG_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by either group regular or injected */
  1187. #define LL_ADC_AWD_CHANNEL_18_REG ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group regular only */
  1188. #define LL_ADC_AWD_CHANNEL_18_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group injected only */
  1189. #define LL_ADC_AWD_CHANNEL_18_REG_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by either group regular or injected */
  1190. #define LL_ADC_AWD_CH_VREFINT_REG ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group regular only */
  1191. #define LL_ADC_AWD_CH_VREFINT_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group injected only */
  1192. #define LL_ADC_AWD_CH_VREFINT_REG_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by either group regular or injected */
  1193. #define LL_ADC_AWD_CH_TEMPSENSOR_REG ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group regular only */
  1194. #define LL_ADC_AWD_CH_TEMPSENSOR_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group injected only */
  1195. #define LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by either group regular or injected */
  1196. #define LL_ADC_AWD_CH_VBAT_REG ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/3 to have Vbat always below Vdda, converted by group regular only */
  1197. #define LL_ADC_AWD_CH_VBAT_INJ ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/3 to have Vbat always below Vdda, converted by group injected only */
  1198. #define LL_ADC_AWD_CH_VBAT_REG_INJ ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/3 to have Vbat always below Vdda */
  1199. #endif /* ADC_SUPPORT_2_5_MSPS */
  1200. /**
  1201. * @}
  1202. */
  1203. /** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
  1204. * @{
  1205. */
  1206. #define LL_ADC_AWD_THRESHOLD_HIGH (ADC_TR1_HT1 ) /*!< ADC analog watchdog threshold high */
  1207. #define LL_ADC_AWD_THRESHOLD_LOW ( ADC_TR1_LT1) /*!< ADC analog watchdog threshold low */
  1208. #define LL_ADC_AWD_THRESHOLDS_HIGH_LOW (ADC_TR1_HT1 | ADC_TR1_LT1) /*!< ADC analog watchdog both thresholds high and low concatenated into the same data */
  1209. /**
  1210. * @}
  1211. */
  1212. /** @defgroup ADC_LL_EC_OVS_SCOPE Oversampling - Oversampling scope
  1213. * @{
  1214. */
  1215. #if defined (ADC_SUPPORT_2_5_MSPS)
  1216. #define LL_ADC_OVS_DISABLE (0x00000000UL) /*!< ADC oversampling disabled. */
  1217. #define LL_ADC_OVS_GRP_REGULAR_CONTINUED ( ADC_CFGR2_OVSE) /*!< ADC oversampling on conversions of ADC group regular. Literal suffix "continued" is kept for compatibility with other STM32 devices featuring ADC group injected, in this case other oversampling scope parameters are available. */
  1218. #else
  1219. #define LL_ADC_OVS_DISABLE (0x00000000UL) /*!< ADC oversampling disabled. */
  1220. #define LL_ADC_OVS_GRP_REGULAR_CONTINUED ( ADC_CFGR2_ROVSE) /*!< ADC oversampling on conversions of ADC group regular. If group injected interrupts group regular: when ADC group injected is triggered, the oversampling on ADC group regular is temporary stopped and continued afterwards. */
  1221. #define LL_ADC_OVS_GRP_REGULAR_RESUMED (ADC_CFGR2_ROVSM | ADC_CFGR2_ROVSE) /*!< ADC oversampling on conversions of ADC group regular. If group injected interrupts group regular: when ADC group injected is triggered, the oversampling on ADC group regular is resumed from start (oversampler buffer reset). */
  1222. #define LL_ADC_OVS_GRP_INJECTED ( ADC_CFGR2_JOVSE ) /*!< ADC oversampling on conversions of ADC group injected. */
  1223. #define LL_ADC_OVS_GRP_INJ_REG_RESUMED ( ADC_CFGR2_JOVSE | ADC_CFGR2_ROVSE) /*!< ADC oversampling on conversions of both ADC groups regular and injected. If group injected interrupting group regular: when ADC group injected is triggered, the oversampling on ADC group regular is resumed from start (oversampler buffer reset). */
  1224. #endif
  1225. /**
  1226. * @}
  1227. */
  1228. /** @defgroup ADC_LL_EC_OVS_DISCONT_MODE Oversampling - Discontinuous mode
  1229. * @{
  1230. */
  1231. #define LL_ADC_OVS_REG_CONT (0x00000000UL) /*!< ADC oversampling discontinuous mode: continuous mode (all conversions of oversampling ratio are done from 1 trigger) */
  1232. #if defined (ADC_SUPPORT_2_5_MSPS)
  1233. #define LL_ADC_OVS_REG_DISCONT (ADC_CFGR2_TOVS) /*!< ADC oversampling discontinuous mode: discontinuous mode (each conversion of oversampling ratio needs a trigger) */
  1234. #else
  1235. #define LL_ADC_OVS_REG_DISCONT (ADC_CFGR2_TROVS) /*!< ADC oversampling discontinuous mode: discontinuous mode (each conversion of oversampling ratio needs a trigger) */
  1236. #endif
  1237. /**
  1238. * @}
  1239. */
  1240. /** @defgroup ADC_LL_EC_OVS_RATIO Oversampling - Ratio
  1241. * @{
  1242. */
  1243. #define LL_ADC_OVS_RATIO_2 (0x00000000UL) /*!< ADC oversampling ratio of 2 (2 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
  1244. #define LL_ADC_OVS_RATIO_4 ( ADC_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 4 (4 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
  1245. #define LL_ADC_OVS_RATIO_8 ( ADC_CFGR2_OVSR_1 ) /*!< ADC oversampling ratio of 8 (8 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
  1246. #define LL_ADC_OVS_RATIO_16 ( ADC_CFGR2_OVSR_1 | ADC_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 16 (16 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
  1247. #define LL_ADC_OVS_RATIO_32 (ADC_CFGR2_OVSR_2 ) /*!< ADC oversampling ratio of 32 (32 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
  1248. #define LL_ADC_OVS_RATIO_64 (ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 64 (64 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
  1249. #define LL_ADC_OVS_RATIO_128 (ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_1 ) /*!< ADC oversampling ratio of 128 (128 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
  1250. #define LL_ADC_OVS_RATIO_256 (ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_1 | ADC_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 256 (256 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
  1251. /**
  1252. * @}
  1253. */
  1254. /** @defgroup ADC_LL_EC_OVS_SHIFT Oversampling - Data shift
  1255. * @{
  1256. */
  1257. #define LL_ADC_OVS_SHIFT_NONE (0x00000000UL) /*!< ADC oversampling no shift (sum of the ADC conversions data is not divided to result as the ADC oversampling conversion data) */
  1258. #define LL_ADC_OVS_SHIFT_RIGHT_1 ( ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 1 (sum of the ADC conversions data is divided by 2 to result as the ADC oversampling conversion data) */
  1259. #define LL_ADC_OVS_SHIFT_RIGHT_2 ( ADC_CFGR2_OVSS_1 ) /*!< ADC oversampling shift of 2 (sum of the ADC conversions data is divided by 4 to result as the ADC oversampling conversion data) */
  1260. #define LL_ADC_OVS_SHIFT_RIGHT_3 ( ADC_CFGR2_OVSS_1 | ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 3 (sum of the ADC conversions data is divided by 8 to result as the ADC oversampling conversion data) */
  1261. #define LL_ADC_OVS_SHIFT_RIGHT_4 ( ADC_CFGR2_OVSS_2 ) /*!< ADC oversampling shift of 4 (sum of the ADC conversions data is divided by 16 to result as the ADC oversampling conversion data) */
  1262. #define LL_ADC_OVS_SHIFT_RIGHT_5 ( ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 5 (sum of the ADC conversions data is divided by 32 to result as the ADC oversampling conversion data) */
  1263. #define LL_ADC_OVS_SHIFT_RIGHT_6 ( ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_1 ) /*!< ADC oversampling shift of 6 (sum of the ADC conversions data is divided by 64 to result as the ADC oversampling conversion data) */
  1264. #define LL_ADC_OVS_SHIFT_RIGHT_7 ( ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_1 | ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 7 (sum of the ADC conversions data is divided by 128 to result as the ADC oversampling conversion data) */
  1265. #define LL_ADC_OVS_SHIFT_RIGHT_8 (ADC_CFGR2_OVSS_3 ) /*!< ADC oversampling shift of 8 (sum of the ADC conversions data is divided by 256 to result as the ADC oversampling conversion data) */
  1266. /**
  1267. * @}
  1268. */
  1269. /** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
  1270. * @note Only ADC peripheral HW delays are defined in ADC LL driver driver,
  1271. * not timeout values.
  1272. * For details on delays values, refer to descriptions in source code
  1273. * above each literal definition.
  1274. * @{
  1275. */
  1276. /* Note: Only ADC peripheral HW delays are defined in ADC LL driver driver, */
  1277. /* not timeout values. */
  1278. /* Timeout values for ADC operations are dependent to device clock */
  1279. /* configuration (system clock versus ADC clock), */
  1280. /* and therefore must be defined in user application. */
  1281. /* Indications for estimation of ADC timeout delays, for this */
  1282. /* STM32 serie: */
  1283. /* - ADC calibration time: maximum delay is 112/fADC. */
  1284. /* (refer to device datasheet, parameter "tCAL") */
  1285. /* - ADC enable time: maximum delay is 1 conversion cycle. */
  1286. /* (refer to device datasheet, parameter "tSTAB") */
  1287. /* - ADC disable time: maximum delay should be a few ADC clock cycles */
  1288. /* - ADC stop conversion time: maximum delay should be a few ADC clock */
  1289. /* cycles */
  1290. /* - ADC conversion time: duration depending on ADC clock and ADC */
  1291. /* configuration. */
  1292. /* (refer to device reference manual, section "Timing") */
  1293. /* Delay for ADC stabilization time (ADC voltage regulator start-up time) */
  1294. /* Delay set to maximum value (refer to device datasheet, */
  1295. /* parameter "tADCVREG_STUP"). */
  1296. /* Unit: us */
  1297. #define LL_ADC_DELAY_INTERNAL_REGUL_STAB_US ( 10UL) /*!< Delay for ADC stabilization time (ADC voltage regulator start-up time) */
  1298. /* Delay for internal voltage reference stabilization time. */
  1299. /* Delay set to maximum value (refer to device datasheet, */
  1300. /* parameter "tstart_vrefint"). */
  1301. /* Unit: us */
  1302. #define LL_ADC_DELAY_VREFINT_STAB_US ( 12UL) /*!< Delay for internal voltage reference stabilization time */
  1303. /* Delay for temperature sensor stabilization time. */
  1304. /* Literal set to maximum value (refer to device datasheet, */
  1305. /* parameter "tSTART"). */
  1306. /* Unit: us */
  1307. #define LL_ADC_DELAY_TEMPSENSOR_STAB_US (120UL) /*!< Delay for temperature sensor stabilization time */
  1308. #define LL_ADC_DELAY_TEMPSENSOR_BUFFER_STAB_US ( 15UL) /*!< Delay for temperature sensor buffer stabilization time (starting from ADC enable, refer to @ref LL_ADC_Enable()) */
  1309. /* Delay required between ADC end of calibration and ADC enable. */
  1310. /* Note: On this STM32 serie, a minimum number of ADC clock cycles */
  1311. /* are required between ADC end of calibration and ADC enable. */
  1312. /* Wait time can be computed in user application by waiting for the */
  1313. /* equivalent number of CPU cycles, by taking into account */
  1314. /* ratio of CPU clock versus ADC clock prescalers. */
  1315. /* Unit: ADC clock cycles. */
  1316. #define LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES ( 4UL) /*!< Delay required between ADC end of calibration and ADC enable */
  1317. /**
  1318. * @}
  1319. */
  1320. /**
  1321. * @}
  1322. */
  1323. /* Exported macro ------------------------------------------------------------*/
  1324. /** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
  1325. * @{
  1326. */
  1327. /** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
  1328. * @{
  1329. */
  1330. /**
  1331. * @brief Write a value in ADC register
  1332. * @param __INSTANCE__ ADC Instance
  1333. * @param __REG__ Register to be written
  1334. * @param __VALUE__ Value to be written in the register
  1335. * @retval None
  1336. */
  1337. #define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  1338. /**
  1339. * @brief Read a value in ADC register
  1340. * @param __INSTANCE__ ADC Instance
  1341. * @param __REG__ Register to be read
  1342. * @retval Register value
  1343. */
  1344. #define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  1345. /**
  1346. * @}
  1347. */
  1348. /** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
  1349. * @{
  1350. */
  1351. /**
  1352. * @brief Helper macro to get ADC channel number in decimal format
  1353. * from literals LL_ADC_CHANNEL_x.
  1354. * @note Example:
  1355. * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
  1356. * will return decimal number "4".
  1357. * @note The input can be a value from functions where a channel
  1358. * number is returned, either defined with number
  1359. * or with bitfield (only one bit must be set).
  1360. * @param __CHANNEL__ This parameter can be one of the following values:
  1361. * @arg @ref LL_ADC_CHANNEL_0
  1362. * @arg @ref LL_ADC_CHANNEL_1 (7)
  1363. * @arg @ref LL_ADC_CHANNEL_2 (7)
  1364. * @arg @ref LL_ADC_CHANNEL_3 (7)
  1365. * @arg @ref LL_ADC_CHANNEL_4 (7)
  1366. * @arg @ref LL_ADC_CHANNEL_5 (7)
  1367. * @arg @ref LL_ADC_CHANNEL_6
  1368. * @arg @ref LL_ADC_CHANNEL_7
  1369. * @arg @ref LL_ADC_CHANNEL_8
  1370. * @arg @ref LL_ADC_CHANNEL_9
  1371. * @arg @ref LL_ADC_CHANNEL_10
  1372. * @arg @ref LL_ADC_CHANNEL_11
  1373. * @arg @ref LL_ADC_CHANNEL_12
  1374. * @arg @ref LL_ADC_CHANNEL_13
  1375. * @arg @ref LL_ADC_CHANNEL_14
  1376. * @arg @ref LL_ADC_CHANNEL_15
  1377. * @arg @ref LL_ADC_CHANNEL_16
  1378. * @arg @ref LL_ADC_CHANNEL_17
  1379. * @arg @ref LL_ADC_CHANNEL_18
  1380. * @arg @ref LL_ADC_CHANNEL_VREFINT
  1381. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  1382. * @arg @ref LL_ADC_CHANNEL_VBAT
  1383. *
  1384. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  1385. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  1386. * @retval Value between Min_Data=0 and Max_Data=18
  1387. */
  1388. #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
  1389. ((((__CHANNEL__) & ADC_CHANNEL_ID_BITFIELD_MASK) == 0UL) \
  1390. ? ( \
  1391. ((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS \
  1392. ) \
  1393. : \
  1394. ( \
  1395. (uint32_t)POSITION_VAL((__CHANNEL__)) \
  1396. ) \
  1397. )
  1398. /**
  1399. * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
  1400. * from number in decimal format.
  1401. * @note Example:
  1402. * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
  1403. * will return a data equivalent to "LL_ADC_CHANNEL_4".
  1404. * @param __DECIMAL_NB__ Value between Min_Data=0 and Max_Data=18
  1405. * @retval Returned value can be one of the following values:
  1406. * @arg @ref LL_ADC_CHANNEL_0
  1407. * @arg @ref LL_ADC_CHANNEL_1 (7)
  1408. * @arg @ref LL_ADC_CHANNEL_2 (7)
  1409. * @arg @ref LL_ADC_CHANNEL_3 (7)
  1410. * @arg @ref LL_ADC_CHANNEL_4 (7)
  1411. * @arg @ref LL_ADC_CHANNEL_5 (7)
  1412. * @arg @ref LL_ADC_CHANNEL_6
  1413. * @arg @ref LL_ADC_CHANNEL_7
  1414. * @arg @ref LL_ADC_CHANNEL_8
  1415. * @arg @ref LL_ADC_CHANNEL_9
  1416. * @arg @ref LL_ADC_CHANNEL_10
  1417. * @arg @ref LL_ADC_CHANNEL_11
  1418. * @arg @ref LL_ADC_CHANNEL_12
  1419. * @arg @ref LL_ADC_CHANNEL_13
  1420. * @arg @ref LL_ADC_CHANNEL_14
  1421. * @arg @ref LL_ADC_CHANNEL_15
  1422. * @arg @ref LL_ADC_CHANNEL_16
  1423. * @arg @ref LL_ADC_CHANNEL_17
  1424. * @arg @ref LL_ADC_CHANNEL_18
  1425. * @arg @ref LL_ADC_CHANNEL_VREFINT (4)
  1426. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  1427. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  1428. *
  1429. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  1430. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).\n
  1431. * (4) For ADC channel read back from ADC register,
  1432. * comparison with internal channel parameter to be done
  1433. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1434. */
  1435. #if defined (ADC_SUPPORT_2_5_MSPS)
  1436. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  1437. ( \
  1438. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1439. (ADC_CHSELR_CHSEL0 << (__DECIMAL_NB__)) \
  1440. )
  1441. #else
  1442. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  1443. (((__DECIMAL_NB__) <= 9UL) \
  1444. ? ( \
  1445. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1446. (ADC_AWD2CR_AWD2CH_0 << (__DECIMAL_NB__)) | \
  1447. (ADC_SMPR1_REGOFFSET | (((3UL * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1448. ) \
  1449. : \
  1450. ( \
  1451. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1452. (ADC_AWD2CR_AWD2CH_0 << (__DECIMAL_NB__)) | \
  1453. (ADC_SMPR2_REGOFFSET | (((3UL * ((__DECIMAL_NB__) - 10UL))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1454. ) \
  1455. )
  1456. #endif /* ADC_SUPPORT_2_5_MSPS */
  1457. /**
  1458. * @brief Helper macro to determine whether the selected channel
  1459. * corresponds to literal definitions of driver.
  1460. * @note The different literal definitions of ADC channels are:
  1461. * - ADC internal channel:
  1462. * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
  1463. * - ADC external channel (channel connected to a GPIO pin):
  1464. * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
  1465. * @note The channel parameter must be a value defined from literal
  1466. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1467. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1468. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
  1469. * must not be a value from functions where a channel number is
  1470. * returned from ADC registers,
  1471. * because internal and external channels share the same channel
  1472. * number in ADC registers. The differentiation is made only with
  1473. * parameters definitions of driver.
  1474. * @param __CHANNEL__ This parameter can be one of the following values:
  1475. * @arg @ref LL_ADC_CHANNEL_0
  1476. * @arg @ref LL_ADC_CHANNEL_1 (7)
  1477. * @arg @ref LL_ADC_CHANNEL_2 (7)
  1478. * @arg @ref LL_ADC_CHANNEL_3 (7)
  1479. * @arg @ref LL_ADC_CHANNEL_4 (7)
  1480. * @arg @ref LL_ADC_CHANNEL_5 (7)
  1481. * @arg @ref LL_ADC_CHANNEL_6
  1482. * @arg @ref LL_ADC_CHANNEL_7
  1483. * @arg @ref LL_ADC_CHANNEL_8
  1484. * @arg @ref LL_ADC_CHANNEL_9
  1485. * @arg @ref LL_ADC_CHANNEL_10
  1486. * @arg @ref LL_ADC_CHANNEL_11
  1487. * @arg @ref LL_ADC_CHANNEL_12
  1488. * @arg @ref LL_ADC_CHANNEL_13
  1489. * @arg @ref LL_ADC_CHANNEL_14
  1490. * @arg @ref LL_ADC_CHANNEL_15
  1491. * @arg @ref LL_ADC_CHANNEL_16
  1492. * @arg @ref LL_ADC_CHANNEL_17
  1493. * @arg @ref LL_ADC_CHANNEL_18
  1494. * @arg @ref LL_ADC_CHANNEL_VREFINT
  1495. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  1496. * @arg @ref LL_ADC_CHANNEL_VBAT
  1497. *
  1498. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  1499. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  1500. * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin).
  1501. * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
  1502. */
  1503. #define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
  1504. (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0UL)
  1505. /**
  1506. * @brief Helper macro to convert a channel defined from parameter
  1507. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1508. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1509. * to its equivalent parameter definition of a ADC external channel
  1510. * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
  1511. * @note The channel parameter can be, additionally to a value
  1512. * defined from parameter definition of a ADC internal channel
  1513. * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1514. * a value defined from parameter definition of
  1515. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1516. * or a value from functions where a channel number is returned
  1517. * from ADC registers.
  1518. * @param __CHANNEL__ This parameter can be one of the following values:
  1519. * @arg @ref LL_ADC_CHANNEL_0
  1520. * @arg @ref LL_ADC_CHANNEL_1 (7)
  1521. * @arg @ref LL_ADC_CHANNEL_2 (7)
  1522. * @arg @ref LL_ADC_CHANNEL_3 (7)
  1523. * @arg @ref LL_ADC_CHANNEL_4 (7)
  1524. * @arg @ref LL_ADC_CHANNEL_5 (7)
  1525. * @arg @ref LL_ADC_CHANNEL_6
  1526. * @arg @ref LL_ADC_CHANNEL_7
  1527. * @arg @ref LL_ADC_CHANNEL_8
  1528. * @arg @ref LL_ADC_CHANNEL_9
  1529. * @arg @ref LL_ADC_CHANNEL_10
  1530. * @arg @ref LL_ADC_CHANNEL_11
  1531. * @arg @ref LL_ADC_CHANNEL_12
  1532. * @arg @ref LL_ADC_CHANNEL_13
  1533. * @arg @ref LL_ADC_CHANNEL_14
  1534. * @arg @ref LL_ADC_CHANNEL_15
  1535. * @arg @ref LL_ADC_CHANNEL_16
  1536. * @arg @ref LL_ADC_CHANNEL_17
  1537. * @arg @ref LL_ADC_CHANNEL_18
  1538. * @arg @ref LL_ADC_CHANNEL_VREFINT
  1539. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  1540. * @arg @ref LL_ADC_CHANNEL_VBAT
  1541. *
  1542. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  1543. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  1544. * @retval Returned value can be one of the following values:
  1545. * @arg @ref LL_ADC_CHANNEL_0
  1546. * @arg @ref LL_ADC_CHANNEL_1
  1547. * @arg @ref LL_ADC_CHANNEL_2
  1548. * @arg @ref LL_ADC_CHANNEL_3
  1549. * @arg @ref LL_ADC_CHANNEL_4
  1550. * @arg @ref LL_ADC_CHANNEL_5
  1551. * @arg @ref LL_ADC_CHANNEL_6
  1552. * @arg @ref LL_ADC_CHANNEL_7
  1553. * @arg @ref LL_ADC_CHANNEL_8
  1554. * @arg @ref LL_ADC_CHANNEL_9
  1555. * @arg @ref LL_ADC_CHANNEL_10
  1556. * @arg @ref LL_ADC_CHANNEL_11
  1557. * @arg @ref LL_ADC_CHANNEL_12
  1558. * @arg @ref LL_ADC_CHANNEL_13
  1559. * @arg @ref LL_ADC_CHANNEL_14
  1560. * @arg @ref LL_ADC_CHANNEL_15
  1561. * @arg @ref LL_ADC_CHANNEL_16
  1562. * @arg @ref LL_ADC_CHANNEL_17
  1563. * @arg @ref LL_ADC_CHANNEL_18
  1564. */
  1565. #define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
  1566. ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  1567. /**
  1568. * @brief Helper macro to determine whether the internal channel
  1569. * selected is available on the ADC instance selected.
  1570. * @note The channel parameter must be a value defined from parameter
  1571. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1572. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1573. * must not be a value defined from parameter definition of
  1574. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1575. * or a value from functions where a channel number is
  1576. * returned from ADC registers,
  1577. * because internal and external channels share the same channel
  1578. * number in ADC registers. The differentiation is made only with
  1579. * parameters definitions of driver.
  1580. * @param __ADC_INSTANCE__ ADC instance
  1581. * @param __CHANNEL__ This parameter can be one of the following values:
  1582. * @arg @ref LL_ADC_CHANNEL_VREFINT
  1583. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  1584. * @arg @ref LL_ADC_CHANNEL_VBAT
  1585. * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
  1586. * Value "1" if the internal channel selected is available on the ADC instance selected.
  1587. */
  1588. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1589. ( \
  1590. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1591. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1592. ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) \
  1593. )
  1594. #if defined (ADC_SUPPORT_2_5_MSPS)
  1595. /**
  1596. * @brief Helper macro to define ADC analog watchdog parameter:
  1597. * define a single channel to monitor with analog watchdog
  1598. * from sequencer channel and groups definition.
  1599. * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
  1600. * Example:
  1601. * LL_ADC_SetAnalogWDMonitChannels(
  1602. * ADC1, LL_ADC_AWD1,
  1603. * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
  1604. * @param __CHANNEL__ This parameter can be one of the following values:
  1605. * @arg @ref LL_ADC_CHANNEL_0
  1606. * @arg @ref LL_ADC_CHANNEL_1 (7)
  1607. * @arg @ref LL_ADC_CHANNEL_2 (7)
  1608. * @arg @ref LL_ADC_CHANNEL_3 (7)
  1609. * @arg @ref LL_ADC_CHANNEL_4 (7)
  1610. * @arg @ref LL_ADC_CHANNEL_5 (7)
  1611. * @arg @ref LL_ADC_CHANNEL_6
  1612. * @arg @ref LL_ADC_CHANNEL_7
  1613. * @arg @ref LL_ADC_CHANNEL_8
  1614. * @arg @ref LL_ADC_CHANNEL_9
  1615. * @arg @ref LL_ADC_CHANNEL_10
  1616. * @arg @ref LL_ADC_CHANNEL_11
  1617. * @arg @ref LL_ADC_CHANNEL_12
  1618. * @arg @ref LL_ADC_CHANNEL_13
  1619. * @arg @ref LL_ADC_CHANNEL_14
  1620. * @arg @ref LL_ADC_CHANNEL_15
  1621. * @arg @ref LL_ADC_CHANNEL_16
  1622. * @arg @ref LL_ADC_CHANNEL_17
  1623. * @arg @ref LL_ADC_CHANNEL_18
  1624. * @arg @ref LL_ADC_CHANNEL_VREFINT (4)
  1625. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  1626. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  1627. *
  1628. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  1629. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).\n
  1630. * (4) For ADC channel read back from ADC register,
  1631. * comparison with internal channel parameter to be done
  1632. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1633. * @param __GROUP__ This parameter can be one of the following values:
  1634. * @arg @ref LL_ADC_GROUP_REGULAR
  1635. * @retval Returned value can be one of the following values:
  1636. * @arg @ref LL_ADC_AWD_DISABLE
  1637. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0)
  1638. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0)
  1639. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0)
  1640. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0)
  1641. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0)
  1642. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0)
  1643. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0)
  1644. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0)
  1645. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0)
  1646. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0)
  1647. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0)
  1648. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0)
  1649. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0)
  1650. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0)
  1651. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0)
  1652. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0)
  1653. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0)
  1654. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0)
  1655. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0)
  1656. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0)
  1657. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (0)
  1658. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (0)
  1659. * @arg @ref LL_ADC_AWD_CH_VBAT_REG (0)
  1660. *
  1661. * (0) On STM32WB, parameter available only on analog watchdog number: AWD1.
  1662. */
  1663. #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \
  1664. (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL)
  1665. #else
  1666. /**
  1667. * @brief Helper macro to define ADC analog watchdog parameter:
  1668. * define a single channel to monitor with analog watchdog
  1669. * from sequencer channel and groups definition.
  1670. * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
  1671. * Example:
  1672. * LL_ADC_SetAnalogWDMonitChannels(
  1673. * ADC1, LL_ADC_AWD1,
  1674. * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
  1675. * @param __CHANNEL__ This parameter can be one of the following values:
  1676. * @arg @ref LL_ADC_CHANNEL_0
  1677. * @arg @ref LL_ADC_CHANNEL_1 (7)
  1678. * @arg @ref LL_ADC_CHANNEL_2 (7)
  1679. * @arg @ref LL_ADC_CHANNEL_3 (7)
  1680. * @arg @ref LL_ADC_CHANNEL_4 (7)
  1681. * @arg @ref LL_ADC_CHANNEL_5 (7)
  1682. * @arg @ref LL_ADC_CHANNEL_6
  1683. * @arg @ref LL_ADC_CHANNEL_7
  1684. * @arg @ref LL_ADC_CHANNEL_8
  1685. * @arg @ref LL_ADC_CHANNEL_9
  1686. * @arg @ref LL_ADC_CHANNEL_10
  1687. * @arg @ref LL_ADC_CHANNEL_11
  1688. * @arg @ref LL_ADC_CHANNEL_12
  1689. * @arg @ref LL_ADC_CHANNEL_13
  1690. * @arg @ref LL_ADC_CHANNEL_14
  1691. * @arg @ref LL_ADC_CHANNEL_15
  1692. * @arg @ref LL_ADC_CHANNEL_16
  1693. * @arg @ref LL_ADC_CHANNEL_17
  1694. * @arg @ref LL_ADC_CHANNEL_18
  1695. * @arg @ref LL_ADC_CHANNEL_VREFINT (4)
  1696. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  1697. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  1698. *
  1699. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  1700. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).\n
  1701. * (4) For ADC channel read back from ADC register,
  1702. * comparison with internal channel parameter to be done
  1703. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1704. * @param __GROUP__ This parameter can be one of the following values:
  1705. * @arg @ref LL_ADC_GROUP_REGULAR
  1706. * @arg @ref LL_ADC_GROUP_INJECTED
  1707. * @arg @ref LL_ADC_GROUP_REGULAR_INJECTED
  1708. * @retval Returned value can be one of the following values:
  1709. * @arg @ref LL_ADC_AWD_DISABLE
  1710. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0)
  1711. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0)(1)
  1712. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ (1)
  1713. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0)
  1714. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0)(1)
  1715. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ (1)
  1716. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0)
  1717. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0)(1)
  1718. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ (1)
  1719. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0)
  1720. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0)(1)
  1721. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ (1)
  1722. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0)
  1723. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0)(1)
  1724. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ (1)
  1725. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0)
  1726. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0)(1)
  1727. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ (1)
  1728. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0)
  1729. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0)(1)
  1730. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ (1)
  1731. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0)
  1732. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0)(1)
  1733. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ (1)
  1734. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0)
  1735. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0)(1)
  1736. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ (1)
  1737. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0)
  1738. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0)(1)
  1739. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ (1)
  1740. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0)
  1741. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0)(1)
  1742. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ (1)
  1743. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0)
  1744. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0)(1)
  1745. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ (1)
  1746. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0)
  1747. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0)(1)
  1748. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ (1)
  1749. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0)
  1750. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0)(1)
  1751. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ (1)
  1752. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0)
  1753. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0)(1)
  1754. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ (1)
  1755. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0)
  1756. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0)(1)
  1757. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ (1)
  1758. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0)
  1759. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0)(1)
  1760. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ (1)
  1761. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0)
  1762. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0)(1)
  1763. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ (1)
  1764. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0)
  1765. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0)(1)
  1766. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ (1)
  1767. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0)
  1768. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0)(1)
  1769. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ (1)
  1770. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (0)
  1771. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (0)(1)
  1772. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1)
  1773. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (0)
  1774. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (0)(1)
  1775. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)
  1776. * @arg @ref LL_ADC_AWD_CH_VBAT_REG (0)
  1777. * @arg @ref LL_ADC_AWD_CH_VBAT_INJ (0)(1)
  1778. * @arg @ref LL_ADC_AWD_CH_VBAT_REG_INJ (1)
  1779. *
  1780. * (0) On STM32WB, parameter available only on analog watchdog number: AWD1.
  1781. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  1782. */
  1783. #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \
  1784. (((__GROUP__) == LL_ADC_GROUP_REGULAR) \
  1785. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) \
  1786. : \
  1787. ((__GROUP__) == LL_ADC_GROUP_INJECTED) \
  1788. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) \
  1789. : \
  1790. (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) \
  1791. )
  1792. #endif
  1793. /**
  1794. * @brief Helper macro to set the value of ADC analog watchdog threshold high
  1795. * or low in function of ADC resolution, when ADC resolution is
  1796. * different of 12 bits.
  1797. * @note To be used with function @ref LL_ADC_ConfigAnalogWDThresholds()
  1798. * or @ref LL_ADC_SetAnalogWDThresholds().
  1799. * Example, with a ADC resolution of 8 bits, to set the value of
  1800. * analog watchdog threshold high (on 8 bits):
  1801. * LL_ADC_SetAnalogWDThresholds
  1802. * (< ADCx param >,
  1803. * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
  1804. * );
  1805. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1806. * @arg @ref LL_ADC_RESOLUTION_12B
  1807. * @arg @ref LL_ADC_RESOLUTION_10B
  1808. * @arg @ref LL_ADC_RESOLUTION_8B
  1809. * @arg @ref LL_ADC_RESOLUTION_6B
  1810. * @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1811. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1812. */
  1813. #define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
  1814. ((__AWD_THRESHOLD__) << ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U )))
  1815. /**
  1816. * @brief Helper macro to get the value of ADC analog watchdog threshold high
  1817. * or low in function of ADC resolution, when ADC resolution is
  1818. * different of 12 bits.
  1819. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  1820. * Example, with a ADC resolution of 8 bits, to get the value of
  1821. * analog watchdog threshold high (on 8 bits):
  1822. * < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
  1823. * (LL_ADC_RESOLUTION_8B,
  1824. * LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
  1825. * );
  1826. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1827. * @arg @ref LL_ADC_RESOLUTION_12B
  1828. * @arg @ref LL_ADC_RESOLUTION_10B
  1829. * @arg @ref LL_ADC_RESOLUTION_8B
  1830. * @arg @ref LL_ADC_RESOLUTION_6B
  1831. * @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1832. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1833. */
  1834. #define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
  1835. ((__AWD_THRESHOLD_12_BITS__) >> ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U )))
  1836. /**
  1837. * @brief Helper macro to get the ADC analog watchdog threshold high
  1838. * or low from raw value containing both thresholds concatenated.
  1839. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  1840. * Example, to get analog watchdog threshold high from the register raw value:
  1841. * __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(LL_ADC_AWD_THRESHOLD_HIGH, <raw_value_with_both_thresholds>);
  1842. * @param __AWD_THRESHOLD_TYPE__ This parameter can be one of the following values:
  1843. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  1844. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  1845. * @param __AWD_THRESHOLDS__ Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  1846. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1847. */
  1848. #define __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(__AWD_THRESHOLD_TYPE__, __AWD_THRESHOLDS__) \
  1849. (((__AWD_THRESHOLDS__) >> (((__AWD_THRESHOLD_TYPE__) & ADC_AWD_TRX_BIT_HIGH_MASK) >> ADC_AWD_TRX_BIT_HIGH_SHIFT4)) & LL_ADC_AWD_THRESHOLD_LOW)
  1850. /**
  1851. * @brief Helper macro to set the ADC calibration value with both single ended
  1852. * and differential modes calibration factors concatenated.
  1853. * @note To be used with function @ref LL_ADC_SetCalibrationFactor().
  1854. * Example, to set calibration factors single ended to 0x55
  1855. * and differential ended to 0x2A:
  1856. * LL_ADC_SetCalibrationFactor(
  1857. * ADC1,
  1858. * __LL_ADC_CALIB_FACTOR_SINGLE_DIFF(0x55, 0x2A))
  1859. * @param __CALIB_FACTOR_SINGLE_ENDED__ Value between Min_Data=0x00 and Max_Data=0x7F
  1860. * @param __CALIB_FACTOR_DIFFERENTIAL__ Value between Min_Data=0x00 and Max_Data=0x7F
  1861. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  1862. */
  1863. #define __LL_ADC_CALIB_FACTOR_SINGLE_DIFF(__CALIB_FACTOR_SINGLE_ENDED__, __CALIB_FACTOR_DIFFERENTIAL__) \
  1864. (((__CALIB_FACTOR_DIFFERENTIAL__) << ADC_CALFACT_CALFACT_D_Pos) | (__CALIB_FACTOR_SINGLE_ENDED__))
  1865. /**
  1866. * @brief Helper macro to select the ADC common instance
  1867. * to which is belonging the selected ADC instance.
  1868. * @note ADC common register instance can be used for:
  1869. * - Set parameters common to several ADC instances
  1870. * - Multimode (for devices with several ADC instances)
  1871. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  1872. * @param __ADCx__ ADC instance
  1873. * @retval ADC common register instance
  1874. */
  1875. #if defined(ADC1) && defined(ADC2) && defined(ADC3)
  1876. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1877. (ADC123_COMMON)
  1878. #elif defined(ADC1) && defined(ADC2)
  1879. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1880. (ADC12_COMMON)
  1881. #else
  1882. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1883. (ADC1_COMMON)
  1884. #endif
  1885. /**
  1886. * @brief Helper macro to check if all ADC instances sharing the same
  1887. * ADC common instance are disabled.
  1888. * @note This check is required by functions with setting conditioned to
  1889. * ADC state:
  1890. * All ADC instances of the ADC common group must be disabled.
  1891. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  1892. * @note On devices with only 1 ADC common instance, parameter of this macro
  1893. * is useless and can be ignored (parameter kept for compatibility
  1894. * with devices featuring several ADC common instances).
  1895. * @param __ADCXY_COMMON__ ADC common instance
  1896. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1897. * @retval Value "0" if all ADC instances sharing the same ADC common instance
  1898. * are disabled.
  1899. * Value "1" if at least one ADC instance sharing the same ADC common instance
  1900. * is enabled.
  1901. */
  1902. #if defined(ADC1) && defined(ADC2) && defined(ADC3)
  1903. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  1904. (LL_ADC_IsEnabled(ADC1) | \
  1905. LL_ADC_IsEnabled(ADC2) | \
  1906. LL_ADC_IsEnabled(ADC3) )
  1907. #elif defined(ADC1) && defined(ADC2)
  1908. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  1909. (LL_ADC_IsEnabled(ADC1) | \
  1910. LL_ADC_IsEnabled(ADC2) )
  1911. #else
  1912. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  1913. (LL_ADC_IsEnabled(ADC1))
  1914. #endif
  1915. /**
  1916. * @brief Helper macro to define the ADC conversion data full-scale digital
  1917. * value corresponding to the selected ADC resolution.
  1918. * @note ADC conversion data full-scale corresponds to voltage range
  1919. * determined by analog voltage references Vref+ and Vref-
  1920. * (refer to reference manual).
  1921. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1922. * @arg @ref LL_ADC_RESOLUTION_12B
  1923. * @arg @ref LL_ADC_RESOLUTION_10B
  1924. * @arg @ref LL_ADC_RESOLUTION_8B
  1925. * @arg @ref LL_ADC_RESOLUTION_6B
  1926. * @retval ADC conversion data full-scale digital value (unit: digital value of ADC conversion data)
  1927. */
  1928. #define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  1929. (0xFFFUL >> ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL)))
  1930. /**
  1931. * @brief Helper macro to convert the ADC conversion data from
  1932. * a resolution to another resolution.
  1933. * @param __DATA__ ADC conversion data to be converted
  1934. * @param __ADC_RESOLUTION_CURRENT__ Resolution of the data to be converted
  1935. * This parameter can be one of the following values:
  1936. * @arg @ref LL_ADC_RESOLUTION_12B
  1937. * @arg @ref LL_ADC_RESOLUTION_10B
  1938. * @arg @ref LL_ADC_RESOLUTION_8B
  1939. * @arg @ref LL_ADC_RESOLUTION_6B
  1940. * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
  1941. * This parameter can be one of the following values:
  1942. * @arg @ref LL_ADC_RESOLUTION_12B
  1943. * @arg @ref LL_ADC_RESOLUTION_10B
  1944. * @arg @ref LL_ADC_RESOLUTION_8B
  1945. * @arg @ref LL_ADC_RESOLUTION_6B
  1946. * @retval ADC conversion data to the requested resolution
  1947. */
  1948. #define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__,\
  1949. __ADC_RESOLUTION_CURRENT__,\
  1950. __ADC_RESOLUTION_TARGET__) \
  1951. (((__DATA__) \
  1952. << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL))) \
  1953. >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL)) \
  1954. )
  1955. /**
  1956. * @brief Helper macro to calculate the voltage (unit: mVolt)
  1957. * corresponding to a ADC conversion data (unit: digital value).
  1958. * @note Analog reference voltage (Vref+) must be either known from
  1959. * user board environment or can be calculated using ADC measurement
  1960. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1961. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  1962. * @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
  1963. * (unit: digital value).
  1964. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1965. * @arg @ref LL_ADC_RESOLUTION_12B
  1966. * @arg @ref LL_ADC_RESOLUTION_10B
  1967. * @arg @ref LL_ADC_RESOLUTION_8B
  1968. * @arg @ref LL_ADC_RESOLUTION_6B
  1969. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  1970. */
  1971. #define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
  1972. __ADC_DATA__,\
  1973. __ADC_RESOLUTION__) \
  1974. ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) \
  1975. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  1976. )
  1977. /**
  1978. * @brief Helper macro to calculate analog reference voltage (Vref+)
  1979. * (unit: mVolt) from ADC conversion data of internal voltage
  1980. * reference VrefInt.
  1981. * @note Computation is using VrefInt calibration value
  1982. * stored in system memory for each device during production.
  1983. * @note This voltage depends on user board environment: voltage level
  1984. * connected to pin Vref+.
  1985. * On devices with small package, the pin Vref+ is not present
  1986. * and internally bonded to pin Vdda.
  1987. * @note On this STM32 serie, calibration data of internal voltage reference
  1988. * VrefInt corresponds to a resolution of 12 bits,
  1989. * this is the recommended ADC resolution to convert voltage of
  1990. * internal voltage reference VrefInt.
  1991. * Otherwise, this macro performs the processing to scale
  1992. * ADC conversion data to 12 bits.
  1993. * @param __VREFINT_ADC_DATA__ ADC conversion data (resolution 12 bits)
  1994. * of internal voltage reference VrefInt (unit: digital value).
  1995. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1996. * @arg @ref LL_ADC_RESOLUTION_12B
  1997. * @arg @ref LL_ADC_RESOLUTION_10B
  1998. * @arg @ref LL_ADC_RESOLUTION_8B
  1999. * @arg @ref LL_ADC_RESOLUTION_6B
  2000. * @retval Analog reference voltage (unit: mV)
  2001. */
  2002. #define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,\
  2003. __ADC_RESOLUTION__) \
  2004. (((uint32_t)(*VREFINT_CAL_ADDR) * VREFINT_CAL_VREF) \
  2005. / __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__), \
  2006. (__ADC_RESOLUTION__), \
  2007. LL_ADC_RESOLUTION_12B))
  2008. /**
  2009. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  2010. * from ADC conversion data of internal temperature sensor.
  2011. * @note Computation is using temperature sensor calibration values
  2012. * stored in system memory for each device during production.
  2013. * @note Calculation formula:
  2014. * Temperature = ((TS_ADC_DATA - TS_CAL1)
  2015. * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
  2016. * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
  2017. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  2018. * Avg_Slope = (TS_CAL2 - TS_CAL1)
  2019. * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
  2020. * TS_CAL1 = equivalent TS_ADC_DATA at temperature
  2021. * TEMP_DEGC_CAL1 (calibrated in factory)
  2022. * TS_CAL2 = equivalent TS_ADC_DATA at temperature
  2023. * TEMP_DEGC_CAL2 (calibrated in factory)
  2024. * Caution: Calculation relevancy under reserve that calibration
  2025. * parameters are correct (address and data).
  2026. * To calculate temperature using temperature sensor
  2027. * datasheet typical values (generic values less, therefore
  2028. * less accurate than calibrated values),
  2029. * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
  2030. * @note As calculation input, the analog reference voltage (Vref+) must be
  2031. * defined as it impacts the ADC LSB equivalent voltage.
  2032. * @note Analog reference voltage (Vref+) must be either known from
  2033. * user board environment or can be calculated using ADC measurement
  2034. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  2035. * @note On this STM32 serie, calibration data of temperature sensor
  2036. * corresponds to a resolution of 12 bits,
  2037. * this is the recommended ADC resolution to convert voltage of
  2038. * temperature sensor.
  2039. * Otherwise, this macro performs the processing to scale
  2040. * ADC conversion data to 12 bits.
  2041. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  2042. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
  2043. * temperature sensor (unit: digital value).
  2044. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
  2045. * sensor voltage has been measured.
  2046. * This parameter can be one of the following values:
  2047. * @arg @ref LL_ADC_RESOLUTION_12B
  2048. * @arg @ref LL_ADC_RESOLUTION_10B
  2049. * @arg @ref LL_ADC_RESOLUTION_8B
  2050. * @arg @ref LL_ADC_RESOLUTION_6B
  2051. * @retval Temperature (unit: degree Celsius)
  2052. */
  2053. #define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
  2054. __TEMPSENSOR_ADC_DATA__,\
  2055. __ADC_RESOLUTION__) \
  2056. (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
  2057. (__ADC_RESOLUTION__), \
  2058. LL_ADC_RESOLUTION_12B) \
  2059. * (__VREFANALOG_VOLTAGE__)) \
  2060. / TEMPSENSOR_CAL_VREFANALOG) \
  2061. - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
  2062. ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
  2063. ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
  2064. ) + TEMPSENSOR_CAL1_TEMP \
  2065. )
  2066. /**
  2067. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  2068. * from ADC conversion data of internal temperature sensor.
  2069. * @note Computation is using temperature sensor typical values
  2070. * (refer to device datasheet).
  2071. * @note Calculation formula:
  2072. * Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV)
  2073. * / Avg_Slope + CALx_TEMP
  2074. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  2075. * (unit: digital value)
  2076. * Avg_Slope = temperature sensor slope
  2077. * (unit: uV/Degree Celsius)
  2078. * TS_TYP_CALx_VOLT = temperature sensor digital value at
  2079. * temperature CALx_TEMP (unit: mV)
  2080. * Caution: Calculation relevancy under reserve the temperature sensor
  2081. * of the current device has characteristics in line with
  2082. * datasheet typical values.
  2083. * If temperature sensor calibration values are available on
  2084. * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
  2085. * temperature calculation will be more accurate using
  2086. * helper macro @ref __LL_ADC_CALC_TEMPERATURE().
  2087. * @note As calculation input, the analog reference voltage (Vref+) must be
  2088. * defined as it impacts the ADC LSB equivalent voltage.
  2089. * @note Analog reference voltage (Vref+) must be either known from
  2090. * user board environment or can be calculated using ADC measurement
  2091. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  2092. * @note ADC measurement data must correspond to a resolution of 12 bits
  2093. * (full scale digital value 4095). If not the case, the data must be
  2094. * preliminarily rescaled to an equivalent resolution of 12 bits.
  2095. * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius).
  2096. * On STM32WB, refer to device datasheet parameter "Avg_Slope".
  2097. * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV).
  2098. * On STM32WB, refer to device datasheet parameter "V30" (corresponding to TS_CAL1).
  2099. * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: mV)
  2100. * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit: mV)
  2101. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value).
  2102. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
  2103. * This parameter can be one of the following values:
  2104. * @arg @ref LL_ADC_RESOLUTION_12B
  2105. * @arg @ref LL_ADC_RESOLUTION_10B
  2106. * @arg @ref LL_ADC_RESOLUTION_8B
  2107. * @arg @ref LL_ADC_RESOLUTION_6B
  2108. * @retval Temperature (unit: degree Celsius)
  2109. */
  2110. #define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
  2111. __TEMPSENSOR_TYP_CALX_V__,\
  2112. __TEMPSENSOR_CALX_TEMP__,\
  2113. __VREFANALOG_VOLTAGE__,\
  2114. __TEMPSENSOR_ADC_DATA__,\
  2115. __ADC_RESOLUTION__) \
  2116. ((( ( \
  2117. (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
  2118. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
  2119. * 1000UL) \
  2120. - \
  2121. (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
  2122. * 1000UL) \
  2123. ) \
  2124. ) / (int32_t)(__TEMPSENSOR_TYP_AVGSLOPE__) \
  2125. ) + (int32_t)(__TEMPSENSOR_CALX_TEMP__) \
  2126. )
  2127. /**
  2128. * @}
  2129. */
  2130. /**
  2131. * @}
  2132. */
  2133. /* Exported functions --------------------------------------------------------*/
  2134. /** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
  2135. * @{
  2136. */
  2137. /** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
  2138. * @{
  2139. */
  2140. /* Note: LL ADC functions to set DMA transfer are located into sections of */
  2141. /* configuration of ADC instance, groups and multimode (if available): */
  2142. /* @ref LL_ADC_REG_SetDMATransfer(), ... */
  2143. /**
  2144. * @brief Function to help to configure DMA transfer from ADC: retrieve the
  2145. * ADC register address from ADC instance and a list of ADC registers
  2146. * intended to be used (most commonly) with DMA transfer.
  2147. * @note These ADC registers are data registers:
  2148. * when ADC conversion data is available in ADC data registers,
  2149. * ADC generates a DMA transfer request.
  2150. * @note This macro is intended to be used with LL DMA driver, refer to
  2151. * function "LL_DMA_ConfigAddresses()".
  2152. * Example:
  2153. * LL_DMA_ConfigAddresses(DMA1,
  2154. * LL_DMA_CHANNEL_1,
  2155. * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
  2156. * (uint32_t)&< array or variable >,
  2157. * LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
  2158. * @note For devices with several ADC: in multimode, some devices
  2159. * use a different data register outside of ADC instance scope
  2160. * (common data register). This macro manages this register difference,
  2161. * only ADC instance has to be set as parameter.
  2162. * @rmtoll DR DATA LL_ADC_DMA_GetRegAddr
  2163. * @param ADCx ADC instance
  2164. * @param Register This parameter can be one of the following values:
  2165. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
  2166. * @retval ADC register address
  2167. */
  2168. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  2169. {
  2170. /* Prevent unused argument(s) compilation warning */
  2171. (void)(Register);
  2172. /* Retrieve address of register DR */
  2173. return (uint32_t)&(ADCx->DR);
  2174. }
  2175. /**
  2176. * @}
  2177. */
  2178. /** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
  2179. * @{
  2180. */
  2181. /**
  2182. * @brief Set parameter common to several ADC: Clock source and prescaler.
  2183. * @note ADC clock source and prescaler must be selected in function of system clock to not exceed ADC maximum frequency, depending on devices.
  2184. * Example: STM32WB55xx ADC maximum frequency is 64MHz (corresponding to 4.27Msmp/s maximum)
  2185. * Example: STM32WB50xx ADC maximum frequency is 32MHz (corresponding to 2.13Msmp/s maximum)
  2186. * For ADC maximum frequency, refer to datasheet of the selected device.
  2187. * @note On this STM32 serie, if ADC group injected is used, some
  2188. * clock ratio constraints between ADC clock and AHB clock
  2189. * must be respected.
  2190. * Refer to reference manual.
  2191. * @note On this STM32 serie, setting of this feature is conditioned to
  2192. * ADC state:
  2193. * All ADC instances of the ADC common group must be disabled.
  2194. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  2195. * ADC instance or by using helper macro helper macro
  2196. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  2197. * @rmtoll CCR CKMODE LL_ADC_SetCommonClock\n
  2198. * CCR PRESC LL_ADC_SetCommonClock
  2199. * @param ADCxy_COMMON ADC common instance
  2200. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2201. * @param CommonClock This parameter can be one of the following values:
  2202. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1 (*)
  2203. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2 (*)
  2204. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4 (*)
  2205. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
  2206. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2
  2207. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4
  2208. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV6
  2209. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV8
  2210. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV10
  2211. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV12
  2212. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV16
  2213. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV32
  2214. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV64
  2215. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV128
  2216. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV256
  2217. *
  2218. * (*) Value available on all STM32 devices except: STM32W10xxx, STM32W15xxx.
  2219. * @retval None
  2220. */
  2221. __STATIC_INLINE void LL_ADC_SetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t CommonClock)
  2222. {
  2223. #if defined (ADC_SUPPORT_2_5_MSPS)
  2224. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_PRESC, CommonClock);
  2225. #else
  2226. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_CKMODE | ADC_CCR_PRESC, CommonClock);
  2227. #endif
  2228. }
  2229. /**
  2230. * @brief Get parameter common to several ADC: Clock source and prescaler.
  2231. * @rmtoll CCR CKMODE LL_ADC_GetCommonClock\n
  2232. * CCR PRESC LL_ADC_GetCommonClock
  2233. * @param ADCxy_COMMON ADC common instance
  2234. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2235. * @retval Returned value can be one of the following values:
  2236. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1 (*)
  2237. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2 (*)
  2238. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4 (*)
  2239. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
  2240. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2
  2241. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4
  2242. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV6
  2243. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV8
  2244. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV10
  2245. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV12
  2246. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV16
  2247. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV32
  2248. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV64
  2249. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV128
  2250. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV256
  2251. *
  2252. * (*) Value available on all STM32 devices except: STM32W10xxx, STM32W15xxx.
  2253. */
  2254. __STATIC_INLINE uint32_t LL_ADC_GetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON)
  2255. {
  2256. #if defined (ADC_SUPPORT_2_5_MSPS)
  2257. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_PRESC));
  2258. #else
  2259. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_CKMODE | ADC_CCR_PRESC));
  2260. #endif
  2261. }
  2262. /**
  2263. * @brief Set parameter common to several ADC: measurement path to
  2264. * internal channels (VrefInt, temperature sensor, ...).
  2265. * Configure all paths (overwrite current configuration).
  2266. * @note One or several values can be selected.
  2267. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  2268. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  2269. * The values not selected are removed from configuration.
  2270. * @note Stabilization time of measurement path to internal channel:
  2271. * After enabling internal paths, before starting ADC conversion,
  2272. * a delay is required for internal voltage reference and
  2273. * temperature sensor stabilization time.
  2274. * Refer to device datasheet.
  2275. * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
  2276. * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
  2277. * @note ADC internal channel sampling time constraint:
  2278. * For ADC conversion of internal channels,
  2279. * a sampling time minimum value is required.
  2280. * Refer to device datasheet.
  2281. * @note On this STM32 serie, setting of this feature is conditioned to
  2282. * ADC state:
  2283. * All ADC instances of the ADC common group must be disabled.
  2284. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  2285. * ADC instance or by using helper macro helper macro
  2286. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  2287. * @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalCh\n
  2288. * CCR TSEN LL_ADC_SetCommonPathInternalCh\n
  2289. * CCR VBATEN LL_ADC_SetCommonPathInternalCh
  2290. * @param ADCxy_COMMON ADC common instance
  2291. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2292. * @param PathInternal This parameter can be a combination of the following values:
  2293. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  2294. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  2295. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  2296. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  2297. * @retval None
  2298. */
  2299. __STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  2300. {
  2301. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN | ADC_CCR_VBATEN, PathInternal);
  2302. }
  2303. /**
  2304. * @brief Set parameter common to several ADC: measurement path to
  2305. * internal channels (VrefInt, temperature sensor, ...).
  2306. * Add paths to the current configuration.
  2307. * @note One or several values can be selected.
  2308. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  2309. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  2310. * @note Stabilization time of measurement path to internal channel:
  2311. * After enabling internal paths, before starting ADC conversion,
  2312. * a delay is required for internal voltage reference and
  2313. * temperature sensor stabilization time.
  2314. * Refer to device datasheet.
  2315. * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
  2316. * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
  2317. * @note ADC internal channel sampling time constraint:
  2318. * For ADC conversion of internal channels,
  2319. * a sampling time minimum value is required.
  2320. * Refer to device datasheet.
  2321. * @note On this STM32 serie, setting of this feature is conditioned to
  2322. * ADC state:
  2323. * All ADC instances of the ADC common group must be disabled.
  2324. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  2325. * ADC instance or by using helper macro helper macro
  2326. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  2327. * @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalChAdd\n
  2328. * CCR TSEN LL_ADC_SetCommonPathInternalChAdd\n
  2329. * CCR VBATEN LL_ADC_SetCommonPathInternalChAdd
  2330. * @param ADCxy_COMMON ADC common instance
  2331. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2332. * @param PathInternal This parameter can be a combination of the following values:
  2333. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  2334. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  2335. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  2336. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  2337. * @retval None
  2338. */
  2339. __STATIC_INLINE void LL_ADC_SetCommonPathInternalChAdd(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  2340. {
  2341. SET_BIT(ADCxy_COMMON->CCR, PathInternal);
  2342. }
  2343. /**
  2344. * @brief Set parameter common to several ADC: measurement path to
  2345. * internal channels (VrefInt, temperature sensor, ...).
  2346. * Remove paths to the current configuration.
  2347. * @note One or several values can be selected.
  2348. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  2349. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  2350. * @note On this STM32 serie, setting of this feature is conditioned to
  2351. * ADC state:
  2352. * All ADC instances of the ADC common group must be disabled.
  2353. * This check can be done with function @ref LL_ADC_IsEnabled() for each
  2354. * ADC instance or by using helper macro helper macro
  2355. * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
  2356. * @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalChRem\n
  2357. * CCR TSEN LL_ADC_SetCommonPathInternalChRem\n
  2358. * CCR VBATEN LL_ADC_SetCommonPathInternalChRem
  2359. * @param ADCxy_COMMON ADC common instance
  2360. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2361. * @param PathInternal This parameter can be a combination of the following values:
  2362. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  2363. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  2364. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  2365. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  2366. * @retval None
  2367. */
  2368. __STATIC_INLINE void LL_ADC_SetCommonPathInternalChRem(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  2369. {
  2370. CLEAR_BIT(ADCxy_COMMON->CCR, PathInternal);
  2371. }
  2372. /**
  2373. * @brief Get parameter common to several ADC: measurement path to internal
  2374. * channels (VrefInt, temperature sensor, ...).
  2375. * @note One or several values can be selected.
  2376. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  2377. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  2378. * @rmtoll CCR VREFEN LL_ADC_GetCommonPathInternalCh\n
  2379. * CCR TSEN LL_ADC_GetCommonPathInternalCh\n
  2380. * CCR VBATEN LL_ADC_GetCommonPathInternalCh
  2381. * @param ADCxy_COMMON ADC common instance
  2382. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2383. * @retval Returned value can be a combination of the following values:
  2384. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  2385. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  2386. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  2387. * @arg @ref LL_ADC_PATH_INTERNAL_VBAT
  2388. */
  2389. __STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
  2390. {
  2391. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN | ADC_CCR_VBATEN));
  2392. }
  2393. /**
  2394. * @}
  2395. */
  2396. /** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
  2397. * @{
  2398. */
  2399. #if defined (ADC_SUPPORT_2_5_MSPS)
  2400. /**
  2401. * @brief Set ADC instance clock source and prescaler.
  2402. * @note On this STM32 serie, setting of this feature is conditioned to
  2403. * ADC state:
  2404. * ADC must be disabled.
  2405. * @rmtoll CFGR2 CKMODE LL_ADC_SetClock
  2406. * @param ADCx ADC instance
  2407. * @param ClockSource This parameter can be one of the following values:
  2408. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
  2409. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
  2410. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1 (2)
  2411. * @arg @ref LL_ADC_CLOCK_ASYNC (1)
  2412. *
  2413. * (1) Asynchronous clock prescaler can be configured using
  2414. * function @ref LL_ADC_SetCommonClock().\n
  2415. * (2) Caution: This parameter has some clock ratio constraints:
  2416. * This configuration must be enabled only if PCLK has a 50%
  2417. * duty clock cycle (APB prescaler configured inside the RCC
  2418. * must be bypassed and the system clock must by 50% duty
  2419. * cycle).
  2420. * Refer to reference manual.
  2421. * @retval None
  2422. */
  2423. __STATIC_INLINE void LL_ADC_SetClock(ADC_TypeDef *ADCx, uint32_t ClockSource)
  2424. {
  2425. MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_CKMODE, ClockSource);
  2426. }
  2427. /**
  2428. * @brief Get ADC instance clock source and prescaler.
  2429. * @rmtoll CFGR2 CKMODE LL_ADC_GetClock
  2430. * @param ADCx ADC instance
  2431. * @retval Returned value can be one of the following values:
  2432. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
  2433. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
  2434. * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1 (2)
  2435. * @arg @ref LL_ADC_CLOCK_ASYNC (1)
  2436. *
  2437. * (1) Asynchronous clock prescaler can be retrieved using
  2438. * function @ref LL_ADC_GetCommonClock().\n
  2439. * (2) Caution: This parameter has some clock ratio constraints:
  2440. * This configuration must be enabled only if PCLK has a 50%
  2441. * duty clock cycle (APB prescaler configured inside the RCC
  2442. * must be bypassed and the system clock must by 50% duty
  2443. * cycle).
  2444. * Refer to reference manual.
  2445. */
  2446. __STATIC_INLINE uint32_t LL_ADC_GetClock(ADC_TypeDef *ADCx)
  2447. {
  2448. return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_CKMODE));
  2449. }
  2450. #endif
  2451. #if defined (ADC_SUPPORT_2_5_MSPS)
  2452. /**
  2453. * @brief Set ADC calibration factor in the mode single-ended
  2454. * or differential (for devices with differential mode available).
  2455. * @note This function is intended to set calibration parameters
  2456. * without having to perform a new calibration using
  2457. * @ref LL_ADC_StartCalibration().
  2458. * @note For devices with differential mode available:
  2459. * Calibration of offset is specific to each of
  2460. * single-ended and differential modes
  2461. * (calibration factor must be specified for each of these
  2462. * differential modes, if used afterwards and if the application
  2463. * requires their calibration).
  2464. * @note In case of setting calibration factors of both modes single ended
  2465. * and differential (parameter LL_ADC_BOTH_SINGLE_DIFF_ENDED):
  2466. * both calibration factors must be concatenated.
  2467. * To perform this processing, use helper macro
  2468. * @ref __LL_ADC_CALIB_FACTOR_SINGLE_DIFF().
  2469. * @note On this STM32 serie, setting of this feature is conditioned to
  2470. * ADC state:
  2471. * ADC must be enabled, without calibration on going, without conversion
  2472. * on going on group regular.
  2473. * @rmtoll CALFACT CALFACT_S LL_ADC_SetCalibrationFactor\n
  2474. * CALFACT CALFACT_D LL_ADC_SetCalibrationFactor
  2475. * @param ADCx ADC instance
  2476. * @param CalibrationFactor Value between Min_Data=0x00 and Max_Data=0x7F
  2477. * @retval None
  2478. */
  2479. __STATIC_INLINE void LL_ADC_SetCalibrationFactor(ADC_TypeDef *ADCx, uint32_t CalibrationFactor)
  2480. {
  2481. MODIFY_REG(ADCx->CALFACT,
  2482. ADC_CALFACT_CALFACT,
  2483. CalibrationFactor);
  2484. }
  2485. #else
  2486. /**
  2487. * @brief Set ADC calibration factor in the mode single-ended
  2488. * or differential (for devices with differential mode available).
  2489. * @note This function is intended to set calibration parameters
  2490. * without having to perform a new calibration using
  2491. * @ref LL_ADC_StartCalibration().
  2492. * @note For devices with differential mode available:
  2493. * Calibration of offset is specific to each of
  2494. * single-ended and differential modes
  2495. * (calibration factor must be specified for each of these
  2496. * differential modes, if used afterwards and if the application
  2497. * requires their calibration).
  2498. * @note In case of setting calibration factors of both modes single ended
  2499. * and differential (parameter LL_ADC_BOTH_SINGLE_DIFF_ENDED):
  2500. * both calibration factors must be concatenated.
  2501. * To perform this processing, use helper macro
  2502. * @ref __LL_ADC_CALIB_FACTOR_SINGLE_DIFF().
  2503. * @note On this STM32 serie, setting of this feature is conditioned to
  2504. * ADC state:
  2505. * ADC must be enabled, without calibration on going, without conversion
  2506. * on going on group regular.
  2507. * @rmtoll CALFACT CALFACT_S LL_ADC_SetCalibrationFactor\n
  2508. * CALFACT CALFACT_D LL_ADC_SetCalibrationFactor
  2509. * @param ADCx ADC instance
  2510. * @param SingleDiff This parameter can be one of the following values:
  2511. * @arg @ref LL_ADC_SINGLE_ENDED
  2512. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED (1)
  2513. * @arg @ref LL_ADC_BOTH_SINGLE_DIFF_ENDED (1)
  2514. *
  2515. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  2516. * @param CalibrationFactor Value between Min_Data=0x00 and Max_Data=0x7F
  2517. * @retval None
  2518. */
  2519. __STATIC_INLINE void LL_ADC_SetCalibrationFactor(ADC_TypeDef *ADCx, uint32_t SingleDiff, uint32_t CalibrationFactor)
  2520. {
  2521. MODIFY_REG(ADCx->CALFACT,
  2522. SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK,
  2523. CalibrationFactor << (((SingleDiff & ADC_SINGLEDIFF_CALIB_F_BIT_D_MASK) >> ADC_SINGLEDIFF_CALIB_F_BIT_D_SHIFT4) & ~(SingleDiff & ADC_CALFACT_CALFACT_S)));
  2524. }
  2525. #endif /* ADC_SUPPORT_2_5_MSPS */
  2526. #if defined (ADC_SUPPORT_2_5_MSPS)
  2527. /**
  2528. * @brief Get ADC calibration factor in the mode single-ended
  2529. * or differential (for devices with differential mode available).
  2530. * @note Calibration factors are set by hardware after performing
  2531. * a calibration run using function @ref LL_ADC_StartCalibration().
  2532. * @note For devices with differential mode available:
  2533. * Calibration of offset is specific to each of
  2534. * single-ended and differential modes
  2535. * @rmtoll CALFACT CALFACT_S LL_ADC_GetCalibrationFactor\n
  2536. * CALFACT CALFACT_D LL_ADC_GetCalibrationFactor
  2537. * @param ADCx ADC instance
  2538. * @retval Value between Min_Data=0x00 and Max_Data=0x7F
  2539. */
  2540. __STATIC_INLINE uint32_t LL_ADC_GetCalibrationFactor(ADC_TypeDef *ADCx)
  2541. {
  2542. return (uint32_t)(READ_BIT(ADCx->CALFACT, ADC_CALFACT_CALFACT));
  2543. }
  2544. #else
  2545. /**
  2546. * @brief Get ADC calibration factor in the mode single-ended
  2547. * or differential (for devices with differential mode available).
  2548. * @note Calibration factors are set by hardware after performing
  2549. * a calibration run using function @ref LL_ADC_StartCalibration().
  2550. * @note For devices with differential mode available:
  2551. * Calibration of offset is specific to each of
  2552. * single-ended and differential modes
  2553. * @rmtoll CALFACT CALFACT_S LL_ADC_GetCalibrationFactor\n
  2554. * CALFACT CALFACT_D LL_ADC_GetCalibrationFactor
  2555. * @param ADCx ADC instance
  2556. * @param SingleDiff This parameter can be one of the following values:
  2557. * @arg @ref LL_ADC_SINGLE_ENDED
  2558. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  2559. * @retval Value between Min_Data=0x00 and Max_Data=0x7F
  2560. */
  2561. __STATIC_INLINE uint32_t LL_ADC_GetCalibrationFactor(ADC_TypeDef *ADCx, uint32_t SingleDiff)
  2562. {
  2563. /* Retrieve bits with position in register depending on parameter */
  2564. /* "SingleDiff". */
  2565. /* Parameter used with mask "ADC_SINGLEDIFF_CALIB_FACTOR_MASK" because */
  2566. /* containing other bits reserved for other purpose. */
  2567. return (uint32_t)(READ_BIT(ADCx->CALFACT, (SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK)) >> ((SingleDiff & ADC_SINGLEDIFF_CALIB_F_BIT_D_MASK) >> ADC_SINGLEDIFF_CALIB_F_BIT_D_SHIFT4));
  2568. }
  2569. #endif /* ADC_SUPPORT_2_5_MSPS */
  2570. /**
  2571. * @brief Set ADC resolution.
  2572. * Refer to reference manual for alignments formats
  2573. * dependencies to ADC resolutions.
  2574. * @note On this STM32 serie, setting of this feature is conditioned to
  2575. * ADC state:
  2576. * ADC must be disabled or enabled without conversion on going
  2577. * on either groups regular or injected.
  2578. * @rmtoll CFGR RES LL_ADC_SetResolution
  2579. * @param ADCx ADC instance
  2580. * @param Resolution This parameter can be one of the following values:
  2581. * @arg @ref LL_ADC_RESOLUTION_12B
  2582. * @arg @ref LL_ADC_RESOLUTION_10B
  2583. * @arg @ref LL_ADC_RESOLUTION_8B
  2584. * @arg @ref LL_ADC_RESOLUTION_6B
  2585. * @retval None
  2586. */
  2587. __STATIC_INLINE void LL_ADC_SetResolution(ADC_TypeDef *ADCx, uint32_t Resolution)
  2588. {
  2589. #if defined (ADC_SUPPORT_2_5_MSPS)
  2590. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_RES, Resolution);
  2591. #else
  2592. MODIFY_REG(ADCx->CFGR, ADC_CFGR_RES, Resolution);
  2593. #endif
  2594. }
  2595. /**
  2596. * @brief Get ADC resolution.
  2597. * Refer to reference manual for alignments formats
  2598. * dependencies to ADC resolutions.
  2599. * @rmtoll CFGR RES LL_ADC_GetResolution
  2600. * @param ADCx ADC instance
  2601. * @retval Returned value can be one of the following values:
  2602. * @arg @ref LL_ADC_RESOLUTION_12B
  2603. * @arg @ref LL_ADC_RESOLUTION_10B
  2604. * @arg @ref LL_ADC_RESOLUTION_8B
  2605. * @arg @ref LL_ADC_RESOLUTION_6B
  2606. */
  2607. __STATIC_INLINE uint32_t LL_ADC_GetResolution(ADC_TypeDef *ADCx)
  2608. {
  2609. #if defined (ADC_SUPPORT_2_5_MSPS)
  2610. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_RES));
  2611. #else
  2612. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_RES));
  2613. #endif
  2614. }
  2615. /**
  2616. * @brief Set ADC conversion data alignment.
  2617. * @note Refer to reference manual for alignments formats
  2618. * dependencies to ADC resolutions.
  2619. * @note On this STM32 serie, setting of this feature is conditioned to
  2620. * ADC state:
  2621. * ADC must be disabled or enabled without conversion on going
  2622. * on either groups regular or injected.
  2623. * @rmtoll CFGR ALIGN LL_ADC_SetDataAlignment
  2624. * @param ADCx ADC instance
  2625. * @param DataAlignment This parameter can be one of the following values:
  2626. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  2627. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  2628. * @retval None
  2629. */
  2630. __STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
  2631. {
  2632. #if defined (ADC_SUPPORT_2_5_MSPS)
  2633. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_ALIGN, DataAlignment);
  2634. #else
  2635. MODIFY_REG(ADCx->CFGR, ADC_CFGR_ALIGN, DataAlignment);
  2636. #endif
  2637. }
  2638. /**
  2639. * @brief Get ADC conversion data alignment.
  2640. * @note Refer to reference manual for alignments formats
  2641. * dependencies to ADC resolutions.
  2642. * @rmtoll CFGR ALIGN LL_ADC_GetDataAlignment
  2643. * @param ADCx ADC instance
  2644. * @retval Returned value can be one of the following values:
  2645. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  2646. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  2647. */
  2648. __STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
  2649. {
  2650. #if defined (ADC_SUPPORT_2_5_MSPS)
  2651. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_ALIGN));
  2652. #else
  2653. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_ALIGN));
  2654. #endif
  2655. }
  2656. /**
  2657. * @brief Set ADC low power mode.
  2658. * @note Description of ADC low power modes:
  2659. * - ADC low power mode "auto wait": Dynamic low power mode,
  2660. * ADC conversions occurrences are limited to the minimum necessary
  2661. * in order to reduce power consumption.
  2662. * New ADC conversion starts only when the previous
  2663. * unitary conversion data (for ADC group regular)
  2664. * or previous sequence conversions data (for ADC group injected)
  2665. * has been retrieved by user software.
  2666. * In the meantime, ADC remains idle: does not performs any
  2667. * other conversion.
  2668. * This mode allows to automatically adapt the ADC conversions
  2669. * triggers to the speed of the software that reads the data.
  2670. * Moreover, this avoids risk of overrun for low frequency
  2671. * applications.
  2672. * How to use this low power mode:
  2673. * - It is not recommended to use with interruption or DMA
  2674. * since these modes have to clear immediately the EOC flag
  2675. * (by CPU to free the IRQ pending event or by DMA).
  2676. * Auto wait will work but fort a very short time, discarding
  2677. * its intended benefit (except specific case of high load of CPU
  2678. * or DMA transfers which can justify usage of auto wait).
  2679. * - Do use with polling: 1. Start conversion,
  2680. * 2. Later on, when conversion data is needed: poll for end of
  2681. * conversion to ensure that conversion is completed and
  2682. * retrieve ADC conversion data. This will trig another
  2683. * ADC conversion start.
  2684. * - ADC low power mode "auto power-off" (feature available on
  2685. * this device if parameter LL_ADC_LP_AUTOPOWEROFF is available):
  2686. * the ADC automatically powers-off after a conversion and
  2687. * automatically wakes up when a new conversion is triggered
  2688. * (with startup time between trigger and start of sampling).
  2689. * This feature can be combined with low power mode "auto wait".
  2690. * @note With ADC low power mode "auto wait", the ADC conversion data read
  2691. * is corresponding to previous ADC conversion start, independently
  2692. * of delay during which ADC was idle.
  2693. * Therefore, the ADC conversion data may be outdated: does not
  2694. * correspond to the current voltage level on the selected
  2695. * ADC channel.
  2696. * @note On this STM32 serie, setting of this feature is conditioned to
  2697. * ADC state:
  2698. * ADC must be disabled or enabled without conversion on going
  2699. * on either groups regular or injected.
  2700. * @rmtoll CFGR AUTDLY LL_ADC_SetLowPowerMode
  2701. * @param ADCx ADC instance
  2702. * @param LowPowerMode This parameter can be one of the following values:
  2703. * @arg @ref LL_ADC_LP_MODE_NONE
  2704. * @arg @ref LL_ADC_LP_AUTOWAIT
  2705. * @arg @ref LL_ADC_LP_AUTOPOWEROFF (1)
  2706. * @arg @ref LL_ADC_LP_AUTOWAIT_AUTOPOWEROFF (1)
  2707. *
  2708. * (1) On STM32WB serie, parameter available only on devices: STM32WB10xx, STM32WB15xx.
  2709. * @retval None
  2710. */
  2711. __STATIC_INLINE void LL_ADC_SetLowPowerMode(ADC_TypeDef *ADCx, uint32_t LowPowerMode)
  2712. {
  2713. #if defined (ADC_SUPPORT_2_5_MSPS)
  2714. MODIFY_REG(ADCx->CFGR1, (ADC_CFGR1_WAIT | ADC_CFGR1_AUTOFF), LowPowerMode);
  2715. #else
  2716. MODIFY_REG(ADCx->CFGR, ADC_CFGR_AUTDLY, LowPowerMode);
  2717. #endif
  2718. }
  2719. /**
  2720. * @brief Get ADC low power mode:
  2721. * @note Description of ADC low power modes:
  2722. * - ADC low power mode "auto wait": Dynamic low power mode,
  2723. * ADC conversions occurrences are limited to the minimum necessary
  2724. * in order to reduce power consumption.
  2725. * New ADC conversion starts only when the previous
  2726. * unitary conversion data (for ADC group regular)
  2727. * or previous sequence conversions data (for ADC group injected)
  2728. * has been retrieved by user software.
  2729. * In the meantime, ADC remains idle: does not performs any
  2730. * other conversion.
  2731. * This mode allows to automatically adapt the ADC conversions
  2732. * triggers to the speed of the software that reads the data.
  2733. * Moreover, this avoids risk of overrun for low frequency
  2734. * applications.
  2735. * How to use this low power mode:
  2736. * - It is not recommended to use with interruption or DMA
  2737. * since these modes have to clear immediately the EOC flag
  2738. * (by CPU to free the IRQ pending event or by DMA).
  2739. * Auto wait will work but fort a very short time, discarding
  2740. * its intended benefit (except specific case of high load of CPU
  2741. * or DMA transfers which can justify usage of auto wait).
  2742. * - Do use with polling: 1. Start conversion,
  2743. * 2. Later on, when conversion data is needed: poll for end of
  2744. * conversion to ensure that conversion is completed and
  2745. * retrieve ADC conversion data. This will trig another
  2746. * ADC conversion start.
  2747. * - ADC low power mode "auto power-off" (feature available on
  2748. * this device if parameter LL_ADC_LP_AUTOPOWEROFF is available):
  2749. * the ADC automatically powers-off after a conversion and
  2750. * automatically wakes up when a new conversion is triggered
  2751. * (with startup time between trigger and start of sampling).
  2752. * This feature can be combined with low power mode "auto wait".
  2753. * @note With ADC low power mode "auto wait", the ADC conversion data read
  2754. * is corresponding to previous ADC conversion start, independently
  2755. * of delay during which ADC was idle.
  2756. * Therefore, the ADC conversion data may be outdated: does not
  2757. * correspond to the current voltage level on the selected
  2758. * ADC channel.
  2759. * @rmtoll CFGR AUTDLY LL_ADC_GetLowPowerMode
  2760. * @param ADCx ADC instance
  2761. * @retval Returned value can be one of the following values:
  2762. * @arg @ref LL_ADC_LP_MODE_NONE
  2763. * @arg @ref LL_ADC_LP_AUTOWAIT
  2764. * @arg @ref LL_ADC_LP_AUTOPOWEROFF (1)
  2765. * @arg @ref LL_ADC_LP_AUTOWAIT_AUTOPOWEROFF (1)
  2766. *
  2767. * (1) On STM32WB serie, parameter available only on devices: STM32WB10xx, STM32WB15xx.
  2768. */
  2769. __STATIC_INLINE uint32_t LL_ADC_GetLowPowerMode(ADC_TypeDef *ADCx)
  2770. {
  2771. #if defined (ADC_SUPPORT_2_5_MSPS)
  2772. return (uint32_t)(READ_BIT(ADCx->CFGR1, (ADC_CFGR1_WAIT | ADC_CFGR1_AUTOFF)));
  2773. #else
  2774. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_AUTDLY));
  2775. #endif
  2776. }
  2777. #if defined(ADC_SUPPORT_2_5_MSPS)
  2778. /**
  2779. * @brief Set ADC trigger frequency mode.
  2780. * @note ADC trigger frequency mode must be set to low frequency when
  2781. * a duration is exceeded before ADC conversion start trigger event
  2782. * (between ADC enable and ADC conversion start trigger event
  2783. * or between two ADC conversion start trigger event).
  2784. * Duration value: Refer to device datasheet, parameter "tIdle".
  2785. * @note When ADC trigger frequency mode is set to low frequency,
  2786. * some rearm cycles are inserted before performing ADC conversion
  2787. * start, inducing a delay of 2 ADC clock cycles.
  2788. * @note Usage of ADC trigger frequency mode with ADC low power mode:
  2789. * - Low power mode auto wait: Only the first ADC conversion
  2790. * start trigger inserts the rearm delay.
  2791. * @note On this STM32 serie, setting of this feature is conditioned to
  2792. * ADC state:
  2793. * ADC must be disabled or enabled without conversion on going
  2794. * on group regular.
  2795. * @rmtoll CFGR2 LFTRIG LL_ADC_SetTriggerFrequencyMode
  2796. * @param ADCx ADC instance
  2797. * @param TriggerFrequencyMode This parameter can be one of the following values:
  2798. * @arg @ref LL_ADC_TRIGGER_FREQ_HIGH
  2799. * @arg @ref LL_ADC_TRIGGER_FREQ_LOW
  2800. * @retval None
  2801. */
  2802. __STATIC_INLINE void LL_ADC_SetTriggerFrequencyMode(ADC_TypeDef *ADCx, uint32_t TriggerFrequencyMode)
  2803. {
  2804. MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_LFTRIG, TriggerFrequencyMode);
  2805. }
  2806. /**
  2807. * @brief Get ADC trigger frequency mode.
  2808. * @rmtoll CFGR2 LFTRIG LL_ADC_GetTriggerFrequencyMode
  2809. * @param ADCx ADC instance
  2810. * @retval Returned value can be one of the following values:
  2811. * @arg @ref LL_ADC_TRIGGER_FREQ_HIGH
  2812. * @arg @ref LL_ADC_TRIGGER_FREQ_LOW
  2813. */
  2814. __STATIC_INLINE uint32_t LL_ADC_GetTriggerFrequencyMode(ADC_TypeDef *ADCx)
  2815. {
  2816. return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_LFTRIG));
  2817. }
  2818. #endif
  2819. #if defined(ADC_SUPPORT_2_5_MSPS)
  2820. /**
  2821. * @brief Set sampling time common to a group of channels.
  2822. * @note Unit: ADC clock cycles.
  2823. * @note On this STM32 serie, sampling time scope is on ADC instance:
  2824. * Sampling time common to all channels, independently
  2825. * of channels mapped on ADC group regular or injected.
  2826. * (on some other STM32 families, sampling time is channel wise)
  2827. * @note In case of internal channel (VrefInt, TempSensor, ...) to be
  2828. * converted:
  2829. * sampling time constraints must be respected (sampling time can be
  2830. * adjusted in function of ADC clock frequency and sampling time
  2831. * setting).
  2832. * Refer to device datasheet for timings values (parameters TS_vrefint,
  2833. * TS_temp, ...).
  2834. * @note Conversion time is the addition of sampling time and processing time.
  2835. * On this STM32 serie, ADC processing time is:
  2836. * - 12.5 ADC clock cycles at ADC resolution 12 bits
  2837. * - 10.5 ADC clock cycles at ADC resolution 10 bits
  2838. * - 8.5 ADC clock cycles at ADC resolution 8 bits
  2839. * - 6.5 ADC clock cycles at ADC resolution 6 bits
  2840. * @note In case of ADC conversion of internal channel (VrefInt,
  2841. * temperature sensor, ...), a sampling time minimum value
  2842. * is required.
  2843. * Refer to device datasheet.
  2844. * @note On this STM32 serie, setting of this feature is conditioned to
  2845. * ADC state:
  2846. * ADC must be disabled or enabled without conversion on going
  2847. * on either groups regular or injected.
  2848. * @rmtoll SMPR SMP1 LL_ADC_SetSamplingTimeCommonChannels\n
  2849. * @rmtoll SMPR SMP2 LL_ADC_SetSamplingTimeCommonChannels
  2850. * @param ADCx ADC instance
  2851. * @param SamplingTimeY This parameter can be one of the following values:
  2852. * @arg @ref LL_ADC_SAMPLINGTIME_COMMON_1
  2853. * @arg @ref LL_ADC_SAMPLINGTIME_COMMON_2
  2854. * @param SamplingTime This parameter can be one of the following values:
  2855. * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
  2856. * @arg @ref LL_ADC_SAMPLINGTIME_3CYCLES_5
  2857. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  2858. * @arg @ref LL_ADC_SAMPLINGTIME_12CYCLES_5
  2859. * @arg @ref LL_ADC_SAMPLINGTIME_19CYCLES_5
  2860. * @arg @ref LL_ADC_SAMPLINGTIME_39CYCLES_5
  2861. * @arg @ref LL_ADC_SAMPLINGTIME_79CYCLES_5
  2862. * @arg @ref LL_ADC_SAMPLINGTIME_160CYCLES_5
  2863. * @retval None
  2864. */
  2865. __STATIC_INLINE void LL_ADC_SetSamplingTimeCommonChannels(ADC_TypeDef *ADCx, uint32_t SamplingTimeY, uint32_t SamplingTime)
  2866. {
  2867. MODIFY_REG(ADCx->SMPR,
  2868. ADC_SMPR_SMP1 << (SamplingTimeY & ADC_SAMPLING_TIME_SMP_SHIFT_MASK),
  2869. SamplingTime << (SamplingTimeY & ADC_SAMPLING_TIME_SMP_SHIFT_MASK));
  2870. }
  2871. /**
  2872. * @brief Get sampling time common to a group of channels.
  2873. * @note Unit: ADC clock cycles.
  2874. * @note On this STM32 serie, sampling time scope is on ADC instance:
  2875. * Sampling time common to all channels, independently
  2876. * of channels mapped on ADC group regular or injected.
  2877. * (on some other STM32 families, sampling time is channel wise)
  2878. * @note Conversion time is the addition of sampling time and processing time.
  2879. * On this STM32 serie, ADC processing time is:
  2880. * - 12.5 ADC clock cycles at ADC resolution 12 bits
  2881. * - 10.5 ADC clock cycles at ADC resolution 10 bits
  2882. * - 8.5 ADC clock cycles at ADC resolution 8 bits
  2883. * - 6.5 ADC clock cycles at ADC resolution 6 bits
  2884. * @rmtoll SMPR SMP1 LL_ADC_GetSamplingTimeCommonChannels\n
  2885. * @rmtoll SMPR SMP2 LL_ADC_GetSamplingTimeCommonChannels
  2886. * @param ADCx ADC instance
  2887. * @param SamplingTimeY This parameter can be one of the following values:
  2888. * @arg @ref LL_ADC_SAMPLINGTIME_COMMON_1
  2889. * @arg @ref LL_ADC_SAMPLINGTIME_COMMON_2
  2890. * @retval Returned value can be one of the following values:
  2891. * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
  2892. * @arg @ref LL_ADC_SAMPLINGTIME_3CYCLES_5
  2893. * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
  2894. * @arg @ref LL_ADC_SAMPLINGTIME_12CYCLES_5
  2895. * @arg @ref LL_ADC_SAMPLINGTIME_19CYCLES_5
  2896. * @arg @ref LL_ADC_SAMPLINGTIME_39CYCLES_5
  2897. * @arg @ref LL_ADC_SAMPLINGTIME_79CYCLES_5
  2898. * @arg @ref LL_ADC_SAMPLINGTIME_160CYCLES_5
  2899. */
  2900. __STATIC_INLINE uint32_t LL_ADC_GetSamplingTimeCommonChannels(ADC_TypeDef *ADCx, uint32_t SamplingTimeY)
  2901. {
  2902. return (uint32_t)((READ_BIT(ADCx->SMPR, ADC_SMPR_SMP1 << (SamplingTimeY & ADC_SAMPLING_TIME_SMP_SHIFT_MASK)))
  2903. >> (SamplingTimeY & ADC_SAMPLING_TIME_SMP_SHIFT_MASK));
  2904. }
  2905. #endif
  2906. #if defined(ADC_SUPPORT_2_5_MSPS)
  2907. /* Feature "ADC offset" not available on ADC peripheral of this STM32WB device */
  2908. #else
  2909. /**
  2910. * @brief Set ADC selected offset number 1, 2, 3 or 4.
  2911. * @note This function set the 2 items of offset configuration:
  2912. * - ADC channel to which the offset programmed will be applied
  2913. * (independently of channel mapped on ADC group regular
  2914. * or group injected)
  2915. * - Offset level (offset to be subtracted from the raw
  2916. * converted data).
  2917. * @note Caution: Offset format is dependent to ADC resolution:
  2918. * offset has to be left-aligned on bit 11, the LSB (right bits)
  2919. * are set to 0.
  2920. * @note This function enables the offset, by default. It can be forced
  2921. * to disable state using function LL_ADC_SetOffsetState().
  2922. * @note If a channel is mapped on several offsets numbers, only the offset
  2923. * with the lowest value is considered for the subtraction.
  2924. * @note On this STM32 serie, setting of this feature is conditioned to
  2925. * ADC state:
  2926. * ADC must be disabled or enabled without conversion on going
  2927. * on either groups regular or injected.
  2928. * @note On STM32WB (except devices: STM32WB10xx, STM32WB15xx), some fast channels are available: fast analog inputs
  2929. * coming from GPIO pads (ADC_IN1..5).
  2930. * @rmtoll OFR1 OFFSET1_CH LL_ADC_SetOffset\n
  2931. * OFR1 OFFSET1 LL_ADC_SetOffset\n
  2932. * OFR1 OFFSET1_EN LL_ADC_SetOffset\n
  2933. * OFR2 OFFSET2_CH LL_ADC_SetOffset\n
  2934. * OFR2 OFFSET2 LL_ADC_SetOffset\n
  2935. * OFR2 OFFSET2_EN LL_ADC_SetOffset\n
  2936. * OFR3 OFFSET3_CH LL_ADC_SetOffset\n
  2937. * OFR3 OFFSET3 LL_ADC_SetOffset\n
  2938. * OFR3 OFFSET3_EN LL_ADC_SetOffset\n
  2939. * OFR4 OFFSET4_CH LL_ADC_SetOffset\n
  2940. * OFR4 OFFSET4 LL_ADC_SetOffset\n
  2941. * OFR4 OFFSET4_EN LL_ADC_SetOffset
  2942. * @param ADCx ADC instance
  2943. * @param Offsety This parameter can be one of the following values:
  2944. * @arg @ref LL_ADC_OFFSET_1
  2945. * @arg @ref LL_ADC_OFFSET_2
  2946. * @arg @ref LL_ADC_OFFSET_3
  2947. * @arg @ref LL_ADC_OFFSET_4
  2948. * @param Channel This parameter can be one of the following values:
  2949. * @arg @ref LL_ADC_CHANNEL_0
  2950. * @arg @ref LL_ADC_CHANNEL_1 (7)
  2951. * @arg @ref LL_ADC_CHANNEL_2 (7)
  2952. * @arg @ref LL_ADC_CHANNEL_3 (7)
  2953. * @arg @ref LL_ADC_CHANNEL_4 (7)
  2954. * @arg @ref LL_ADC_CHANNEL_5 (7)
  2955. * @arg @ref LL_ADC_CHANNEL_6
  2956. * @arg @ref LL_ADC_CHANNEL_7
  2957. * @arg @ref LL_ADC_CHANNEL_8
  2958. * @arg @ref LL_ADC_CHANNEL_9
  2959. * @arg @ref LL_ADC_CHANNEL_10
  2960. * @arg @ref LL_ADC_CHANNEL_11
  2961. * @arg @ref LL_ADC_CHANNEL_12
  2962. * @arg @ref LL_ADC_CHANNEL_13
  2963. * @arg @ref LL_ADC_CHANNEL_14
  2964. * @arg @ref LL_ADC_CHANNEL_15
  2965. * @arg @ref LL_ADC_CHANNEL_16
  2966. * @arg @ref LL_ADC_CHANNEL_17
  2967. * @arg @ref LL_ADC_CHANNEL_18
  2968. * @arg @ref LL_ADC_CHANNEL_VREFINT
  2969. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  2970. * @arg @ref LL_ADC_CHANNEL_VBAT
  2971. *
  2972. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  2973. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  2974. * @param OffsetLevel Value between Min_Data=0x000 and Max_Data=0xFFF
  2975. * @retval None
  2976. */
  2977. __STATIC_INLINE void LL_ADC_SetOffset(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t Channel, uint32_t OffsetLevel)
  2978. {
  2979. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  2980. MODIFY_REG(*preg,
  2981. ADC_OFR1_OFFSET1_EN | ADC_OFR1_OFFSET1_CH | ADC_OFR1_OFFSET1,
  2982. ADC_OFR1_OFFSET1_EN | (Channel & ADC_CHANNEL_ID_NUMBER_MASK) | OffsetLevel);
  2983. }
  2984. /**
  2985. * @brief Get for the ADC selected offset number 1, 2, 3 or 4:
  2986. * Channel to which the offset programmed will be applied
  2987. * (independently of channel mapped on ADC group regular
  2988. * or group injected)
  2989. * @note Usage of the returned channel number:
  2990. * - To reinject this channel into another function LL_ADC_xxx:
  2991. * the returned channel number is only partly formatted on definition
  2992. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  2993. * with parts of literals LL_ADC_CHANNEL_x or using
  2994. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2995. * Then the selected literal LL_ADC_CHANNEL_x can be used
  2996. * as parameter for another function.
  2997. * - To get the channel number in decimal format:
  2998. * process the returned value with the helper macro
  2999. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3000. * @note On STM32WB (except devices: STM32WB10xx, STM32WB15xx), some fast channels are available: fast analog inputs
  3001. * coming from GPIO pads (ADC_IN1..5).
  3002. * @rmtoll OFR1 OFFSET1_CH LL_ADC_GetOffsetChannel\n
  3003. * OFR2 OFFSET2_CH LL_ADC_GetOffsetChannel\n
  3004. * OFR3 OFFSET3_CH LL_ADC_GetOffsetChannel\n
  3005. * OFR4 OFFSET4_CH LL_ADC_GetOffsetChannel
  3006. * @param ADCx ADC instance
  3007. * @param Offsety This parameter can be one of the following values:
  3008. * @arg @ref LL_ADC_OFFSET_1
  3009. * @arg @ref LL_ADC_OFFSET_2
  3010. * @arg @ref LL_ADC_OFFSET_3
  3011. * @arg @ref LL_ADC_OFFSET_4
  3012. * @retval Returned value can be one of the following values:
  3013. * @arg @ref LL_ADC_CHANNEL_0
  3014. * @arg @ref LL_ADC_CHANNEL_1 (7)
  3015. * @arg @ref LL_ADC_CHANNEL_2 (7)
  3016. * @arg @ref LL_ADC_CHANNEL_3 (7)
  3017. * @arg @ref LL_ADC_CHANNEL_4 (7)
  3018. * @arg @ref LL_ADC_CHANNEL_5 (7)
  3019. * @arg @ref LL_ADC_CHANNEL_6
  3020. * @arg @ref LL_ADC_CHANNEL_7
  3021. * @arg @ref LL_ADC_CHANNEL_8
  3022. * @arg @ref LL_ADC_CHANNEL_9
  3023. * @arg @ref LL_ADC_CHANNEL_10
  3024. * @arg @ref LL_ADC_CHANNEL_11
  3025. * @arg @ref LL_ADC_CHANNEL_12
  3026. * @arg @ref LL_ADC_CHANNEL_13
  3027. * @arg @ref LL_ADC_CHANNEL_14
  3028. * @arg @ref LL_ADC_CHANNEL_15
  3029. * @arg @ref LL_ADC_CHANNEL_16
  3030. * @arg @ref LL_ADC_CHANNEL_17
  3031. * @arg @ref LL_ADC_CHANNEL_18
  3032. * @arg @ref LL_ADC_CHANNEL_VREFINT (4)
  3033. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  3034. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  3035. *
  3036. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  3037. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).\n
  3038. * (4) For ADC channel read back from ADC register,
  3039. * comparison with internal channel parameter to be done
  3040. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  3041. */
  3042. __STATIC_INLINE uint32_t LL_ADC_GetOffsetChannel(ADC_TypeDef *ADCx, uint32_t Offsety)
  3043. {
  3044. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  3045. return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1_CH);
  3046. }
  3047. /**
  3048. * @brief Get for the ADC selected offset number 1, 2, 3 or 4:
  3049. * Offset level (offset to be subtracted from the raw
  3050. * converted data).
  3051. * @note Caution: Offset format is dependent to ADC resolution:
  3052. * offset has to be left-aligned on bit 11, the LSB (right bits)
  3053. * are set to 0.
  3054. * @rmtoll OFR1 OFFSET1 LL_ADC_GetOffsetLevel\n
  3055. * OFR2 OFFSET2 LL_ADC_GetOffsetLevel\n
  3056. * OFR3 OFFSET3 LL_ADC_GetOffsetLevel\n
  3057. * OFR4 OFFSET4 LL_ADC_GetOffsetLevel
  3058. * @param ADCx ADC instance
  3059. * @param Offsety This parameter can be one of the following values:
  3060. * @arg @ref LL_ADC_OFFSET_1
  3061. * @arg @ref LL_ADC_OFFSET_2
  3062. * @arg @ref LL_ADC_OFFSET_3
  3063. * @arg @ref LL_ADC_OFFSET_4
  3064. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  3065. */
  3066. __STATIC_INLINE uint32_t LL_ADC_GetOffsetLevel(ADC_TypeDef *ADCx, uint32_t Offsety)
  3067. {
  3068. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  3069. return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1);
  3070. }
  3071. /**
  3072. * @brief Set for the ADC selected offset number 1, 2, 3 or 4:
  3073. * force offset state disable or enable
  3074. * without modifying offset channel or offset value.
  3075. * @note This function should be needed only in case of offset to be
  3076. * enabled-disabled dynamically, and should not be needed in other cases:
  3077. * function LL_ADC_SetOffset() automatically enables the offset.
  3078. * @note On this STM32 serie, setting of this feature is conditioned to
  3079. * ADC state:
  3080. * ADC must be disabled or enabled without conversion on going
  3081. * on either groups regular or injected.
  3082. * @rmtoll OFR1 OFFSET1_EN LL_ADC_SetOffsetState\n
  3083. * OFR2 OFFSET2_EN LL_ADC_SetOffsetState\n
  3084. * OFR3 OFFSET3_EN LL_ADC_SetOffsetState\n
  3085. * OFR4 OFFSET4_EN LL_ADC_SetOffsetState
  3086. * @param ADCx ADC instance
  3087. * @param Offsety This parameter can be one of the following values:
  3088. * @arg @ref LL_ADC_OFFSET_1
  3089. * @arg @ref LL_ADC_OFFSET_2
  3090. * @arg @ref LL_ADC_OFFSET_3
  3091. * @arg @ref LL_ADC_OFFSET_4
  3092. * @param OffsetState This parameter can be one of the following values:
  3093. * @arg @ref LL_ADC_OFFSET_DISABLE
  3094. * @arg @ref LL_ADC_OFFSET_ENABLE
  3095. * @retval None
  3096. */
  3097. __STATIC_INLINE void LL_ADC_SetOffsetState(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t OffsetState)
  3098. {
  3099. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  3100. MODIFY_REG(*preg,
  3101. ADC_OFR1_OFFSET1_EN,
  3102. OffsetState);
  3103. }
  3104. /**
  3105. * @brief Get for the ADC selected offset number 1, 2, 3 or 4:
  3106. * offset state disabled or enabled.
  3107. * @rmtoll OFR1 OFFSET1_EN LL_ADC_GetOffsetState\n
  3108. * OFR2 OFFSET2_EN LL_ADC_GetOffsetState\n
  3109. * OFR3 OFFSET3_EN LL_ADC_GetOffsetState\n
  3110. * OFR4 OFFSET4_EN LL_ADC_GetOffsetState
  3111. * @param ADCx ADC instance
  3112. * @param Offsety This parameter can be one of the following values:
  3113. * @arg @ref LL_ADC_OFFSET_1
  3114. * @arg @ref LL_ADC_OFFSET_2
  3115. * @arg @ref LL_ADC_OFFSET_3
  3116. * @arg @ref LL_ADC_OFFSET_4
  3117. * @retval Returned value can be one of the following values:
  3118. * @arg @ref LL_ADC_OFFSET_DISABLE
  3119. * @arg @ref LL_ADC_OFFSET_ENABLE
  3120. */
  3121. __STATIC_INLINE uint32_t LL_ADC_GetOffsetState(ADC_TypeDef *ADCx, uint32_t Offsety)
  3122. {
  3123. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety);
  3124. return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1_EN);
  3125. }
  3126. #endif
  3127. /**
  3128. * @}
  3129. */
  3130. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
  3131. * @{
  3132. */
  3133. /**
  3134. * @brief Set ADC group regular conversion trigger source:
  3135. * internal (SW start) or from external peripheral (timer event,
  3136. * external interrupt line).
  3137. * @note On this STM32 serie, setting trigger source to external trigger
  3138. * also set trigger polarity to rising edge
  3139. * (default setting for compatibility with some ADC on other
  3140. * STM32 families having this setting set by HW default value).
  3141. * In case of need to modify trigger edge, use
  3142. * function @ref LL_ADC_REG_SetTriggerEdge().
  3143. * @note On devices STM32WB10xx, STM32WB15xx: ADC trigger frequency mode must be set
  3144. * in function of frequency of ADC group regular conversion trigger.
  3145. * Refer to description of function
  3146. * "LL_ADC_SetTriggerFrequencyMode()".
  3147. * @note Availability of parameters of trigger sources from timer
  3148. * depends on timers availability on the selected device.
  3149. * @note On this STM32 serie, setting of this feature is conditioned to
  3150. * ADC state:
  3151. * ADC must be disabled or enabled without conversion on going
  3152. * on group regular.
  3153. * @rmtoll CFGR EXTSEL LL_ADC_REG_SetTriggerSource\n
  3154. * CFGR EXTEN LL_ADC_REG_SetTriggerSource
  3155. * @param ADCx ADC instance
  3156. * @param TriggerSource This parameter can be one of the following values:
  3157. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  3158. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO (1)
  3159. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO2
  3160. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1 (1)
  3161. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2 (1)
  3162. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3 (1)
  3163. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH4 (2)
  3164. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
  3165. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  3166. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3 (2)
  3167. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH4 (2)
  3168. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  3169. *
  3170. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  3171. * (2) On STM32WB serie, parameter available only devices: STM32WB10xx, STM32WB15xx.
  3172. * @retval None
  3173. */
  3174. __STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  3175. {
  3176. #if defined (ADC_SUPPORT_2_5_MSPS)
  3177. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_EXTEN | ADC_CFGR1_EXTSEL, TriggerSource);
  3178. #else
  3179. MODIFY_REG(ADCx->CFGR, ADC_CFGR_EXTEN | ADC_CFGR_EXTSEL, TriggerSource);
  3180. #endif
  3181. }
  3182. /**
  3183. * @brief Get ADC group regular conversion trigger source:
  3184. * internal (SW start) or from external peripheral (timer event,
  3185. * external interrupt line).
  3186. * @note To determine whether group regular trigger source is
  3187. * internal (SW start) or external, without detail
  3188. * of which peripheral is selected as external trigger,
  3189. * (equivalent to
  3190. * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
  3191. * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
  3192. * @note Availability of parameters of trigger sources from timer
  3193. * depends on timers availability on the selected device.
  3194. * @rmtoll CFGR EXTSEL LL_ADC_REG_GetTriggerSource\n
  3195. * CFGR EXTEN LL_ADC_REG_GetTriggerSource
  3196. * @param ADCx ADC instance
  3197. * @retval Returned value can be one of the following values:
  3198. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  3199. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO (1)
  3200. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO2
  3201. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1 (1)
  3202. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2 (1)
  3203. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3 (1)
  3204. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH4 (2)
  3205. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
  3206. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  3207. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3 (2)
  3208. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH4 (2)
  3209. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  3210. *
  3211. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  3212. * (2) On STM32WB serie, parameter available only devices: STM32WB10xx, STM32WB15xx.
  3213. */
  3214. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
  3215. {
  3216. #if defined (ADC_SUPPORT_2_5_MSPS)
  3217. __IO uint32_t TriggerSource = READ_BIT(ADCx->CFGR1, ADC_CFGR1_EXTSEL | ADC_CFGR1_EXTEN);
  3218. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  3219. /* corresponding to ADC_CFGR1_EXTEN {0; 1; 2; 3}. */
  3220. uint32_t ShiftExten = ((TriggerSource & ADC_CFGR1_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2UL));
  3221. /* Set bitfield corresponding to ADC_CFGR1_EXTEN and ADC_CFGR1_EXTSEL */
  3222. /* to match with triggers literals definition. */
  3223. return ((TriggerSource
  3224. & (ADC_REG_TRIG_SOURCE_MASK >> ShiftExten) & ADC_CFGR1_EXTSEL)
  3225. | ((ADC_REG_TRIG_EDGE_MASK >> ShiftExten) & ADC_CFGR1_EXTEN)
  3226. );
  3227. #else
  3228. __IO uint32_t TriggerSource = READ_BIT(ADCx->CFGR, ADC_CFGR_EXTSEL | ADC_CFGR_EXTEN);
  3229. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  3230. /* corresponding to ADC_CFGR_EXTEN {0; 1; 2; 3}. */
  3231. uint32_t ShiftExten = ((TriggerSource & ADC_CFGR_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2UL));
  3232. /* Set bitfield corresponding to ADC_CFGR_EXTEN and ADC_CFGR_EXTSEL */
  3233. /* to match with triggers literals definition. */
  3234. return ((TriggerSource
  3235. & (ADC_REG_TRIG_SOURCE_MASK >> ShiftExten) & ADC_CFGR_EXTSEL)
  3236. | ((ADC_REG_TRIG_EDGE_MASK >> ShiftExten) & ADC_CFGR_EXTEN)
  3237. );
  3238. #endif
  3239. }
  3240. /**
  3241. * @brief Get ADC group regular conversion trigger source internal (SW start)
  3242. * or external.
  3243. * @note In case of group regular trigger source set to external trigger,
  3244. * to determine which peripheral is selected as external trigger,
  3245. * use function @ref LL_ADC_REG_GetTriggerSource().
  3246. * @rmtoll CFGR EXTEN LL_ADC_REG_IsTriggerSourceSWStart
  3247. * @param ADCx ADC instance
  3248. * @retval Value "0" if trigger source external trigger
  3249. * Value "1" if trigger source SW start.
  3250. */
  3251. __STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  3252. {
  3253. #if defined (ADC_SUPPORT_2_5_MSPS)
  3254. return ((READ_BIT(ADCx->CFGR1, ADC_CFGR1_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR1_EXTEN)) ? 1UL : 0UL);
  3255. #else
  3256. return ((READ_BIT(ADCx->CFGR, ADC_CFGR_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTEN)) ? 1UL : 0UL);
  3257. #endif
  3258. }
  3259. /**
  3260. * @brief Set ADC group regular conversion trigger polarity.
  3261. * @note Applicable only for trigger source set to external trigger.
  3262. * @note On this STM32 serie, setting of this feature is conditioned to
  3263. * ADC state:
  3264. * ADC must be disabled or enabled without conversion on going
  3265. * on group regular.
  3266. * @rmtoll CFGR EXTEN LL_ADC_REG_SetTriggerEdge
  3267. * @param ADCx ADC instance
  3268. * @param ExternalTriggerEdge This parameter can be one of the following values:
  3269. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  3270. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  3271. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  3272. * @retval None
  3273. */
  3274. __STATIC_INLINE void LL_ADC_REG_SetTriggerEdge(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  3275. {
  3276. #if defined (ADC_SUPPORT_2_5_MSPS)
  3277. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_EXTEN, ExternalTriggerEdge);
  3278. #else
  3279. MODIFY_REG(ADCx->CFGR, ADC_CFGR_EXTEN, ExternalTriggerEdge);
  3280. #endif
  3281. }
  3282. /**
  3283. * @brief Get ADC group regular conversion trigger polarity.
  3284. * @note Applicable only for trigger source set to external trigger.
  3285. * @rmtoll CFGR EXTEN LL_ADC_REG_GetTriggerEdge
  3286. * @param ADCx ADC instance
  3287. * @retval Returned value can be one of the following values:
  3288. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  3289. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  3290. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  3291. */
  3292. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerEdge(ADC_TypeDef *ADCx)
  3293. {
  3294. #if defined (ADC_SUPPORT_2_5_MSPS)
  3295. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_EXTEN));
  3296. #else
  3297. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_EXTEN));
  3298. #endif
  3299. }
  3300. #if defined(ADC_SUPPORT_2_5_MSPS)
  3301. /**
  3302. * @brief Set ADC group regular sequencer configuration flexibility.
  3303. * @note On this STM32 serie, ADC group regular sequencer both modes
  3304. * "fully configurable" or "not fully configurable" are
  3305. * available:
  3306. * - sequencer configured to fully configurable:
  3307. * sequencer length and each rank
  3308. * affectation to a channel are configurable.
  3309. * Refer to description of function
  3310. * @ref LL_ADC_REG_SetSequencerLength().
  3311. * - sequencer configured to not fully configurable:
  3312. * sequencer length and each rank affectation to a channel
  3313. * are fixed by channel HW number.
  3314. * Refer to description of function
  3315. * @ref LL_ADC_REG_SetSequencerChannels().
  3316. * @note On this STM32 serie, setting of this feature is conditioned to
  3317. * ADC state:
  3318. * ADC must be disabled or enabled without conversion on going
  3319. * on group regular.
  3320. * @rmtoll CFGR CHSELRMOD LL_ADC_REG_SetSequencerConfigurable
  3321. * @param ADCx ADC instance
  3322. * @param Configurability This parameter can be one of the following values:
  3323. * @arg @ref LL_ADC_REG_SEQ_FIXED
  3324. * @arg @ref LL_ADC_REG_SEQ_CONFIGURABLE
  3325. * @retval None
  3326. */
  3327. __STATIC_INLINE void LL_ADC_REG_SetSequencerConfigurable(ADC_TypeDef *ADCx, uint32_t Configurability)
  3328. {
  3329. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_CHSELRMOD, Configurability);
  3330. }
  3331. /**
  3332. * @brief Get ADC group regular sequencer configuration flexibility.
  3333. * @note On this STM32 serie, ADC group regular sequencer both modes
  3334. * "fully configurable" or "not fully configurable" are
  3335. * available:
  3336. * - sequencer configured to fully configurable:
  3337. * sequencer length and each rank
  3338. * affectation to a channel are configurable.
  3339. * Refer to description of function
  3340. * @ref LL_ADC_REG_SetSequencerLength().
  3341. * - sequencer configured to not fully configurable:
  3342. * sequencer length and each rank affectation to a channel
  3343. * are fixed by channel HW number.
  3344. * Refer to description of function
  3345. * @ref LL_ADC_REG_SetSequencerChannels().
  3346. * @rmtoll CFGR CHSELRMOD LL_ADC_REG_SetSequencerConfigurable
  3347. * @param ADCx ADC instance
  3348. * @retval Returned value can be one of the following values:
  3349. * @arg @ref LL_ADC_REG_SEQ_FIXED
  3350. * @arg @ref LL_ADC_REG_SEQ_CONFIGURABLE
  3351. */
  3352. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerConfigurable(ADC_TypeDef *ADCx)
  3353. {
  3354. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_CHSELRMOD));
  3355. }
  3356. #endif
  3357. /**
  3358. * @brief Set ADC group regular sequencer length and scan direction.
  3359. * @note Description of ADC group regular sequencer features:
  3360. * - For devices with sequencer fully configurable
  3361. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  3362. * sequencer length and each rank affectation to a channel
  3363. * are configurable.
  3364. * This function performs configuration of:
  3365. * - Sequence length: Number of ranks in the scan sequence.
  3366. * - Sequence direction: Unless specified in parameters, sequencer
  3367. * scan direction is forward (from rank 1 to rank n).
  3368. * Sequencer ranks are selected using
  3369. * function "LL_ADC_REG_SetSequencerRanks()".
  3370. * - For devices with sequencer not fully configurable
  3371. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  3372. * sequencer length and each rank affectation to a channel
  3373. * are defined by channel number.
  3374. * This function performs configuration of:
  3375. * - Sequence length: Number of ranks in the scan sequence is
  3376. * defined by number of channels set in the sequence,
  3377. * rank of each channel is fixed by channel HW number.
  3378. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  3379. * - Sequence direction: Unless specified in parameters, sequencer
  3380. * scan direction is forward (from lowest channel number to
  3381. * highest channel number).
  3382. * Sequencer ranks are selected using
  3383. * function "LL_ADC_REG_SetSequencerChannels()".
  3384. * To set scan direction differently, refer to function
  3385. * "LL_ADC_REG_SetSequencerScanDirection()".
  3386. * @note On devices STM32WB10xx, STM32WB15xx: after calling functions
  3387. * @ref LL_ADC_REG_SetSequencerLength()
  3388. * or @ref LL_ADC_REG_SetSequencerRanks(),
  3389. * it is mandatory to wait for the assertion of CCRDY flag
  3390. * using "LL_ADC_IsActiveFlag_CCRDY()".
  3391. * Otherwise, performing some actions (configuration update,
  3392. * ADC conversion start, ... ) will be ignored.
  3393. * Refer to reference manual for more details.
  3394. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3395. * ADC conversion on only 1 channel.
  3396. * @note On this STM32 serie, setting of this feature is conditioned to
  3397. * ADC state:
  3398. * ADC must be disabled or enabled without conversion on going
  3399. * on group regular.
  3400. * @rmtoll CHSELR SQ1 LL_ADC_REG_SetSequencerLength\n
  3401. * CHSELR SQ2 LL_ADC_REG_SetSequencerLength\n
  3402. * CHSELR SQ3 LL_ADC_REG_SetSequencerLength\n
  3403. * CHSELR SQ4 LL_ADC_REG_SetSequencerLength\n
  3404. * CHSELR SQ5 LL_ADC_REG_SetSequencerLength\n
  3405. * CHSELR SQ6 LL_ADC_REG_SetSequencerLength\n
  3406. * CHSELR SQ7 LL_ADC_REG_SetSequencerLength\n
  3407. * CHSELR SQ8 LL_ADC_REG_SetSequencerLength
  3408. * @param ADCx ADC instance
  3409. * @param SequencerNbRanks This parameter can be one of the following values:
  3410. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  3411. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  3412. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  3413. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  3414. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  3415. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  3416. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  3417. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  3418. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (1)
  3419. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS (1)
  3420. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS (1)
  3421. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS (1)
  3422. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS (1)
  3423. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS (1)
  3424. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS (1)
  3425. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS (1)
  3426. *
  3427. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  3428. * @retval None
  3429. */
  3430. __STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  3431. {
  3432. #if defined (ADC_SUPPORT_2_5_MSPS)
  3433. SET_BIT(ADCx->CHSELR, SequencerNbRanks);
  3434. #else
  3435. MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks);
  3436. #endif
  3437. }
  3438. /**
  3439. * @brief Get ADC group regular sequencer length and scan direction.
  3440. * @note Description of ADC group regular sequencer features:
  3441. * - For devices with sequencer fully configurable
  3442. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  3443. * sequencer length and each rank affectation to a channel
  3444. * are configurable.
  3445. * This function retrieves:
  3446. * - Sequence length: Number of ranks in the scan sequence.
  3447. * - Sequence direction: Unless specified in parameters, sequencer
  3448. * scan direction is forward (from rank 1 to rank n).
  3449. * Sequencer ranks are selected using
  3450. * function "LL_ADC_REG_SetSequencerRanks()".
  3451. * - For devices with sequencer not fully configurable
  3452. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  3453. * sequencer length and each rank affectation to a channel
  3454. * are defined by channel number.
  3455. * This function retrieves:
  3456. * - Sequence length: Number of ranks in the scan sequence is
  3457. * defined by number of channels set in the sequence,
  3458. * rank of each channel is fixed by channel HW number.
  3459. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  3460. * - Sequence direction: Unless specified in parameters, sequencer
  3461. * scan direction is forward (from lowest channel number to
  3462. * highest channel number).
  3463. * Sequencer ranks are selected using
  3464. * function "LL_ADC_REG_SetSequencerChannels()".
  3465. * To set scan direction differently, refer to function
  3466. * "LL_ADC_REG_SetSequencerScanDirection()".
  3467. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3468. * ADC conversion on only 1 channel.
  3469. * @rmtoll CHSELR SQ1 LL_ADC_REG_GetSequencerLength\n
  3470. * CHSELR SQ2 LL_ADC_REG_GetSequencerLength\n
  3471. * CHSELR SQ3 LL_ADC_REG_GetSequencerLength\n
  3472. * CHSELR SQ4 LL_ADC_REG_GetSequencerLength\n
  3473. * CHSELR SQ5 LL_ADC_REG_GetSequencerLength\n
  3474. * CHSELR SQ6 LL_ADC_REG_GetSequencerLength\n
  3475. * CHSELR SQ7 LL_ADC_REG_GetSequencerLength\n
  3476. * CHSELR SQ8 LL_ADC_REG_GetSequencerLength
  3477. * @param ADCx ADC instance
  3478. * @retval Returned value can be one of the following values:
  3479. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  3480. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  3481. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  3482. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  3483. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  3484. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  3485. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  3486. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  3487. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (1)
  3488. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS (1)
  3489. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS (1)
  3490. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS (1)
  3491. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS (1)
  3492. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS (1)
  3493. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS (1)
  3494. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS (1)
  3495. *
  3496. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  3497. */
  3498. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerLength(ADC_TypeDef *ADCx)
  3499. {
  3500. #if defined (ADC_SUPPORT_2_5_MSPS)
  3501. __IO uint32_t ChannelsRanks = READ_BIT(ADCx->CHSELR, ADC_CHSELR_SQ_ALL);
  3502. uint32_t SequencerLength = LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS;
  3503. uint32_t RankIndex;
  3504. /* Parse register for end of sequence identifier */
  3505. for(RankIndex = 0UL; RankIndex < (32U - 4U); RankIndex+=4U)
  3506. {
  3507. if((ChannelsRanks & (ADC_CHSELR_SQ2 << RankIndex)) == (ADC_CHSELR_SQ2 << RankIndex))
  3508. {
  3509. SequencerLength = (ADC_CHSELR_SQ2 << RankIndex);
  3510. break;
  3511. }
  3512. }
  3513. return SequencerLength;
  3514. #else
  3515. return (uint32_t)(READ_BIT(ADCx->SQR1, ADC_SQR1_L));
  3516. #endif
  3517. }
  3518. #if defined(ADC_SUPPORT_2_5_MSPS)
  3519. /**
  3520. * @brief Set ADC group regular sequencer scan direction.
  3521. * @note On this STM32 serie, parameter relevant only is sequencer is set
  3522. * to mode not fully configurable,
  3523. * refer to function @ref LL_ADC_REG_SetSequencerConfigurable().
  3524. * @note On some other STM32 families, this setting is not available and
  3525. * the default scan direction is forward.
  3526. * @note On this STM32 serie, setting of this feature is conditioned to
  3527. * ADC state:
  3528. * ADC must be disabled or enabled without conversion on going
  3529. * on group regular.
  3530. * @rmtoll CFGR1 SCANDIR LL_ADC_REG_SetSequencerScanDirection
  3531. * @param ADCx ADC instance
  3532. * @param ScanDirection This parameter can be one of the following values:
  3533. * @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_FORWARD
  3534. * @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_BACKWARD
  3535. * @retval None
  3536. */
  3537. __STATIC_INLINE void LL_ADC_REG_SetSequencerScanDirection(ADC_TypeDef *ADCx, uint32_t ScanDirection)
  3538. {
  3539. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_SCANDIR, ScanDirection);
  3540. }
  3541. /**
  3542. * @brief Get ADC group regular sequencer scan direction.
  3543. * @note On some other STM32 families, this setting is not available and
  3544. * the default scan direction is forward.
  3545. * @rmtoll CFGR1 SCANDIR LL_ADC_REG_GetSequencerScanDirection
  3546. * @param ADCx ADC instance
  3547. * @retval Returned value can be one of the following values:
  3548. * @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_FORWARD
  3549. * @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_BACKWARD
  3550. */
  3551. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerScanDirection(ADC_TypeDef *ADCx)
  3552. {
  3553. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_SCANDIR));
  3554. }
  3555. #endif
  3556. /**
  3557. * @brief Set ADC group regular sequencer discontinuous mode:
  3558. * sequence subdivided and scan conversions interrupted every selected
  3559. * number of ranks.
  3560. * @note It is not possible to enable both ADC group regular
  3561. * continuous mode and sequencer discontinuous mode.
  3562. * @note It is not possible to enable both ADC auto-injected mode
  3563. * and ADC group regular sequencer discontinuous mode.
  3564. * @note On this STM32 serie, setting of this feature is conditioned to
  3565. * ADC state:
  3566. * ADC must be disabled or enabled without conversion on going
  3567. * on group regular.
  3568. * @rmtoll CFGR DISCEN LL_ADC_REG_SetSequencerDiscont\n
  3569. * CFGR DISCNUM LL_ADC_REG_SetSequencerDiscont
  3570. * @param ADCx ADC instance
  3571. * @param SeqDiscont This parameter can be one of the following values:
  3572. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  3573. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  3574. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS (1)
  3575. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS (1)
  3576. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS (1)
  3577. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS (1)
  3578. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS (1)
  3579. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS (1)
  3580. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS (1)
  3581. *
  3582. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  3583. * @retval None
  3584. */
  3585. __STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  3586. {
  3587. #if defined (ADC_SUPPORT_2_5_MSPS)
  3588. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_DISCEN, SeqDiscont);
  3589. #else
  3590. MODIFY_REG(ADCx->CFGR, ADC_CFGR_DISCEN | ADC_CFGR_DISCNUM, SeqDiscont);
  3591. #endif
  3592. }
  3593. /**
  3594. * @brief Get ADC group regular sequencer discontinuous mode:
  3595. * sequence subdivided and scan conversions interrupted every selected
  3596. * number of ranks.
  3597. * @rmtoll CFGR DISCEN LL_ADC_REG_GetSequencerDiscont\n
  3598. * CFGR DISCNUM LL_ADC_REG_GetSequencerDiscont
  3599. * @param ADCx ADC instance
  3600. * @retval Returned value can be one of the following values:
  3601. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  3602. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  3603. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS (1)
  3604. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS (1)
  3605. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS (1)
  3606. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS (1)
  3607. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS (1)
  3608. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS (1)
  3609. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS (1)
  3610. *
  3611. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  3612. */
  3613. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
  3614. {
  3615. #if defined (ADC_SUPPORT_2_5_MSPS)
  3616. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_DISCEN));
  3617. #else
  3618. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_DISCEN | ADC_CFGR_DISCNUM));
  3619. #endif
  3620. }
  3621. /**
  3622. * @brief Set ADC group regular sequence: channel on the selected
  3623. * scan sequence rank.
  3624. * @note This function performs configuration of:
  3625. * - Channels ordering into each rank of scan sequence:
  3626. * whatever channel can be placed into whatever rank.
  3627. * @note On this STM32 serie, ADC group regular sequencer is
  3628. * fully configurable: sequencer length and each rank
  3629. * affectation to a channel are configurable.
  3630. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  3631. * @note Depending on devices and packages, some channels may not be available.
  3632. * Refer to device datasheet for channels availability.
  3633. * @note On this STM32 serie, to measure internal channels (VrefInt,
  3634. * TempSensor, ...), measurement paths to internal channels must be
  3635. * enabled separately.
  3636. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  3637. * @note On devices STM32WB10xx, STM32WB15xx: after calling functions
  3638. * @ref LL_ADC_REG_SetSequencerLength()
  3639. * or @ref LL_ADC_REG_SetSequencerRanks(),
  3640. * it is mandatory to wait for the assertion of CCRDY flag
  3641. * using "LL_ADC_IsActiveFlag_CCRDY()".
  3642. * Otherwise, performing some actions (configuration update,
  3643. * ADC conversion start, ... ) will be ignored.
  3644. * Refer to reference manual for more details.
  3645. * @note On this STM32 serie, setting of this feature is conditioned to
  3646. * ADC state:
  3647. * ADC must be disabled or enabled without conversion on going
  3648. * on group regular.
  3649. * @rmtoll SQR1 SQ1 LL_ADC_REG_SetSequencerRanks\n
  3650. * SQR1 SQ2 LL_ADC_REG_SetSequencerRanks\n
  3651. * SQR1 SQ3 LL_ADC_REG_SetSequencerRanks\n
  3652. * SQR1 SQ4 LL_ADC_REG_SetSequencerRanks\n
  3653. * SQR2 SQ5 LL_ADC_REG_SetSequencerRanks\n
  3654. * SQR2 SQ6 LL_ADC_REG_SetSequencerRanks\n
  3655. * SQR2 SQ7 LL_ADC_REG_SetSequencerRanks\n
  3656. * SQR2 SQ8 LL_ADC_REG_SetSequencerRanks\n
  3657. * SQR2 SQ9 LL_ADC_REG_SetSequencerRanks\n
  3658. * SQR3 SQ10 LL_ADC_REG_SetSequencerRanks\n
  3659. * SQR3 SQ11 LL_ADC_REG_SetSequencerRanks\n
  3660. * SQR3 SQ12 LL_ADC_REG_SetSequencerRanks\n
  3661. * SQR3 SQ13 LL_ADC_REG_SetSequencerRanks\n
  3662. * SQR3 SQ14 LL_ADC_REG_SetSequencerRanks\n
  3663. * SQR4 SQ15 LL_ADC_REG_SetSequencerRanks\n
  3664. * SQR4 SQ16 LL_ADC_REG_SetSequencerRanks
  3665. * @param ADCx ADC instance
  3666. * @param Rank This parameter can be one of the following values:
  3667. * @arg @ref LL_ADC_REG_RANK_1
  3668. * @arg @ref LL_ADC_REG_RANK_2
  3669. * @arg @ref LL_ADC_REG_RANK_3
  3670. * @arg @ref LL_ADC_REG_RANK_4
  3671. * @arg @ref LL_ADC_REG_RANK_5
  3672. * @arg @ref LL_ADC_REG_RANK_6
  3673. * @arg @ref LL_ADC_REG_RANK_7
  3674. * @arg @ref LL_ADC_REG_RANK_8
  3675. * @arg @ref LL_ADC_REG_RANK_9 (1)
  3676. * @arg @ref LL_ADC_REG_RANK_10 (1)
  3677. * @arg @ref LL_ADC_REG_RANK_11 (1)
  3678. * @arg @ref LL_ADC_REG_RANK_12 (1)
  3679. * @arg @ref LL_ADC_REG_RANK_13 (1)
  3680. * @arg @ref LL_ADC_REG_RANK_14 (1)
  3681. * @arg @ref LL_ADC_REG_RANK_15 (1)
  3682. * @arg @ref LL_ADC_REG_RANK_16 (1)
  3683. *
  3684. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  3685. * @param Channel This parameter can be one of the following values:
  3686. * @arg @ref LL_ADC_CHANNEL_0
  3687. * @arg @ref LL_ADC_CHANNEL_1 (7)
  3688. * @arg @ref LL_ADC_CHANNEL_2 (7)
  3689. * @arg @ref LL_ADC_CHANNEL_3 (7)
  3690. * @arg @ref LL_ADC_CHANNEL_4 (7)
  3691. * @arg @ref LL_ADC_CHANNEL_5 (7)
  3692. * @arg @ref LL_ADC_CHANNEL_6
  3693. * @arg @ref LL_ADC_CHANNEL_7
  3694. * @arg @ref LL_ADC_CHANNEL_8
  3695. * @arg @ref LL_ADC_CHANNEL_9
  3696. * @arg @ref LL_ADC_CHANNEL_10
  3697. * @arg @ref LL_ADC_CHANNEL_11
  3698. * @arg @ref LL_ADC_CHANNEL_12
  3699. * @arg @ref LL_ADC_CHANNEL_13
  3700. * @arg @ref LL_ADC_CHANNEL_14
  3701. * @arg @ref LL_ADC_CHANNEL_15
  3702. * @arg @ref LL_ADC_CHANNEL_16
  3703. * @arg @ref LL_ADC_CHANNEL_17
  3704. * @arg @ref LL_ADC_CHANNEL_18
  3705. * @arg @ref LL_ADC_CHANNEL_VREFINT
  3706. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  3707. * @arg @ref LL_ADC_CHANNEL_VBAT
  3708. *
  3709. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  3710. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  3711. * @retval None
  3712. */
  3713. __STATIC_INLINE void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  3714. {
  3715. #if defined (ADC_SUPPORT_2_5_MSPS)
  3716. /* Set bits with content of parameter "Channel" with bits position */
  3717. /* in register depending on parameter "Rank". */
  3718. /* Parameters "Rank" and "Channel" are used with masks because containing */
  3719. /* other bits reserved for other purpose. */
  3720. MODIFY_REG(ADCx->CHSELR,
  3721. ADC_CHSELR_SQ1 << (Rank & ADC_REG_RANK_ID_SQRX_MASK),
  3722. ((Channel & ADC_CHANNEL_ID_NUMBER_MASK_SEQ) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (Rank & ADC_REG_RANK_ID_SQRX_MASK));
  3723. #else
  3724. /* Set bits with content of parameter "Channel" with bits position */
  3725. /* in register and register position depending on parameter "Rank". */
  3726. /* Parameters "Rank" and "Channel" are used with masks because containing */
  3727. /* other bits reserved for other purpose. */
  3728. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, ((Rank & ADC_REG_SQRX_REGOFFSET_MASK) >> ADC_SQRX_REGOFFSET_POS));
  3729. MODIFY_REG(*preg,
  3730. ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 << (Rank & ADC_REG_RANK_ID_SQRX_MASK),
  3731. ((Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (Rank & ADC_REG_RANK_ID_SQRX_MASK));
  3732. #endif
  3733. }
  3734. /**
  3735. * @brief Get ADC group regular sequence: channel on the selected
  3736. * scan sequence rank.
  3737. * @note On this STM32 serie, ADC group regular sequencer is
  3738. * fully configurable: sequencer length and each rank
  3739. * affectation to a channel are configurable.
  3740. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  3741. * @note Depending on devices and packages, some channels may not be available.
  3742. * Refer to device datasheet for channels availability.
  3743. * @note Usage of the returned channel number:
  3744. * - To reinject this channel into another function LL_ADC_xxx:
  3745. * the returned channel number is only partly formatted on definition
  3746. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  3747. * with parts of literals LL_ADC_CHANNEL_x or using
  3748. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3749. * Then the selected literal LL_ADC_CHANNEL_x can be used
  3750. * as parameter for another function.
  3751. * - To get the channel number in decimal format:
  3752. * process the returned value with the helper macro
  3753. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3754. * @rmtoll SQR1 SQ1 LL_ADC_REG_GetSequencerRanks\n
  3755. * SQR1 SQ2 LL_ADC_REG_GetSequencerRanks\n
  3756. * SQR1 SQ3 LL_ADC_REG_GetSequencerRanks\n
  3757. * SQR1 SQ4 LL_ADC_REG_GetSequencerRanks\n
  3758. * SQR2 SQ5 LL_ADC_REG_GetSequencerRanks\n
  3759. * SQR2 SQ6 LL_ADC_REG_GetSequencerRanks\n
  3760. * SQR2 SQ7 LL_ADC_REG_GetSequencerRanks\n
  3761. * SQR2 SQ8 LL_ADC_REG_GetSequencerRanks\n
  3762. * SQR2 SQ9 LL_ADC_REG_GetSequencerRanks\n
  3763. * SQR3 SQ10 LL_ADC_REG_GetSequencerRanks\n
  3764. * SQR3 SQ11 LL_ADC_REG_GetSequencerRanks\n
  3765. * SQR3 SQ12 LL_ADC_REG_GetSequencerRanks\n
  3766. * SQR3 SQ13 LL_ADC_REG_GetSequencerRanks\n
  3767. * SQR3 SQ14 LL_ADC_REG_GetSequencerRanks\n
  3768. * SQR4 SQ15 LL_ADC_REG_GetSequencerRanks\n
  3769. * SQR4 SQ16 LL_ADC_REG_GetSequencerRanks
  3770. * @param ADCx ADC instance
  3771. * @param Rank This parameter can be one of the following values:
  3772. * @arg @ref LL_ADC_REG_RANK_1
  3773. * @arg @ref LL_ADC_REG_RANK_2
  3774. * @arg @ref LL_ADC_REG_RANK_3
  3775. * @arg @ref LL_ADC_REG_RANK_4
  3776. * @arg @ref LL_ADC_REG_RANK_5
  3777. * @arg @ref LL_ADC_REG_RANK_6
  3778. * @arg @ref LL_ADC_REG_RANK_7
  3779. * @arg @ref LL_ADC_REG_RANK_8
  3780. * @arg @ref LL_ADC_REG_RANK_9 (1)
  3781. * @arg @ref LL_ADC_REG_RANK_10 (1)
  3782. * @arg @ref LL_ADC_REG_RANK_11 (1)
  3783. * @arg @ref LL_ADC_REG_RANK_12 (1)
  3784. * @arg @ref LL_ADC_REG_RANK_13 (1)
  3785. * @arg @ref LL_ADC_REG_RANK_14 (1)
  3786. * @arg @ref LL_ADC_REG_RANK_15 (1)
  3787. * @arg @ref LL_ADC_REG_RANK_16 (1)
  3788. *
  3789. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  3790. * @retval Returned value can be one of the following values:
  3791. * @arg @ref LL_ADC_CHANNEL_0
  3792. * @arg @ref LL_ADC_CHANNEL_1 (7)
  3793. * @arg @ref LL_ADC_CHANNEL_2 (7)
  3794. * @arg @ref LL_ADC_CHANNEL_3 (7)
  3795. * @arg @ref LL_ADC_CHANNEL_4 (7)
  3796. * @arg @ref LL_ADC_CHANNEL_5 (7)
  3797. * @arg @ref LL_ADC_CHANNEL_6
  3798. * @arg @ref LL_ADC_CHANNEL_7
  3799. * @arg @ref LL_ADC_CHANNEL_8
  3800. * @arg @ref LL_ADC_CHANNEL_9
  3801. * @arg @ref LL_ADC_CHANNEL_10
  3802. * @arg @ref LL_ADC_CHANNEL_11
  3803. * @arg @ref LL_ADC_CHANNEL_12
  3804. * @arg @ref LL_ADC_CHANNEL_13
  3805. * @arg @ref LL_ADC_CHANNEL_14
  3806. * @arg @ref LL_ADC_CHANNEL_15
  3807. * @arg @ref LL_ADC_CHANNEL_16
  3808. * @arg @ref LL_ADC_CHANNEL_17
  3809. * @arg @ref LL_ADC_CHANNEL_18
  3810. * @arg @ref LL_ADC_CHANNEL_VREFINT (4)
  3811. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  3812. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  3813. *
  3814. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  3815. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).\n
  3816. * (4) For ADC channel read back from ADC register,
  3817. * comparison with internal channel parameter to be done
  3818. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  3819. */
  3820. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  3821. {
  3822. #if defined (ADC_SUPPORT_2_5_MSPS)
  3823. return (uint32_t) ((READ_BIT(ADCx->CHSELR,
  3824. ADC_CHSELR_SQ1 << (Rank & ADC_REG_RANK_ID_SQRX_MASK))
  3825. >> (Rank & ADC_REG_RANK_ID_SQRX_MASK)
  3826. ) << (ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  3827. );
  3828. #else
  3829. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, ((Rank & ADC_REG_SQRX_REGOFFSET_MASK) >> ADC_SQRX_REGOFFSET_POS));
  3830. return (uint32_t)((READ_BIT(*preg,
  3831. ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 << (Rank & ADC_REG_RANK_ID_SQRX_MASK))
  3832. >> (Rank & ADC_REG_RANK_ID_SQRX_MASK)) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS
  3833. );
  3834. #endif
  3835. }
  3836. #if defined(ADC_SUPPORT_2_5_MSPS)
  3837. /**
  3838. * @brief Set ADC group regular sequence: channel on rank corresponding to
  3839. * channel number.
  3840. * @note This function performs:
  3841. * - Channels ordering into each rank of scan sequence:
  3842. * rank of each channel is fixed by channel HW number
  3843. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  3844. * - Set channels selected by overwriting the current sequencer
  3845. * configuration.
  3846. * @note On this STM32 serie, ADC group regular sequencer both modes
  3847. * "fully configurable" or "not fully configurable"
  3848. * are available, they can be chosen using
  3849. * function @ref LL_ADC_REG_SetSequencerConfigurable().
  3850. * This function can be used with setting "not fully configurable".
  3851. * Refer to description of functions @ref LL_ADC_REG_SetSequencerConfigurable()
  3852. * and @ref LL_ADC_REG_SetSequencerLength().
  3853. * @note Depending on devices and packages, some channels may not be available.
  3854. * Refer to device datasheet for channels availability.
  3855. * @note On this STM32 serie, to measure internal channels (VrefInt,
  3856. * TempSensor, ...), measurement paths to internal channels must be
  3857. * enabled separately.
  3858. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  3859. * @note On STM32WB (except devices: STM32WB10xx, STM32WB15xx), some fast channels are available: fast analog inputs
  3860. * coming from GPIO pads (ADC_IN1..5).
  3861. * @note On this STM32 serie, setting of this feature is conditioned to
  3862. * ADC state:
  3863. * ADC must be disabled or enabled without conversion on going
  3864. * on group regular.
  3865. * @note One or several values can be selected.
  3866. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  3867. * @rmtoll CHSELR CHSEL0 LL_ADC_REG_SetSequencerChannels\n
  3868. * CHSELR CHSEL1 LL_ADC_REG_SetSequencerChannels\n
  3869. * CHSELR CHSEL2 LL_ADC_REG_SetSequencerChannels\n
  3870. * CHSELR CHSEL3 LL_ADC_REG_SetSequencerChannels\n
  3871. * CHSELR CHSEL4 LL_ADC_REG_SetSequencerChannels\n
  3872. * CHSELR CHSEL5 LL_ADC_REG_SetSequencerChannels\n
  3873. * CHSELR CHSEL6 LL_ADC_REG_SetSequencerChannels\n
  3874. * CHSELR CHSEL7 LL_ADC_REG_SetSequencerChannels\n
  3875. * CHSELR CHSEL8 LL_ADC_REG_SetSequencerChannels\n
  3876. * CHSELR CHSEL9 LL_ADC_REG_SetSequencerChannels\n
  3877. * CHSELR CHSEL10 LL_ADC_REG_SetSequencerChannels\n
  3878. * CHSELR CHSEL11 LL_ADC_REG_SetSequencerChannels\n
  3879. * CHSELR CHSEL12 LL_ADC_REG_SetSequencerChannels\n
  3880. * CHSELR CHSEL13 LL_ADC_REG_SetSequencerChannels\n
  3881. * CHSELR CHSEL14 LL_ADC_REG_SetSequencerChannels\n
  3882. * CHSELR CHSEL15 LL_ADC_REG_SetSequencerChannels\n
  3883. * CHSELR CHSEL16 LL_ADC_REG_SetSequencerChannels\n
  3884. * CHSELR CHSEL17 LL_ADC_REG_SetSequencerChannels\n
  3885. * CHSELR CHSEL18 LL_ADC_REG_SetSequencerChannels
  3886. * @param ADCx ADC instance
  3887. * @param Channel This parameter can be a combination of the following values:
  3888. * @arg @ref LL_ADC_CHANNEL_0
  3889. * @arg @ref LL_ADC_CHANNEL_1 (7)
  3890. * @arg @ref LL_ADC_CHANNEL_2 (7)
  3891. * @arg @ref LL_ADC_CHANNEL_3 (7)
  3892. * @arg @ref LL_ADC_CHANNEL_4 (7)
  3893. * @arg @ref LL_ADC_CHANNEL_5 (7)
  3894. * @arg @ref LL_ADC_CHANNEL_6
  3895. * @arg @ref LL_ADC_CHANNEL_7
  3896. * @arg @ref LL_ADC_CHANNEL_8
  3897. * @arg @ref LL_ADC_CHANNEL_9
  3898. * @arg @ref LL_ADC_CHANNEL_10
  3899. * @arg @ref LL_ADC_CHANNEL_11
  3900. * @arg @ref LL_ADC_CHANNEL_12
  3901. * @arg @ref LL_ADC_CHANNEL_13
  3902. * @arg @ref LL_ADC_CHANNEL_14
  3903. * @arg @ref LL_ADC_CHANNEL_15
  3904. * @arg @ref LL_ADC_CHANNEL_16
  3905. * @arg @ref LL_ADC_CHANNEL_17
  3906. * @arg @ref LL_ADC_CHANNEL_18
  3907. * @arg @ref LL_ADC_CHANNEL_VREFINT
  3908. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  3909. * @arg @ref LL_ADC_CHANNEL_VBAT
  3910. *
  3911. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  3912. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  3913. * @retval None
  3914. */
  3915. __STATIC_INLINE void LL_ADC_REG_SetSequencerChannels(ADC_TypeDef *ADCx, uint32_t Channel)
  3916. {
  3917. /* Parameter "Channel" is used with masks because containing */
  3918. /* other bits reserved for other purpose. */
  3919. WRITE_REG(ADCx->CHSELR, (Channel & ADC_CHANNEL_ID_BITFIELD_MASK));
  3920. }
  3921. /**
  3922. * @brief Add channel to ADC group regular sequence: channel on rank corresponding to
  3923. * channel number.
  3924. * @note This function performs:
  3925. * - Channels ordering into each rank of scan sequence:
  3926. * rank of each channel is fixed by channel HW number
  3927. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  3928. * - Set channels selected by adding them to the current sequencer
  3929. * configuration.
  3930. * @note On this STM32 serie, ADC group regular sequencer both modes
  3931. * "fully configurable" or "not fully configurable"
  3932. * are available, they can be chosen using
  3933. * function @ref LL_ADC_REG_SetSequencerConfigurable().
  3934. * This function can be used with setting "not fully configurable".
  3935. * Refer to description of functions @ref LL_ADC_REG_SetSequencerConfigurable()
  3936. * and @ref LL_ADC_REG_SetSequencerLength().
  3937. * @note Depending on devices and packages, some channels may not be available.
  3938. * Refer to device datasheet for channels availability.
  3939. * @note On this STM32 serie, to measure internal channels (VrefInt,
  3940. * TempSensor, ...), measurement paths to internal channels must be
  3941. * enabled separately.
  3942. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  3943. * @note On STM32WB (except devices: STM32WB10xx, STM32WB15xx), some fast channels are available: fast analog inputs
  3944. * coming from GPIO pads (ADC_IN1..5).
  3945. * @note On this STM32 serie, setting of this feature is conditioned to
  3946. * ADC state:
  3947. * ADC must be disabled or enabled without conversion on going
  3948. * on group regular.
  3949. * @note One or several values can be selected.
  3950. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  3951. * @rmtoll CHSELR CHSEL0 LL_ADC_REG_SetSequencerChAdd\n
  3952. * CHSELR CHSEL1 LL_ADC_REG_SetSequencerChAdd\n
  3953. * CHSELR CHSEL2 LL_ADC_REG_SetSequencerChAdd\n
  3954. * CHSELR CHSEL3 LL_ADC_REG_SetSequencerChAdd\n
  3955. * CHSELR CHSEL4 LL_ADC_REG_SetSequencerChAdd\n
  3956. * CHSELR CHSEL5 LL_ADC_REG_SetSequencerChAdd\n
  3957. * CHSELR CHSEL6 LL_ADC_REG_SetSequencerChAdd\n
  3958. * CHSELR CHSEL7 LL_ADC_REG_SetSequencerChAdd\n
  3959. * CHSELR CHSEL8 LL_ADC_REG_SetSequencerChAdd\n
  3960. * CHSELR CHSEL9 LL_ADC_REG_SetSequencerChAdd\n
  3961. * CHSELR CHSEL10 LL_ADC_REG_SetSequencerChAdd\n
  3962. * CHSELR CHSEL11 LL_ADC_REG_SetSequencerChAdd\n
  3963. * CHSELR CHSEL12 LL_ADC_REG_SetSequencerChAdd\n
  3964. * CHSELR CHSEL13 LL_ADC_REG_SetSequencerChAdd\n
  3965. * CHSELR CHSEL14 LL_ADC_REG_SetSequencerChAdd\n
  3966. * CHSELR CHSEL15 LL_ADC_REG_SetSequencerChAdd\n
  3967. * CHSELR CHSEL16 LL_ADC_REG_SetSequencerChAdd\n
  3968. * CHSELR CHSEL17 LL_ADC_REG_SetSequencerChAdd\n
  3969. * CHSELR CHSEL18 LL_ADC_REG_SetSequencerChAdd
  3970. * @param ADCx ADC instance
  3971. * @param Channel This parameter can be a combination of the following values:
  3972. * @arg @ref LL_ADC_CHANNEL_0
  3973. * @arg @ref LL_ADC_CHANNEL_1 (7)
  3974. * @arg @ref LL_ADC_CHANNEL_2 (7)
  3975. * @arg @ref LL_ADC_CHANNEL_3 (7)
  3976. * @arg @ref LL_ADC_CHANNEL_4 (7)
  3977. * @arg @ref LL_ADC_CHANNEL_5 (7)
  3978. * @arg @ref LL_ADC_CHANNEL_6
  3979. * @arg @ref LL_ADC_CHANNEL_7
  3980. * @arg @ref LL_ADC_CHANNEL_8
  3981. * @arg @ref LL_ADC_CHANNEL_9
  3982. * @arg @ref LL_ADC_CHANNEL_10
  3983. * @arg @ref LL_ADC_CHANNEL_11
  3984. * @arg @ref LL_ADC_CHANNEL_12
  3985. * @arg @ref LL_ADC_CHANNEL_13
  3986. * @arg @ref LL_ADC_CHANNEL_14
  3987. * @arg @ref LL_ADC_CHANNEL_15
  3988. * @arg @ref LL_ADC_CHANNEL_16
  3989. * @arg @ref LL_ADC_CHANNEL_17
  3990. * @arg @ref LL_ADC_CHANNEL_18
  3991. * @arg @ref LL_ADC_CHANNEL_VREFINT
  3992. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  3993. * @arg @ref LL_ADC_CHANNEL_VBAT
  3994. *
  3995. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  3996. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  3997. * @retval None
  3998. */
  3999. __STATIC_INLINE void LL_ADC_REG_SetSequencerChAdd(ADC_TypeDef *ADCx, uint32_t Channel)
  4000. {
  4001. /* Parameter "Channel" is used with masks because containing */
  4002. /* other bits reserved for other purpose. */
  4003. SET_BIT(ADCx->CHSELR, (Channel & ADC_CHANNEL_ID_BITFIELD_MASK));
  4004. }
  4005. /**
  4006. * @brief Remove channel to ADC group regular sequence: channel on rank corresponding to
  4007. * channel number.
  4008. * @note This function performs:
  4009. * - Channels ordering into each rank of scan sequence:
  4010. * rank of each channel is fixed by channel HW number
  4011. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  4012. * - Set channels selected by removing them to the current sequencer
  4013. * configuration.
  4014. * @note On this STM32 serie, ADC group regular sequencer both modes
  4015. * "fully configurable" or "not fully configurable"
  4016. * are available, they can be chosen using
  4017. * function @ref LL_ADC_REG_SetSequencerConfigurable().
  4018. * This function can be used with setting "not fully configurable".
  4019. * Refer to description of functions @ref LL_ADC_REG_SetSequencerConfigurable()
  4020. * and @ref LL_ADC_REG_SetSequencerLength().
  4021. * @note Depending on devices and packages, some channels may not be available.
  4022. * Refer to device datasheet for channels availability.
  4023. * @note On this STM32 serie, to measure internal channels (VrefInt,
  4024. * TempSensor, ...), measurement paths to internal channels must be
  4025. * enabled separately.
  4026. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  4027. * @note On STM32WB (except devices: STM32WB10xx, STM32WB15xx), some fast channels are available: fast analog inputs
  4028. * coming from GPIO pads (ADC_IN1..5).
  4029. * @note On this STM32 serie, setting of this feature is conditioned to
  4030. * ADC state:
  4031. * ADC must be disabled or enabled without conversion on going
  4032. * on group regular.
  4033. * @note One or several values can be selected.
  4034. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  4035. * @rmtoll CHSELR CHSEL0 LL_ADC_REG_SetSequencerChRem\n
  4036. * CHSELR CHSEL1 LL_ADC_REG_SetSequencerChRem\n
  4037. * CHSELR CHSEL2 LL_ADC_REG_SetSequencerChRem\n
  4038. * CHSELR CHSEL3 LL_ADC_REG_SetSequencerChRem\n
  4039. * CHSELR CHSEL4 LL_ADC_REG_SetSequencerChRem\n
  4040. * CHSELR CHSEL5 LL_ADC_REG_SetSequencerChRem\n
  4041. * CHSELR CHSEL6 LL_ADC_REG_SetSequencerChRem\n
  4042. * CHSELR CHSEL7 LL_ADC_REG_SetSequencerChRem\n
  4043. * CHSELR CHSEL8 LL_ADC_REG_SetSequencerChRem\n
  4044. * CHSELR CHSEL9 LL_ADC_REG_SetSequencerChRem\n
  4045. * CHSELR CHSEL10 LL_ADC_REG_SetSequencerChRem\n
  4046. * CHSELR CHSEL11 LL_ADC_REG_SetSequencerChRem\n
  4047. * CHSELR CHSEL12 LL_ADC_REG_SetSequencerChRem\n
  4048. * CHSELR CHSEL13 LL_ADC_REG_SetSequencerChRem\n
  4049. * CHSELR CHSEL14 LL_ADC_REG_SetSequencerChRem\n
  4050. * CHSELR CHSEL15 LL_ADC_REG_SetSequencerChRem\n
  4051. * CHSELR CHSEL16 LL_ADC_REG_SetSequencerChRem\n
  4052. * CHSELR CHSEL17 LL_ADC_REG_SetSequencerChRem\n
  4053. * CHSELR CHSEL18 LL_ADC_REG_SetSequencerChRem
  4054. * @param ADCx ADC instance
  4055. * @param Channel This parameter can be a combination of the following values:
  4056. * @arg @ref LL_ADC_CHANNEL_0
  4057. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4058. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4059. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4060. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4061. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4062. * @arg @ref LL_ADC_CHANNEL_6
  4063. * @arg @ref LL_ADC_CHANNEL_7
  4064. * @arg @ref LL_ADC_CHANNEL_8
  4065. * @arg @ref LL_ADC_CHANNEL_9
  4066. * @arg @ref LL_ADC_CHANNEL_10
  4067. * @arg @ref LL_ADC_CHANNEL_11
  4068. * @arg @ref LL_ADC_CHANNEL_12
  4069. * @arg @ref LL_ADC_CHANNEL_13
  4070. * @arg @ref LL_ADC_CHANNEL_14
  4071. * @arg @ref LL_ADC_CHANNEL_15
  4072. * @arg @ref LL_ADC_CHANNEL_16
  4073. * @arg @ref LL_ADC_CHANNEL_17
  4074. * @arg @ref LL_ADC_CHANNEL_18
  4075. * @arg @ref LL_ADC_CHANNEL_VREFINT
  4076. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  4077. * @arg @ref LL_ADC_CHANNEL_VBAT
  4078. *
  4079. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4080. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  4081. * @retval None
  4082. */
  4083. __STATIC_INLINE void LL_ADC_REG_SetSequencerChRem(ADC_TypeDef *ADCx, uint32_t Channel)
  4084. {
  4085. /* Parameter "Channel" is used with masks because containing */
  4086. /* other bits reserved for other purpose. */
  4087. CLEAR_BIT(ADCx->CHSELR, (Channel & ADC_CHANNEL_ID_BITFIELD_MASK));
  4088. }
  4089. /**
  4090. * @brief Get ADC group regular sequence: channel on rank corresponding to
  4091. * channel number.
  4092. * @note This function performs:
  4093. * - Channels order reading into each rank of scan sequence:
  4094. * rank of each channel is fixed by channel HW number
  4095. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  4096. * @note On this STM32 serie, ADC group regular sequencer both modes
  4097. * "fully configurable" or "not fully configurable"
  4098. * are available, they can be chosen using
  4099. * function @ref LL_ADC_REG_SetSequencerConfigurable().
  4100. * This function can be used with setting "not fully configurable".
  4101. * Refer to description of functions @ref LL_ADC_REG_SetSequencerConfigurable()
  4102. * and @ref LL_ADC_REG_SetSequencerLength().
  4103. * @note Depending on devices and packages, some channels may not be available.
  4104. * Refer to device datasheet for channels availability.
  4105. * @note On this STM32 serie, to measure internal channels (VrefInt,
  4106. * TempSensor, ...), measurement paths to internal channels must be
  4107. * enabled separately.
  4108. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  4109. * @note On STM32WB (except devices: STM32WB10xx, STM32WB15xx), some fast channels are available: fast analog inputs
  4110. * coming from GPIO pads (ADC_IN1..5).
  4111. */
  4112. //TBC
  4113. /*
  4114. * @note On this STM32 serie, setting of this feature is conditioned to
  4115. * ADC state:
  4116. * ADC must be disabled or enabled without conversion on going
  4117. * on group regular.
  4118. * @note One or several values can be retrieved.
  4119. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  4120. * @rmtoll CHSELR CHSEL0 LL_ADC_REG_GetSequencerChannels\n
  4121. * CHSELR CHSEL1 LL_ADC_REG_GetSequencerChannels\n
  4122. * CHSELR CHSEL2 LL_ADC_REG_GetSequencerChannels\n
  4123. * CHSELR CHSEL3 LL_ADC_REG_GetSequencerChannels\n
  4124. * CHSELR CHSEL4 LL_ADC_REG_GetSequencerChannels\n
  4125. * CHSELR CHSEL5 LL_ADC_REG_GetSequencerChannels\n
  4126. * CHSELR CHSEL6 LL_ADC_REG_GetSequencerChannels\n
  4127. * CHSELR CHSEL7 LL_ADC_REG_GetSequencerChannels\n
  4128. * CHSELR CHSEL8 LL_ADC_REG_GetSequencerChannels\n
  4129. * CHSELR CHSEL9 LL_ADC_REG_GetSequencerChannels\n
  4130. * CHSELR CHSEL10 LL_ADC_REG_GetSequencerChannels\n
  4131. * CHSELR CHSEL11 LL_ADC_REG_GetSequencerChannels\n
  4132. * CHSELR CHSEL12 LL_ADC_REG_GetSequencerChannels\n
  4133. * CHSELR CHSEL13 LL_ADC_REG_GetSequencerChannels\n
  4134. * CHSELR CHSEL14 LL_ADC_REG_GetSequencerChannels\n
  4135. * CHSELR CHSEL15 LL_ADC_REG_GetSequencerChannels\n
  4136. * CHSELR CHSEL16 LL_ADC_REG_GetSequencerChannels\n
  4137. * CHSELR CHSEL17 LL_ADC_REG_GetSequencerChannels\n
  4138. * CHSELR CHSEL18 LL_ADC_REG_GetSequencerChannels
  4139. * @param ADCx ADC instance
  4140. * @retval Returned value can be a combination of the following values:
  4141. * @arg @ref LL_ADC_CHANNEL_0
  4142. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4143. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4144. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4145. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4146. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4147. * @arg @ref LL_ADC_CHANNEL_6
  4148. * @arg @ref LL_ADC_CHANNEL_7
  4149. * @arg @ref LL_ADC_CHANNEL_8
  4150. * @arg @ref LL_ADC_CHANNEL_9
  4151. * @arg @ref LL_ADC_CHANNEL_10
  4152. * @arg @ref LL_ADC_CHANNEL_11
  4153. * @arg @ref LL_ADC_CHANNEL_12
  4154. * @arg @ref LL_ADC_CHANNEL_13
  4155. * @arg @ref LL_ADC_CHANNEL_14
  4156. * @arg @ref LL_ADC_CHANNEL_15
  4157. * @arg @ref LL_ADC_CHANNEL_16
  4158. * @arg @ref LL_ADC_CHANNEL_17
  4159. * @arg @ref LL_ADC_CHANNEL_18
  4160. * @arg @ref LL_ADC_CHANNEL_VREFINT
  4161. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  4162. * @arg @ref LL_ADC_CHANNEL_VBAT
  4163. *
  4164. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4165. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  4166. */
  4167. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerChannels(ADC_TypeDef *ADCx)
  4168. {
  4169. uint32_t ChannelsBitfield = READ_BIT(ADCx->CHSELR, ADC_CHSELR_CHSEL);
  4170. return ( (((ChannelsBitfield & ADC_CHSELR_CHSEL0) >> ADC_CHSELR_CHSEL0_BITOFFSET_POS) * LL_ADC_CHANNEL_0)
  4171. | (((ChannelsBitfield & ADC_CHSELR_CHSEL1) >> ADC_CHSELR_CHSEL1_BITOFFSET_POS) * LL_ADC_CHANNEL_1)
  4172. | (((ChannelsBitfield & ADC_CHSELR_CHSEL2) >> ADC_CHSELR_CHSEL2_BITOFFSET_POS) * LL_ADC_CHANNEL_2)
  4173. | (((ChannelsBitfield & ADC_CHSELR_CHSEL3) >> ADC_CHSELR_CHSEL3_BITOFFSET_POS) * LL_ADC_CHANNEL_3)
  4174. | (((ChannelsBitfield & ADC_CHSELR_CHSEL4) >> ADC_CHSELR_CHSEL4_BITOFFSET_POS) * LL_ADC_CHANNEL_4)
  4175. | (((ChannelsBitfield & ADC_CHSELR_CHSEL5) >> ADC_CHSELR_CHSEL5_BITOFFSET_POS) * LL_ADC_CHANNEL_5)
  4176. | (((ChannelsBitfield & ADC_CHSELR_CHSEL6) >> ADC_CHSELR_CHSEL6_BITOFFSET_POS) * LL_ADC_CHANNEL_6)
  4177. | (((ChannelsBitfield & ADC_CHSELR_CHSEL7) >> ADC_CHSELR_CHSEL7_BITOFFSET_POS) * LL_ADC_CHANNEL_7)
  4178. | (((ChannelsBitfield & ADC_CHSELR_CHSEL8) >> ADC_CHSELR_CHSEL8_BITOFFSET_POS) * LL_ADC_CHANNEL_8)
  4179. | (((ChannelsBitfield & ADC_CHSELR_CHSEL9) >> ADC_CHSELR_CHSEL9_BITOFFSET_POS) * LL_ADC_CHANNEL_9)
  4180. | (((ChannelsBitfield & ADC_CHSELR_CHSEL10) >> ADC_CHSELR_CHSEL10_BITOFFSET_POS) * LL_ADC_CHANNEL_10)
  4181. | (((ChannelsBitfield & ADC_CHSELR_CHSEL11) >> ADC_CHSELR_CHSEL11_BITOFFSET_POS) * LL_ADC_CHANNEL_11)
  4182. | (((ChannelsBitfield & ADC_CHSELR_CHSEL12) >> ADC_CHSELR_CHSEL12_BITOFFSET_POS) * LL_ADC_CHANNEL_12)
  4183. | (((ChannelsBitfield & ADC_CHSELR_CHSEL13) >> ADC_CHSELR_CHSEL13_BITOFFSET_POS) * LL_ADC_CHANNEL_13)
  4184. | (((ChannelsBitfield & ADC_CHSELR_CHSEL14) >> ADC_CHSELR_CHSEL14_BITOFFSET_POS) * LL_ADC_CHANNEL_14)
  4185. | (((ChannelsBitfield & ADC_CHSELR_CHSEL15) >> ADC_CHSELR_CHSEL15_BITOFFSET_POS) * LL_ADC_CHANNEL_15)
  4186. | (((ChannelsBitfield & ADC_CHSELR_CHSEL16) >> ADC_CHSELR_CHSEL16_BITOFFSET_POS) * LL_ADC_CHANNEL_16)
  4187. | (((ChannelsBitfield & ADC_CHSELR_CHSEL17) >> ADC_CHSELR_CHSEL17_BITOFFSET_POS) * LL_ADC_CHANNEL_17)
  4188. | (((ChannelsBitfield & ADC_CHSELR_CHSEL18) >> ADC_CHSELR_CHSEL18_BITOFFSET_POS) * LL_ADC_CHANNEL_18)
  4189. );
  4190. }
  4191. #endif
  4192. /**
  4193. * @brief Set ADC continuous conversion mode on ADC group regular.
  4194. * @note Description of ADC continuous conversion mode:
  4195. * - single mode: one conversion per trigger
  4196. * - continuous mode: after the first trigger, following
  4197. * conversions launched successively automatically.
  4198. * @note It is not possible to enable both ADC group regular
  4199. * continuous mode and sequencer discontinuous mode.
  4200. * @note On this STM32 serie, setting of this feature is conditioned to
  4201. * ADC state:
  4202. * ADC must be disabled or enabled without conversion on going
  4203. * on group regular.
  4204. * @rmtoll CFGR CONT LL_ADC_REG_SetContinuousMode
  4205. * @param ADCx ADC instance
  4206. * @param Continuous This parameter can be one of the following values:
  4207. * @arg @ref LL_ADC_REG_CONV_SINGLE
  4208. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  4209. * @retval None
  4210. */
  4211. __STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
  4212. {
  4213. #if defined (ADC_SUPPORT_2_5_MSPS)
  4214. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_CONT, Continuous);
  4215. #else
  4216. MODIFY_REG(ADCx->CFGR, ADC_CFGR_CONT, Continuous);
  4217. #endif
  4218. }
  4219. /**
  4220. * @brief Get ADC continuous conversion mode on ADC group regular.
  4221. * @note Description of ADC continuous conversion mode:
  4222. * - single mode: one conversion per trigger
  4223. * - continuous mode: after the first trigger, following
  4224. * conversions launched successively automatically.
  4225. * @rmtoll CFGR CONT LL_ADC_REG_GetContinuousMode
  4226. * @param ADCx ADC instance
  4227. * @retval Returned value can be one of the following values:
  4228. * @arg @ref LL_ADC_REG_CONV_SINGLE
  4229. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  4230. */
  4231. __STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
  4232. {
  4233. #if defined (ADC_SUPPORT_2_5_MSPS)
  4234. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_CONT));
  4235. #else
  4236. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_CONT));
  4237. #endif
  4238. }
  4239. /**
  4240. * @brief Set ADC group regular conversion data transfer: no transfer or
  4241. * transfer by DMA, and DMA requests mode.
  4242. * @note If transfer by DMA selected, specifies the DMA requests
  4243. * mode:
  4244. * - Limited mode (One shot mode): DMA transfer requests are stopped
  4245. * when number of DMA data transfers (number of
  4246. * ADC conversions) is reached.
  4247. * This ADC mode is intended to be used with DMA mode non-circular.
  4248. * - Unlimited mode: DMA transfer requests are unlimited,
  4249. * whatever number of DMA data transfers (number of
  4250. * ADC conversions).
  4251. * This ADC mode is intended to be used with DMA mode circular.
  4252. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  4253. * mode non-circular:
  4254. * when DMA transfers size will be reached, DMA will stop transfers of
  4255. * ADC conversions data ADC will raise an overrun error
  4256. * (overrun flag and interruption if enabled).
  4257. * @note To configure DMA source address (peripheral address),
  4258. * use function @ref LL_ADC_DMA_GetRegAddr().
  4259. * @note On this STM32 serie, setting of this feature is conditioned to
  4260. * ADC state:
  4261. * ADC must be disabled or enabled without conversion on going
  4262. * on either groups regular or injected.
  4263. * @rmtoll CFGR DMAEN LL_ADC_REG_SetDMATransfer\n
  4264. * CFGR DMACFG LL_ADC_REG_SetDMATransfer
  4265. * @param ADCx ADC instance
  4266. * @param DMATransfer This parameter can be one of the following values:
  4267. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  4268. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  4269. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  4270. * @retval None
  4271. */
  4272. __STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
  4273. {
  4274. #if defined (ADC_SUPPORT_2_5_MSPS)
  4275. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_DMAEN | ADC_CFGR1_DMACFG, DMATransfer);
  4276. #else
  4277. MODIFY_REG(ADCx->CFGR, ADC_CFGR_DMAEN | ADC_CFGR_DMACFG, DMATransfer);
  4278. #endif
  4279. }
  4280. /**
  4281. * @brief Get ADC group regular conversion data transfer: no transfer or
  4282. * transfer by DMA, and DMA requests mode.
  4283. * @note If transfer by DMA selected, specifies the DMA requests
  4284. * mode:
  4285. * - Limited mode (One shot mode): DMA transfer requests are stopped
  4286. * when number of DMA data transfers (number of
  4287. * ADC conversions) is reached.
  4288. * This ADC mode is intended to be used with DMA mode non-circular.
  4289. * - Unlimited mode: DMA transfer requests are unlimited,
  4290. * whatever number of DMA data transfers (number of
  4291. * ADC conversions).
  4292. * This ADC mode is intended to be used with DMA mode circular.
  4293. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  4294. * mode non-circular:
  4295. * when DMA transfers size will be reached, DMA will stop transfers of
  4296. * ADC conversions data ADC will raise an overrun error
  4297. * (overrun flag and interruption if enabled).
  4298. * @note To configure DMA source address (peripheral address),
  4299. * use function @ref LL_ADC_DMA_GetRegAddr().
  4300. * @rmtoll CFGR DMAEN LL_ADC_REG_GetDMATransfer\n
  4301. * CFGR DMACFG LL_ADC_REG_GetDMATransfer
  4302. * @param ADCx ADC instance
  4303. * @retval Returned value can be one of the following values:
  4304. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  4305. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  4306. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  4307. */
  4308. __STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
  4309. {
  4310. #if defined (ADC_SUPPORT_2_5_MSPS)
  4311. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_DMAEN | ADC_CFGR1_DMACFG));
  4312. #else
  4313. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_DMAEN | ADC_CFGR_DMACFG));
  4314. #endif
  4315. }
  4316. /**
  4317. * @brief Set ADC group regular behavior in case of overrun:
  4318. * data preserved or overwritten.
  4319. * @note Compatibility with devices without feature overrun:
  4320. * other devices without this feature have a behavior
  4321. * equivalent to data overwritten.
  4322. * The default setting of overrun is data preserved.
  4323. * Therefore, for compatibility with all devices, parameter
  4324. * overrun should be set to data overwritten.
  4325. * @note On this STM32 serie, setting of this feature is conditioned to
  4326. * ADC state:
  4327. * ADC must be disabled or enabled without conversion on going
  4328. * on group regular.
  4329. * @rmtoll CFGR OVRMOD LL_ADC_REG_SetOverrun
  4330. * @param ADCx ADC instance
  4331. * @param Overrun This parameter can be one of the following values:
  4332. * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
  4333. * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
  4334. * @retval None
  4335. */
  4336. __STATIC_INLINE void LL_ADC_REG_SetOverrun(ADC_TypeDef *ADCx, uint32_t Overrun)
  4337. {
  4338. #if defined (ADC_SUPPORT_2_5_MSPS)
  4339. MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_OVRMOD, Overrun);
  4340. #else
  4341. MODIFY_REG(ADCx->CFGR, ADC_CFGR_OVRMOD, Overrun);
  4342. #endif
  4343. }
  4344. /**
  4345. * @brief Get ADC group regular behavior in case of overrun:
  4346. * data preserved or overwritten.
  4347. * @rmtoll CFGR OVRMOD LL_ADC_REG_GetOverrun
  4348. * @param ADCx ADC instance
  4349. * @retval Returned value can be one of the following values:
  4350. * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
  4351. * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
  4352. */
  4353. __STATIC_INLINE uint32_t LL_ADC_REG_GetOverrun(ADC_TypeDef *ADCx)
  4354. {
  4355. #if defined (ADC_SUPPORT_2_5_MSPS)
  4356. return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_OVRMOD));
  4357. #else
  4358. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_OVRMOD));
  4359. #endif
  4360. }
  4361. /**
  4362. * @}
  4363. */
  4364. #if defined (ADC_SUPPORT_2_5_MSPS)
  4365. /* Feature "ADC group injected" not available on ADC peripheral of this STM32WB device */
  4366. #else
  4367. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected
  4368. * @{
  4369. */
  4370. /**
  4371. * @brief Set ADC group injected conversion trigger source:
  4372. * internal (SW start) or from external peripheral (timer event,
  4373. * external interrupt line).
  4374. * @note On this STM32 serie, setting trigger source to external trigger
  4375. * also set trigger polarity to rising edge
  4376. * (default setting for compatibility with some ADC on other
  4377. * STM32 families having this setting set by HW default value).
  4378. * In case of need to modify trigger edge, use
  4379. * function @ref LL_ADC_INJ_SetTriggerEdge().
  4380. * @note Availability of parameters of trigger sources from timer
  4381. * depends on timers availability on the selected device.
  4382. * @note On this STM32 serie, setting of this feature is conditioned to
  4383. * ADC state:
  4384. * ADC must not be disabled. Can be enabled with or without conversion
  4385. * on going on either groups regular or injected.
  4386. * @rmtoll JSQR JEXTSEL LL_ADC_INJ_SetTriggerSource\n
  4387. * JSQR JEXTEN LL_ADC_INJ_SetTriggerSource
  4388. * @param ADCx ADC instance
  4389. * @param TriggerSource This parameter can be one of the following values:
  4390. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  4391. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  4392. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2
  4393. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  4394. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  4395. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  4396. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  4397. * @retval None
  4398. */
  4399. __STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  4400. {
  4401. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN, TriggerSource);
  4402. }
  4403. /**
  4404. * @brief Get ADC group injected conversion trigger source:
  4405. * internal (SW start) or from external peripheral (timer event,
  4406. * external interrupt line).
  4407. * @note To determine whether group injected trigger source is
  4408. * internal (SW start) or external, without detail
  4409. * of which peripheral is selected as external trigger,
  4410. * (equivalent to
  4411. * "if(LL_ADC_INJ_GetTriggerSource(ADC1) == LL_ADC_INJ_TRIG_SOFTWARE)")
  4412. * use function @ref LL_ADC_INJ_IsTriggerSourceSWStart.
  4413. * @note Availability of parameters of trigger sources from timer
  4414. * depends on timers availability on the selected device.
  4415. * @rmtoll JSQR JEXTSEL LL_ADC_INJ_GetTriggerSource\n
  4416. * JSQR JEXTEN LL_ADC_INJ_GetTriggerSource
  4417. * @param ADCx ADC instance
  4418. * @retval Returned value can be one of the following values:
  4419. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  4420. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  4421. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2
  4422. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  4423. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  4424. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  4425. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  4426. */
  4427. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerSource(ADC_TypeDef *ADCx)
  4428. {
  4429. __IO uint32_t TriggerSource = READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN);
  4430. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  4431. /* corresponding to ADC_JSQR_JEXTEN {0; 1; 2; 3}. */
  4432. uint32_t ShiftJexten = ((TriggerSource & ADC_JSQR_JEXTEN) >> (ADC_INJ_TRIG_EXTEN_BITOFFSET_POS - 2UL));
  4433. /* Set bitfield corresponding to ADC_JSQR_JEXTEN and ADC_JSQR_JEXTSEL */
  4434. /* to match with triggers literals definition. */
  4435. return ((TriggerSource
  4436. & (ADC_INJ_TRIG_SOURCE_MASK >> ShiftJexten) & ADC_JSQR_JEXTSEL)
  4437. | ((ADC_INJ_TRIG_EDGE_MASK >> ShiftJexten) & ADC_JSQR_JEXTEN)
  4438. );
  4439. }
  4440. /**
  4441. * @brief Get ADC group injected conversion trigger source internal (SW start)
  4442. or external
  4443. * @note In case of group injected trigger source set to external trigger,
  4444. * to determine which peripheral is selected as external trigger,
  4445. * use function @ref LL_ADC_INJ_GetTriggerSource.
  4446. * @rmtoll JSQR JEXTEN LL_ADC_INJ_IsTriggerSourceSWStart
  4447. * @param ADCx ADC instance
  4448. * @retval Value "0" if trigger source external trigger
  4449. * Value "1" if trigger source SW start.
  4450. */
  4451. __STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  4452. {
  4453. return ((READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTEN) == (LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTEN)) ? 1UL : 0UL);
  4454. }
  4455. /**
  4456. * @brief Set ADC group injected conversion trigger polarity.
  4457. * Applicable only for trigger source set to external trigger.
  4458. * @note On this STM32 serie, setting of this feature is conditioned to
  4459. * ADC state:
  4460. * ADC must not be disabled. Can be enabled with or without conversion
  4461. * on going on either groups regular or injected.
  4462. * @rmtoll JSQR JEXTEN LL_ADC_INJ_SetTriggerEdge
  4463. * @param ADCx ADC instance
  4464. * @param ExternalTriggerEdge This parameter can be one of the following values:
  4465. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  4466. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  4467. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  4468. * @retval None
  4469. */
  4470. __STATIC_INLINE void LL_ADC_INJ_SetTriggerEdge(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  4471. {
  4472. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JEXTEN, ExternalTriggerEdge);
  4473. }
  4474. /**
  4475. * @brief Get ADC group injected conversion trigger polarity.
  4476. * Applicable only for trigger source set to external trigger.
  4477. * @rmtoll JSQR JEXTEN LL_ADC_INJ_GetTriggerEdge
  4478. * @param ADCx ADC instance
  4479. * @retval Returned value can be one of the following values:
  4480. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  4481. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  4482. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  4483. */
  4484. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerEdge(ADC_TypeDef *ADCx)
  4485. {
  4486. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTEN));
  4487. }
  4488. /**
  4489. * @brief Set ADC group injected sequencer length and scan direction.
  4490. * @note This function performs configuration of:
  4491. * - Sequence length: Number of ranks in the scan sequence.
  4492. * - Sequence direction: Unless specified in parameters, sequencer
  4493. * scan direction is forward (from rank 1 to rank n).
  4494. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  4495. * ADC conversion on only 1 channel.
  4496. * @note On this STM32 serie, setting of this feature is conditioned to
  4497. * ADC state:
  4498. * ADC must not be disabled. Can be enabled with or without conversion
  4499. * on going on either groups regular or injected.
  4500. * @rmtoll JSQR JL LL_ADC_INJ_SetSequencerLength
  4501. * @param ADCx ADC instance
  4502. * @param SequencerNbRanks This parameter can be one of the following values:
  4503. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  4504. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  4505. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  4506. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  4507. * @retval None
  4508. */
  4509. __STATIC_INLINE void LL_ADC_INJ_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  4510. {
  4511. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JL, SequencerNbRanks);
  4512. }
  4513. /**
  4514. * @brief Get ADC group injected sequencer length and scan direction.
  4515. * @note This function retrieves:
  4516. * - Sequence length: Number of ranks in the scan sequence.
  4517. * - Sequence direction: Unless specified in parameters, sequencer
  4518. * scan direction is forward (from rank 1 to rank n).
  4519. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  4520. * ADC conversion on only 1 channel.
  4521. * @rmtoll JSQR JL LL_ADC_INJ_GetSequencerLength
  4522. * @param ADCx ADC instance
  4523. * @retval Returned value can be one of the following values:
  4524. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  4525. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  4526. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  4527. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  4528. */
  4529. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerLength(ADC_TypeDef *ADCx)
  4530. {
  4531. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JL));
  4532. }
  4533. /**
  4534. * @brief Set ADC group injected sequencer discontinuous mode:
  4535. * sequence subdivided and scan conversions interrupted every selected
  4536. * number of ranks.
  4537. * @note It is not possible to enable both ADC group injected
  4538. * auto-injected mode and sequencer discontinuous mode.
  4539. * @rmtoll CFGR JDISCEN LL_ADC_INJ_SetSequencerDiscont
  4540. * @param ADCx ADC instance
  4541. * @param SeqDiscont This parameter can be one of the following values:
  4542. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  4543. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  4544. * @retval None
  4545. */
  4546. __STATIC_INLINE void LL_ADC_INJ_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  4547. {
  4548. MODIFY_REG(ADCx->CFGR, ADC_CFGR_JDISCEN, SeqDiscont);
  4549. }
  4550. /**
  4551. * @brief Get ADC group injected sequencer discontinuous mode:
  4552. * sequence subdivided and scan conversions interrupted every selected
  4553. * number of ranks.
  4554. * @rmtoll CFGR JDISCEN LL_ADC_INJ_GetSequencerDiscont
  4555. * @param ADCx ADC instance
  4556. * @retval Returned value can be one of the following values:
  4557. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  4558. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  4559. */
  4560. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerDiscont(ADC_TypeDef *ADCx)
  4561. {
  4562. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JDISCEN));
  4563. }
  4564. /**
  4565. * @brief Set ADC group injected sequence: channel on the selected
  4566. * sequence rank.
  4567. * @note Depending on devices and packages, some channels may not be available.
  4568. * Refer to device datasheet for channels availability.
  4569. * @note On this STM32 serie, to measure internal channels (VrefInt,
  4570. * TempSensor, ...), measurement paths to internal channels must be
  4571. * enabled separately.
  4572. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  4573. * @note On STM32WB (except devices: STM32WB10xx, STM32WB15xx), some fast channels are available: fast analog inputs
  4574. * coming from GPIO pads (ADC_IN1..5).
  4575. * @note On this STM32 serie, setting of this feature is conditioned to
  4576. * ADC state:
  4577. * ADC must not be disabled. Can be enabled with or without conversion
  4578. * on going on either groups regular or injected.
  4579. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  4580. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  4581. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  4582. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  4583. * @param ADCx ADC instance
  4584. * @param Rank This parameter can be one of the following values:
  4585. * @arg @ref LL_ADC_INJ_RANK_1
  4586. * @arg @ref LL_ADC_INJ_RANK_2
  4587. * @arg @ref LL_ADC_INJ_RANK_3
  4588. * @arg @ref LL_ADC_INJ_RANK_4
  4589. * @param Channel This parameter can be one of the following values:
  4590. * @arg @ref LL_ADC_CHANNEL_0
  4591. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4592. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4593. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4594. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4595. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4596. * @arg @ref LL_ADC_CHANNEL_6
  4597. * @arg @ref LL_ADC_CHANNEL_7
  4598. * @arg @ref LL_ADC_CHANNEL_8
  4599. * @arg @ref LL_ADC_CHANNEL_9
  4600. * @arg @ref LL_ADC_CHANNEL_10
  4601. * @arg @ref LL_ADC_CHANNEL_11
  4602. * @arg @ref LL_ADC_CHANNEL_12
  4603. * @arg @ref LL_ADC_CHANNEL_13
  4604. * @arg @ref LL_ADC_CHANNEL_14
  4605. * @arg @ref LL_ADC_CHANNEL_15
  4606. * @arg @ref LL_ADC_CHANNEL_16
  4607. * @arg @ref LL_ADC_CHANNEL_17
  4608. * @arg @ref LL_ADC_CHANNEL_18
  4609. * @arg @ref LL_ADC_CHANNEL_VREFINT
  4610. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  4611. * @arg @ref LL_ADC_CHANNEL_VBAT
  4612. *
  4613. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4614. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  4615. * @retval None
  4616. */
  4617. __STATIC_INLINE void LL_ADC_INJ_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  4618. {
  4619. /* Set bits with content of parameter "Channel" with bits position */
  4620. /* in register depending on parameter "Rank". */
  4621. /* Parameters "Rank" and "Channel" are used with masks because containing */
  4622. /* other bits reserved for other purpose. */
  4623. MODIFY_REG(ADCx->JSQR,
  4624. (ADC_CHANNEL_ID_NUMBER_MASK >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK),
  4625. ((Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK));
  4626. }
  4627. /**
  4628. * @brief Get ADC group injected sequence: channel on the selected
  4629. * sequence rank.
  4630. * @note Depending on devices and packages, some channels may not be available.
  4631. * Refer to device datasheet for channels availability.
  4632. * @note Usage of the returned channel number:
  4633. * - To reinject this channel into another function LL_ADC_xxx:
  4634. * the returned channel number is only partly formatted on definition
  4635. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  4636. * with parts of literals LL_ADC_CHANNEL_x or using
  4637. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4638. * Then the selected literal LL_ADC_CHANNEL_x can be used
  4639. * as parameter for another function.
  4640. * - To get the channel number in decimal format:
  4641. * process the returned value with the helper macro
  4642. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  4643. * @rmtoll JSQR JSQ1 LL_ADC_INJ_GetSequencerRanks\n
  4644. * JSQR JSQ2 LL_ADC_INJ_GetSequencerRanks\n
  4645. * JSQR JSQ3 LL_ADC_INJ_GetSequencerRanks\n
  4646. * JSQR JSQ4 LL_ADC_INJ_GetSequencerRanks
  4647. * @param ADCx ADC instance
  4648. * @param Rank This parameter can be one of the following values:
  4649. * @arg @ref LL_ADC_INJ_RANK_1
  4650. * @arg @ref LL_ADC_INJ_RANK_2
  4651. * @arg @ref LL_ADC_INJ_RANK_3
  4652. * @arg @ref LL_ADC_INJ_RANK_4
  4653. * @retval Returned value can be one of the following values:
  4654. * @arg @ref LL_ADC_CHANNEL_0
  4655. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4656. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4657. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4658. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4659. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4660. * @arg @ref LL_ADC_CHANNEL_6
  4661. * @arg @ref LL_ADC_CHANNEL_7
  4662. * @arg @ref LL_ADC_CHANNEL_8
  4663. * @arg @ref LL_ADC_CHANNEL_9
  4664. * @arg @ref LL_ADC_CHANNEL_10
  4665. * @arg @ref LL_ADC_CHANNEL_11
  4666. * @arg @ref LL_ADC_CHANNEL_12
  4667. * @arg @ref LL_ADC_CHANNEL_13
  4668. * @arg @ref LL_ADC_CHANNEL_14
  4669. * @arg @ref LL_ADC_CHANNEL_15
  4670. * @arg @ref LL_ADC_CHANNEL_16
  4671. * @arg @ref LL_ADC_CHANNEL_17
  4672. * @arg @ref LL_ADC_CHANNEL_18
  4673. * @arg @ref LL_ADC_CHANNEL_VREFINT (4)
  4674. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (4)
  4675. * @arg @ref LL_ADC_CHANNEL_VBAT (4)
  4676. *
  4677. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4678. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).\n
  4679. * (4) For ADC channel read back from ADC register,
  4680. * comparison with internal channel parameter to be done
  4681. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  4682. */
  4683. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  4684. {
  4685. return (uint32_t)((READ_BIT(ADCx->JSQR,
  4686. (ADC_CHANNEL_ID_NUMBER_MASK >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK))
  4687. >> (Rank & ADC_INJ_RANK_ID_JSQR_MASK)) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS
  4688. );
  4689. }
  4690. /**
  4691. * @brief Set ADC group injected conversion trigger:
  4692. * independent or from ADC group regular.
  4693. * @note This mode can be used to extend number of data registers
  4694. * updated after one ADC conversion trigger and with data
  4695. * permanently kept (not erased by successive conversions of scan of
  4696. * ADC sequencer ranks), up to 5 data registers:
  4697. * 1 data register on ADC group regular, 4 data registers
  4698. * on ADC group injected.
  4699. * @note If ADC group injected injected trigger source is set to an
  4700. * external trigger, this feature must be must be set to
  4701. * independent trigger.
  4702. * ADC group injected automatic trigger is compliant only with
  4703. * group injected trigger source set to SW start, without any
  4704. * further action on ADC group injected conversion start or stop:
  4705. * in this case, ADC group injected is controlled only
  4706. * from ADC group regular.
  4707. * @note It is not possible to enable both ADC group injected
  4708. * auto-injected mode and sequencer discontinuous mode.
  4709. * @note On this STM32 serie, setting of this feature is conditioned to
  4710. * ADC state:
  4711. * ADC must be disabled or enabled without conversion on going
  4712. * on either groups regular or injected.
  4713. * @rmtoll CFGR JAUTO LL_ADC_INJ_SetTrigAuto
  4714. * @param ADCx ADC instance
  4715. * @param TrigAuto This parameter can be one of the following values:
  4716. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  4717. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  4718. * @retval None
  4719. */
  4720. __STATIC_INLINE void LL_ADC_INJ_SetTrigAuto(ADC_TypeDef *ADCx, uint32_t TrigAuto)
  4721. {
  4722. MODIFY_REG(ADCx->CFGR, ADC_CFGR_JAUTO, TrigAuto);
  4723. }
  4724. /**
  4725. * @brief Get ADC group injected conversion trigger:
  4726. * independent or from ADC group regular.
  4727. * @rmtoll CFGR JAUTO LL_ADC_INJ_GetTrigAuto
  4728. * @param ADCx ADC instance
  4729. * @retval Returned value can be one of the following values:
  4730. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  4731. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  4732. */
  4733. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx)
  4734. {
  4735. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JAUTO));
  4736. }
  4737. /**
  4738. * @brief Set ADC group injected contexts queue mode.
  4739. * @note A context is a setting of group injected sequencer:
  4740. * - group injected trigger
  4741. * - sequencer length
  4742. * - sequencer ranks
  4743. * If contexts queue is disabled:
  4744. * - only 1 sequence can be configured
  4745. * and is active perpetually.
  4746. * If contexts queue is enabled:
  4747. * - up to 2 contexts can be queued
  4748. * and are checked in and out as a FIFO stack (first-in, first-out).
  4749. * - If a new context is set when queues is full, error is triggered
  4750. * by interruption "Injected Queue Overflow".
  4751. * - Two behaviors are possible when all contexts have been processed:
  4752. * the contexts queue can maintain the last context active perpetually
  4753. * or can be empty and injected group triggers are disabled.
  4754. * - Triggers can be only external (not internal SW start)
  4755. * - Caution: The sequence must be fully configured in one time
  4756. * (one write of register JSQR makes a check-in of a new context
  4757. * into the queue).
  4758. * Therefore functions to set separately injected trigger and
  4759. * sequencer channels cannot be used, register JSQR must be set
  4760. * using function @ref LL_ADC_INJ_ConfigQueueContext().
  4761. * @note This parameter can be modified only when no conversion is on going
  4762. * on either groups regular or injected.
  4763. * @note A modification of the context mode (bit JQDIS) causes the contexts
  4764. * queue to be flushed and the register JSQR is cleared.
  4765. * @note On this STM32 serie, setting of this feature is conditioned to
  4766. * ADC state:
  4767. * ADC must be disabled or enabled without conversion on going
  4768. * on either groups regular or injected.
  4769. * @rmtoll CFGR JQM LL_ADC_INJ_SetQueueMode\n
  4770. * CFGR JQDIS LL_ADC_INJ_SetQueueMode
  4771. * @param ADCx ADC instance
  4772. * @param QueueMode This parameter can be one of the following values:
  4773. * @arg @ref LL_ADC_INJ_QUEUE_DISABLE
  4774. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE
  4775. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY
  4776. * @retval None
  4777. */
  4778. __STATIC_INLINE void LL_ADC_INJ_SetQueueMode(ADC_TypeDef *ADCx, uint32_t QueueMode)
  4779. {
  4780. MODIFY_REG(ADCx->CFGR, ADC_CFGR_JQM | ADC_CFGR_JQDIS, QueueMode);
  4781. }
  4782. /**
  4783. * @brief Get ADC group injected context queue mode.
  4784. * @rmtoll CFGR JQM LL_ADC_INJ_GetQueueMode\n
  4785. * CFGR JQDIS LL_ADC_INJ_GetQueueMode
  4786. * @param ADCx ADC instance
  4787. * @retval Returned value can be one of the following values:
  4788. * @arg @ref LL_ADC_INJ_QUEUE_DISABLE
  4789. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE
  4790. * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY
  4791. */
  4792. __STATIC_INLINE uint32_t LL_ADC_INJ_GetQueueMode(ADC_TypeDef *ADCx)
  4793. {
  4794. return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JQM | ADC_CFGR_JQDIS));
  4795. }
  4796. /**
  4797. * @brief Set one context on ADC group injected that will be checked in
  4798. * contexts queue.
  4799. * @note A context is a setting of group injected sequencer:
  4800. * - group injected trigger
  4801. * - sequencer length
  4802. * - sequencer ranks
  4803. * This function is intended to be used when contexts queue is enabled,
  4804. * because the sequence must be fully configured in one time
  4805. * (functions to set separately injected trigger and sequencer channels
  4806. * cannot be used):
  4807. * Refer to function @ref LL_ADC_INJ_SetQueueMode().
  4808. * @note In the contexts queue, only the active context can be read.
  4809. * The parameters of this function can be read using functions:
  4810. * @arg @ref LL_ADC_INJ_GetTriggerSource()
  4811. * @arg @ref LL_ADC_INJ_GetTriggerEdge()
  4812. * @arg @ref LL_ADC_INJ_GetSequencerRanks()
  4813. * @note On this STM32 serie, to measure internal channels (VrefInt,
  4814. * TempSensor, ...), measurement paths to internal channels must be
  4815. * enabled separately.
  4816. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  4817. * @note On STM32WB (except devices: STM32WB10xx, STM32WB15xx), some fast channels are available: fast analog inputs
  4818. * coming from GPIO pads (ADC_IN1..5).
  4819. * @note On this STM32 serie, setting of this feature is conditioned to
  4820. * ADC state:
  4821. * ADC must not be disabled. Can be enabled with or without conversion
  4822. * on going on either groups regular or injected.
  4823. * @rmtoll JSQR JEXTSEL LL_ADC_INJ_ConfigQueueContext\n
  4824. * JSQR JEXTEN LL_ADC_INJ_ConfigQueueContext\n
  4825. * JSQR JL LL_ADC_INJ_ConfigQueueContext\n
  4826. * JSQR JSQ1 LL_ADC_INJ_ConfigQueueContext\n
  4827. * JSQR JSQ2 LL_ADC_INJ_ConfigQueueContext\n
  4828. * JSQR JSQ3 LL_ADC_INJ_ConfigQueueContext\n
  4829. * JSQR JSQ4 LL_ADC_INJ_ConfigQueueContext
  4830. * @param ADCx ADC instance
  4831. * @param TriggerSource This parameter can be one of the following values:
  4832. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  4833. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO
  4834. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2
  4835. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4
  4836. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  4837. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  4838. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  4839. * @param ExternalTriggerEdge This parameter can be one of the following values:
  4840. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  4841. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  4842. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  4843. *
  4844. * Note: This parameter is discarded in case of SW start:
  4845. * parameter "TriggerSource" set to "LL_ADC_INJ_TRIG_SOFTWARE".
  4846. * @param SequencerNbRanks This parameter can be one of the following values:
  4847. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  4848. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  4849. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  4850. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  4851. * @param Rank1_Channel This parameter can be one of the following values:
  4852. * @arg @ref LL_ADC_CHANNEL_0
  4853. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4854. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4855. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4856. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4857. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4858. * @arg @ref LL_ADC_CHANNEL_6
  4859. * @arg @ref LL_ADC_CHANNEL_7
  4860. * @arg @ref LL_ADC_CHANNEL_8
  4861. * @arg @ref LL_ADC_CHANNEL_9
  4862. * @arg @ref LL_ADC_CHANNEL_10
  4863. * @arg @ref LL_ADC_CHANNEL_11
  4864. * @arg @ref LL_ADC_CHANNEL_12
  4865. * @arg @ref LL_ADC_CHANNEL_13
  4866. * @arg @ref LL_ADC_CHANNEL_14
  4867. * @arg @ref LL_ADC_CHANNEL_15
  4868. * @arg @ref LL_ADC_CHANNEL_16
  4869. * @arg @ref LL_ADC_CHANNEL_17
  4870. * @arg @ref LL_ADC_CHANNEL_18
  4871. * @arg @ref LL_ADC_CHANNEL_VREFINT
  4872. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  4873. * @arg @ref LL_ADC_CHANNEL_VBAT
  4874. *
  4875. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4876. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  4877. * @param Rank2_Channel This parameter can be one of the following values:
  4878. * @arg @ref LL_ADC_CHANNEL_0
  4879. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4880. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4881. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4882. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4883. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4884. * @arg @ref LL_ADC_CHANNEL_6
  4885. * @arg @ref LL_ADC_CHANNEL_7
  4886. * @arg @ref LL_ADC_CHANNEL_8
  4887. * @arg @ref LL_ADC_CHANNEL_9
  4888. * @arg @ref LL_ADC_CHANNEL_10
  4889. * @arg @ref LL_ADC_CHANNEL_11
  4890. * @arg @ref LL_ADC_CHANNEL_12
  4891. * @arg @ref LL_ADC_CHANNEL_13
  4892. * @arg @ref LL_ADC_CHANNEL_14
  4893. * @arg @ref LL_ADC_CHANNEL_15
  4894. * @arg @ref LL_ADC_CHANNEL_16
  4895. * @arg @ref LL_ADC_CHANNEL_17
  4896. * @arg @ref LL_ADC_CHANNEL_18
  4897. * @arg @ref LL_ADC_CHANNEL_VREFINT
  4898. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  4899. * @arg @ref LL_ADC_CHANNEL_VBAT
  4900. *
  4901. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4902. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  4903. * @param Rank3_Channel This parameter can be one of the following values:
  4904. * @arg @ref LL_ADC_CHANNEL_0
  4905. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4906. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4907. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4908. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4909. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4910. * @arg @ref LL_ADC_CHANNEL_6
  4911. * @arg @ref LL_ADC_CHANNEL_7
  4912. * @arg @ref LL_ADC_CHANNEL_8
  4913. * @arg @ref LL_ADC_CHANNEL_9
  4914. * @arg @ref LL_ADC_CHANNEL_10
  4915. * @arg @ref LL_ADC_CHANNEL_11
  4916. * @arg @ref LL_ADC_CHANNEL_12
  4917. * @arg @ref LL_ADC_CHANNEL_13
  4918. * @arg @ref LL_ADC_CHANNEL_14
  4919. * @arg @ref LL_ADC_CHANNEL_15
  4920. * @arg @ref LL_ADC_CHANNEL_16
  4921. * @arg @ref LL_ADC_CHANNEL_17
  4922. * @arg @ref LL_ADC_CHANNEL_18
  4923. * @arg @ref LL_ADC_CHANNEL_VREFINT
  4924. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  4925. * @arg @ref LL_ADC_CHANNEL_VBAT
  4926. *
  4927. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4928. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  4929. * @param Rank4_Channel This parameter can be one of the following values:
  4930. * @arg @ref LL_ADC_CHANNEL_0
  4931. * @arg @ref LL_ADC_CHANNEL_1 (7)
  4932. * @arg @ref LL_ADC_CHANNEL_2 (7)
  4933. * @arg @ref LL_ADC_CHANNEL_3 (7)
  4934. * @arg @ref LL_ADC_CHANNEL_4 (7)
  4935. * @arg @ref LL_ADC_CHANNEL_5 (7)
  4936. * @arg @ref LL_ADC_CHANNEL_6
  4937. * @arg @ref LL_ADC_CHANNEL_7
  4938. * @arg @ref LL_ADC_CHANNEL_8
  4939. * @arg @ref LL_ADC_CHANNEL_9
  4940. * @arg @ref LL_ADC_CHANNEL_10
  4941. * @arg @ref LL_ADC_CHANNEL_11
  4942. * @arg @ref LL_ADC_CHANNEL_12
  4943. * @arg @ref LL_ADC_CHANNEL_13
  4944. * @arg @ref LL_ADC_CHANNEL_14
  4945. * @arg @ref LL_ADC_CHANNEL_15
  4946. * @arg @ref LL_ADC_CHANNEL_16
  4947. * @arg @ref LL_ADC_CHANNEL_17
  4948. * @arg @ref LL_ADC_CHANNEL_18
  4949. * @arg @ref LL_ADC_CHANNEL_VREFINT
  4950. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  4951. * @arg @ref LL_ADC_CHANNEL_VBAT
  4952. *
  4953. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  4954. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  4955. * @retval None
  4956. */
  4957. __STATIC_INLINE void LL_ADC_INJ_ConfigQueueContext(ADC_TypeDef *ADCx,
  4958. uint32_t TriggerSource,
  4959. uint32_t ExternalTriggerEdge,
  4960. uint32_t SequencerNbRanks,
  4961. uint32_t Rank1_Channel,
  4962. uint32_t Rank2_Channel,
  4963. uint32_t Rank3_Channel,
  4964. uint32_t Rank4_Channel)
  4965. {
  4966. /* Set bits with content of parameter "Rankx_Channel" with bits position */
  4967. /* in register depending on literal "LL_ADC_INJ_RANK_x". */
  4968. /* Parameters "Rankx_Channel" and "LL_ADC_INJ_RANK_x" are used with masks */
  4969. /* because containing other bits reserved for other purpose. */
  4970. /* If parameter "TriggerSource" is set to SW start, then parameter */
  4971. /* "ExternalTriggerEdge" is discarded. */
  4972. uint32_t is_trigger_not_sw = (uint32_t)((TriggerSource != LL_ADC_INJ_TRIG_SOFTWARE) ? 1UL : 0UL);
  4973. MODIFY_REG(ADCx->JSQR,
  4974. ADC_JSQR_JEXTSEL |
  4975. ADC_JSQR_JEXTEN |
  4976. ADC_JSQR_JSQ4 |
  4977. ADC_JSQR_JSQ3 |
  4978. ADC_JSQR_JSQ2 |
  4979. ADC_JSQR_JSQ1 |
  4980. ADC_JSQR_JL,
  4981. (TriggerSource & ADC_JSQR_JEXTSEL) |
  4982. (ExternalTriggerEdge * (is_trigger_not_sw)) |
  4983. (((Rank4_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (LL_ADC_INJ_RANK_4 & ADC_INJ_RANK_ID_JSQR_MASK)) |
  4984. (((Rank3_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (LL_ADC_INJ_RANK_3 & ADC_INJ_RANK_ID_JSQR_MASK)) |
  4985. (((Rank2_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (LL_ADC_INJ_RANK_2 & ADC_INJ_RANK_ID_JSQR_MASK)) |
  4986. (((Rank1_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (LL_ADC_INJ_RANK_1 & ADC_INJ_RANK_ID_JSQR_MASK)) |
  4987. SequencerNbRanks
  4988. );
  4989. }
  4990. /**
  4991. * @}
  4992. */
  4993. #endif /* ADC_SUPPORT_2_5_MSPS */
  4994. /** @defgroup ADC_LL_EF_Configuration_Channels Configuration of ADC hierarchical scope: channels
  4995. * @{
  4996. */
  4997. #if defined (ADC_SUPPORT_2_5_MSPS)
  4998. /**
  4999. * @brief Set sampling time of the selected ADC channel
  5000. * Unit: ADC clock cycles.
  5001. * @note On this device, sampling time is on channel scope: independently
  5002. * of channel mapped on ADC group regular or injected.
  5003. * @note In case of internal channel (VrefInt, TempSensor, ...) to be
  5004. * converted:
  5005. * sampling time constraints must be respected (sampling time can be
  5006. * adjusted in function of ADC clock frequency and sampling time
  5007. * setting).
  5008. * Refer to device datasheet for timings values (parameters TS_vrefint,
  5009. * TS_temp, ...).
  5010. * @note Conversion time is the addition of sampling time and processing time.
  5011. * On this STM32 serie, ADC processing time is:
  5012. * - 12.5 ADC clock cycles at ADC resolution 12 bits
  5013. * - 10.5 ADC clock cycles at ADC resolution 10 bits
  5014. * - 8.5 ADC clock cycles at ADC resolution 8 bits
  5015. * - 6.5 ADC clock cycles at ADC resolution 6 bits
  5016. * @note In case of ADC conversion of internal channel (VrefInt,
  5017. * temperature sensor, ...), a sampling time minimum value
  5018. * is required.
  5019. * Refer to device datasheet.
  5020. * @note On this STM32 serie, setting of this feature is conditioned to
  5021. * ADC state:
  5022. * ADC must be disabled or enabled without conversion on going
  5023. * on either groups regular or injected.
  5024. * @rmtoll SMPR1 SMP0 LL_ADC_SetChannelSamplingTime\n
  5025. * SMPR1 SMP1 LL_ADC_SetChannelSamplingTime\n
  5026. * SMPR1 SMP2 LL_ADC_SetChannelSamplingTime\n
  5027. * SMPR1 SMP3 LL_ADC_SetChannelSamplingTime\n
  5028. * SMPR1 SMP4 LL_ADC_SetChannelSamplingTime\n
  5029. * SMPR1 SMP5 LL_ADC_SetChannelSamplingTime\n
  5030. * SMPR1 SMP6 LL_ADC_SetChannelSamplingTime\n
  5031. * SMPR1 SMP7 LL_ADC_SetChannelSamplingTime\n
  5032. * SMPR1 SMP8 LL_ADC_SetChannelSamplingTime\n
  5033. * SMPR1 SMP9 LL_ADC_SetChannelSamplingTime\n
  5034. * SMPR2 SMP10 LL_ADC_SetChannelSamplingTime\n
  5035. * SMPR2 SMP11 LL_ADC_SetChannelSamplingTime\n
  5036. * SMPR2 SMP12 LL_ADC_SetChannelSamplingTime\n
  5037. * SMPR2 SMP13 LL_ADC_SetChannelSamplingTime\n
  5038. * SMPR2 SMP14 LL_ADC_SetChannelSamplingTime\n
  5039. * SMPR2 SMP15 LL_ADC_SetChannelSamplingTime\n
  5040. * SMPR2 SMP16 LL_ADC_SetChannelSamplingTime\n
  5041. * SMPR2 SMP17 LL_ADC_SetChannelSamplingTime\n
  5042. * SMPR2 SMP18 LL_ADC_SetChannelSamplingTime
  5043. * @param ADCx ADC instance
  5044. * @param Channel This parameter can be one of the following values:
  5045. * @arg @ref LL_ADC_CHANNEL_0
  5046. * @arg @ref LL_ADC_CHANNEL_1 (7)
  5047. * @arg @ref LL_ADC_CHANNEL_2 (7)
  5048. * @arg @ref LL_ADC_CHANNEL_3 (7)
  5049. * @arg @ref LL_ADC_CHANNEL_4 (7)
  5050. * @arg @ref LL_ADC_CHANNEL_5 (7)
  5051. * @arg @ref LL_ADC_CHANNEL_6
  5052. * @arg @ref LL_ADC_CHANNEL_7
  5053. * @arg @ref LL_ADC_CHANNEL_8
  5054. * @arg @ref LL_ADC_CHANNEL_9
  5055. * @arg @ref LL_ADC_CHANNEL_10
  5056. * @arg @ref LL_ADC_CHANNEL_11
  5057. * @arg @ref LL_ADC_CHANNEL_12
  5058. * @arg @ref LL_ADC_CHANNEL_13
  5059. * @arg @ref LL_ADC_CHANNEL_14
  5060. * @arg @ref LL_ADC_CHANNEL_15
  5061. * @arg @ref LL_ADC_CHANNEL_16
  5062. * @arg @ref LL_ADC_CHANNEL_17
  5063. * @arg @ref LL_ADC_CHANNEL_18
  5064. * @arg @ref LL_ADC_CHANNEL_VREFINT
  5065. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  5066. * @arg @ref LL_ADC_CHANNEL_VBAT
  5067. *
  5068. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  5069. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  5070. * @param SamplingTimeY This parameter can be one of the following values:
  5071. * @arg @ref LL_ADC_SAMPLINGTIME_COMMON_1
  5072. * @arg @ref LL_ADC_SAMPLINGTIME_COMMON_2
  5073. * @retval None
  5074. */
  5075. __STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTimeY)
  5076. {
  5077. /* Parameter "Channel" is used with masks because containing */
  5078. /* other bits reserved for other purpose. */
  5079. MODIFY_REG(ADCx->SMPR,
  5080. (Channel << ADC_SMPR_SMPSEL0_BITOFFSET_POS),
  5081. (Channel << ADC_SMPR_SMPSEL0_BITOFFSET_POS) & (SamplingTimeY & ADC_SAMPLING_TIME_CH_MASK)
  5082. );
  5083. }
  5084. #else
  5085. /**
  5086. * @brief Set sampling time of the selected ADC channel
  5087. * Unit: ADC clock cycles.
  5088. * @note On this device, sampling time is on channel scope: independently
  5089. * of channel mapped on ADC group regular or injected.
  5090. * @note In case of internal channel (VrefInt, TempSensor, ...) to be
  5091. * converted:
  5092. * sampling time constraints must be respected (sampling time can be
  5093. * adjusted in function of ADC clock frequency and sampling time
  5094. * setting).
  5095. * Refer to device datasheet for timings values (parameters TS_vrefint,
  5096. * TS_temp, ...).
  5097. * @note Conversion time is the addition of sampling time and processing time.
  5098. * On this STM32 serie, ADC processing time is:
  5099. * - 12.5 ADC clock cycles at ADC resolution 12 bits
  5100. * - 10.5 ADC clock cycles at ADC resolution 10 bits
  5101. * - 8.5 ADC clock cycles at ADC resolution 8 bits
  5102. * - 6.5 ADC clock cycles at ADC resolution 6 bits
  5103. * @note In case of ADC conversion of internal channel (VrefInt,
  5104. * temperature sensor, ...), a sampling time minimum value
  5105. * is required.
  5106. * Refer to device datasheet.
  5107. * @note On this STM32 serie, setting of this feature is conditioned to
  5108. * ADC state:
  5109. * ADC must be disabled or enabled without conversion on going
  5110. * on either groups regular or injected.
  5111. * @rmtoll SMPR1 SMP0 LL_ADC_SetChannelSamplingTime\n
  5112. * SMPR1 SMP1 LL_ADC_SetChannelSamplingTime\n
  5113. * SMPR1 SMP2 LL_ADC_SetChannelSamplingTime\n
  5114. * SMPR1 SMP3 LL_ADC_SetChannelSamplingTime\n
  5115. * SMPR1 SMP4 LL_ADC_SetChannelSamplingTime\n
  5116. * SMPR1 SMP5 LL_ADC_SetChannelSamplingTime\n
  5117. * SMPR1 SMP6 LL_ADC_SetChannelSamplingTime\n
  5118. * SMPR1 SMP7 LL_ADC_SetChannelSamplingTime\n
  5119. * SMPR1 SMP8 LL_ADC_SetChannelSamplingTime\n
  5120. * SMPR1 SMP9 LL_ADC_SetChannelSamplingTime\n
  5121. * SMPR2 SMP10 LL_ADC_SetChannelSamplingTime\n
  5122. * SMPR2 SMP11 LL_ADC_SetChannelSamplingTime\n
  5123. * SMPR2 SMP12 LL_ADC_SetChannelSamplingTime\n
  5124. * SMPR2 SMP13 LL_ADC_SetChannelSamplingTime\n
  5125. * SMPR2 SMP14 LL_ADC_SetChannelSamplingTime\n
  5126. * SMPR2 SMP15 LL_ADC_SetChannelSamplingTime\n
  5127. * SMPR2 SMP16 LL_ADC_SetChannelSamplingTime\n
  5128. * SMPR2 SMP17 LL_ADC_SetChannelSamplingTime\n
  5129. * SMPR2 SMP18 LL_ADC_SetChannelSamplingTime
  5130. * @param ADCx ADC instance
  5131. * @param Channel This parameter can be one of the following values:
  5132. * @arg @ref LL_ADC_CHANNEL_0
  5133. * @arg @ref LL_ADC_CHANNEL_1 (7)
  5134. * @arg @ref LL_ADC_CHANNEL_2 (7)
  5135. * @arg @ref LL_ADC_CHANNEL_3 (7)
  5136. * @arg @ref LL_ADC_CHANNEL_4 (7)
  5137. * @arg @ref LL_ADC_CHANNEL_5 (7)
  5138. * @arg @ref LL_ADC_CHANNEL_6
  5139. * @arg @ref LL_ADC_CHANNEL_7
  5140. * @arg @ref LL_ADC_CHANNEL_8
  5141. * @arg @ref LL_ADC_CHANNEL_9
  5142. * @arg @ref LL_ADC_CHANNEL_10
  5143. * @arg @ref LL_ADC_CHANNEL_11
  5144. * @arg @ref LL_ADC_CHANNEL_12
  5145. * @arg @ref LL_ADC_CHANNEL_13
  5146. * @arg @ref LL_ADC_CHANNEL_14
  5147. * @arg @ref LL_ADC_CHANNEL_15
  5148. * @arg @ref LL_ADC_CHANNEL_16
  5149. * @arg @ref LL_ADC_CHANNEL_17
  5150. * @arg @ref LL_ADC_CHANNEL_18
  5151. * @arg @ref LL_ADC_CHANNEL_VREFINT
  5152. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  5153. * @arg @ref LL_ADC_CHANNEL_VBAT
  5154. *
  5155. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  5156. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  5157. * @param SamplingTime This parameter can be one of the following values:
  5158. * @arg @ref LL_ADC_SAMPLINGTIME_2CYCLES_5
  5159. * @arg @ref LL_ADC_SAMPLINGTIME_6CYCLES_5
  5160. * @arg @ref LL_ADC_SAMPLINGTIME_12CYCLES_5
  5161. * @arg @ref LL_ADC_SAMPLINGTIME_24CYCLES_5
  5162. * @arg @ref LL_ADC_SAMPLINGTIME_47CYCLES_5
  5163. * @arg @ref LL_ADC_SAMPLINGTIME_92CYCLES_5
  5164. * @arg @ref LL_ADC_SAMPLINGTIME_247CYCLES_5
  5165. * @arg @ref LL_ADC_SAMPLINGTIME_640CYCLES_5
  5166. * @retval None
  5167. */
  5168. __STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTime)
  5169. {
  5170. #if defined (ADC_SUPPORT_2_5_MSPS)
  5171. /* Parameter "Channel" is used with masks because containing */
  5172. /* other bits reserved for other purpose. */
  5173. MODIFY_REG(ADCx->SMPR,
  5174. (Channel << ADC_SMPR_SMPSEL0_BITOFFSET_POS),
  5175. (Channel << ADC_SMPR_SMPSEL0_BITOFFSET_POS) & (SamplingTimeY & ADC_SAMPLING_TIME_CH_MASK)
  5176. );
  5177. #else
  5178. /* Set bits with content of parameter "SamplingTime" with bits position */
  5179. /* in register and register position depending on parameter "Channel". */
  5180. /* Parameter "Channel" is used with masks because containing */
  5181. /* other bits reserved for other purpose. */
  5182. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, ((Channel & ADC_CHANNEL_SMPRX_REGOFFSET_MASK) >> ADC_SMPRX_REGOFFSET_POS));
  5183. MODIFY_REG(*preg,
  5184. ADC_SMPR1_SMP0 << ((Channel & ADC_CHANNEL_SMPx_BITOFFSET_MASK) >> ADC_CHANNEL_SMPx_BITOFFSET_POS),
  5185. SamplingTime << ((Channel & ADC_CHANNEL_SMPx_BITOFFSET_MASK) >> ADC_CHANNEL_SMPx_BITOFFSET_POS));
  5186. #endif
  5187. }
  5188. #endif /* ADC_SUPPORT_2_5_MSPS */
  5189. #if defined (ADC_SUPPORT_2_5_MSPS)
  5190. /**
  5191. * @brief Get sampling time of the selected ADC channel
  5192. * Unit: ADC clock cycles.
  5193. * @note On this device, sampling time is on channel scope: independently
  5194. * of channel mapped on ADC group regular or injected.
  5195. * @note Conversion time is the addition of sampling time and processing time.
  5196. * On this STM32 serie, ADC processing time is:
  5197. * - 12.5 ADC clock cycles at ADC resolution 12 bits
  5198. * - 10.5 ADC clock cycles at ADC resolution 10 bits
  5199. * - 8.5 ADC clock cycles at ADC resolution 8 bits
  5200. * - 6.5 ADC clock cycles at ADC resolution 6 bits
  5201. * @rmtoll SMPR1 SMP0 LL_ADC_GetChannelSamplingTime\n
  5202. * SMPR1 SMP1 LL_ADC_GetChannelSamplingTime\n
  5203. * SMPR1 SMP2 LL_ADC_GetChannelSamplingTime\n
  5204. * SMPR1 SMP3 LL_ADC_GetChannelSamplingTime\n
  5205. * SMPR1 SMP4 LL_ADC_GetChannelSamplingTime\n
  5206. * SMPR1 SMP5 LL_ADC_GetChannelSamplingTime\n
  5207. * SMPR1 SMP6 LL_ADC_GetChannelSamplingTime\n
  5208. * SMPR1 SMP7 LL_ADC_GetChannelSamplingTime\n
  5209. * SMPR1 SMP8 LL_ADC_GetChannelSamplingTime\n
  5210. * SMPR1 SMP9 LL_ADC_GetChannelSamplingTime\n
  5211. * SMPR2 SMP10 LL_ADC_GetChannelSamplingTime\n
  5212. * SMPR2 SMP11 LL_ADC_GetChannelSamplingTime\n
  5213. * SMPR2 SMP12 LL_ADC_GetChannelSamplingTime\n
  5214. * SMPR2 SMP13 LL_ADC_GetChannelSamplingTime\n
  5215. * SMPR2 SMP14 LL_ADC_GetChannelSamplingTime\n
  5216. * SMPR2 SMP15 LL_ADC_GetChannelSamplingTime\n
  5217. * SMPR2 SMP16 LL_ADC_GetChannelSamplingTime\n
  5218. * SMPR2 SMP17 LL_ADC_GetChannelSamplingTime\n
  5219. * SMPR2 SMP18 LL_ADC_GetChannelSamplingTime
  5220. * @param ADCx ADC instance
  5221. * @param Channel This parameter can be one of the following values:
  5222. * @arg @ref LL_ADC_CHANNEL_0
  5223. * @arg @ref LL_ADC_CHANNEL_1 (7)
  5224. * @arg @ref LL_ADC_CHANNEL_2 (7)
  5225. * @arg @ref LL_ADC_CHANNEL_3 (7)
  5226. * @arg @ref LL_ADC_CHANNEL_4 (7)
  5227. * @arg @ref LL_ADC_CHANNEL_5 (7)
  5228. * @arg @ref LL_ADC_CHANNEL_6
  5229. * @arg @ref LL_ADC_CHANNEL_7
  5230. * @arg @ref LL_ADC_CHANNEL_8
  5231. * @arg @ref LL_ADC_CHANNEL_9
  5232. * @arg @ref LL_ADC_CHANNEL_10
  5233. * @arg @ref LL_ADC_CHANNEL_11
  5234. * @arg @ref LL_ADC_CHANNEL_12
  5235. * @arg @ref LL_ADC_CHANNEL_13
  5236. * @arg @ref LL_ADC_CHANNEL_14
  5237. * @arg @ref LL_ADC_CHANNEL_15
  5238. * @arg @ref LL_ADC_CHANNEL_16
  5239. * @arg @ref LL_ADC_CHANNEL_17
  5240. * @arg @ref LL_ADC_CHANNEL_18
  5241. * @arg @ref LL_ADC_CHANNEL_VREFINT
  5242. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  5243. * @arg @ref LL_ADC_CHANNEL_VBAT
  5244. *
  5245. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  5246. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  5247. * @retval Returned value can be one of the following values:
  5248. * @arg @ref LL_ADC_SAMPLINGTIME_COMMON_1
  5249. * @arg @ref LL_ADC_SAMPLINGTIME_COMMON_2
  5250. */
  5251. __STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel)
  5252. {
  5253. __IO uint32_t smpr = READ_REG(ADCx->SMPR);
  5254. /* Retrieve sampling time bit corresponding to the selected channel */
  5255. /* and shift it to position 0. */
  5256. uint32_t smp_channel_posbit0 = ((smpr & ADC_SAMPLING_TIME_CH_MASK)
  5257. >> ((((Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) + ADC_SMPR_SMPSEL0_BITOFFSET_POS) & 0x1FUL));
  5258. /* Select sampling time bitfield depending on sampling time bit value 0 or 1. */
  5259. return( (~(smp_channel_posbit0) * LL_ADC_SAMPLINGTIME_COMMON_1)
  5260. | (smp_channel_posbit0 * LL_ADC_SAMPLINGTIME_COMMON_2) );
  5261. }
  5262. #else
  5263. /**
  5264. * @brief Get sampling time of the selected ADC channel
  5265. * Unit: ADC clock cycles.
  5266. * @note On this device, sampling time is on channel scope: independently
  5267. * of channel mapped on ADC group regular or injected.
  5268. * @note Conversion time is the addition of sampling time and processing time.
  5269. * On this STM32 serie, ADC processing time is:
  5270. * - 12.5 ADC clock cycles at ADC resolution 12 bits
  5271. * - 10.5 ADC clock cycles at ADC resolution 10 bits
  5272. * - 8.5 ADC clock cycles at ADC resolution 8 bits
  5273. * - 6.5 ADC clock cycles at ADC resolution 6 bits
  5274. * @rmtoll SMPR1 SMP0 LL_ADC_GetChannelSamplingTime\n
  5275. * SMPR1 SMP1 LL_ADC_GetChannelSamplingTime\n
  5276. * SMPR1 SMP2 LL_ADC_GetChannelSamplingTime\n
  5277. * SMPR1 SMP3 LL_ADC_GetChannelSamplingTime\n
  5278. * SMPR1 SMP4 LL_ADC_GetChannelSamplingTime\n
  5279. * SMPR1 SMP5 LL_ADC_GetChannelSamplingTime\n
  5280. * SMPR1 SMP6 LL_ADC_GetChannelSamplingTime\n
  5281. * SMPR1 SMP7 LL_ADC_GetChannelSamplingTime\n
  5282. * SMPR1 SMP8 LL_ADC_GetChannelSamplingTime\n
  5283. * SMPR1 SMP9 LL_ADC_GetChannelSamplingTime\n
  5284. * SMPR2 SMP10 LL_ADC_GetChannelSamplingTime\n
  5285. * SMPR2 SMP11 LL_ADC_GetChannelSamplingTime\n
  5286. * SMPR2 SMP12 LL_ADC_GetChannelSamplingTime\n
  5287. * SMPR2 SMP13 LL_ADC_GetChannelSamplingTime\n
  5288. * SMPR2 SMP14 LL_ADC_GetChannelSamplingTime\n
  5289. * SMPR2 SMP15 LL_ADC_GetChannelSamplingTime\n
  5290. * SMPR2 SMP16 LL_ADC_GetChannelSamplingTime\n
  5291. * SMPR2 SMP17 LL_ADC_GetChannelSamplingTime\n
  5292. * SMPR2 SMP18 LL_ADC_GetChannelSamplingTime
  5293. * @param ADCx ADC instance
  5294. * @param Channel This parameter can be one of the following values:
  5295. * @arg @ref LL_ADC_CHANNEL_0
  5296. * @arg @ref LL_ADC_CHANNEL_1 (7)
  5297. * @arg @ref LL_ADC_CHANNEL_2 (7)
  5298. * @arg @ref LL_ADC_CHANNEL_3 (7)
  5299. * @arg @ref LL_ADC_CHANNEL_4 (7)
  5300. * @arg @ref LL_ADC_CHANNEL_5 (7)
  5301. * @arg @ref LL_ADC_CHANNEL_6
  5302. * @arg @ref LL_ADC_CHANNEL_7
  5303. * @arg @ref LL_ADC_CHANNEL_8
  5304. * @arg @ref LL_ADC_CHANNEL_9
  5305. * @arg @ref LL_ADC_CHANNEL_10
  5306. * @arg @ref LL_ADC_CHANNEL_11
  5307. * @arg @ref LL_ADC_CHANNEL_12
  5308. * @arg @ref LL_ADC_CHANNEL_13
  5309. * @arg @ref LL_ADC_CHANNEL_14
  5310. * @arg @ref LL_ADC_CHANNEL_15
  5311. * @arg @ref LL_ADC_CHANNEL_16
  5312. * @arg @ref LL_ADC_CHANNEL_17
  5313. * @arg @ref LL_ADC_CHANNEL_18
  5314. * @arg @ref LL_ADC_CHANNEL_VREFINT
  5315. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
  5316. * @arg @ref LL_ADC_CHANNEL_VBAT
  5317. *
  5318. * (7) On STM32WB devices (except devices: STM32WB10xx, STM32WB15xx) fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)).
  5319. * Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
  5320. * @retval Returned value can be one of the following values:
  5321. * @arg @ref LL_ADC_SAMPLINGTIME_2CYCLES_5
  5322. * @arg @ref LL_ADC_SAMPLINGTIME_6CYCLES_5
  5323. * @arg @ref LL_ADC_SAMPLINGTIME_12CYCLES_5
  5324. * @arg @ref LL_ADC_SAMPLINGTIME_24CYCLES_5
  5325. * @arg @ref LL_ADC_SAMPLINGTIME_47CYCLES_5
  5326. * @arg @ref LL_ADC_SAMPLINGTIME_92CYCLES_5
  5327. * @arg @ref LL_ADC_SAMPLINGTIME_247CYCLES_5
  5328. * @arg @ref LL_ADC_SAMPLINGTIME_640CYCLES_5
  5329. */
  5330. __STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel)
  5331. {
  5332. #if defined (ADC_SUPPORT_2_5_MSPS)
  5333. __IO uint32_t smpr = READ_REG(ADCx->SMPR);
  5334. /* Retrieve sampling time bit corresponding to the selected channel */
  5335. /* and shift it to position 0. */
  5336. uint32_t smp_channel_posbit0 = ((smpr & ADC_SAMPLING_TIME_CH_MASK)
  5337. >> ((((Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) + ADC_SMPR_SMPSEL0_BITOFFSET_POS) & 0x1FUL));
  5338. /* Select sampling time bitfield depending on sampling time bit value 0 or 1. */
  5339. return( (~(smp_channel_posbit0) * LL_ADC_SAMPLINGTIME_COMMON_1)
  5340. | (smp_channel_posbit0 * LL_ADC_SAMPLINGTIME_COMMON_2) );
  5341. #else
  5342. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, ((Channel & ADC_CHANNEL_SMPRX_REGOFFSET_MASK) >> ADC_SMPRX_REGOFFSET_POS));
  5343. return (uint32_t)(READ_BIT(*preg,
  5344. ADC_SMPR1_SMP0 << ((Channel & ADC_CHANNEL_SMPx_BITOFFSET_MASK) >> ADC_CHANNEL_SMPx_BITOFFSET_POS))
  5345. >> ((Channel & ADC_CHANNEL_SMPx_BITOFFSET_MASK) >> ADC_CHANNEL_SMPx_BITOFFSET_POS)
  5346. );
  5347. #endif
  5348. }
  5349. #endif /* ADC_SUPPORT_2_5_MSPS */
  5350. #if defined (ADC_SUPPORT_2_5_MSPS)
  5351. /* Feature "ADC channel differential mode" not available on ADC peripheral of this STM32WB device */
  5352. #else
  5353. /**
  5354. * @brief Set mode single-ended or differential input of the selected
  5355. * ADC channel.
  5356. * @note Channel ending is on channel scope: independently of channel mapped
  5357. * on ADC group regular or injected.
  5358. * In differential mode: Differential measurement is carried out
  5359. * between the selected channel 'i' (positive input) and
  5360. * channel 'i+1' (negative input). Only channel 'i' has to be
  5361. * configured, channel 'i+1' is configured automatically.
  5362. * @note Refer to Reference Manual to ensure the selected channel is
  5363. * available in differential mode.
  5364. * For example, internal channels (VrefInt, TempSensor, ...) are
  5365. * not available in differential mode.
  5366. * @note When configuring a channel 'i' in differential mode,
  5367. * the channel 'i+1' is not usable separately.
  5368. * @note On STM32WB, channels 16, 17, 18 of ADC1
  5369. * are internally fixed to single-ended inputs configuration.
  5370. * @note For ADC channels configured in differential mode, both inputs
  5371. * should be biased at (Vref+)/2 +/-200mV.
  5372. * (Vref+ is the analog voltage reference)
  5373. * @note On this STM32 serie, setting of this feature is conditioned to
  5374. * ADC state:
  5375. * ADC must be ADC disabled.
  5376. * @note One or several values can be selected.
  5377. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  5378. * @rmtoll DIFSEL DIFSEL LL_ADC_SetChannelSingleDiff
  5379. * @param ADCx ADC instance
  5380. * @param Channel This parameter can be one of the following values:
  5381. * @arg @ref LL_ADC_CHANNEL_1
  5382. * @arg @ref LL_ADC_CHANNEL_2
  5383. * @arg @ref LL_ADC_CHANNEL_3
  5384. * @arg @ref LL_ADC_CHANNEL_4
  5385. * @arg @ref LL_ADC_CHANNEL_5
  5386. * @arg @ref LL_ADC_CHANNEL_6
  5387. * @arg @ref LL_ADC_CHANNEL_7
  5388. * @arg @ref LL_ADC_CHANNEL_8
  5389. * @arg @ref LL_ADC_CHANNEL_9
  5390. * @arg @ref LL_ADC_CHANNEL_10
  5391. * @arg @ref LL_ADC_CHANNEL_11
  5392. * @arg @ref LL_ADC_CHANNEL_12
  5393. * @arg @ref LL_ADC_CHANNEL_13
  5394. * @arg @ref LL_ADC_CHANNEL_14
  5395. * @arg @ref LL_ADC_CHANNEL_15
  5396. * @param SingleDiff This parameter can be a combination of the following values:
  5397. * @arg @ref LL_ADC_SINGLE_ENDED
  5398. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  5399. * @retval None
  5400. */
  5401. __STATIC_INLINE void LL_ADC_SetChannelSingleDiff(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SingleDiff)
  5402. {
  5403. /* Bits of channels in single or differential mode are set only for */
  5404. /* differential mode (for single mode, mask of bits allowed to be set is */
  5405. /* shifted out of range of bits of channels in single or differential mode. */
  5406. MODIFY_REG(ADCx->DIFSEL,
  5407. Channel & ADC_SINGLEDIFF_CHANNEL_MASK,
  5408. (Channel & ADC_SINGLEDIFF_CHANNEL_MASK) & (ADC_DIFSEL_DIFSEL >> (SingleDiff & ADC_SINGLEDIFF_CHANNEL_SHIFT_MASK)));
  5409. }
  5410. /**
  5411. * @brief Get mode single-ended or differential input of the selected
  5412. * ADC channel.
  5413. * @note When configuring a channel 'i' in differential mode,
  5414. * the channel 'i+1' is not usable separately.
  5415. * Therefore, to ensure a channel is configured in single-ended mode,
  5416. * the configuration of channel itself and the channel 'i-1' must be
  5417. * read back (to ensure that the selected channel channel has not been
  5418. * configured in differential mode by the previous channel).
  5419. * @note Refer to Reference Manual to ensure the selected channel is
  5420. * available in differential mode.
  5421. * For example, internal channels (VrefInt, TempSensor, ...) are
  5422. * not available in differential mode.
  5423. * @note When configuring a channel 'i' in differential mode,
  5424. * the channel 'i+1' is not usable separately.
  5425. * @note On STM32WB, channels 16, 17, 18 of ADC1
  5426. * are internally fixed to single-ended inputs configuration.
  5427. * @note One or several values can be selected. In this case, the value
  5428. * returned is null if all channels are in single ended-mode.
  5429. * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
  5430. * @rmtoll DIFSEL DIFSEL LL_ADC_GetChannelSingleDiff
  5431. * @param ADCx ADC instance
  5432. * @param Channel This parameter can be a combination of the following values:
  5433. * @arg @ref LL_ADC_CHANNEL_1
  5434. * @arg @ref LL_ADC_CHANNEL_2
  5435. * @arg @ref LL_ADC_CHANNEL_3
  5436. * @arg @ref LL_ADC_CHANNEL_4
  5437. * @arg @ref LL_ADC_CHANNEL_5
  5438. * @arg @ref LL_ADC_CHANNEL_6
  5439. * @arg @ref LL_ADC_CHANNEL_7
  5440. * @arg @ref LL_ADC_CHANNEL_8
  5441. * @arg @ref LL_ADC_CHANNEL_9
  5442. * @arg @ref LL_ADC_CHANNEL_10
  5443. * @arg @ref LL_ADC_CHANNEL_11
  5444. * @arg @ref LL_ADC_CHANNEL_12
  5445. * @arg @ref LL_ADC_CHANNEL_13
  5446. * @arg @ref LL_ADC_CHANNEL_14
  5447. * @arg @ref LL_ADC_CHANNEL_15
  5448. * @retval 0: channel in single-ended mode, else: channel in differential mode
  5449. */
  5450. __STATIC_INLINE uint32_t LL_ADC_GetChannelSingleDiff(ADC_TypeDef *ADCx, uint32_t Channel)
  5451. {
  5452. return (uint32_t)(READ_BIT(ADCx->DIFSEL, (Channel & ADC_SINGLEDIFF_CHANNEL_MASK)));
  5453. }
  5454. #endif /* ADC_SUPPORT_2_5_MSPS */
  5455. /**
  5456. * @}
  5457. */
  5458. /** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
  5459. * @{
  5460. */
  5461. /**
  5462. * @brief Set ADC analog watchdog monitored channels:
  5463. * a single channel, multiple channels or all channels,
  5464. * on ADC groups regular and-or injected.
  5465. * @note Once monitored channels are selected, analog watchdog
  5466. * is enabled.
  5467. * @note In case of need to define a single channel to monitor
  5468. * with analog watchdog from sequencer channel definition,
  5469. * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
  5470. * @note On this STM32 serie, there are 2 kinds of analog watchdog
  5471. * instance:
  5472. * - AWD standard (instance AWD1):
  5473. * - channels monitored: can monitor 1 channel or all channels.
  5474. * - groups monitored: ADC groups regular and-or injected.
  5475. * - resolution: resolution is not limited (corresponds to
  5476. * ADC resolution configured).
  5477. * - AWD flexible (instances AWD2, AWD3):
  5478. * - channels monitored: flexible on channels monitored, selection is
  5479. * channel wise, from from 1 to all channels.
  5480. * Specificity of this analog watchdog: Multiple channels can
  5481. * be selected. For example:
  5482. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  5483. * - groups monitored: not selection possible (monitoring on both
  5484. * groups regular and injected).
  5485. * Channels selected are monitored on groups regular and injected:
  5486. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  5487. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  5488. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  5489. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  5490. * the 2 LSB are ignored.
  5491. * @note On this STM32 serie, setting of this feature is conditioned to
  5492. * ADC state:
  5493. * ADC must be disabled or enabled without conversion on going
  5494. * on either groups regular or injected.
  5495. * @rmtoll CFGR AWD1CH LL_ADC_SetAnalogWDMonitChannels\n
  5496. * CFGR AWD1SGL LL_ADC_SetAnalogWDMonitChannels\n
  5497. * CFGR AWD1EN LL_ADC_SetAnalogWDMonitChannels\n
  5498. * CFGR JAWD1EN LL_ADC_SetAnalogWDMonitChannels\n
  5499. * AWD2CR AWD2CH LL_ADC_SetAnalogWDMonitChannels\n
  5500. * AWD3CR AWD3CH LL_ADC_SetAnalogWDMonitChannels
  5501. * @param ADCx ADC instance
  5502. * @param AWDy This parameter can be one of the following values:
  5503. * @arg @ref LL_ADC_AWD1
  5504. * @arg @ref LL_ADC_AWD2
  5505. * @arg @ref LL_ADC_AWD3
  5506. * @param AWDChannelGroup This parameter can be one of the following values:
  5507. * @arg @ref LL_ADC_AWD_DISABLE
  5508. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0)
  5509. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0)(1)
  5510. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ (1)
  5511. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0)
  5512. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0)(1)
  5513. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ (1)
  5514. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0)
  5515. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0)(1)
  5516. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ (1)
  5517. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0)
  5518. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0)(1)
  5519. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ (1)
  5520. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0)
  5521. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0)(1)
  5522. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ (1)
  5523. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0)
  5524. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0)(1)
  5525. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ (1)
  5526. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0)
  5527. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0)(1)
  5528. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ (1)
  5529. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0)
  5530. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0)(1)
  5531. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ (1)
  5532. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0)
  5533. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0)(1)
  5534. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ (1)
  5535. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0)
  5536. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0)(1)
  5537. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ (1)
  5538. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0)
  5539. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0)(1)
  5540. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ (1)
  5541. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0)
  5542. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0)(1)
  5543. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ (1)
  5544. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0)
  5545. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0)(1)
  5546. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ (1)
  5547. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0)
  5548. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0)(1)
  5549. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ (1)
  5550. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0)
  5551. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0)(1)
  5552. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ (1)
  5553. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0)
  5554. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0)(1)
  5555. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ (1)
  5556. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0)
  5557. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0)(1)
  5558. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ (1)
  5559. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0)
  5560. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0)(1)
  5561. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ (1)
  5562. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0)
  5563. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0)(1)
  5564. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ (1)
  5565. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0)
  5566. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0)(1)
  5567. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ (1)
  5568. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (0)
  5569. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (0)(1)
  5570. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1)
  5571. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (0)
  5572. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (0)(1)
  5573. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1)
  5574. * @arg @ref LL_ADC_AWD_CH_VBAT_REG (0)
  5575. * @arg @ref LL_ADC_AWD_CH_VBAT_INJ (0)(1)
  5576. * @arg @ref LL_ADC_AWD_CH_VBAT_REG_INJ (1)
  5577. *
  5578. * (0) On STM32WB, parameter available only on analog watchdog number: AWD1.
  5579. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  5580. * @retval None
  5581. */
  5582. __STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDChannelGroup)
  5583. {
  5584. #if defined (ADC_SUPPORT_2_5_MSPS)
  5585. /* Prevent unused argument(s) compilation warning */
  5586. (void)(AWDy);
  5587. MODIFY_REG(ADCx->CFGR1,
  5588. (LL_ADC_AWD1 & ADC_AWD_CR_ALL_CHANNEL_MASK),
  5589. AWDChannelGroup & LL_ADC_AWD1);
  5590. #else
  5591. /* Set bits with content of parameter "AWDChannelGroup" with bits position */
  5592. /* in register and register position depending on parameter "AWDy". */
  5593. /* Parameters "AWDChannelGroup" and "AWDy" are used with masks because */
  5594. /* containing other bits reserved for other purpose. */
  5595. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->CFGR, ((AWDy & ADC_AWD_CRX_REGOFFSET_MASK) >> ADC_AWD_CRX_REGOFFSET_POS)
  5596. + ((AWDy & ADC_AWD_CR12_REGOFFSETGAP_MASK) * ADC_AWD_CR12_REGOFFSETGAP_VAL));
  5597. MODIFY_REG(*preg,
  5598. (AWDy & ADC_AWD_CR_ALL_CHANNEL_MASK),
  5599. AWDChannelGroup & AWDy);
  5600. #endif
  5601. }
  5602. /**
  5603. * @brief Get ADC analog watchdog monitored channel.
  5604. * @note Usage of the returned channel number:
  5605. * - To reinject this channel into another function LL_ADC_xxx:
  5606. * the returned channel number is only partly formatted on definition
  5607. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  5608. * with parts of literals LL_ADC_CHANNEL_x or using
  5609. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  5610. * Then the selected literal LL_ADC_CHANNEL_x can be used
  5611. * as parameter for another function.
  5612. * - To get the channel number in decimal format:
  5613. * process the returned value with the helper macro
  5614. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  5615. * Applicable only when the analog watchdog is set to monitor
  5616. * one channel.
  5617. * @note On this STM32 serie, there are 2 kinds of analog watchdog
  5618. * instance:
  5619. * - AWD standard (instance AWD1):
  5620. * - channels monitored: can monitor 1 channel or all channels.
  5621. * - groups monitored: ADC groups regular and-or injected.
  5622. * - resolution: resolution is not limited (corresponds to
  5623. * ADC resolution configured).
  5624. * - AWD flexible (instances AWD2, AWD3):
  5625. * - channels monitored: flexible on channels monitored, selection is
  5626. * channel wise, from from 1 to all channels.
  5627. * Specificity of this analog watchdog: Multiple channels can
  5628. * be selected. For example:
  5629. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  5630. * - groups monitored: not selection possible (monitoring on both
  5631. * groups regular and injected).
  5632. * Channels selected are monitored on groups regular and injected:
  5633. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  5634. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  5635. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  5636. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  5637. * the 2 LSB are ignored.
  5638. * @note On this STM32 serie, setting of this feature is conditioned to
  5639. * ADC state:
  5640. * ADC must be disabled or enabled without conversion on going
  5641. * on either groups regular or injected.
  5642. * @rmtoll CFGR AWD1CH LL_ADC_GetAnalogWDMonitChannels\n
  5643. * CFGR AWD1SGL LL_ADC_GetAnalogWDMonitChannels\n
  5644. * CFGR AWD1EN LL_ADC_GetAnalogWDMonitChannels\n
  5645. * CFGR JAWD1EN LL_ADC_GetAnalogWDMonitChannels\n
  5646. * AWD2CR AWD2CH LL_ADC_GetAnalogWDMonitChannels\n
  5647. * AWD3CR AWD3CH LL_ADC_GetAnalogWDMonitChannels
  5648. * @param ADCx ADC instance
  5649. * @param AWDy This parameter can be one of the following values:
  5650. * @arg @ref LL_ADC_AWD1
  5651. * @arg @ref LL_ADC_AWD2 (1)(2)
  5652. * @arg @ref LL_ADC_AWD3 (1)(2)
  5653. *
  5654. * (1) On this AWD number, monitored channel can be retrieved
  5655. * if only 1 channel is programmed (or none or all channels).
  5656. * This function cannot retrieve monitored channel if
  5657. * multiple channels are programmed simultaneously
  5658. * by bitfield.
  5659. * (2) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  5660. * @retval Returned value can be one of the following values:
  5661. * @arg @ref LL_ADC_AWD_DISABLE
  5662. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0)
  5663. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0)(1)
  5664. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ (1)
  5665. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0)
  5666. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0)(1)
  5667. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ (1)
  5668. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0)
  5669. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0)(1)
  5670. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ (1)
  5671. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0)
  5672. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0)(1)
  5673. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ (1)
  5674. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0)
  5675. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0)(1)
  5676. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ (1)
  5677. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0)
  5678. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0)(1)
  5679. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ (1)
  5680. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0)
  5681. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0)(1)
  5682. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ (1)
  5683. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0)
  5684. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0)(1)
  5685. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ (1)
  5686. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0)
  5687. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0)(1)
  5688. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ (1)
  5689. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0)
  5690. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0)(1)
  5691. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ (1)
  5692. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0)
  5693. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0)(1)
  5694. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ (1)
  5695. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0)
  5696. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0)(1)
  5697. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ (1)
  5698. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0)
  5699. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0)(1)
  5700. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ (1)
  5701. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0)
  5702. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0)(1)
  5703. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ (1)
  5704. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0)
  5705. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0)(1)
  5706. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ (1)
  5707. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0)
  5708. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0)(1)
  5709. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ (1)
  5710. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0)
  5711. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0)(1)
  5712. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ (1)
  5713. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0)
  5714. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0)(1)
  5715. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ (1)
  5716. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0)
  5717. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0)(1)
  5718. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ (1)
  5719. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0)
  5720. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0)(1)
  5721. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ (1)
  5722. *
  5723. * (0) On STM32WB, parameter available only on analog watchdog number: AWD1.
  5724. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  5725. */
  5726. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDy)
  5727. {
  5728. #if defined (ADC_SUPPORT_2_5_MSPS)
  5729. /* Prevent unused argument(s) compilation warning */
  5730. (void)(AWDy);
  5731. uint32_t AnalogWDMonitChannels = (READ_BIT(ADCx->CFGR1, LL_ADC_AWD1) & LL_ADC_AWD1 & ADC_AWD_CR_ALL_CHANNEL_MASK);
  5732. /* If "AnalogWDMonitChannels" == 0, then the selected AWD is disabled */
  5733. /* (parameter value LL_ADC_AWD_DISABLE). */
  5734. /* Else, the selected AWD is enabled and is monitoring a group of channels */
  5735. /* or a single channel. */
  5736. if(AnalogWDMonitChannels != 0UL)
  5737. {
  5738. if((AnalogWDMonitChannels & ADC_CFGR1_AWD1SGL) == 0UL)
  5739. {
  5740. /* AWD monitoring a group of channels */
  5741. AnalogWDMonitChannels = (AnalogWDMonitChannels
  5742. & (~(ADC_CFGR1_AWD1CH))
  5743. );
  5744. }
  5745. else
  5746. {
  5747. /* AWD monitoring a single channel */
  5748. AnalogWDMonitChannels = (AnalogWDMonitChannels
  5749. | (0x01UL << (AnalogWDMonitChannels >> ADC_CFGR1_AWD1CH_Pos))
  5750. );
  5751. }
  5752. }
  5753. return AnalogWDMonitChannels;
  5754. #else
  5755. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->CFGR, ((AWDy & ADC_AWD_CRX_REGOFFSET_MASK) >> ADC_AWD_CRX_REGOFFSET_POS)
  5756. + ((AWDy & ADC_AWD_CR12_REGOFFSETGAP_MASK) * ADC_AWD_CR12_REGOFFSETGAP_VAL));
  5757. uint32_t AnalogWDMonitChannels = (READ_BIT(*preg, AWDy) & AWDy & ADC_AWD_CR_ALL_CHANNEL_MASK);
  5758. /* If "AnalogWDMonitChannels" == 0, then the selected AWD is disabled */
  5759. /* (parameter value LL_ADC_AWD_DISABLE). */
  5760. /* Else, the selected AWD is enabled and is monitoring a group of channels */
  5761. /* or a single channel. */
  5762. if (AnalogWDMonitChannels != 0UL)
  5763. {
  5764. if (AWDy == LL_ADC_AWD1)
  5765. {
  5766. if ((AnalogWDMonitChannels & ADC_CFGR_AWD1SGL) == 0UL)
  5767. {
  5768. /* AWD monitoring a group of channels */
  5769. AnalogWDMonitChannels = ((AnalogWDMonitChannels
  5770. | (ADC_AWD_CR23_CHANNEL_MASK)
  5771. )
  5772. & (~(ADC_CFGR_AWD1CH))
  5773. );
  5774. }
  5775. else
  5776. {
  5777. /* AWD monitoring a single channel */
  5778. AnalogWDMonitChannels = (AnalogWDMonitChannels
  5779. | (ADC_AWD2CR_AWD2CH_0 << (AnalogWDMonitChannels >> ADC_CFGR_AWD1CH_Pos))
  5780. );
  5781. }
  5782. }
  5783. else
  5784. {
  5785. if ((AnalogWDMonitChannels & ADC_AWD_CR23_CHANNEL_MASK) == ADC_AWD_CR23_CHANNEL_MASK)
  5786. {
  5787. /* AWD monitoring a group of channels */
  5788. AnalogWDMonitChannels = (ADC_AWD_CR23_CHANNEL_MASK
  5789. | ((ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN))
  5790. );
  5791. }
  5792. else
  5793. {
  5794. /* AWD monitoring a single channel */
  5795. /* AWD monitoring a group of channels */
  5796. AnalogWDMonitChannels = (AnalogWDMonitChannels
  5797. | (ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL)
  5798. | (__LL_ADC_CHANNEL_TO_DECIMAL_NB(AnalogWDMonitChannels) << ADC_CFGR_AWD1CH_Pos)
  5799. );
  5800. }
  5801. }
  5802. }
  5803. return AnalogWDMonitChannels;
  5804. #endif
  5805. }
  5806. /**
  5807. * @brief Set ADC analog watchdog thresholds value of both thresholds
  5808. * high and low.
  5809. * @note If value of only one threshold high or low must be set,
  5810. * use function @ref LL_ADC_SetAnalogWDThresholds().
  5811. * @note In case of ADC resolution different of 12 bits,
  5812. * analog watchdog thresholds data require a specific shift.
  5813. * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
  5814. * @note On this STM32 serie, there are 2 kinds of analog watchdog
  5815. * instance:
  5816. * - AWD standard (instance AWD1):
  5817. * - channels monitored: can monitor 1 channel or all channels.
  5818. * - groups monitored: ADC groups regular and-or injected.
  5819. * - resolution: resolution is not limited (corresponds to
  5820. * ADC resolution configured).
  5821. * - AWD flexible (instances AWD2, AWD3):
  5822. * - channels monitored: flexible on channels monitored, selection is
  5823. * channel wise, from from 1 to all channels.
  5824. * Specificity of this analog watchdog: Multiple channels can
  5825. * be selected. For example:
  5826. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  5827. * - groups monitored: not selection possible (monitoring on both
  5828. * groups regular and injected).
  5829. * Channels selected are monitored on groups regular and injected:
  5830. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  5831. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  5832. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  5833. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  5834. * the 2 LSB are ignored.
  5835. * @note If ADC oversampling is enabled, ADC analog watchdog thresholds are
  5836. * impacted: the comparison of analog watchdog thresholds is done on
  5837. * oversampling final computation (after ratio and shift application):
  5838. * ADC data register bitfield [15:4] (12 most significant bits).
  5839. * @note On this STM32 serie, setting of this feature is conditioned to
  5840. * ADC state:
  5841. * ADC must be disabled or enabled without conversion on going
  5842. * on either groups regular or injected.
  5843. * @rmtoll TR1 HT1 LL_ADC_ConfigAnalogWDThresholds\n
  5844. * TR2 HT2 LL_ADC_ConfigAnalogWDThresholds\n
  5845. * TR3 HT3 LL_ADC_ConfigAnalogWDThresholds\n
  5846. * TR1 LT1 LL_ADC_ConfigAnalogWDThresholds\n
  5847. * TR2 LT2 LL_ADC_ConfigAnalogWDThresholds\n
  5848. * TR3 LT3 LL_ADC_ConfigAnalogWDThresholds
  5849. * @param ADCx ADC instance
  5850. * @param AWDy This parameter can be one of the following values:
  5851. * @arg @ref LL_ADC_AWD1
  5852. * @arg @ref LL_ADC_AWD2 (1)
  5853. * @arg @ref LL_ADC_AWD3 (1)
  5854. *
  5855. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  5856. * @param AWDThresholdHighValue Value between Min_Data=0x000 and Max_Data=0xFFF
  5857. * @param AWDThresholdLowValue Value between Min_Data=0x000 and Max_Data=0xFFF
  5858. * @retval None
  5859. */
  5860. __STATIC_INLINE void LL_ADC_ConfigAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdHighValue,
  5861. uint32_t AWDThresholdLowValue)
  5862. {
  5863. /* Set bits with content of parameter "AWDThresholdxxxValue" with bits */
  5864. /* position in register and register position depending on parameter */
  5865. /* "AWDy". */
  5866. /* Parameters "AWDy" and "AWDThresholdxxxValue" are used with masks because */
  5867. /* containing other bits reserved for other purpose. */
  5868. #if defined (ADC_SUPPORT_2_5_MSPS)
  5869. /* Prevent unused argument(s) compilation warning */
  5870. (void)(AWDy);
  5871. MODIFY_REG(ADCx->TR1,
  5872. ADC_TR1_HT1 | ADC_TR1_LT1,
  5873. (AWDThresholdHighValue << ADC_TR1_HT1_BITOFFSET_POS) | AWDThresholdLowValue);
  5874. #else
  5875. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->TR1, ((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS));
  5876. MODIFY_REG(*preg,
  5877. ADC_TR1_HT1 | ADC_TR1_LT1,
  5878. (AWDThresholdHighValue << ADC_TR1_HT1_BITOFFSET_POS) | AWDThresholdLowValue);
  5879. #endif
  5880. }
  5881. /**
  5882. * @brief Set ADC analog watchdog threshold value of threshold
  5883. * high or low.
  5884. * @note If values of both thresholds high or low must be set,
  5885. * use function @ref LL_ADC_ConfigAnalogWDThresholds().
  5886. * @note In case of ADC resolution different of 12 bits,
  5887. * analog watchdog thresholds data require a specific shift.
  5888. * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
  5889. * @note On this STM32 serie, there are 2 kinds of analog watchdog
  5890. * instance:
  5891. * - AWD standard (instance AWD1):
  5892. * - channels monitored: can monitor 1 channel or all channels.
  5893. * - groups monitored: ADC groups regular and-or injected.
  5894. * - resolution: resolution is not limited (corresponds to
  5895. * ADC resolution configured).
  5896. * - AWD flexible (instances AWD2, AWD3):
  5897. * - channels monitored: flexible on channels monitored, selection is
  5898. * channel wise, from from 1 to all channels.
  5899. * Specificity of this analog watchdog: Multiple channels can
  5900. * be selected. For example:
  5901. * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...)
  5902. * - groups monitored: not selection possible (monitoring on both
  5903. * groups regular and injected).
  5904. * Channels selected are monitored on groups regular and injected:
  5905. * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters
  5906. * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ)
  5907. * - resolution: resolution is limited to 8 bits: if ADC resolution is
  5908. * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits
  5909. * the 2 LSB are ignored.
  5910. * @note If ADC oversampling is enabled, ADC analog watchdog thresholds are
  5911. * impacted: the comparison of analog watchdog thresholds is done on
  5912. * oversampling final computation (after ratio and shift application):
  5913. * ADC data register bitfield [15:4] (12 most significant bits).
  5914. * @note On this STM32 serie, setting of this feature is conditioned to
  5915. * ADC state:
  5916. * ADC must be disabled or enabled without conversion on going
  5917. * on either ADC groups regular or injected.
  5918. * @rmtoll TR1 HT1 LL_ADC_SetAnalogWDThresholds\n
  5919. * TR2 HT2 LL_ADC_SetAnalogWDThresholds\n
  5920. * TR3 HT3 LL_ADC_SetAnalogWDThresholds\n
  5921. * TR1 LT1 LL_ADC_SetAnalogWDThresholds\n
  5922. * TR2 LT2 LL_ADC_SetAnalogWDThresholds\n
  5923. * TR3 LT3 LL_ADC_SetAnalogWDThresholds
  5924. * @param ADCx ADC instance
  5925. * @param AWDy This parameter can be one of the following values:
  5926. * @arg @ref LL_ADC_AWD1
  5927. * @arg @ref LL_ADC_AWD2 (1)
  5928. * @arg @ref LL_ADC_AWD3 (1)
  5929. *
  5930. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  5931. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  5932. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  5933. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  5934. * @param AWDThresholdValue Value between Min_Data=0x000 and Max_Data=0xFFF
  5935. * @retval None
  5936. */
  5937. __STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdsHighLow,
  5938. uint32_t AWDThresholdValue)
  5939. {
  5940. /* Set bits with content of parameter "AWDThresholdValue" with bits */
  5941. /* position in register and register position depending on parameters */
  5942. /* "AWDThresholdsHighLow" and "AWDy". */
  5943. /* Parameters "AWDy" and "AWDThresholdValue" are used with masks because */
  5944. /* containing other bits reserved for other purpose. */
  5945. #if defined (ADC_SUPPORT_2_5_MSPS)
  5946. /* Prevent unused argument(s) compilation warning */
  5947. (void)(AWDy);
  5948. MODIFY_REG(ADCx->TR1,
  5949. AWDThresholdsHighLow,
  5950. AWDThresholdValue << ((AWDThresholdsHighLow & ADC_AWD_TRX_BIT_HIGH_MASK) >> ADC_AWD_TRX_BIT_HIGH_SHIFT4));
  5951. #else
  5952. __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->TR1, ((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS));
  5953. MODIFY_REG(*preg,
  5954. AWDThresholdsHighLow,
  5955. AWDThresholdValue << ((AWDThresholdsHighLow & ADC_AWD_TRX_BIT_HIGH_MASK) >> ADC_AWD_TRX_BIT_HIGH_SHIFT4));
  5956. #endif
  5957. }
  5958. /**
  5959. * @brief Get ADC analog watchdog threshold value of threshold high,
  5960. * threshold low or raw data with ADC thresholds high and low
  5961. * concatenated.
  5962. * @note If raw data with ADC thresholds high and low is retrieved,
  5963. * the data of each threshold high or low can be isolated
  5964. * using helper macro:
  5965. * @ref __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW().
  5966. * @note In case of ADC resolution different of 12 bits,
  5967. * analog watchdog thresholds data require a specific shift.
  5968. * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
  5969. * @rmtoll TR1 HT1 LL_ADC_GetAnalogWDThresholds\n
  5970. * TR2 HT2 LL_ADC_GetAnalogWDThresholds\n
  5971. * TR3 HT3 LL_ADC_GetAnalogWDThresholds\n
  5972. * TR1 LT1 LL_ADC_GetAnalogWDThresholds\n
  5973. * TR2 LT2 LL_ADC_GetAnalogWDThresholds\n
  5974. * TR3 LT3 LL_ADC_GetAnalogWDThresholds
  5975. * @param ADCx ADC instance
  5976. * @param AWDy This parameter can be one of the following values:
  5977. * @arg @ref LL_ADC_AWD1
  5978. * @arg @ref LL_ADC_AWD2 (1)
  5979. * @arg @ref LL_ADC_AWD3 (1)
  5980. *
  5981. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  5982. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  5983. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  5984. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  5985. * @arg @ref LL_ADC_AWD_THRESHOLDS_HIGH_LOW
  5986. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  5987. */
  5988. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdsHighLow)
  5989. {
  5990. #if defined (ADC_SUPPORT_2_5_MSPS)
  5991. /* Prevent unused argument(s) compilation warning */
  5992. (void)(AWDy);
  5993. return (uint32_t)(READ_BIT(ADCx->TR1,
  5994. (AWDThresholdsHighLow | ADC_TR1_LT1))
  5995. >> (((AWDThresholdsHighLow & ADC_AWD_TRX_BIT_HIGH_MASK) >> ADC_AWD_TRX_BIT_HIGH_SHIFT4) & ~(AWDThresholdsHighLow & ADC_TR1_LT1))
  5996. );
  5997. #else
  5998. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->TR1, ((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS));
  5999. return (uint32_t)(READ_BIT(*preg,
  6000. (AWDThresholdsHighLow | ADC_TR1_LT1))
  6001. >> (((AWDThresholdsHighLow & ADC_AWD_TRX_BIT_HIGH_MASK) >> ADC_AWD_TRX_BIT_HIGH_SHIFT4) & ~(AWDThresholdsHighLow & ADC_TR1_LT1))
  6002. );
  6003. #endif
  6004. }
  6005. /**
  6006. * @}
  6007. */
  6008. #if defined (ADC_SUPPORT_2_5_MSPS)
  6009. /* Feature "ADC oversampling" not available on ADC peripheral of this STM32WB device */
  6010. #else
  6011. /** @defgroup ADC_LL_EF_Configuration_ADC_oversampling Configuration of ADC transversal scope: oversampling
  6012. * @{
  6013. */
  6014. /**
  6015. * @brief Set ADC oversampling scope: ADC groups regular and-or injected
  6016. * (availability of ADC group injected depends on STM32 families).
  6017. * @note If both groups regular and injected are selected,
  6018. * specify behavior of ADC group injected interrupting
  6019. * group regular: when ADC group injected is triggered,
  6020. * the oversampling on ADC group regular is either
  6021. * temporary stopped and continued, or resumed from start
  6022. * (oversampler buffer reset).
  6023. * @note On this STM32 serie, setting of this feature is conditioned to
  6024. * ADC state:
  6025. * ADC must be disabled or enabled without conversion on going
  6026. * on either groups regular or injected.
  6027. * @rmtoll CFGR2 ROVSE LL_ADC_SetOverSamplingScope\n
  6028. * CFGR2 JOVSE LL_ADC_SetOverSamplingScope\n
  6029. * CFGR2 ROVSM LL_ADC_SetOverSamplingScope
  6030. * @param ADCx ADC instance
  6031. * @param OvsScope This parameter can be one of the following values:
  6032. * @arg @ref LL_ADC_OVS_DISABLE
  6033. * @arg @ref LL_ADC_OVS_GRP_REGULAR_CONTINUED
  6034. * @arg @ref LL_ADC_OVS_GRP_REGULAR_RESUMED (1)
  6035. * @arg @ref LL_ADC_OVS_GRP_INJECTED (1)
  6036. * @arg @ref LL_ADC_OVS_GRP_INJ_REG_RESUMED (1)
  6037. *
  6038. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  6039. * @retval None
  6040. */
  6041. __STATIC_INLINE void LL_ADC_SetOverSamplingScope(ADC_TypeDef *ADCx, uint32_t OvsScope)
  6042. {
  6043. #if defined (ADC_SUPPORT_2_5_MSPS)
  6044. MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_OVSE, OvsScope);
  6045. #else
  6046. MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_ROVSE | ADC_CFGR2_JOVSE | ADC_CFGR2_ROVSM, OvsScope);
  6047. #endif
  6048. }
  6049. /**
  6050. * @brief Get ADC oversampling scope: ADC groups regular and-or injected
  6051. * (availability of ADC group injected depends on STM32 families).
  6052. * @note If both groups regular and injected are selected,
  6053. * specify behavior of ADC group injected interrupting
  6054. * group regular: when ADC group injected is triggered,
  6055. * the oversampling on ADC group regular is either
  6056. * temporary stopped and continued, or resumed from start
  6057. * (oversampler buffer reset).
  6058. * @rmtoll CFGR2 ROVSE LL_ADC_GetOverSamplingScope\n
  6059. * CFGR2 JOVSE LL_ADC_GetOverSamplingScope\n
  6060. * CFGR2 ROVSM LL_ADC_GetOverSamplingScope
  6061. * @param ADCx ADC instance
  6062. * @retval Returned value can be one of the following values:
  6063. * @arg @ref LL_ADC_OVS_DISABLE
  6064. * @arg @ref LL_ADC_OVS_GRP_REGULAR_CONTINUED
  6065. * @arg @ref LL_ADC_OVS_GRP_REGULAR_RESUMED (1)
  6066. * @arg @ref LL_ADC_OVS_GRP_INJECTED (1)
  6067. * @arg @ref LL_ADC_OVS_GRP_INJ_REG_RESUMED (1)
  6068. *
  6069. * (1) On STM32WB serie, parameter not available on devices: STM32WB10xx, STM32WB15xx.
  6070. */
  6071. __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingScope(ADC_TypeDef *ADCx)
  6072. {
  6073. #if defined (ADC_SUPPORT_2_5_MSPS)
  6074. return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_OVSE));
  6075. #else
  6076. return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_ROVSE | ADC_CFGR2_JOVSE | ADC_CFGR2_ROVSM));
  6077. #endif
  6078. }
  6079. /**
  6080. * @brief Set ADC oversampling discontinuous mode (triggered mode)
  6081. * on the selected ADC group.
  6082. * @note Number of oversampled conversions are done either in:
  6083. * - continuous mode (all conversions of oversampling ratio
  6084. * are done from 1 trigger)
  6085. * - discontinuous mode (each conversion of oversampling ratio
  6086. * needs a trigger)
  6087. * @note On this STM32 serie, setting of this feature is conditioned to
  6088. * ADC state:
  6089. * ADC must be disabled or enabled without conversion on going
  6090. * on group regular.
  6091. * @note On this STM32 serie, oversampling discontinuous mode
  6092. * (triggered mode) can be used only when oversampling is
  6093. * set on group regular only and in resumed mode.
  6094. * @rmtoll CFGR2 TROVS LL_ADC_SetOverSamplingDiscont
  6095. * @param ADCx ADC instance
  6096. * @param OverSamplingDiscont This parameter can be one of the following values:
  6097. * @arg @ref LL_ADC_OVS_REG_CONT
  6098. * @arg @ref LL_ADC_OVS_REG_DISCONT
  6099. * @retval None
  6100. */
  6101. __STATIC_INLINE void LL_ADC_SetOverSamplingDiscont(ADC_TypeDef *ADCx, uint32_t OverSamplingDiscont)
  6102. {
  6103. #if defined (ADC_SUPPORT_2_5_MSPS)
  6104. MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_TOVS, OverSamplingDiscont);
  6105. #else
  6106. MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_TROVS, OverSamplingDiscont);
  6107. #endif
  6108. }
  6109. /**
  6110. * @brief Get ADC oversampling discontinuous mode (triggered mode)
  6111. * on the selected ADC group.
  6112. * @note Number of oversampled conversions are done either in:
  6113. * - continuous mode (all conversions of oversampling ratio
  6114. * are done from 1 trigger)
  6115. * - discontinuous mode (each conversion of oversampling ratio
  6116. * needs a trigger)
  6117. * @rmtoll CFGR2 TROVS LL_ADC_GetOverSamplingDiscont
  6118. * @param ADCx ADC instance
  6119. * @retval Returned value can be one of the following values:
  6120. * @arg @ref LL_ADC_OVS_REG_CONT
  6121. * @arg @ref LL_ADC_OVS_REG_DISCONT
  6122. */
  6123. __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingDiscont(ADC_TypeDef *ADCx)
  6124. {
  6125. #if defined (ADC_SUPPORT_2_5_MSPS)
  6126. return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_TOVS));
  6127. #else
  6128. return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_TROVS));
  6129. #endif
  6130. }
  6131. /**
  6132. * @brief Set ADC oversampling
  6133. * (impacting both ADC groups regular and injected)
  6134. * @note This function set the 2 items of oversampling configuration:
  6135. * - ratio
  6136. * - shift
  6137. * @note On this STM32 serie, setting of this feature is conditioned to
  6138. * ADC state:
  6139. * ADC must be disabled or enabled without conversion on going
  6140. * on either groups regular or injected.
  6141. * @rmtoll CFGR2 OVSS LL_ADC_ConfigOverSamplingRatioShift\n
  6142. * CFGR2 OVSR LL_ADC_ConfigOverSamplingRatioShift
  6143. * @param ADCx ADC instance
  6144. * @param Ratio This parameter can be one of the following values:
  6145. * @arg @ref LL_ADC_OVS_RATIO_2
  6146. * @arg @ref LL_ADC_OVS_RATIO_4
  6147. * @arg @ref LL_ADC_OVS_RATIO_8
  6148. * @arg @ref LL_ADC_OVS_RATIO_16
  6149. * @arg @ref LL_ADC_OVS_RATIO_32
  6150. * @arg @ref LL_ADC_OVS_RATIO_64
  6151. * @arg @ref LL_ADC_OVS_RATIO_128
  6152. * @arg @ref LL_ADC_OVS_RATIO_256
  6153. * @param Shift This parameter can be one of the following values:
  6154. * @arg @ref LL_ADC_OVS_SHIFT_NONE
  6155. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_1
  6156. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_2
  6157. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_3
  6158. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_4
  6159. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_5
  6160. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_6
  6161. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_7
  6162. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_8
  6163. * @retval None
  6164. */
  6165. __STATIC_INLINE void LL_ADC_ConfigOverSamplingRatioShift(ADC_TypeDef *ADCx, uint32_t Ratio, uint32_t Shift)
  6166. {
  6167. MODIFY_REG(ADCx->CFGR2, (ADC_CFGR2_OVSS | ADC_CFGR2_OVSR), (Shift | Ratio));
  6168. }
  6169. /**
  6170. * @brief Get ADC oversampling ratio
  6171. * (impacting both ADC groups regular and injected)
  6172. * @rmtoll CFGR2 OVSR LL_ADC_GetOverSamplingRatio
  6173. * @param ADCx ADC instance
  6174. * @retval Ratio This parameter can be one of the following values:
  6175. * @arg @ref LL_ADC_OVS_RATIO_2
  6176. * @arg @ref LL_ADC_OVS_RATIO_4
  6177. * @arg @ref LL_ADC_OVS_RATIO_8
  6178. * @arg @ref LL_ADC_OVS_RATIO_16
  6179. * @arg @ref LL_ADC_OVS_RATIO_32
  6180. * @arg @ref LL_ADC_OVS_RATIO_64
  6181. * @arg @ref LL_ADC_OVS_RATIO_128
  6182. * @arg @ref LL_ADC_OVS_RATIO_256
  6183. */
  6184. __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingRatio(ADC_TypeDef *ADCx)
  6185. {
  6186. return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_OVSR));
  6187. }
  6188. /**
  6189. * @brief Get ADC oversampling shift
  6190. * (impacting both ADC groups regular and injected)
  6191. * @rmtoll CFGR2 OVSS LL_ADC_GetOverSamplingShift
  6192. * @param ADCx ADC instance
  6193. * @retval Shift This parameter can be one of the following values:
  6194. * @arg @ref LL_ADC_OVS_SHIFT_NONE
  6195. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_1
  6196. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_2
  6197. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_3
  6198. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_4
  6199. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_5
  6200. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_6
  6201. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_7
  6202. * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_8
  6203. */
  6204. __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingShift(ADC_TypeDef *ADCx)
  6205. {
  6206. return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_OVSS));
  6207. }
  6208. /**
  6209. * @}
  6210. */
  6211. #endif /* ADC_SUPPORT_2_5_MSPS */
  6212. /** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
  6213. * @{
  6214. */
  6215. #if defined(ADC_SUPPORT_2_5_MSPS)
  6216. /* Feature "ADC deep power down" not available on ADC peripheral of this STM32WB device */
  6217. #else
  6218. /**
  6219. * @brief Put ADC instance in deep power down state.
  6220. * @note In case of ADC calibration necessary: When ADC is in deep-power-down
  6221. * state, the internal analog calibration is lost. After exiting from
  6222. * deep power down, calibration must be relaunched or calibration factor
  6223. * (preliminarily saved) must be set back into calibration register.
  6224. * @note On this STM32 serie, setting of this feature is conditioned to
  6225. * ADC state:
  6226. * ADC must be ADC disabled.
  6227. * @rmtoll CR DEEPPWD LL_ADC_EnableDeepPowerDown
  6228. * @param ADCx ADC instance
  6229. * @retval None
  6230. */
  6231. __STATIC_INLINE void LL_ADC_EnableDeepPowerDown(ADC_TypeDef *ADCx)
  6232. {
  6233. /* Note: Write register with some additional bits forced to state reset */
  6234. /* instead of modifying only the selected bit for this function, */
  6235. /* to not interfere with bits with HW property "rs". */
  6236. MODIFY_REG(ADCx->CR,
  6237. ADC_CR_BITS_PROPERTY_RS,
  6238. ADC_CR_DEEPPWD);
  6239. }
  6240. /**
  6241. * @brief Disable ADC deep power down mode.
  6242. * @note In case of ADC calibration necessary: When ADC is in deep-power-down
  6243. * state, the internal analog calibration is lost. After exiting from
  6244. * deep power down, calibration must be relaunched or calibration factor
  6245. * (preliminarily saved) must be set back into calibration register.
  6246. * @note On this STM32 serie, setting of this feature is conditioned to
  6247. * ADC state:
  6248. * ADC must be ADC disabled.
  6249. * @rmtoll CR DEEPPWD LL_ADC_DisableDeepPowerDown
  6250. * @param ADCx ADC instance
  6251. * @retval None
  6252. */
  6253. __STATIC_INLINE void LL_ADC_DisableDeepPowerDown(ADC_TypeDef *ADCx)
  6254. {
  6255. /* Note: Write register with some additional bits forced to state reset */
  6256. /* instead of modifying only the selected bit for this function, */
  6257. /* to not interfere with bits with HW property "rs". */
  6258. CLEAR_BIT(ADCx->CR, (ADC_CR_DEEPPWD | ADC_CR_BITS_PROPERTY_RS));
  6259. }
  6260. /**
  6261. * @brief Get the selected ADC instance deep power down state.
  6262. * @rmtoll CR DEEPPWD LL_ADC_IsDeepPowerDownEnabled
  6263. * @param ADCx ADC instance
  6264. * @retval 0: deep power down is disabled, 1: deep power down is enabled.
  6265. */
  6266. __STATIC_INLINE uint32_t LL_ADC_IsDeepPowerDownEnabled(ADC_TypeDef *ADCx)
  6267. {
  6268. return ((READ_BIT(ADCx->CR, ADC_CR_DEEPPWD) == (ADC_CR_DEEPPWD)) ? 1UL : 0UL);
  6269. }
  6270. #endif /* ADC_SUPPORT_2_5_MSPS */
  6271. /**
  6272. * @brief Enable ADC instance internal voltage regulator.
  6273. * @note On this STM32 serie, after ADC internal voltage regulator enable,
  6274. * a delay for ADC internal voltage regulator stabilization
  6275. * is required before performing a ADC calibration or ADC enable.
  6276. * Refer to device datasheet, parameter tADCVREG_STUP.
  6277. * Refer to literal @ref LL_ADC_DELAY_INTERNAL_REGUL_STAB_US.
  6278. * @note On this STM32 serie, setting of this feature is conditioned to
  6279. * ADC state:
  6280. * ADC must be ADC disabled.
  6281. * @rmtoll CR ADVREGEN LL_ADC_EnableInternalRegulator
  6282. * @param ADCx ADC instance
  6283. * @retval None
  6284. */
  6285. __STATIC_INLINE void LL_ADC_EnableInternalRegulator(ADC_TypeDef *ADCx)
  6286. {
  6287. /* Note: Write register with some additional bits forced to state reset */
  6288. /* instead of modifying only the selected bit for this function, */
  6289. /* to not interfere with bits with HW property "rs". */
  6290. MODIFY_REG(ADCx->CR,
  6291. ADC_CR_BITS_PROPERTY_RS,
  6292. ADC_CR_ADVREGEN);
  6293. }
  6294. /**
  6295. * @brief Disable ADC internal voltage regulator.
  6296. * @note On this STM32 serie, setting of this feature is conditioned to
  6297. * ADC state:
  6298. * ADC must be ADC disabled.
  6299. * @rmtoll CR ADVREGEN LL_ADC_DisableInternalRegulator
  6300. * @param ADCx ADC instance
  6301. * @retval None
  6302. */
  6303. __STATIC_INLINE void LL_ADC_DisableInternalRegulator(ADC_TypeDef *ADCx)
  6304. {
  6305. CLEAR_BIT(ADCx->CR, (ADC_CR_ADVREGEN | ADC_CR_BITS_PROPERTY_RS));
  6306. }
  6307. /**
  6308. * @brief Get the selected ADC instance internal voltage regulator state.
  6309. * @rmtoll CR ADVREGEN LL_ADC_IsInternalRegulatorEnabled
  6310. * @param ADCx ADC instance
  6311. * @retval 0: internal regulator is disabled, 1: internal regulator is enabled.
  6312. */
  6313. __STATIC_INLINE uint32_t LL_ADC_IsInternalRegulatorEnabled(ADC_TypeDef *ADCx)
  6314. {
  6315. return ((READ_BIT(ADCx->CR, ADC_CR_ADVREGEN) == (ADC_CR_ADVREGEN)) ? 1UL : 0UL);
  6316. }
  6317. /**
  6318. * @brief Enable the selected ADC instance.
  6319. * @note On this STM32 serie, after ADC enable, a delay for
  6320. * ADC internal analog stabilization is required before performing a
  6321. * ADC conversion start.
  6322. * Refer to device datasheet, parameter tSTAB.
  6323. * @note On this STM32 serie, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  6324. * is enabled and when conversion clock is active.
  6325. * (not only core clock: this ADC has a dual clock domain)
  6326. * @note On this STM32 serie, setting of this feature is conditioned to
  6327. * ADC state:
  6328. * ADC must be ADC disabled and ADC internal voltage regulator enabled.
  6329. * @rmtoll CR ADEN LL_ADC_Enable
  6330. * @param ADCx ADC instance
  6331. * @retval None
  6332. */
  6333. __STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
  6334. {
  6335. /* Note: Write register with some additional bits forced to state reset */
  6336. /* instead of modifying only the selected bit for this function, */
  6337. /* to not interfere with bits with HW property "rs". */
  6338. MODIFY_REG(ADCx->CR,
  6339. ADC_CR_BITS_PROPERTY_RS,
  6340. ADC_CR_ADEN);
  6341. }
  6342. /**
  6343. * @brief Disable the selected ADC instance.
  6344. * @note On this STM32 serie, setting of this feature is conditioned to
  6345. * ADC state:
  6346. * ADC must be not disabled. Must be enabled without conversion on going
  6347. * on either groups regular or injected.
  6348. * @rmtoll CR ADDIS LL_ADC_Disable
  6349. * @param ADCx ADC instance
  6350. * @retval None
  6351. */
  6352. __STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
  6353. {
  6354. /* Note: Write register with some additional bits forced to state reset */
  6355. /* instead of modifying only the selected bit for this function, */
  6356. /* to not interfere with bits with HW property "rs". */
  6357. MODIFY_REG(ADCx->CR,
  6358. ADC_CR_BITS_PROPERTY_RS,
  6359. ADC_CR_ADDIS);
  6360. }
  6361. /**
  6362. * @brief Get the selected ADC instance enable state.
  6363. * @note On this STM32 serie, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  6364. * is enabled and when conversion clock is active.
  6365. * (not only core clock: this ADC has a dual clock domain)
  6366. * @rmtoll CR ADEN LL_ADC_IsEnabled
  6367. * @param ADCx ADC instance
  6368. * @retval 0: ADC is disabled, 1: ADC is enabled.
  6369. */
  6370. __STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
  6371. {
  6372. return ((READ_BIT(ADCx->CR, ADC_CR_ADEN) == (ADC_CR_ADEN)) ? 1UL : 0UL);
  6373. }
  6374. /**
  6375. * @brief Get the selected ADC instance disable state.
  6376. * @rmtoll CR ADDIS LL_ADC_IsDisableOngoing
  6377. * @param ADCx ADC instance
  6378. * @retval 0: no ADC disable command on going.
  6379. */
  6380. __STATIC_INLINE uint32_t LL_ADC_IsDisableOngoing(ADC_TypeDef *ADCx)
  6381. {
  6382. return ((READ_BIT(ADCx->CR, ADC_CR_ADDIS) == (ADC_CR_ADDIS)) ? 1UL : 0UL);
  6383. }
  6384. #if defined (ADC_SUPPORT_2_5_MSPS)
  6385. /**
  6386. * @brief Start ADC calibration in the mode single-ended
  6387. * or differential (for devices with differential mode available).
  6388. * @note On this STM32 serie, a minimum number of ADC clock cycles
  6389. * are required between ADC end of calibration and ADC enable.
  6390. * Refer to literal @ref LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES.
  6391. * @note For devices with differential mode available:
  6392. * Calibration of offset is specific to each of
  6393. * single-ended and differential modes
  6394. * (calibration run must be performed for each of these
  6395. * differential modes, if used afterwards and if the application
  6396. * requires their calibration).
  6397. * @note On this STM32 serie, setting of this feature is conditioned to
  6398. * ADC state:
  6399. * ADC must be ADC disabled.
  6400. * @rmtoll CR ADCAL LL_ADC_StartCalibration\n
  6401. * CR ADCALDIF LL_ADC_StartCalibration
  6402. * @param ADCx ADC instance
  6403. * @retval None
  6404. */
  6405. __STATIC_INLINE void LL_ADC_StartCalibration(ADC_TypeDef *ADCx)
  6406. {
  6407. /* Note: Write register with some additional bits forced to state reset */
  6408. /* instead of modifying only the selected bit for this function, */
  6409. /* to not interfere with bits with HW property "rs". */
  6410. MODIFY_REG(ADCx->CR,
  6411. ADC_CR_BITS_PROPERTY_RS,
  6412. ADC_CR_ADCAL);
  6413. }
  6414. #else
  6415. /**
  6416. * @brief Start ADC calibration in the mode single-ended
  6417. * or differential (for devices with differential mode available).
  6418. * @note On this STM32 serie, a minimum number of ADC clock cycles
  6419. * are required between ADC end of calibration and ADC enable.
  6420. * Refer to literal @ref LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES.
  6421. * @note For devices with differential mode available:
  6422. * Calibration of offset is specific to each of
  6423. * single-ended and differential modes
  6424. * (calibration run must be performed for each of these
  6425. * differential modes, if used afterwards and if the application
  6426. * requires their calibration).
  6427. * @note On this STM32 serie, setting of this feature is conditioned to
  6428. * ADC state:
  6429. * ADC must be ADC disabled.
  6430. * @rmtoll CR ADCAL LL_ADC_StartCalibration\n
  6431. * CR ADCALDIF LL_ADC_StartCalibration
  6432. * @param ADCx ADC instance
  6433. * @param SingleDiff This parameter can be one of the following values:
  6434. * @arg @ref LL_ADC_SINGLE_ENDED
  6435. * @arg @ref LL_ADC_DIFFERENTIAL_ENDED
  6436. * @retval None
  6437. */
  6438. __STATIC_INLINE void LL_ADC_StartCalibration(ADC_TypeDef *ADCx, uint32_t SingleDiff)
  6439. {
  6440. /* Note: Write register with some additional bits forced to state reset */
  6441. /* instead of modifying only the selected bit for this function, */
  6442. /* to not interfere with bits with HW property "rs". */
  6443. MODIFY_REG(ADCx->CR,
  6444. ADC_CR_ADCALDIF | ADC_CR_BITS_PROPERTY_RS,
  6445. ADC_CR_ADCAL | (SingleDiff & ADC_SINGLEDIFF_CALIB_START_MASK));
  6446. }
  6447. #endif /* ADC_SUPPORT_2_5_MSPS */
  6448. /**
  6449. * @brief Get ADC calibration state.
  6450. * @rmtoll CR ADCAL LL_ADC_IsCalibrationOnGoing
  6451. * @param ADCx ADC instance
  6452. * @retval 0: calibration complete, 1: calibration in progress.
  6453. */
  6454. __STATIC_INLINE uint32_t LL_ADC_IsCalibrationOnGoing(ADC_TypeDef *ADCx)
  6455. {
  6456. return ((READ_BIT(ADCx->CR, ADC_CR_ADCAL) == (ADC_CR_ADCAL)) ? 1UL : 0UL);
  6457. }
  6458. /**
  6459. * @}
  6460. */
  6461. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
  6462. * @{
  6463. */
  6464. /**
  6465. * @brief Start ADC group regular conversion.
  6466. * @note On this STM32 serie, this function is relevant for both
  6467. * internal trigger (SW start) and external trigger:
  6468. * - If ADC trigger has been set to software start, ADC conversion
  6469. * starts immediately.
  6470. * - If ADC trigger has been set to external trigger, ADC conversion
  6471. * will start at next trigger event (on the selected trigger edge)
  6472. * following the ADC start conversion command.
  6473. * @note On this STM32 serie, setting of this feature is conditioned to
  6474. * ADC state:
  6475. * ADC must be enabled without conversion on going on group regular,
  6476. * without conversion stop command on going on group regular,
  6477. * without ADC disable command on going.
  6478. * @rmtoll CR ADSTART LL_ADC_REG_StartConversion
  6479. * @param ADCx ADC instance
  6480. * @retval None
  6481. */
  6482. __STATIC_INLINE void LL_ADC_REG_StartConversion(ADC_TypeDef *ADCx)
  6483. {
  6484. /* Note: Write register with some additional bits forced to state reset */
  6485. /* instead of modifying only the selected bit for this function, */
  6486. /* to not interfere with bits with HW property "rs". */
  6487. MODIFY_REG(ADCx->CR,
  6488. ADC_CR_BITS_PROPERTY_RS,
  6489. ADC_CR_ADSTART);
  6490. }
  6491. /**
  6492. * @brief Stop ADC group regular conversion.
  6493. * @note On this STM32 serie, setting of this feature is conditioned to
  6494. * ADC state:
  6495. * ADC must be enabled with conversion on going on group regular,
  6496. * without ADC disable command on going.
  6497. * @rmtoll CR ADSTP LL_ADC_REG_StopConversion
  6498. * @param ADCx ADC instance
  6499. * @retval None
  6500. */
  6501. __STATIC_INLINE void LL_ADC_REG_StopConversion(ADC_TypeDef *ADCx)
  6502. {
  6503. /* Note: Write register with some additional bits forced to state reset */
  6504. /* instead of modifying only the selected bit for this function, */
  6505. /* to not interfere with bits with HW property "rs". */
  6506. MODIFY_REG(ADCx->CR,
  6507. ADC_CR_BITS_PROPERTY_RS,
  6508. ADC_CR_ADSTP);
  6509. }
  6510. /**
  6511. * @brief Get ADC group regular conversion state.
  6512. * @rmtoll CR ADSTART LL_ADC_REG_IsConversionOngoing
  6513. * @param ADCx ADC instance
  6514. * @retval 0: no conversion is on going on ADC group regular.
  6515. */
  6516. __STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(ADC_TypeDef *ADCx)
  6517. {
  6518. return ((READ_BIT(ADCx->CR, ADC_CR_ADSTART) == (ADC_CR_ADSTART)) ? 1UL : 0UL);
  6519. }
  6520. /**
  6521. * @brief Get ADC group regular command of conversion stop state
  6522. * @rmtoll CR ADSTP LL_ADC_REG_IsStopConversionOngoing
  6523. * @param ADCx ADC instance
  6524. * @retval 0: no command of conversion stop is on going on ADC group regular.
  6525. */
  6526. __STATIC_INLINE uint32_t LL_ADC_REG_IsStopConversionOngoing(ADC_TypeDef *ADCx)
  6527. {
  6528. return ((READ_BIT(ADCx->CR, ADC_CR_ADSTP) == (ADC_CR_ADSTP)) ? 1UL : 0UL);
  6529. }
  6530. /**
  6531. * @brief Get ADC group regular conversion data, range fit for
  6532. * all ADC configurations: all ADC resolutions and
  6533. * all oversampling increased data width (for devices
  6534. * with feature oversampling).
  6535. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData32
  6536. * @param ADCx ADC instance
  6537. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  6538. */
  6539. __STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
  6540. {
  6541. return (uint32_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  6542. }
  6543. /**
  6544. * @brief Get ADC group regular conversion data, range fit for
  6545. * ADC resolution 12 bits.
  6546. * @note For devices with feature oversampling: Oversampling
  6547. * can increase data width, function for extended range
  6548. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  6549. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData12
  6550. * @param ADCx ADC instance
  6551. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  6552. */
  6553. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
  6554. {
  6555. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  6556. }
  6557. /**
  6558. * @brief Get ADC group regular conversion data, range fit for
  6559. * ADC resolution 10 bits.
  6560. * @note For devices with feature oversampling: Oversampling
  6561. * can increase data width, function for extended range
  6562. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  6563. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData10
  6564. * @param ADCx ADC instance
  6565. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  6566. */
  6567. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData10(ADC_TypeDef *ADCx)
  6568. {
  6569. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  6570. }
  6571. /**
  6572. * @brief Get ADC group regular conversion data, range fit for
  6573. * ADC resolution 8 bits.
  6574. * @note For devices with feature oversampling: Oversampling
  6575. * can increase data width, function for extended range
  6576. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  6577. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData8
  6578. * @param ADCx ADC instance
  6579. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  6580. */
  6581. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData8(ADC_TypeDef *ADCx)
  6582. {
  6583. return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  6584. }
  6585. /**
  6586. * @brief Get ADC group regular conversion data, range fit for
  6587. * ADC resolution 6 bits.
  6588. * @note For devices with feature oversampling: Oversampling
  6589. * can increase data width, function for extended range
  6590. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  6591. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData6
  6592. * @param ADCx ADC instance
  6593. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  6594. */
  6595. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData6(ADC_TypeDef *ADCx)
  6596. {
  6597. return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA));
  6598. }
  6599. /**
  6600. * @}
  6601. */
  6602. #if defined (ADC_SUPPORT_2_5_MSPS)
  6603. /* Feature "ADC group injected" not available on ADC peripheral of this STM32WB device */
  6604. #else
  6605. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected
  6606. * @{
  6607. */
  6608. /**
  6609. * @brief Start ADC group injected conversion.
  6610. * @note On this STM32 serie, this function is relevant for both
  6611. * internal trigger (SW start) and external trigger:
  6612. * - If ADC trigger has been set to software start, ADC conversion
  6613. * starts immediately.
  6614. * - If ADC trigger has been set to external trigger, ADC conversion
  6615. * will start at next trigger event (on the selected trigger edge)
  6616. * following the ADC start conversion command.
  6617. * @note On this STM32 serie, setting of this feature is conditioned to
  6618. * ADC state:
  6619. * ADC must be enabled without conversion on going on group injected,
  6620. * without conversion stop command on going on group injected,
  6621. * without ADC disable command on going.
  6622. * @rmtoll CR JADSTART LL_ADC_INJ_StartConversion
  6623. * @param ADCx ADC instance
  6624. * @retval None
  6625. */
  6626. __STATIC_INLINE void LL_ADC_INJ_StartConversion(ADC_TypeDef *ADCx)
  6627. {
  6628. /* Note: Write register with some additional bits forced to state reset */
  6629. /* instead of modifying only the selected bit for this function, */
  6630. /* to not interfere with bits with HW property "rs". */
  6631. MODIFY_REG(ADCx->CR,
  6632. ADC_CR_BITS_PROPERTY_RS,
  6633. ADC_CR_JADSTART);
  6634. }
  6635. /**
  6636. * @brief Stop ADC group injected conversion.
  6637. * @note On this STM32 serie, setting of this feature is conditioned to
  6638. * ADC state:
  6639. * ADC must be enabled with conversion on going on group injected,
  6640. * without ADC disable command on going.
  6641. * @rmtoll CR JADSTP LL_ADC_INJ_StopConversion
  6642. * @param ADCx ADC instance
  6643. * @retval None
  6644. */
  6645. __STATIC_INLINE void LL_ADC_INJ_StopConversion(ADC_TypeDef *ADCx)
  6646. {
  6647. /* Note: Write register with some additional bits forced to state reset */
  6648. /* instead of modifying only the selected bit for this function, */
  6649. /* to not interfere with bits with HW property "rs". */
  6650. MODIFY_REG(ADCx->CR,
  6651. ADC_CR_BITS_PROPERTY_RS,
  6652. ADC_CR_JADSTP);
  6653. }
  6654. /**
  6655. * @brief Get ADC group injected conversion state.
  6656. * @rmtoll CR JADSTART LL_ADC_INJ_IsConversionOngoing
  6657. * @param ADCx ADC instance
  6658. * @retval 0: no conversion is on going on ADC group injected.
  6659. */
  6660. __STATIC_INLINE uint32_t LL_ADC_INJ_IsConversionOngoing(ADC_TypeDef *ADCx)
  6661. {
  6662. return ((READ_BIT(ADCx->CR, ADC_CR_JADSTART) == (ADC_CR_JADSTART)) ? 1UL : 0UL);
  6663. }
  6664. /**
  6665. * @brief Get ADC group injected command of conversion stop state
  6666. * @rmtoll CR JADSTP LL_ADC_INJ_IsStopConversionOngoing
  6667. * @param ADCx ADC instance
  6668. * @retval 0: no command of conversion stop is on going on ADC group injected.
  6669. */
  6670. __STATIC_INLINE uint32_t LL_ADC_INJ_IsStopConversionOngoing(ADC_TypeDef *ADCx)
  6671. {
  6672. return ((READ_BIT(ADCx->CR, ADC_CR_JADSTP) == (ADC_CR_JADSTP)) ? 1UL : 0UL);
  6673. }
  6674. /**
  6675. * @brief Get ADC group injected conversion data, range fit for
  6676. * all ADC configurations: all ADC resolutions and
  6677. * all oversampling increased data width (for devices
  6678. * with feature oversampling).
  6679. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData32\n
  6680. * JDR2 JDATA LL_ADC_INJ_ReadConversionData32\n
  6681. * JDR3 JDATA LL_ADC_INJ_ReadConversionData32\n
  6682. * JDR4 JDATA LL_ADC_INJ_ReadConversionData32
  6683. * @param ADCx ADC instance
  6684. * @param Rank This parameter can be one of the following values:
  6685. * @arg @ref LL_ADC_INJ_RANK_1
  6686. * @arg @ref LL_ADC_INJ_RANK_2
  6687. * @arg @ref LL_ADC_INJ_RANK_3
  6688. * @arg @ref LL_ADC_INJ_RANK_4
  6689. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  6690. */
  6691. __STATIC_INLINE uint32_t LL_ADC_INJ_ReadConversionData32(ADC_TypeDef *ADCx, uint32_t Rank)
  6692. {
  6693. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
  6694. return (uint32_t)(READ_BIT(*preg,
  6695. ADC_JDR1_JDATA)
  6696. );
  6697. }
  6698. /**
  6699. * @brief Get ADC group injected conversion data, range fit for
  6700. * ADC resolution 12 bits.
  6701. * @note For devices with feature oversampling: Oversampling
  6702. * can increase data width, function for extended range
  6703. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  6704. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData12\n
  6705. * JDR2 JDATA LL_ADC_INJ_ReadConversionData12\n
  6706. * JDR3 JDATA LL_ADC_INJ_ReadConversionData12\n
  6707. * JDR4 JDATA LL_ADC_INJ_ReadConversionData12
  6708. * @param ADCx ADC instance
  6709. * @param Rank This parameter can be one of the following values:
  6710. * @arg @ref LL_ADC_INJ_RANK_1
  6711. * @arg @ref LL_ADC_INJ_RANK_2
  6712. * @arg @ref LL_ADC_INJ_RANK_3
  6713. * @arg @ref LL_ADC_INJ_RANK_4
  6714. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  6715. */
  6716. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData12(ADC_TypeDef *ADCx, uint32_t Rank)
  6717. {
  6718. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
  6719. return (uint16_t)(READ_BIT(*preg,
  6720. ADC_JDR1_JDATA)
  6721. );
  6722. }
  6723. /**
  6724. * @brief Get ADC group injected conversion data, range fit for
  6725. * ADC resolution 10 bits.
  6726. * @note For devices with feature oversampling: Oversampling
  6727. * can increase data width, function for extended range
  6728. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  6729. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData10\n
  6730. * JDR2 JDATA LL_ADC_INJ_ReadConversionData10\n
  6731. * JDR3 JDATA LL_ADC_INJ_ReadConversionData10\n
  6732. * JDR4 JDATA LL_ADC_INJ_ReadConversionData10
  6733. * @param ADCx ADC instance
  6734. * @param Rank This parameter can be one of the following values:
  6735. * @arg @ref LL_ADC_INJ_RANK_1
  6736. * @arg @ref LL_ADC_INJ_RANK_2
  6737. * @arg @ref LL_ADC_INJ_RANK_3
  6738. * @arg @ref LL_ADC_INJ_RANK_4
  6739. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  6740. */
  6741. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData10(ADC_TypeDef *ADCx, uint32_t Rank)
  6742. {
  6743. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
  6744. return (uint16_t)(READ_BIT(*preg,
  6745. ADC_JDR1_JDATA)
  6746. );
  6747. }
  6748. /**
  6749. * @brief Get ADC group injected conversion data, range fit for
  6750. * ADC resolution 8 bits.
  6751. * @note For devices with feature oversampling: Oversampling
  6752. * can increase data width, function for extended range
  6753. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  6754. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData8\n
  6755. * JDR2 JDATA LL_ADC_INJ_ReadConversionData8\n
  6756. * JDR3 JDATA LL_ADC_INJ_ReadConversionData8\n
  6757. * JDR4 JDATA LL_ADC_INJ_ReadConversionData8
  6758. * @param ADCx ADC instance
  6759. * @param Rank This parameter can be one of the following values:
  6760. * @arg @ref LL_ADC_INJ_RANK_1
  6761. * @arg @ref LL_ADC_INJ_RANK_2
  6762. * @arg @ref LL_ADC_INJ_RANK_3
  6763. * @arg @ref LL_ADC_INJ_RANK_4
  6764. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  6765. */
  6766. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData8(ADC_TypeDef *ADCx, uint32_t Rank)
  6767. {
  6768. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
  6769. return (uint8_t)(READ_BIT(*preg,
  6770. ADC_JDR1_JDATA)
  6771. );
  6772. }
  6773. /**
  6774. * @brief Get ADC group injected conversion data, range fit for
  6775. * ADC resolution 6 bits.
  6776. * @note For devices with feature oversampling: Oversampling
  6777. * can increase data width, function for extended range
  6778. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  6779. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData6\n
  6780. * JDR2 JDATA LL_ADC_INJ_ReadConversionData6\n
  6781. * JDR3 JDATA LL_ADC_INJ_ReadConversionData6\n
  6782. * JDR4 JDATA LL_ADC_INJ_ReadConversionData6
  6783. * @param ADCx ADC instance
  6784. * @param Rank This parameter can be one of the following values:
  6785. * @arg @ref LL_ADC_INJ_RANK_1
  6786. * @arg @ref LL_ADC_INJ_RANK_2
  6787. * @arg @ref LL_ADC_INJ_RANK_3
  6788. * @arg @ref LL_ADC_INJ_RANK_4
  6789. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  6790. */
  6791. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData6(ADC_TypeDef *ADCx, uint32_t Rank)
  6792. {
  6793. const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
  6794. return (uint8_t)(READ_BIT(*preg,
  6795. ADC_JDR1_JDATA)
  6796. );
  6797. }
  6798. /**
  6799. * @}
  6800. */
  6801. #endif /* ADC_SUPPORT_2_5_MSPS */
  6802. /** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
  6803. * @{
  6804. */
  6805. /**
  6806. * @brief Get flag ADC ready.
  6807. * @note On this STM32 serie, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  6808. * is enabled and when conversion clock is active.
  6809. * (not only core clock: this ADC has a dual clock domain)
  6810. * @rmtoll ISR ADRDY LL_ADC_IsActiveFlag_ADRDY
  6811. * @param ADCx ADC instance
  6812. * @retval State of bit (1 or 0).
  6813. */
  6814. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_ADRDY(ADC_TypeDef *ADCx)
  6815. {
  6816. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_ADRDY) == (LL_ADC_FLAG_ADRDY)) ? 1UL : 0UL);
  6817. }
  6818. #if defined(ADC_SUPPORT_2_5_MSPS)
  6819. /**
  6820. * @brief Get flag ADC channel configuration ready.
  6821. * @note Duration of ADC channel configuration ready: CCRDY handshake
  6822. * requires 1APB + 2 ADC + 3 APB cycles after the channel configuration
  6823. * has been changed.
  6824. * @rmtoll ISR CCRDY LL_ADC_IsActiveFlag_CCRDY
  6825. * @param ADCx ADC instance
  6826. * @retval State of bit (1 or 0).
  6827. */
  6828. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_CCRDY(ADC_TypeDef *ADCx)
  6829. {
  6830. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_CCRDY) == (LL_ADC_FLAG_CCRDY)) ? 1UL : 0UL);
  6831. }
  6832. #else
  6833. #endif
  6834. /**
  6835. * @brief Get flag ADC group regular end of unitary conversion.
  6836. * @rmtoll ISR EOC LL_ADC_IsActiveFlag_EOC
  6837. * @param ADCx ADC instance
  6838. * @retval State of bit (1 or 0).
  6839. */
  6840. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOC(ADC_TypeDef *ADCx)
  6841. {
  6842. return ((READ_BIT(ADCx->ISR, ADC_ISR_EOC) == (ADC_ISR_EOC)) ? 1UL : 0UL);
  6843. }
  6844. /**
  6845. * @brief Get flag ADC group regular end of sequence conversions.
  6846. * @rmtoll ISR EOS LL_ADC_IsActiveFlag_EOS
  6847. * @param ADCx ADC instance
  6848. * @retval State of bit (1 or 0).
  6849. */
  6850. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOS(ADC_TypeDef *ADCx)
  6851. {
  6852. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOS) == (LL_ADC_FLAG_EOS)) ? 1UL : 0UL);
  6853. }
  6854. /**
  6855. * @brief Get flag ADC group regular overrun.
  6856. * @rmtoll ISR OVR LL_ADC_IsActiveFlag_OVR
  6857. * @param ADCx ADC instance
  6858. * @retval State of bit (1 or 0).
  6859. */
  6860. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_OVR(ADC_TypeDef *ADCx)
  6861. {
  6862. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_OVR) == (LL_ADC_FLAG_OVR)) ? 1UL : 0UL);
  6863. }
  6864. /**
  6865. * @brief Get flag ADC group regular end of sampling phase.
  6866. * @rmtoll ISR EOSMP LL_ADC_IsActiveFlag_EOSMP
  6867. * @param ADCx ADC instance
  6868. * @retval State of bit (1 or 0).
  6869. */
  6870. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOSMP(ADC_TypeDef *ADCx)
  6871. {
  6872. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOSMP) == (LL_ADC_FLAG_EOSMP)) ? 1UL : 0UL);
  6873. }
  6874. #if defined (ADC_SUPPORT_2_5_MSPS)
  6875. /* Feature "ADC group injected" not available on ADC peripheral of this STM32WB device */
  6876. #else
  6877. /**
  6878. * @brief Get flag ADC group injected end of unitary conversion.
  6879. * @rmtoll ISR JEOC LL_ADC_IsActiveFlag_JEOC
  6880. * @param ADCx ADC instance
  6881. * @retval State of bit (1 or 0).
  6882. */
  6883. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOC(ADC_TypeDef *ADCx)
  6884. {
  6885. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_JEOC) == (LL_ADC_FLAG_JEOC)) ? 1UL : 0UL);
  6886. }
  6887. /**
  6888. * @brief Get flag ADC group injected end of sequence conversions.
  6889. * @rmtoll ISR JEOS LL_ADC_IsActiveFlag_JEOS
  6890. * @param ADCx ADC instance
  6891. * @retval State of bit (1 or 0).
  6892. */
  6893. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOS(ADC_TypeDef *ADCx)
  6894. {
  6895. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_JEOS) == (LL_ADC_FLAG_JEOS)) ? 1UL : 0UL);
  6896. }
  6897. /**
  6898. * @brief Get flag ADC group injected contexts queue overflow.
  6899. * @rmtoll ISR JQOVF LL_ADC_IsActiveFlag_JQOVF
  6900. * @param ADCx ADC instance
  6901. * @retval State of bit (1 or 0).
  6902. */
  6903. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JQOVF(ADC_TypeDef *ADCx)
  6904. {
  6905. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_JQOVF) == (LL_ADC_FLAG_JQOVF)) ? 1UL : 0UL);
  6906. }
  6907. #endif /* ADC_SUPPORT_2_5_MSPS */
  6908. /**
  6909. * @brief Get flag ADC analog watchdog 1 flag
  6910. * @rmtoll ISR AWD1 LL_ADC_IsActiveFlag_AWD1
  6911. * @param ADCx ADC instance
  6912. * @retval State of bit (1 or 0).
  6913. */
  6914. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(ADC_TypeDef *ADCx)
  6915. {
  6916. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1)) ? 1UL : 0UL);
  6917. }
  6918. /**
  6919. * @brief Get flag ADC analog watchdog 2.
  6920. * @rmtoll ISR AWD2 LL_ADC_IsActiveFlag_AWD2
  6921. * @param ADCx ADC instance
  6922. * @retval State of bit (1 or 0).
  6923. */
  6924. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD2(ADC_TypeDef *ADCx)
  6925. {
  6926. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD2) == (LL_ADC_FLAG_AWD2)) ? 1UL : 0UL);
  6927. }
  6928. /**
  6929. * @brief Get flag ADC analog watchdog 3.
  6930. * @rmtoll ISR AWD3 LL_ADC_IsActiveFlag_AWD3
  6931. * @param ADCx ADC instance
  6932. * @retval State of bit (1 or 0).
  6933. */
  6934. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD3(ADC_TypeDef *ADCx)
  6935. {
  6936. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD3) == (LL_ADC_FLAG_AWD3)) ? 1UL : 0UL);
  6937. }
  6938. #if defined(ADC_SUPPORT_2_5_MSPS)
  6939. /**
  6940. * @brief Get flag ADC end of calibration.
  6941. * @rmtoll ISR EOCAL LL_ADC_IsActiveFlag_EOCAL
  6942. * @param ADCx ADC instance
  6943. * @retval State of bit (1 or 0).
  6944. */
  6945. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOCAL(ADC_TypeDef *ADCx)
  6946. {
  6947. return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOCAL) == (LL_ADC_FLAG_EOCAL)) ? 1UL : 0UL);
  6948. }
  6949. #endif
  6950. /**
  6951. * @brief Clear flag ADC ready.
  6952. * @note On this STM32 serie, flag LL_ADC_FLAG_ADRDY is raised when the ADC
  6953. * is enabled and when conversion clock is active.
  6954. * (not only core clock: this ADC has a dual clock domain)
  6955. * @rmtoll ISR ADRDY LL_ADC_ClearFlag_ADRDY
  6956. * @param ADCx ADC instance
  6957. * @retval None
  6958. */
  6959. __STATIC_INLINE void LL_ADC_ClearFlag_ADRDY(ADC_TypeDef *ADCx)
  6960. {
  6961. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_ADRDY);
  6962. }
  6963. #if defined(ADC_SUPPORT_2_5_MSPS)
  6964. /**
  6965. * @brief Clear flag ADC channel configuration ready.
  6966. * @rmtoll ISR CCRDY LL_ADC_ClearFlag_CCRDY
  6967. * @param ADCx ADC instance
  6968. * @retval State of bit (1 or 0).
  6969. */
  6970. __STATIC_INLINE void LL_ADC_ClearFlag_CCRDY(ADC_TypeDef *ADCx)
  6971. {
  6972. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_CCRDY);
  6973. }
  6974. #else
  6975. #endif
  6976. /**
  6977. * @brief Clear flag ADC group regular end of unitary conversion.
  6978. * @rmtoll ISR EOC LL_ADC_ClearFlag_EOC
  6979. * @param ADCx ADC instance
  6980. * @retval None
  6981. */
  6982. __STATIC_INLINE void LL_ADC_ClearFlag_EOC(ADC_TypeDef *ADCx)
  6983. {
  6984. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOC);
  6985. }
  6986. /**
  6987. * @brief Clear flag ADC group regular end of sequence conversions.
  6988. * @rmtoll ISR EOS LL_ADC_ClearFlag_EOS
  6989. * @param ADCx ADC instance
  6990. * @retval None
  6991. */
  6992. __STATIC_INLINE void LL_ADC_ClearFlag_EOS(ADC_TypeDef *ADCx)
  6993. {
  6994. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOS);
  6995. }
  6996. /**
  6997. * @brief Clear flag ADC group regular overrun.
  6998. * @rmtoll ISR OVR LL_ADC_ClearFlag_OVR
  6999. * @param ADCx ADC instance
  7000. * @retval None
  7001. */
  7002. __STATIC_INLINE void LL_ADC_ClearFlag_OVR(ADC_TypeDef *ADCx)
  7003. {
  7004. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_OVR);
  7005. }
  7006. /**
  7007. * @brief Clear flag ADC group regular end of sampling phase.
  7008. * @rmtoll ISR EOSMP LL_ADC_ClearFlag_EOSMP
  7009. * @param ADCx ADC instance
  7010. * @retval None
  7011. */
  7012. __STATIC_INLINE void LL_ADC_ClearFlag_EOSMP(ADC_TypeDef *ADCx)
  7013. {
  7014. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOSMP);
  7015. }
  7016. #if defined (ADC_SUPPORT_2_5_MSPS)
  7017. /* Feature "ADC group injected" not available on ADC peripheral of this STM32WB device */
  7018. #else
  7019. /**
  7020. * @brief Clear flag ADC group injected end of unitary conversion.
  7021. * @rmtoll ISR JEOC LL_ADC_ClearFlag_JEOC
  7022. * @param ADCx ADC instance
  7023. * @retval None
  7024. */
  7025. __STATIC_INLINE void LL_ADC_ClearFlag_JEOC(ADC_TypeDef *ADCx)
  7026. {
  7027. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JEOC);
  7028. }
  7029. /**
  7030. * @brief Clear flag ADC group injected end of sequence conversions.
  7031. * @rmtoll ISR JEOS LL_ADC_ClearFlag_JEOS
  7032. * @param ADCx ADC instance
  7033. * @retval None
  7034. */
  7035. __STATIC_INLINE void LL_ADC_ClearFlag_JEOS(ADC_TypeDef *ADCx)
  7036. {
  7037. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JEOS);
  7038. }
  7039. /**
  7040. * @brief Clear flag ADC group injected contexts queue overflow.
  7041. * @rmtoll ISR JQOVF LL_ADC_ClearFlag_JQOVF
  7042. * @param ADCx ADC instance
  7043. * @retval None
  7044. */
  7045. __STATIC_INLINE void LL_ADC_ClearFlag_JQOVF(ADC_TypeDef *ADCx)
  7046. {
  7047. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JQOVF);
  7048. }
  7049. #endif /* ADC_SUPPORT_2_5_MSPS */
  7050. /**
  7051. * @brief Clear flag ADC analog watchdog 1.
  7052. * @rmtoll ISR AWD1 LL_ADC_ClearFlag_AWD1
  7053. * @param ADCx ADC instance
  7054. * @retval None
  7055. */
  7056. __STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx)
  7057. {
  7058. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD1);
  7059. }
  7060. /**
  7061. * @brief Clear flag ADC analog watchdog 2.
  7062. * @rmtoll ISR AWD2 LL_ADC_ClearFlag_AWD2
  7063. * @param ADCx ADC instance
  7064. * @retval None
  7065. */
  7066. __STATIC_INLINE void LL_ADC_ClearFlag_AWD2(ADC_TypeDef *ADCx)
  7067. {
  7068. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD2);
  7069. }
  7070. /**
  7071. * @brief Clear flag ADC analog watchdog 3.
  7072. * @rmtoll ISR AWD3 LL_ADC_ClearFlag_AWD3
  7073. * @param ADCx ADC instance
  7074. * @retval None
  7075. */
  7076. __STATIC_INLINE void LL_ADC_ClearFlag_AWD3(ADC_TypeDef *ADCx)
  7077. {
  7078. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD3);
  7079. }
  7080. #if defined(ADC_SUPPORT_2_5_MSPS)
  7081. /**
  7082. * @brief Clear flag ADC end of calibration.
  7083. * @rmtoll ISR EOCAL LL_ADC_ClearFlag_EOCAL
  7084. * @param ADCx ADC instance
  7085. * @retval None
  7086. */
  7087. __STATIC_INLINE void LL_ADC_ClearFlag_EOCAL(ADC_TypeDef *ADCx)
  7088. {
  7089. WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOCAL);
  7090. }
  7091. #endif
  7092. /**
  7093. * @}
  7094. */
  7095. /** @defgroup ADC_LL_EF_IT_Management ADC IT management
  7096. * @{
  7097. */
  7098. /**
  7099. * @brief Enable ADC ready.
  7100. * @rmtoll IER ADRDYIE LL_ADC_EnableIT_ADRDY
  7101. * @param ADCx ADC instance
  7102. * @retval None
  7103. */
  7104. __STATIC_INLINE void LL_ADC_EnableIT_ADRDY(ADC_TypeDef *ADCx)
  7105. {
  7106. SET_BIT(ADCx->IER, LL_ADC_IT_ADRDY);
  7107. }
  7108. #if defined(ADC_SUPPORT_2_5_MSPS)
  7109. /**
  7110. * @brief Enable interruption ADC channel configuration ready.
  7111. * @rmtoll IER ADRDYIE LL_ADC_EnableIT_CCRDY
  7112. * @param ADCx ADC instance
  7113. * @retval State of bit (1 or 0).
  7114. */
  7115. __STATIC_INLINE void LL_ADC_EnableIT_CCRDY(ADC_TypeDef *ADCx)
  7116. {
  7117. SET_BIT(ADCx->IER, LL_ADC_FLAG_CCRDY);
  7118. }
  7119. #else
  7120. #endif
  7121. /**
  7122. * @brief Enable interruption ADC group regular end of unitary conversion.
  7123. * @rmtoll IER EOCIE LL_ADC_EnableIT_EOC
  7124. * @param ADCx ADC instance
  7125. * @retval None
  7126. */
  7127. __STATIC_INLINE void LL_ADC_EnableIT_EOC(ADC_TypeDef *ADCx)
  7128. {
  7129. SET_BIT(ADCx->IER, LL_ADC_IT_EOC);
  7130. }
  7131. /**
  7132. * @brief Enable interruption ADC group regular end of sequence conversions.
  7133. * @rmtoll IER EOSIE LL_ADC_EnableIT_EOS
  7134. * @param ADCx ADC instance
  7135. * @retval None
  7136. */
  7137. __STATIC_INLINE void LL_ADC_EnableIT_EOS(ADC_TypeDef *ADCx)
  7138. {
  7139. SET_BIT(ADCx->IER, LL_ADC_IT_EOS);
  7140. }
  7141. /**
  7142. * @brief Enable ADC group regular interruption overrun.
  7143. * @rmtoll IER OVRIE LL_ADC_EnableIT_OVR
  7144. * @param ADCx ADC instance
  7145. * @retval None
  7146. */
  7147. __STATIC_INLINE void LL_ADC_EnableIT_OVR(ADC_TypeDef *ADCx)
  7148. {
  7149. SET_BIT(ADCx->IER, LL_ADC_IT_OVR);
  7150. }
  7151. /**
  7152. * @brief Enable interruption ADC group regular end of sampling.
  7153. * @rmtoll IER EOSMPIE LL_ADC_EnableIT_EOSMP
  7154. * @param ADCx ADC instance
  7155. * @retval None
  7156. */
  7157. __STATIC_INLINE void LL_ADC_EnableIT_EOSMP(ADC_TypeDef *ADCx)
  7158. {
  7159. SET_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
  7160. }
  7161. #if defined (ADC_SUPPORT_2_5_MSPS)
  7162. /* Feature "ADC group injected" not available on ADC peripheral of this STM32WB device */
  7163. #else
  7164. /**
  7165. * @brief Enable interruption ADC group injected end of unitary conversion.
  7166. * @rmtoll IER JEOCIE LL_ADC_EnableIT_JEOC
  7167. * @param ADCx ADC instance
  7168. * @retval None
  7169. */
  7170. __STATIC_INLINE void LL_ADC_EnableIT_JEOC(ADC_TypeDef *ADCx)
  7171. {
  7172. SET_BIT(ADCx->IER, LL_ADC_IT_JEOC);
  7173. }
  7174. /**
  7175. * @brief Enable interruption ADC group injected end of sequence conversions.
  7176. * @rmtoll IER JEOSIE LL_ADC_EnableIT_JEOS
  7177. * @param ADCx ADC instance
  7178. * @retval None
  7179. */
  7180. __STATIC_INLINE void LL_ADC_EnableIT_JEOS(ADC_TypeDef *ADCx)
  7181. {
  7182. SET_BIT(ADCx->IER, LL_ADC_IT_JEOS);
  7183. }
  7184. /**
  7185. * @brief Enable interruption ADC group injected context queue overflow.
  7186. * @rmtoll IER JQOVFIE LL_ADC_EnableIT_JQOVF
  7187. * @param ADCx ADC instance
  7188. * @retval None
  7189. */
  7190. __STATIC_INLINE void LL_ADC_EnableIT_JQOVF(ADC_TypeDef *ADCx)
  7191. {
  7192. SET_BIT(ADCx->IER, LL_ADC_IT_JQOVF);
  7193. }
  7194. #endif /* ADC_SUPPORT_2_5_MSPS */
  7195. /**
  7196. * @brief Enable interruption ADC analog watchdog 1.
  7197. * @rmtoll IER AWD1IE LL_ADC_EnableIT_AWD1
  7198. * @param ADCx ADC instance
  7199. * @retval None
  7200. */
  7201. __STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx)
  7202. {
  7203. SET_BIT(ADCx->IER, LL_ADC_IT_AWD1);
  7204. }
  7205. /**
  7206. * @brief Enable interruption ADC analog watchdog 2.
  7207. * @rmtoll IER AWD2IE LL_ADC_EnableIT_AWD2
  7208. * @param ADCx ADC instance
  7209. * @retval None
  7210. */
  7211. __STATIC_INLINE void LL_ADC_EnableIT_AWD2(ADC_TypeDef *ADCx)
  7212. {
  7213. SET_BIT(ADCx->IER, LL_ADC_IT_AWD2);
  7214. }
  7215. /**
  7216. * @brief Enable interruption ADC analog watchdog 3.
  7217. * @rmtoll IER AWD3IE LL_ADC_EnableIT_AWD3
  7218. * @param ADCx ADC instance
  7219. * @retval None
  7220. */
  7221. __STATIC_INLINE void LL_ADC_EnableIT_AWD3(ADC_TypeDef *ADCx)
  7222. {
  7223. SET_BIT(ADCx->IER, LL_ADC_IT_AWD3);
  7224. }
  7225. #if defined(ADC_SUPPORT_2_5_MSPS)
  7226. /**
  7227. * @brief Enable interruption ADC end of calibration.
  7228. * @rmtoll IER EOCALIE LL_ADC_EnableIT_EOCAL
  7229. * @param ADCx ADC instance
  7230. * @retval None
  7231. */
  7232. __STATIC_INLINE void LL_ADC_EnableIT_EOCAL(ADC_TypeDef *ADCx)
  7233. {
  7234. SET_BIT(ADCx->IER, LL_ADC_IT_EOCAL);
  7235. }
  7236. #endif
  7237. /**
  7238. * @brief Disable interruption ADC ready.
  7239. * @rmtoll IER ADRDYIE LL_ADC_DisableIT_ADRDY
  7240. * @param ADCx ADC instance
  7241. * @retval None
  7242. */
  7243. __STATIC_INLINE void LL_ADC_DisableIT_ADRDY(ADC_TypeDef *ADCx)
  7244. {
  7245. CLEAR_BIT(ADCx->IER, LL_ADC_IT_ADRDY);
  7246. }
  7247. #if defined(ADC_SUPPORT_2_5_MSPS)
  7248. /**
  7249. * @brief Disable interruption ADC channel configuration ready.
  7250. * @rmtoll IER ADRDYIE LL_ADC_DisableIT_CCRDY
  7251. * @param ADCx ADC instance
  7252. * @retval State of bit (1 or 0).
  7253. */
  7254. __STATIC_INLINE void LL_ADC_DisableIT_CCRDY(ADC_TypeDef *ADCx)
  7255. {
  7256. CLEAR_BIT(ADCx->IER, LL_ADC_FLAG_CCRDY);
  7257. }
  7258. #else
  7259. #endif
  7260. /**
  7261. * @brief Disable interruption ADC group regular end of unitary conversion.
  7262. * @rmtoll IER EOCIE LL_ADC_DisableIT_EOC
  7263. * @param ADCx ADC instance
  7264. * @retval None
  7265. */
  7266. __STATIC_INLINE void LL_ADC_DisableIT_EOC(ADC_TypeDef *ADCx)
  7267. {
  7268. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOC);
  7269. }
  7270. /**
  7271. * @brief Disable interruption ADC group regular end of sequence conversions.
  7272. * @rmtoll IER EOSIE LL_ADC_DisableIT_EOS
  7273. * @param ADCx ADC instance
  7274. * @retval None
  7275. */
  7276. __STATIC_INLINE void LL_ADC_DisableIT_EOS(ADC_TypeDef *ADCx)
  7277. {
  7278. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOS);
  7279. }
  7280. /**
  7281. * @brief Disable interruption ADC group regular overrun.
  7282. * @rmtoll IER OVRIE LL_ADC_DisableIT_OVR
  7283. * @param ADCx ADC instance
  7284. * @retval None
  7285. */
  7286. __STATIC_INLINE void LL_ADC_DisableIT_OVR(ADC_TypeDef *ADCx)
  7287. {
  7288. CLEAR_BIT(ADCx->IER, LL_ADC_IT_OVR);
  7289. }
  7290. /**
  7291. * @brief Disable interruption ADC group regular end of sampling.
  7292. * @rmtoll IER EOSMPIE LL_ADC_DisableIT_EOSMP
  7293. * @param ADCx ADC instance
  7294. * @retval None
  7295. */
  7296. __STATIC_INLINE void LL_ADC_DisableIT_EOSMP(ADC_TypeDef *ADCx)
  7297. {
  7298. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
  7299. }
  7300. #if defined (ADC_SUPPORT_2_5_MSPS)
  7301. /* Feature "ADC group injected" not available on ADC peripheral of this STM32WB device */
  7302. #else
  7303. /**
  7304. * @brief Disable interruption ADC group regular end of unitary conversion.
  7305. * @rmtoll IER JEOCIE LL_ADC_DisableIT_JEOC
  7306. * @param ADCx ADC instance
  7307. * @retval None
  7308. */
  7309. __STATIC_INLINE void LL_ADC_DisableIT_JEOC(ADC_TypeDef *ADCx)
  7310. {
  7311. CLEAR_BIT(ADCx->IER, LL_ADC_IT_JEOC);
  7312. }
  7313. /**
  7314. * @brief Disable interruption ADC group injected end of sequence conversions.
  7315. * @rmtoll IER JEOSIE LL_ADC_DisableIT_JEOS
  7316. * @param ADCx ADC instance
  7317. * @retval None
  7318. */
  7319. __STATIC_INLINE void LL_ADC_DisableIT_JEOS(ADC_TypeDef *ADCx)
  7320. {
  7321. CLEAR_BIT(ADCx->IER, LL_ADC_IT_JEOS);
  7322. }
  7323. /**
  7324. * @brief Disable interruption ADC group injected context queue overflow.
  7325. * @rmtoll IER JQOVFIE LL_ADC_DisableIT_JQOVF
  7326. * @param ADCx ADC instance
  7327. * @retval None
  7328. */
  7329. __STATIC_INLINE void LL_ADC_DisableIT_JQOVF(ADC_TypeDef *ADCx)
  7330. {
  7331. CLEAR_BIT(ADCx->IER, LL_ADC_IT_JQOVF);
  7332. }
  7333. #endif /* ADC_SUPPORT_2_5_MSPS */
  7334. /**
  7335. * @brief Disable interruption ADC analog watchdog 1.
  7336. * @rmtoll IER AWD1IE LL_ADC_DisableIT_AWD1
  7337. * @param ADCx ADC instance
  7338. * @retval None
  7339. */
  7340. __STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx)
  7341. {
  7342. CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD1);
  7343. }
  7344. /**
  7345. * @brief Disable interruption ADC analog watchdog 2.
  7346. * @rmtoll IER AWD2IE LL_ADC_DisableIT_AWD2
  7347. * @param ADCx ADC instance
  7348. * @retval None
  7349. */
  7350. __STATIC_INLINE void LL_ADC_DisableIT_AWD2(ADC_TypeDef *ADCx)
  7351. {
  7352. CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD2);
  7353. }
  7354. /**
  7355. * @brief Disable interruption ADC analog watchdog 3.
  7356. * @rmtoll IER AWD3IE LL_ADC_DisableIT_AWD3
  7357. * @param ADCx ADC instance
  7358. * @retval None
  7359. */
  7360. __STATIC_INLINE void LL_ADC_DisableIT_AWD3(ADC_TypeDef *ADCx)
  7361. {
  7362. CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD3);
  7363. }
  7364. #if defined(ADC_SUPPORT_2_5_MSPS)
  7365. /**
  7366. * @brief Disable interruption ADC end of calibration.
  7367. * @rmtoll IER EOCALIE LL_ADC_DisableIT_EOCAL
  7368. * @param ADCx ADC instance
  7369. * @retval None
  7370. */
  7371. __STATIC_INLINE void LL_ADC_DisableIT_EOCAL(ADC_TypeDef *ADCx)
  7372. {
  7373. CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOCAL);
  7374. }
  7375. #endif
  7376. /**
  7377. * @brief Get state of interruption ADC ready
  7378. * (0: interrupt disabled, 1: interrupt enabled).
  7379. * @rmtoll IER ADRDYIE LL_ADC_IsEnabledIT_ADRDY
  7380. * @param ADCx ADC instance
  7381. * @retval State of bit (1 or 0).
  7382. */
  7383. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_ADRDY(ADC_TypeDef *ADCx)
  7384. {
  7385. return ((READ_BIT(ADCx->IER, LL_ADC_IT_ADRDY) == (LL_ADC_IT_ADRDY)) ? 1UL : 0UL);
  7386. }
  7387. #if defined(ADC_SUPPORT_2_5_MSPS)
  7388. /**
  7389. * @brief Get state of interruption ADC channel configuration ready.
  7390. * @rmtoll IER ADRDYIE LL_ADC_IsEnabledIT_CCRDY
  7391. * @param ADCx ADC instance
  7392. * @retval State of bit (1 or 0).
  7393. */
  7394. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_CCRDY(ADC_TypeDef *ADCx)
  7395. {
  7396. return ((READ_BIT(ADCx->IER, LL_ADC_FLAG_CCRDY) == (LL_ADC_FLAG_CCRDY)) ? 1UL : 0UL);
  7397. }
  7398. #else
  7399. #endif
  7400. /**
  7401. * @brief Get state of interruption ADC group regular end of unitary conversion
  7402. * (0: interrupt disabled, 1: interrupt enabled).
  7403. * @rmtoll IER EOCIE LL_ADC_IsEnabledIT_EOC
  7404. * @param ADCx ADC instance
  7405. * @retval State of bit (1 or 0).
  7406. */
  7407. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOC(ADC_TypeDef *ADCx)
  7408. {
  7409. return ((READ_BIT(ADCx->IER, LL_ADC_IT_EOC) == (LL_ADC_IT_EOC)) ? 1UL : 0UL);
  7410. }
  7411. /**
  7412. * @brief Get state of interruption ADC group regular end of sequence conversions
  7413. * (0: interrupt disabled, 1: interrupt enabled).
  7414. * @rmtoll IER EOSIE LL_ADC_IsEnabledIT_EOS
  7415. * @param ADCx ADC instance
  7416. * @retval State of bit (1 or 0).
  7417. */
  7418. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOS(ADC_TypeDef *ADCx)
  7419. {
  7420. return ((READ_BIT(ADCx->IER, LL_ADC_IT_EOS) == (LL_ADC_IT_EOS)) ? 1UL : 0UL);
  7421. }
  7422. /**
  7423. * @brief Get state of interruption ADC group regular overrun
  7424. * (0: interrupt disabled, 1: interrupt enabled).
  7425. * @rmtoll IER OVRIE LL_ADC_IsEnabledIT_OVR
  7426. * @param ADCx ADC instance
  7427. * @retval State of bit (1 or 0).
  7428. */
  7429. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_OVR(ADC_TypeDef *ADCx)
  7430. {
  7431. return ((READ_BIT(ADCx->IER, LL_ADC_IT_OVR) == (LL_ADC_IT_OVR)) ? 1UL : 0UL);
  7432. }
  7433. /**
  7434. * @brief Get state of interruption ADC group regular end of sampling
  7435. * (0: interrupt disabled, 1: interrupt enabled).
  7436. * @rmtoll IER EOSMPIE LL_ADC_IsEnabledIT_EOSMP
  7437. * @param ADCx ADC instance
  7438. * @retval State of bit (1 or 0).
  7439. */
  7440. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOSMP(ADC_TypeDef *ADCx)
  7441. {
  7442. return ((READ_BIT(ADCx->IER, LL_ADC_IT_EOSMP) == (LL_ADC_IT_EOSMP)) ? 1UL : 0UL);
  7443. }
  7444. #if defined (ADC_SUPPORT_2_5_MSPS)
  7445. /* Feature "ADC group injected" not available on ADC peripheral of this STM32WB device */
  7446. #else
  7447. /**
  7448. * @brief Get state of interruption ADC group injected end of unitary conversion
  7449. * (0: interrupt disabled, 1: interrupt enabled).
  7450. * @rmtoll IER JEOCIE LL_ADC_IsEnabledIT_JEOC
  7451. * @param ADCx ADC instance
  7452. * @retval State of bit (1 or 0).
  7453. */
  7454. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOC(ADC_TypeDef *ADCx)
  7455. {
  7456. return ((READ_BIT(ADCx->IER, LL_ADC_IT_JEOC) == (LL_ADC_IT_JEOC)) ? 1UL : 0UL);
  7457. }
  7458. /**
  7459. * @brief Get state of interruption ADC group injected end of sequence conversions
  7460. * (0: interrupt disabled, 1: interrupt enabled).
  7461. * @rmtoll IER JEOSIE LL_ADC_IsEnabledIT_JEOS
  7462. * @param ADCx ADC instance
  7463. * @retval State of bit (1 or 0).
  7464. */
  7465. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOS(ADC_TypeDef *ADCx)
  7466. {
  7467. return ((READ_BIT(ADCx->IER, LL_ADC_IT_JEOS) == (LL_ADC_IT_JEOS)) ? 1UL : 0UL);
  7468. }
  7469. /**
  7470. * @brief Get state of interruption ADC group injected context queue overflow interrupt state
  7471. * (0: interrupt disabled, 1: interrupt enabled).
  7472. * @rmtoll IER JQOVFIE LL_ADC_IsEnabledIT_JQOVF
  7473. * @param ADCx ADC instance
  7474. * @retval State of bit (1 or 0).
  7475. */
  7476. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JQOVF(ADC_TypeDef *ADCx)
  7477. {
  7478. return ((READ_BIT(ADCx->IER, LL_ADC_IT_JQOVF) == (LL_ADC_IT_JQOVF)) ? 1UL : 0UL);
  7479. }
  7480. #endif /* ADC_SUPPORT_2_5_MSPS */
  7481. /**
  7482. * @brief Get state of interruption ADC analog watchdog 1
  7483. * (0: interrupt disabled, 1: interrupt enabled).
  7484. * @rmtoll IER AWD1IE LL_ADC_IsEnabledIT_AWD1
  7485. * @param ADCx ADC instance
  7486. * @retval State of bit (1 or 0).
  7487. */
  7488. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(ADC_TypeDef *ADCx)
  7489. {
  7490. return ((READ_BIT(ADCx->IER, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1)) ? 1UL : 0UL);
  7491. }
  7492. /**
  7493. * @brief Get state of interruption Get ADC analog watchdog 2
  7494. * (0: interrupt disabled, 1: interrupt enabled).
  7495. * @rmtoll IER AWD2IE LL_ADC_IsEnabledIT_AWD2
  7496. * @param ADCx ADC instance
  7497. * @retval State of bit (1 or 0).
  7498. */
  7499. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD2(ADC_TypeDef *ADCx)
  7500. {
  7501. return ((READ_BIT(ADCx->IER, LL_ADC_IT_AWD2) == (LL_ADC_IT_AWD2)) ? 1UL : 0UL);
  7502. }
  7503. /**
  7504. * @brief Get state of interruption Get ADC analog watchdog 3
  7505. * (0: interrupt disabled, 1: interrupt enabled).
  7506. * @rmtoll IER AWD3IE LL_ADC_IsEnabledIT_AWD3
  7507. * @param ADCx ADC instance
  7508. * @retval State of bit (1 or 0).
  7509. */
  7510. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD3(ADC_TypeDef *ADCx)
  7511. {
  7512. return ((READ_BIT(ADCx->IER, LL_ADC_IT_AWD3) == (LL_ADC_IT_AWD3)) ? 1UL : 0UL);
  7513. }
  7514. #if defined(ADC_SUPPORT_2_5_MSPS)
  7515. /**
  7516. * @brief Get state of interruption ADC end of calibration
  7517. * (0: interrupt disabled, 1: interrupt enabled).
  7518. * @rmtoll IER EOCALIE LL_ADC_IsEnabledIT_EOCAL
  7519. * @param ADCx ADC instance
  7520. * @retval State of bit (1 or 0).
  7521. */
  7522. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOCAL(ADC_TypeDef *ADCx)
  7523. {
  7524. return ((READ_BIT(ADCx->IER, LL_ADC_IT_EOCAL) == (LL_ADC_IT_EOCAL)) ? 1UL : 0UL);
  7525. }
  7526. #endif
  7527. /**
  7528. * @}
  7529. */
  7530. #if defined(USE_FULL_LL_DRIVER)
  7531. /** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
  7532. * @{
  7533. */
  7534. /* Initialization of some features of ADC common parameters and multimode */
  7535. ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
  7536. ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  7537. void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  7538. /* De-initialization of ADC instance, ADC group regular and ADC group injected */
  7539. /* (availability of ADC group injected depends on STM32 families) */
  7540. ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
  7541. /* Initialization of some features of ADC instance */
  7542. ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
  7543. void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
  7544. /* Initialization of some features of ADC instance and ADC group regular */
  7545. ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  7546. void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  7547. #if defined (ADC_SUPPORT_2_5_MSPS)
  7548. /* Feature "ADC group injected" not available on ADC peripheral of this STM32WB device */
  7549. #else
  7550. /* Initialization of some features of ADC instance and ADC group injected */
  7551. ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  7552. void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  7553. #endif
  7554. /**
  7555. * @}
  7556. */
  7557. #endif /* USE_FULL_LL_DRIVER */
  7558. /**
  7559. * @}
  7560. */
  7561. /**
  7562. * @}
  7563. */
  7564. #endif /* ADC1 */
  7565. /**
  7566. * @}
  7567. */
  7568. #ifdef __cplusplus
  7569. }
  7570. #endif
  7571. #endif /* STM32WBxx_LL_ADC_H */
  7572. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/