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.
 
 
 

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