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.
 
 
 

7169 lines
402 KiB

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