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.
 
 
 

5162 lines
318 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_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 __STM32L1xx_LL_ADC_H
  21. #define __STM32L1xx_LL_ADC_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32l1xx.h"
  27. /** @addtogroup STM32L1xx_LL_Driver
  28. * @{
  29. */
  30. #if defined (ADC1)
  31. /** @defgroup ADC_LL ADC
  32. * @{
  33. */
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /* Private constants ---------------------------------------------------------*/
  37. /** @defgroup ADC_LL_Private_Constants ADC Private Constants
  38. * @{
  39. */
  40. /* Internal mask for ADC group regular sequencer: */
  41. /* To select into literal LL_ADC_REG_RANK_x the relevant bits for: */
  42. /* - sequencer register offset */
  43. /* - sequencer rank bits position into the selected register */
  44. /* Internal register offset for ADC group regular sequencer configuration */
  45. /* (offset placed into a spare area of literal definition) */
  46. #define ADC_SQR1_REGOFFSET 0x00000000U
  47. #define ADC_SQR2_REGOFFSET 0x00000100U
  48. #define ADC_SQR3_REGOFFSET 0x00000200U
  49. #define ADC_SQR4_REGOFFSET 0x00000300U
  50. #define ADC_SQR5_REGOFFSET 0x00000400U
  51. #define ADC_REG_SQRX_REGOFFSET_MASK (ADC_SQR1_REGOFFSET | ADC_SQR2_REGOFFSET | ADC_SQR3_REGOFFSET | ADC_SQR4_REGOFFSET | ADC_SQR5_REGOFFSET)
  52. #define ADC_REG_RANK_ID_SQRX_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  53. /* Definition of ADC group regular sequencer bits information to be inserted */
  54. /* into ADC group regular sequencer ranks literals definition. */
  55. #define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ1) */
  56. #define ADC_REG_RANK_2_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ2) */
  57. #define ADC_REG_RANK_3_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ3) */
  58. #define ADC_REG_RANK_4_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ4) */
  59. #define ADC_REG_RANK_5_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ5) */
  60. #define ADC_REG_RANK_6_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ6) */
  61. #define ADC_REG_RANK_7_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ7) */
  62. #define ADC_REG_RANK_8_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ8) */
  63. #define ADC_REG_RANK_9_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ9) */
  64. #define ADC_REG_RANK_10_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ10) */
  65. #define ADC_REG_RANK_11_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ11) */
  66. #define ADC_REG_RANK_12_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ12) */
  67. #define ADC_REG_RANK_13_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ13) */
  68. #define ADC_REG_RANK_14_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ14) */
  69. #define ADC_REG_RANK_15_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ15) */
  70. #define ADC_REG_RANK_16_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ16) */
  71. #define ADC_REG_RANK_17_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ17) */
  72. #define ADC_REG_RANK_18_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ18) */
  73. #define ADC_REG_RANK_19_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ29) */
  74. #define ADC_REG_RANK_20_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ20) */
  75. #define ADC_REG_RANK_21_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ21) */
  76. #define ADC_REG_RANK_22_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ22) */
  77. #define ADC_REG_RANK_23_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ23) */
  78. #define ADC_REG_RANK_24_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ24) */
  79. #define ADC_REG_RANK_25_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ25) */
  80. #define ADC_REG_RANK_26_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ26) */
  81. #define ADC_REG_RANK_27_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ27) */
  82. #if defined(ADC_SQR1_SQ28)
  83. #define ADC_REG_RANK_28_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ28) */
  84. #endif
  85. /* Internal mask for ADC group injected sequencer: */
  86. /* To select into literal LL_ADC_INJ_RANK_x the relevant bits for: */
  87. /* - data register offset */
  88. /* - offset register offset */
  89. /* - sequencer rank bits position into the selected register */
  90. /* Internal register offset for ADC group injected data register */
  91. /* (offset placed into a spare area of literal definition) */
  92. #define ADC_JDR1_REGOFFSET 0x00000000U
  93. #define ADC_JDR2_REGOFFSET 0x00000100U
  94. #define ADC_JDR3_REGOFFSET 0x00000200U
  95. #define ADC_JDR4_REGOFFSET 0x00000300U
  96. /* Internal register offset for ADC group injected offset configuration */
  97. /* (offset placed into a spare area of literal definition) */
  98. #define ADC_JOFR1_REGOFFSET 0x00000000U
  99. #define ADC_JOFR2_REGOFFSET 0x00001000U
  100. #define ADC_JOFR3_REGOFFSET 0x00002000U
  101. #define ADC_JOFR4_REGOFFSET 0x00003000U
  102. #define ADC_INJ_JDRX_REGOFFSET_MASK (ADC_JDR1_REGOFFSET | ADC_JDR2_REGOFFSET | ADC_JDR3_REGOFFSET | ADC_JDR4_REGOFFSET)
  103. #define ADC_INJ_JOFRX_REGOFFSET_MASK (ADC_JOFR1_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_JOFR4_REGOFFSET)
  104. #define ADC_INJ_RANK_ID_JSQR_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
  105. /* Definition of ADC group injected sequencer bits information to be inserted */
  106. /* into ADC group injected sequencer ranks literals definition. */
  107. #define ADC_INJ_RANK_1_JSQR_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ1) */
  108. #define ADC_INJ_RANK_2_JSQR_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ2) */
  109. #define ADC_INJ_RANK_3_JSQR_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ3) */
  110. #define ADC_INJ_RANK_4_JSQR_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ4) */
  111. /* Internal mask for ADC group regular trigger: */
  112. /* To select into literal LL_ADC_REG_TRIG_x the relevant bits for: */
  113. /* - regular trigger source */
  114. /* - regular trigger edge */
  115. #define ADC_REG_TRIG_EXT_EDGE_DEFAULT (ADC_CR2_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) */
  116. /* Mask containing trigger source masks for each of possible */
  117. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  118. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  119. #define ADC_REG_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTSEL) >> (4U * 0U)) | \
  120. ((ADC_CR2_EXTSEL) >> (4U * 1U)) | \
  121. ((ADC_CR2_EXTSEL) >> (4U * 2U)) | \
  122. ((ADC_CR2_EXTSEL) >> (4U * 3U)))
  123. /* Mask containing trigger edge masks for each of possible */
  124. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  125. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  126. #define ADC_REG_TRIG_EDGE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTEN) >> (4U * 0U)) | \
  127. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) >> (4U * 1U)) | \
  128. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) >> (4U * 2U)) | \
  129. ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) >> (4U * 3U)))
  130. /* Definition of ADC group regular trigger bits information. */
  131. #define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS (24U) /* Value equivalent to POSITION_VAL(ADC_CR2_EXTSEL) */
  132. #define ADC_REG_TRIG_EXTEN_BITOFFSET_POS (28U) /* Value equivalent to POSITION_VAL(ADC_CR2_EXTEN) */
  133. /* Internal mask for ADC group injected trigger: */
  134. /* To select into literal LL_ADC_INJ_TRIG_x the relevant bits for: */
  135. /* - injected trigger source */
  136. /* - injected trigger edge */
  137. #define ADC_INJ_TRIG_EXT_EDGE_DEFAULT (ADC_CR2_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) */
  138. /* Mask containing trigger source masks for each of possible */
  139. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  140. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  141. #define ADC_INJ_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_JEXTSEL) >> (4U * 0U)) | \
  142. ((ADC_CR2_JEXTSEL) >> (4U * 1U)) | \
  143. ((ADC_CR2_JEXTSEL) >> (4U * 2U)) | \
  144. ((ADC_CR2_JEXTSEL) >> (4U * 3U)))
  145. /* Mask containing trigger edge masks for each of possible */
  146. /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
  147. /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
  148. #define ADC_INJ_TRIG_EDGE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_CR2_JEXTEN) >> (4U * 0U)) | \
  149. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) >> (4U * 1U)) | \
  150. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) >> (4U * 2U)) | \
  151. ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) >> (4U * 3U)))
  152. /* Definition of ADC group injected trigger bits information. */
  153. #define ADC_INJ_TRIG_EXTSEL_BITOFFSET_POS (16U) /* Value equivalent to POSITION_VAL(ADC_CR2_JEXTSEL) */
  154. #define ADC_INJ_TRIG_EXTEN_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_CR2_JEXTEN) */
  155. /* Internal mask for ADC channel: */
  156. /* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
  157. /* - channel identifier defined by number */
  158. /* - channel differentiation between external channels (connected to */
  159. /* GPIO pins) and internal channels (connected to internal paths) */
  160. /* - channel sampling time defined by SMPRx register offset */
  161. /* and SMPx bits positions into SMPRx register */
  162. #define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CR1_AWDCH)
  163. #define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS ( 0U)/* Value equivalent to POSITION_VAL(ADC_CHANNEL_ID_NUMBER_MASK) */
  164. #define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  165. /* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
  166. #define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 0x0000001FU /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> POSITION_VAL(ADC_CHANNEL_NUMBER_MASK)) */
  167. /* Channel differentiation between external and internal channels */
  168. #define ADC_CHANNEL_ID_INTERNAL_CH 0x80000000U /* Marker of internal channel */
  169. #define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH)
  170. /* Internal register offset for ADC channel sampling time configuration */
  171. /* (offset placed into a spare area of literal definition) */
  172. #define ADC_SMPR1_REGOFFSET 0x00000000U
  173. #define ADC_SMPR2_REGOFFSET 0x02000000U
  174. #define ADC_SMPR3_REGOFFSET 0x04000000U
  175. #if defined(ADC_SMPR0_SMP31)
  176. #define ADC_SMPR0_REGOFFSET 0x28000000U /* SMPR0 register offset from SMPR1 is 20 registers. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  177. #define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET | ADC_SMPR3_REGOFFSET | ADC_SMPR0_REGOFFSET)
  178. #else
  179. #define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET | ADC_SMPR3_REGOFFSET)
  180. #endif /* ADC_SMPR0_SMP31 */
  181. #define ADC_CHANNEL_SMPx_BITOFFSET_MASK 0x01F00000U
  182. #define ADC_CHANNEL_SMPx_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_CHANNEL_SMPx_BITOFFSET_MASK) */
  183. /* Definition of channels ID number information to be inserted into */
  184. /* channels literals definition. */
  185. #define ADC_CHANNEL_0_NUMBER 0x00000000U
  186. #define ADC_CHANNEL_1_NUMBER ( ADC_CR1_AWDCH_0)
  187. #define ADC_CHANNEL_2_NUMBER ( ADC_CR1_AWDCH_1 )
  188. #define ADC_CHANNEL_3_NUMBER ( ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  189. #define ADC_CHANNEL_4_NUMBER ( ADC_CR1_AWDCH_2 )
  190. #define ADC_CHANNEL_5_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  191. #define ADC_CHANNEL_6_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  192. #define ADC_CHANNEL_7_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  193. #define ADC_CHANNEL_8_NUMBER ( ADC_CR1_AWDCH_3 )
  194. #define ADC_CHANNEL_9_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0)
  195. #define ADC_CHANNEL_10_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 )
  196. #define ADC_CHANNEL_11_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  197. #define ADC_CHANNEL_12_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 )
  198. #define ADC_CHANNEL_13_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  199. #define ADC_CHANNEL_14_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  200. #define ADC_CHANNEL_15_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  201. #define ADC_CHANNEL_16_NUMBER (ADC_CR1_AWDCH_4 )
  202. #define ADC_CHANNEL_17_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0)
  203. #define ADC_CHANNEL_18_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1 )
  204. #define ADC_CHANNEL_19_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  205. #define ADC_CHANNEL_20_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_2 )
  206. #define ADC_CHANNEL_21_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  207. #define ADC_CHANNEL_22_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  208. #define ADC_CHANNEL_23_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  209. #define ADC_CHANNEL_24_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 )
  210. #define ADC_CHANNEL_25_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0)
  211. #define ADC_CHANNEL_26_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 )
  212. #if defined(ADC_SMPR0_SMP31)
  213. #define ADC_CHANNEL_27_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  214. #define ADC_CHANNEL_28_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 )
  215. #define ADC_CHANNEL_29_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
  216. #define ADC_CHANNEL_30_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
  217. #define ADC_CHANNEL_31_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
  218. #endif /* ADC_SMPR0_SMP31 */
  219. /* Definition of channels sampling time information to be inserted into */
  220. /* channels literals definition. */
  221. #define ADC_CHANNEL_0_SMP (ADC_SMPR3_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP0) */
  222. #define ADC_CHANNEL_1_SMP (ADC_SMPR3_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP1) */
  223. #define ADC_CHANNEL_2_SMP (ADC_SMPR3_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP2) */
  224. #define ADC_CHANNEL_3_SMP (ADC_SMPR3_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP3) */
  225. #define ADC_CHANNEL_4_SMP (ADC_SMPR3_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP4) */
  226. #define ADC_CHANNEL_5_SMP (ADC_SMPR3_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP5) */
  227. #define ADC_CHANNEL_6_SMP (ADC_SMPR3_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP6) */
  228. #define ADC_CHANNEL_7_SMP (ADC_SMPR3_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP7) */
  229. #define ADC_CHANNEL_8_SMP (ADC_SMPR3_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP8) */
  230. #define ADC_CHANNEL_9_SMP (ADC_SMPR3_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP9) */
  231. #define ADC_CHANNEL_10_SMP (ADC_SMPR2_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP10) */
  232. #define ADC_CHANNEL_11_SMP (ADC_SMPR2_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP11) */
  233. #define ADC_CHANNEL_12_SMP (ADC_SMPR2_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP12) */
  234. #define ADC_CHANNEL_13_SMP (ADC_SMPR2_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP13) */
  235. #define ADC_CHANNEL_14_SMP (ADC_SMPR2_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP14) */
  236. #define ADC_CHANNEL_15_SMP (ADC_SMPR2_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP15) */
  237. #define ADC_CHANNEL_16_SMP (ADC_SMPR2_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP16) */
  238. #define ADC_CHANNEL_17_SMP (ADC_SMPR2_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP17) */
  239. #define ADC_CHANNEL_18_SMP (ADC_SMPR2_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP18) */
  240. #define ADC_CHANNEL_19_SMP (ADC_SMPR2_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP19) */
  241. #define ADC_CHANNEL_20_SMP (ADC_SMPR1_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP20) */
  242. #define ADC_CHANNEL_21_SMP (ADC_SMPR1_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP21) */
  243. #define ADC_CHANNEL_22_SMP (ADC_SMPR1_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP22) */
  244. #define ADC_CHANNEL_23_SMP (ADC_SMPR1_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP23) */
  245. #define ADC_CHANNEL_24_SMP (ADC_SMPR1_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP24) */
  246. #define ADC_CHANNEL_25_SMP (ADC_SMPR1_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP25) */
  247. #define ADC_CHANNEL_26_SMP (ADC_SMPR1_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP26) */
  248. #if defined(ADC_SMPR0_SMP31)
  249. #define ADC_CHANNEL_27_SMP (ADC_SMPR1_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP27) */
  250. #define ADC_CHANNEL_28_SMP (ADC_SMPR1_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP28) */
  251. #define ADC_CHANNEL_29_SMP (ADC_SMPR1_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP19) */
  252. #define ADC_CHANNEL_30_SMP (ADC_SMPR0_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR0_SMP30) */
  253. #define ADC_CHANNEL_31_SMP (ADC_SMPR0_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR0_SMP31) */
  254. #endif /* ADC_SMPR0_SMP31 */
  255. /* Internal mask for ADC analog watchdog: */
  256. /* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
  257. /* (concatenation of multiple bits used in different analog watchdogs, */
  258. /* (feature of several watchdogs not available on all STM32 families)). */
  259. /* - analog watchdog 1: monitored channel defined by number, */
  260. /* selection of ADC group (ADC groups regular and-or injected). */
  261. /* Internal register offset for ADC analog watchdog channel configuration */
  262. #define ADC_AWD_CR1_REGOFFSET 0x00000000U
  263. #define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET)
  264. #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CR1_AWDCH | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL)
  265. #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK)
  266. /* Internal register offset for ADC analog watchdog threshold configuration */
  267. #define ADC_AWD_TR1_HIGH_REGOFFSET 0x00000000U
  268. #define ADC_AWD_TR1_LOW_REGOFFSET 0x00000001U
  269. #define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_HIGH_REGOFFSET | ADC_AWD_TR1_LOW_REGOFFSET)
  270. /* ADC registers bits positions */
  271. #define ADC_CR1_RES_BITOFFSET_POS (24U) /* Value equivalent to POSITION_VAL(ADC_CR1_RES) */
  272. #define ADC_TR_HT_BITOFFSET_POS (16U) /* Value equivalent to POSITION_VAL(ADC_TR_HT) */
  273. /* ADC internal channels related definitions */
  274. /* Internal voltage reference VrefInt */
  275. #define VREFINT_CAL_ADDR ((uint16_t*) VREFINT_CAL_ADDR_CMSIS) /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
  276. #define VREFINT_CAL_VREF ( 3000U) /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
  277. /* Temperature sensor */
  278. #if defined (TEMPSENSOR_CAL1_ADDR_CMSIS)
  279. #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) TEMPSENSOR_CAL1_ADDR_CMSIS) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32L1, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
  280. #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) TEMPSENSOR_CAL2_ADDR_CMSIS) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32L1, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
  281. #endif /* TEMPSENSOR_CAL1_ADDR_CMSIS */
  282. #define TEMPSENSOR_CAL1_TEMP (( int32_t) 30) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  283. #define TEMPSENSOR_CAL2_TEMP (( int32_t) 110) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
  284. #define TEMPSENSOR_CAL_VREFANALOG ( 3000U) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
  285. /**
  286. * @}
  287. */
  288. /* Private macros ------------------------------------------------------------*/
  289. /** @defgroup ADC_LL_Private_Macros ADC Private Macros
  290. * @{
  291. */
  292. /**
  293. * @brief Driver macro reserved for internal use: isolate bits with the
  294. * selected mask and shift them to the register LSB
  295. * (shift mask on register position bit 0).
  296. * @param __BITS__ Bits in register 32 bits
  297. * @param __MASK__ Mask in register 32 bits
  298. * @retval Bits in register 32 bits
  299. */
  300. #define __ADC_MASK_SHIFT(__BITS__, __MASK__) \
  301. (((__BITS__) & (__MASK__)) >> POSITION_VAL((__MASK__)))
  302. /**
  303. * @brief Driver macro reserved for internal use: set a pointer to
  304. * a register from a register basis from which an offset
  305. * is applied.
  306. * @param __REG__ Register basis from which the offset is applied.
  307. * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
  308. * @retval Pointer to register address
  309. */
  310. #define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
  311. ((uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2U))))
  312. /**
  313. * @}
  314. */
  315. /* Exported types ------------------------------------------------------------*/
  316. #if defined(USE_FULL_LL_DRIVER)
  317. /** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
  318. * @{
  319. */
  320. /**
  321. * @brief Structure definition of some features of ADC common parameters
  322. * and multimode
  323. * (all ADC instances belonging to the same ADC common instance).
  324. * @note The setting of these parameters by function @ref LL_ADC_CommonInit()
  325. * is conditioned to ADC instances state (all ADC instances
  326. * sharing the same ADC common instance):
  327. * All ADC instances sharing the same ADC common instance must be
  328. * disabled.
  329. */
  330. typedef struct
  331. {
  332. uint32_t CommonClock; /*!< Set parameter common to several ADC: Clock source and prescaler.
  333. This parameter can be a value of @ref ADC_LL_EC_COMMON_CLOCK_SOURCE
  334. @note On this STM32 serie, HSI RC oscillator is the only clock source for ADC.
  335. Therefore, HSI RC oscillator must be preliminarily enabled at RCC top level.
  336. @note On this STM32 serie, some clock ratio constraints between ADC clock and APB clock
  337. must be respected:
  338. - In all cases: if APB clock frequency is too low compared ADC clock frequency, a delay between conversions must be inserted.
  339. - If ADC group injected is used: ADC clock frequency should be lower than APB clock frequency /4 for resolution 12 or 10 bits, APB clock frequency /3 for resolution 8 bits, APB clock frequency /2 for resolution 6 bits.
  340. Refer to reference manual.
  341. This feature can be modified afterwards using unitary function @ref LL_ADC_SetCommonClock(). */
  342. } LL_ADC_CommonInitTypeDef;
  343. /**
  344. * @brief Structure definition of some features of ADC instance.
  345. * @note These parameters have an impact on ADC scope: ADC instance.
  346. * Affects both group regular and group injected (availability
  347. * of ADC group injected depends on STM32 families).
  348. * Refer to corresponding unitary functions into
  349. * @ref ADC_LL_EF_Configuration_ADC_Instance .
  350. * @note The setting of these parameters by function @ref LL_ADC_Init()
  351. * is conditioned to ADC state:
  352. * ADC instance must be disabled.
  353. * This condition is applied to all ADC features, for efficiency
  354. * and compatibility over all STM32 families. However, the different
  355. * features can be set under different ADC state conditions
  356. * (setting possible with ADC enabled without conversion on going,
  357. * ADC enabled with conversion on going, ...)
  358. * Each feature can be updated afterwards with a unitary function
  359. * and potentially with ADC in a different state than disabled,
  360. * refer to description of each function for setting
  361. * conditioned to ADC state.
  362. */
  363. typedef struct
  364. {
  365. uint32_t Resolution; /*!< Set ADC resolution.
  366. This parameter can be a value of @ref ADC_LL_EC_RESOLUTION
  367. This feature can be modified afterwards using unitary function @ref LL_ADC_SetResolution(). */
  368. uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
  369. This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
  370. This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
  371. uint32_t LowPowerMode; /*!< Set ADC low power mode.
  372. This parameter can be a concatenation of a value of @ref ADC_LL_EC_LP_MODE_AUTOWAIT and a value of @ref ADC_LL_EC_LP_MODE_AUTOPOWEROFF
  373. This feature can be modified afterwards using unitary function @ref LL_ADC_SetLowPowerModeAutoWait() and @ref LL_ADC_SetLowPowerModeAutoPowerOff(). */
  374. uint32_t SequencersScanMode; /*!< Set ADC scan selection.
  375. This parameter can be a value of @ref ADC_LL_EC_SCAN_SELECTION
  376. This feature can be modified afterwards using unitary function @ref LL_ADC_SetSequencersScanMode(). */
  377. } LL_ADC_InitTypeDef;
  378. /**
  379. * @brief Structure definition of some features of ADC group regular.
  380. * @note These parameters have an impact on ADC scope: ADC group regular.
  381. * Refer to corresponding unitary functions into
  382. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  383. * (functions with prefix "REG").
  384. * @note The setting of these parameters by function @ref LL_ADC_REG_Init()
  385. * is conditioned to ADC state:
  386. * ADC instance must be disabled.
  387. * This condition is applied to all ADC features, for efficiency
  388. * and compatibility over all STM32 families. However, the different
  389. * features can be set under different ADC state conditions
  390. * (setting possible with ADC enabled without conversion on going,
  391. * ADC enabled with conversion on going, ...)
  392. * Each feature can be updated afterwards with a unitary function
  393. * and potentially with ADC in a different state than disabled,
  394. * refer to description of each function for setting
  395. * conditioned to ADC state.
  396. */
  397. typedef struct
  398. {
  399. uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
  400. This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
  401. @note On this STM32 serie, setting of external trigger edge is performed
  402. using function @ref LL_ADC_REG_StartConversionExtTrig().
  403. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
  404. uint32_t SequencerLength; /*!< Set ADC group regular sequencer length.
  405. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_SCAN_LENGTH
  406. @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
  407. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerLength(). */
  408. uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  409. This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
  410. @note This parameter has an effect only if group regular sequencer is enabled
  411. (scan length of 2 ranks or more).
  412. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
  413. 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).
  414. This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
  415. Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
  416. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
  417. uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
  418. This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
  419. This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
  420. } LL_ADC_REG_InitTypeDef;
  421. /**
  422. * @brief Structure definition of some features of ADC group injected.
  423. * @note These parameters have an impact on ADC scope: ADC group injected.
  424. * Refer to corresponding unitary functions into
  425. * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
  426. * (functions with prefix "INJ").
  427. * @note The setting of these parameters by function @ref LL_ADC_INJ_Init()
  428. * is conditioned to ADC state:
  429. * ADC instance must be disabled.
  430. * This condition is applied to all ADC features, for efficiency
  431. * and compatibility over all STM32 families. However, the different
  432. * features can be set under different ADC state conditions
  433. * (setting possible with ADC enabled without conversion on going,
  434. * ADC enabled with conversion on going, ...)
  435. * Each feature can be updated afterwards with a unitary function
  436. * and potentially with ADC in a different state than disabled,
  437. * refer to description of each function for setting
  438. * conditioned to ADC state.
  439. */
  440. typedef struct
  441. {
  442. uint32_t TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
  443. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIGGER_SOURCE
  444. @note On this STM32 serie, setting of external trigger edge is performed
  445. using function @ref LL_ADC_INJ_StartConversionExtTrig().
  446. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTriggerSource(). */
  447. uint32_t SequencerLength; /*!< Set ADC group injected sequencer length.
  448. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_SCAN_LENGTH
  449. @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
  450. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerLength(). */
  451. uint32_t SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
  452. This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_DISCONT_MODE
  453. @note This parameter has an effect only if group injected sequencer is enabled
  454. (scan length of 2 ranks or more).
  455. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerDiscont(). */
  456. uint32_t TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group regular.
  457. This parameter can be a value of @ref ADC_LL_EC_INJ_TRIG_AUTO
  458. Note: This parameter must be set to set to independent trigger if injected trigger source is set to an external trigger.
  459. This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTrigAuto(). */
  460. } LL_ADC_INJ_InitTypeDef;
  461. /**
  462. * @}
  463. */
  464. #endif /* USE_FULL_LL_DRIVER */
  465. /* Exported constants --------------------------------------------------------*/
  466. /** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
  467. * @{
  468. */
  469. /** @defgroup ADC_LL_EC_FLAG ADC flags
  470. * @brief Flags defines which can be used with LL_ADC_ReadReg function
  471. * @{
  472. */
  473. #define LL_ADC_FLAG_ADRDY ADC_SR_ADONS /*!< ADC flag ADC instance ready */
  474. #define LL_ADC_FLAG_STRT ADC_SR_STRT /*!< ADC flag ADC group regular conversion start */
  475. #define LL_ADC_FLAG_EOCS ADC_SR_EOC /*!< ADC flag ADC group regular end of unitary conversion or sequence conversions (to configure flag of end of conversion, use function @ref LL_ADC_REG_SetFlagEndOfConversion() ) */
  476. #define LL_ADC_FLAG_OVR ADC_SR_OVR /*!< ADC flag ADC group regular overrun */
  477. #define LL_ADC_FLAG_JSTRT ADC_SR_JSTRT /*!< ADC flag ADC group injected conversion start */
  478. #define LL_ADC_FLAG_JEOS ADC_SR_JEOC /*!< ADC flag ADC group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  479. #define LL_ADC_FLAG_AWD1 ADC_SR_AWD /*!< ADC flag ADC analog watchdog 1 */
  480. /**
  481. * @}
  482. */
  483. /** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
  484. * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
  485. * @{
  486. */
  487. #define LL_ADC_IT_EOCS ADC_CR1_EOCIE /*!< ADC interruption ADC group regular end of unitary conversion or sequence conversions (to configure flag of end of conversion, use function @ref LL_ADC_REG_SetFlagEndOfConversion() ) */
  488. #define LL_ADC_IT_OVR ADC_CR1_OVRIE /*!< ADC interruption ADC group regular overrun */
  489. #define LL_ADC_IT_JEOS ADC_CR1_JEOCIE /*!< ADC interruption ADC group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
  490. #define LL_ADC_IT_AWD1 ADC_CR1_AWDIE /*!< ADC interruption ADC analog watchdog 1 */
  491. /**
  492. * @}
  493. */
  494. /** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
  495. * @{
  496. */
  497. /* List of ADC registers intended to be used (most commonly) with */
  498. /* DMA transfer. */
  499. /* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
  500. #define LL_ADC_DMA_REG_REGULAR_DATA 0x00000000U /* 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() */
  501. /**
  502. * @}
  503. */
  504. /** @defgroup ADC_LL_EC_COMMON_CLOCK_SOURCE ADC common - Clock source
  505. * @{
  506. */
  507. #define LL_ADC_CLOCK_ASYNC_DIV1 0x00000000U /*!< ADC asynchronous clock without prescaler */
  508. #define LL_ADC_CLOCK_ASYNC_DIV2 (ADC_CCR_ADCPRE_0) /*!< ADC asynchronous clock with prescaler division by 2 */
  509. #define LL_ADC_CLOCK_ASYNC_DIV4 (ADC_CCR_ADCPRE_1) /*!< ADC asynchronous clock with prescaler division by 4 */
  510. /**
  511. * @}
  512. */
  513. /** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
  514. * @{
  515. */
  516. /* Note: Other measurement paths to internal channels may be available */
  517. /* (connections to other peripherals). */
  518. /* If they are not listed below, they do not require any specific */
  519. /* path enable. In this case, Access to measurement path is done */
  520. /* only by selecting the corresponding ADC internal channel. */
  521. #define LL_ADC_PATH_INTERNAL_NONE 0x00000000U /*!< ADC measurement pathes all disabled */
  522. #define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CCR_TSVREFE) /*!< ADC measurement path to internal channel VrefInt */
  523. #define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CCR_TSVREFE) /*!< ADC measurement path to internal channel temperature sensor */
  524. /**
  525. * @}
  526. */
  527. /** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
  528. * @{
  529. */
  530. #define LL_ADC_RESOLUTION_12B 0x00000000U /*!< ADC resolution 12 bits */
  531. #define LL_ADC_RESOLUTION_10B ( ADC_CR1_RES_0) /*!< ADC resolution 10 bits */
  532. #define LL_ADC_RESOLUTION_8B (ADC_CR1_RES_1 ) /*!< ADC resolution 8 bits */
  533. #define LL_ADC_RESOLUTION_6B (ADC_CR1_RES_1 | ADC_CR1_RES_0) /*!< ADC resolution 6 bits */
  534. /**
  535. * @}
  536. */
  537. /** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
  538. * @{
  539. */
  540. #define LL_ADC_DATA_ALIGN_RIGHT 0x00000000U /*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
  541. #define LL_ADC_DATA_ALIGN_LEFT (ADC_CR2_ALIGN) /*!< ADC conversion data alignment: left aligned (aligment on data register MSB bit 15)*/
  542. /**
  543. * @}
  544. */
  545. /** @defgroup ADC_LL_EC_LP_MODE_AUTOWAIT ADC instance - Low power mode auto wait (auto delay)
  546. * @{
  547. */
  548. #define LL_ADC_LP_AUTOWAIT_NONE 0x00000000U /*!< ADC low power mode auto wait not activated */
  549. #define LL_ADC_LP_AUTOWAIT ( ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: 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_SetLowPowerModeAutoWait(). */
  550. #define LL_ADC_LP_AUTOWAIT_7_APBCLOCKCYCLES ( ADC_CR2_DELS_1 ) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 7 APB clock cycles */
  551. #define LL_ADC_LP_AUTOWAIT_15_APBCLOCKCYCLES ( ADC_CR2_DELS_1 | ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 15 APB clock cycles */
  552. #define LL_ADC_LP_AUTOWAIT_31_APBCLOCKCYCLES (ADC_CR2_DELS_2 ) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 31 APB clock cycles */
  553. #define LL_ADC_LP_AUTOWAIT_63_APBCLOCKCYCLES (ADC_CR2_DELS_2 | ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 63 APB clock cycles */
  554. #define LL_ADC_LP_AUTOWAIT_127_APBCLOCKCYCLES (ADC_CR2_DELS_2 | ADC_CR2_DELS_1 ) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 127 APB clock cycles */
  555. #define LL_ADC_LP_AUTOWAIT_255_APBCLOCKCYCLES (ADC_CR2_DELS_2 | ADC_CR2_DELS_1 | ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 255 APB clock cycles */
  556. /**
  557. * @}
  558. */
  559. /** @defgroup ADC_LL_EC_LP_MODE_AUTOPOWEROFF ADC instance - Low power mode auto power-off
  560. * @{
  561. */
  562. #define LL_ADC_LP_AUTOPOWEROFF_NONE 0x00000000U /*!< ADC low power mode auto power-off not activated */
  563. #define LL_ADC_LP_AUTOPOWEROFF_IDLE_PHASE (ADC_CR1_PDI) /*!< ADC low power mode auto power-off: ADC power off when ADC is not converting (idle phase) */
  564. #define LL_ADC_LP_AUTOPOWEROFF_AUTOWAIT_PHASE (ADC_CR1_PDD) /*!< ADC low power mode auto power-off: ADC power off when a delay is inserted between conversions (refer to function @ref LL_ADC_SetLowPowerModeAutoWait() ) */
  565. #define LL_ADC_LP_AUTOPOWEROFF_IDLE_AUTOWAIT_PHASES (ADC_CR1_PDI | ADC_CR1_PDD) /*!< ADC low power mode auto power-off: ADC power off when ADC is not converting (idle phase) and when a delay is inserted between conversions (refer to function @ref LL_ADC_SetLowPowerModeAutoWait() ) */
  566. /**
  567. * @}
  568. */
  569. /** @defgroup ADC_LL_EC_SCAN_SELECTION ADC instance - Scan selection
  570. * @{
  571. */
  572. #define LL_ADC_SEQ_SCAN_DISABLE 0x00000000U /*!< ADC conversion is performed in unitary conversion mode (one channel converted, that defined in rank 1). Configuration of both groups regular and injected sequencers (sequence length, ...) is discarded: equivalent to length of 1 rank.*/
  573. #define LL_ADC_SEQ_SCAN_ENABLE (ADC_CR1_SCAN) /*!< ADC conversions are performed in sequence conversions mode, according to configuration of both groups regular and injected sequencers (sequence length, ...). */
  574. /**
  575. * @}
  576. */
  577. #if defined(ADC_CR2_CFG)
  578. /** @defgroup ADC_LL_EC_CHANNELS_BANK ADC instance - Channels bank
  579. * @{
  580. */
  581. #define LL_ADC_CHANNELS_BANK_A 0x00000000U /*!< ADC channels bank A */
  582. #define LL_ADC_CHANNELS_BANK_B (ADC_CR2_CFG) /*!< ADC channels bank B, available in devices categories 3, 4, 5. */
  583. /**
  584. * @}
  585. */
  586. #endif
  587. /** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
  588. * @{
  589. */
  590. #define LL_ADC_GROUP_REGULAR 0x00000001U /*!< ADC group regular (available on all STM32 devices) */
  591. #define LL_ADC_GROUP_INJECTED 0x00000002U /*!< ADC group injected (not available on all STM32 devices)*/
  592. #define LL_ADC_GROUP_REGULAR_INJECTED 0x00000003U /*!< ADC both groups regular and injected */
  593. /**
  594. * @}
  595. */
  596. /** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
  597. * @{
  598. */
  599. #define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 . Channel different in bank A and bank B. */
  600. #define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 . Channel different in bank A and bank B. */
  601. #define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 . Channel different in bank A and bank B. */
  602. #define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 . Channel different in bank A and bank B. */
  603. #define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 . Direct (fast) channel. */
  604. #define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 . Direct (fast) channel. */
  605. #define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 . Channel different in bank A and bank B. */
  606. #define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 . Channel different in bank A and bank B. */
  607. #define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 . Channel different in bank A and bank B. */
  608. #define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 . Channel different in bank A and bank B. */
  609. #define LL_ADC_CHANNEL_10 (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10. Channel different in bank A and bank B. */
  610. #define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11. Channel different in bank A and bank B. */
  611. #define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12. Channel different in bank A and bank B. */
  612. #define LL_ADC_CHANNEL_13 (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN13. Channel common to both bank A and bank B. */
  613. #define LL_ADC_CHANNEL_14 (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN14. Channel common to both bank A and bank B. */
  614. #define LL_ADC_CHANNEL_15 (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN15. Channel common to both bank A and bank B. */
  615. #define LL_ADC_CHANNEL_16 (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN16. Channel common to both bank A and bank B. */
  616. #define LL_ADC_CHANNEL_17 (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN17. Channel common to both bank A and bank B. */
  617. #define LL_ADC_CHANNEL_18 (ADC_CHANNEL_18_NUMBER | ADC_CHANNEL_18_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN18. Channel common to both bank A and bank B. */
  618. #define LL_ADC_CHANNEL_19 (ADC_CHANNEL_19_NUMBER | ADC_CHANNEL_19_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN19. Channel common to both bank A and bank B. */
  619. #define LL_ADC_CHANNEL_20 (ADC_CHANNEL_20_NUMBER | ADC_CHANNEL_20_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN20. Channel common to both bank A and bank B. */
  620. #define LL_ADC_CHANNEL_21 (ADC_CHANNEL_21_NUMBER | ADC_CHANNEL_21_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN21. Channel common to both bank A and bank B. */
  621. #define LL_ADC_CHANNEL_22 (ADC_CHANNEL_22_NUMBER | ADC_CHANNEL_22_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN22. Direct (fast) channel. */
  622. #define LL_ADC_CHANNEL_23 (ADC_CHANNEL_23_NUMBER | ADC_CHANNEL_23_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN23. Direct (fast) channel. */
  623. #define LL_ADC_CHANNEL_24 (ADC_CHANNEL_24_NUMBER | ADC_CHANNEL_24_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN24. Direct (fast) channel. */
  624. #define LL_ADC_CHANNEL_25 (ADC_CHANNEL_25_NUMBER | ADC_CHANNEL_25_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN25. Direct (fast) channel. */
  625. #define LL_ADC_CHANNEL_26 (ADC_CHANNEL_26_NUMBER | ADC_CHANNEL_26_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN26. Direct (fast) channel. */
  626. #if defined(ADC_SMPR0_SMP31)
  627. #define LL_ADC_CHANNEL_27 (ADC_CHANNEL_27_NUMBER | ADC_CHANNEL_27_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN27. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  628. #define LL_ADC_CHANNEL_28 (ADC_CHANNEL_28_NUMBER | ADC_CHANNEL_28_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN28. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  629. #define LL_ADC_CHANNEL_29 (ADC_CHANNEL_29_NUMBER | ADC_CHANNEL_29_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN29. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  630. #define LL_ADC_CHANNEL_30 (ADC_CHANNEL_30_NUMBER | ADC_CHANNEL_30_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN30. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  631. #define LL_ADC_CHANNEL_31 (ADC_CHANNEL_31_NUMBER | ADC_CHANNEL_31_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN31. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  632. #endif /* ADC_SMPR0_SMP31 */
  633. #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. Channel common to both bank A and bank B. */
  634. #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_16 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. Channel common to both bank A and bank B. */
  635. #define LL_ADC_CHANNEL_VCOMP (LL_ADC_CHANNEL_26 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
  636. #if defined(OPAMP_CSR_OPA1PD) || defined (OPAMP_CSR_OPA2PD) || defined (OPAMP_CSR_OPA3PD)
  637. #define LL_ADC_CHANNEL_VOPAMP1 (LL_ADC_CHANNEL_3 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
  638. #define LL_ADC_CHANNEL_VOPAMP2 (LL_ADC_CHANNEL_8 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
  639. #if defined(OPAMP_CSR_OPA3PD)
  640. #define LL_ADC_CHANNEL_VOPAMP3 (LL_ADC_CHANNEL_13 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
  641. #endif /* OPAMP_CSR_OPA3PD */
  642. #endif /* OPAMP_CSR_OPA1PD || OPAMP_CSR_OPA2PD || OPAMP_CSR_OPA3PD */
  643. /**
  644. * @}
  645. */
  646. /** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source
  647. * @{
  648. */
  649. #define LL_ADC_REG_TRIG_SOFTWARE 0x00000000U /*!< ADC group regular conversion trigger internal: SW start. */
  650. #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  651. #define LL_ADC_REG_TRIG_EXT_TIM2_CH3 (ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  652. #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CR2_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
  653. #define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  654. #define LL_ADC_REG_TRIG_EXT_TIM3_CH1 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  655. #define LL_ADC_REG_TRIG_EXT_TIM3_CH3 (ADC_CR2_EXTSEL_3 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  656. #define LL_ADC_REG_TRIG_EXT_TIM4_TRGO (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  657. #define LL_ADC_REG_TRIG_EXT_TIM4_CH4 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  658. #define LL_ADC_REG_TRIG_EXT_TIM6_TRGO (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM6 TRGO. Trigger edge set to rising edge (default setting). */
  659. #define LL_ADC_REG_TRIG_EXT_TIM9_CH2 (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM9 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  660. #define LL_ADC_REG_TRIG_EXT_TIM9_TRGO (ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM9 TRGO. Trigger edge set to rising edge (default setting). */
  661. #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: external interrupt line 11. Trigger edge set to rising edge (default setting). */
  662. /**
  663. * @}
  664. */
  665. /** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
  666. * @{
  667. */
  668. #define LL_ADC_REG_TRIG_EXT_RISING ( ADC_CR2_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to rising edge */
  669. #define LL_ADC_REG_TRIG_EXT_FALLING (ADC_CR2_EXTEN_1 ) /*!< ADC group regular conversion trigger polarity set to falling edge */
  670. #define LL_ADC_REG_TRIG_EXT_RISINGFALLING (ADC_CR2_EXTEN_1 | ADC_CR2_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to both rising and falling edges */
  671. /**
  672. * @}
  673. */
  674. /** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
  675. * @{
  676. */
  677. #define LL_ADC_REG_CONV_SINGLE 0x00000000U /*!< ADC conversions are performed in single mode: one conversion per trigger */
  678. #define LL_ADC_REG_CONV_CONTINUOUS (ADC_CR2_CONT) /*!< ADC conversions are performed in continuous mode: after the first trigger, following conversions launched successively automatically */
  679. /**
  680. * @}
  681. */
  682. /** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer of ADC conversion data
  683. * @{
  684. */
  685. #define LL_ADC_REG_DMA_TRANSFER_NONE 0x00000000U /*!< ADC conversions are not transferred by DMA */
  686. #define LL_ADC_REG_DMA_TRANSFER_LIMITED ( ADC_CR2_DMA) /*!< 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. */
  687. #define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CR2_DDS | ADC_CR2_DMA) /*!< 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. */
  688. /**
  689. * @}
  690. */
  691. /** @defgroup ADC_LL_EC_REG_FLAG_EOC_SELECTION ADC group regular - Flag EOC selection (unitary or sequence conversions)
  692. * @{
  693. */
  694. #define LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV 0x00000000U /*!< ADC flag EOC (end of unitary conversion) selected */
  695. #define LL_ADC_REG_FLAG_EOC_UNITARY_CONV (ADC_CR2_EOCS) /*!< ADC flag EOS (end of sequence conversions) selected */
  696. /**
  697. * @}
  698. */
  699. /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_LENGTH ADC group regular - Sequencer scan length
  700. * @{
  701. */
  702. #define LL_ADC_REG_SEQ_SCAN_DISABLE 0x00000000U /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  703. #define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS ( ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 2 ranks in the sequence */
  704. #define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS ( ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 3 ranks in the sequence */
  705. #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 */
  706. #define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS ( ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 5 ranks in the sequence */
  707. #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 */
  708. #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 */
  709. #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 */
  710. #define LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (ADC_SQR1_L_3 ) /*!< ADC group regular sequencer enable with 9 ranks in the sequence */
  711. #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 */
  712. #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 */
  713. #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 */
  714. #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 */
  715. #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 */
  716. #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 */
  717. #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 */
  718. /**
  719. * @}
  720. */
  721. /** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
  722. * @{
  723. */
  724. #define LL_ADC_REG_SEQ_DISCONT_DISABLE 0x00000000U /*!< ADC group regular sequencer discontinuous mode disable */
  725. #define LL_ADC_REG_SEQ_DISCONT_1RANK ( ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
  726. #define LL_ADC_REG_SEQ_DISCONT_2RANKS ( ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enabled with sequence interruption every 2 ranks */
  727. #define LL_ADC_REG_SEQ_DISCONT_3RANKS ( ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 3 ranks */
  728. #define LL_ADC_REG_SEQ_DISCONT_4RANKS ( ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 4 ranks */
  729. #define LL_ADC_REG_SEQ_DISCONT_5RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 5 ranks */
  730. #define LL_ADC_REG_SEQ_DISCONT_6RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 6 ranks */
  731. #define LL_ADC_REG_SEQ_DISCONT_7RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 7 ranks */
  732. #define LL_ADC_REG_SEQ_DISCONT_8RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 8 ranks */
  733. /**
  734. * @}
  735. */
  736. /** @defgroup ADC_LL_EC_REG_SEQ_RANKS ADC group regular - Sequencer ranks
  737. * @{
  738. */
  739. #define LL_ADC_REG_RANK_1 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 1 */
  740. #define LL_ADC_REG_RANK_2 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_2_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 2 */
  741. #define LL_ADC_REG_RANK_3 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_3_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 3 */
  742. #define LL_ADC_REG_RANK_4 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_4_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 4 */
  743. #define LL_ADC_REG_RANK_5 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_5_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 5 */
  744. #define LL_ADC_REG_RANK_6 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_6_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 6 */
  745. #define LL_ADC_REG_RANK_7 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_7_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 7 */
  746. #define LL_ADC_REG_RANK_8 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_8_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 8 */
  747. #define LL_ADC_REG_RANK_9 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_9_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 9 */
  748. #define LL_ADC_REG_RANK_10 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_10_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 10 */
  749. #define LL_ADC_REG_RANK_11 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_11_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 11 */
  750. #define LL_ADC_REG_RANK_12 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_12_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 12 */
  751. #define LL_ADC_REG_RANK_13 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_13_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 13 */
  752. #define LL_ADC_REG_RANK_14 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_14_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 14 */
  753. #define LL_ADC_REG_RANK_15 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_15_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 15 */
  754. #define LL_ADC_REG_RANK_16 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_16_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 16 */
  755. #define LL_ADC_REG_RANK_17 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_17_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 17 */
  756. #define LL_ADC_REG_RANK_18 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_18_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 18 */
  757. #define LL_ADC_REG_RANK_19 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_19_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 19 */
  758. #define LL_ADC_REG_RANK_20 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_20_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 20 */
  759. #define LL_ADC_REG_RANK_21 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_21_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 21 */
  760. #define LL_ADC_REG_RANK_22 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_22_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 22 */
  761. #define LL_ADC_REG_RANK_23 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_23_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 23 */
  762. #define LL_ADC_REG_RANK_24 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_24_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 24 */
  763. #define LL_ADC_REG_RANK_25 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_25_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 25 */
  764. #define LL_ADC_REG_RANK_26 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_26_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 26 */
  765. #define LL_ADC_REG_RANK_27 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_27_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 27 */
  766. #if defined(ADC_SQR1_SQ28)
  767. #define LL_ADC_REG_RANK_28 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_28_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 28 */
  768. #endif
  769. /**
  770. * @}
  771. */
  772. /** @defgroup ADC_LL_EC_INJ_TRIGGER_SOURCE ADC group injected - Trigger source
  773. * @{
  774. */
  775. #define LL_ADC_INJ_TRIG_SOFTWARE 0x00000000U /*!< ADC group injected conversion trigger internal: SW start. */
  776. #define LL_ADC_INJ_TRIG_EXT_TIM9_CH1 (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM9 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  777. #define LL_ADC_INJ_TRIG_EXT_TIM9_TRGO (ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM9 TRGO. Trigger edge set to rising edge (default setting). */
  778. #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
  779. #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  780. #define LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (ADC_CR2_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  781. #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
  782. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH1 (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  783. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH2 (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  784. #define LL_ADC_INJ_TRIG_EXT_TIM4_CH3 (ADC_CR2_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  785. #define LL_ADC_INJ_TRIG_EXT_TIM10_CH1 (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM10 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
  786. #define LL_ADC_INJ_TRIG_EXT_TIM7_TRGO (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM7 TRGO. Trigger edge set to rising edge (default setting). */
  787. #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: external interrupt line 15. Trigger edge set to rising edge (default setting). */
  788. /**
  789. * @}
  790. */
  791. /** @defgroup ADC_LL_EC_INJ_TRIGGER_EDGE ADC group injected - Trigger edge
  792. * @{
  793. */
  794. #define LL_ADC_INJ_TRIG_EXT_RISING ( ADC_CR2_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to rising edge */
  795. #define LL_ADC_INJ_TRIG_EXT_FALLING (ADC_CR2_JEXTEN_1 ) /*!< ADC group injected conversion trigger polarity set to falling edge */
  796. #define LL_ADC_INJ_TRIG_EXT_RISINGFALLING (ADC_CR2_JEXTEN_1 | ADC_CR2_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to both rising and falling edges */
  797. /**
  798. * @}
  799. */
  800. /** @defgroup ADC_LL_EC_INJ_TRIG_AUTO ADC group injected - Automatic trigger mode
  801. * @{
  802. */
  803. #define LL_ADC_INJ_TRIG_INDEPENDENT 0x00000000U /*!< ADC group injected conversion trigger independent. Setting mandatory if ADC group injected injected trigger source is set to an external trigger. */
  804. #define LL_ADC_INJ_TRIG_FROM_GRP_REGULAR (ADC_CR1_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. */
  805. /**
  806. * @}
  807. */
  808. /** @defgroup ADC_LL_EC_INJ_SEQ_SCAN_LENGTH ADC group injected - Sequencer scan length
  809. * @{
  810. */
  811. #define LL_ADC_INJ_SEQ_SCAN_DISABLE 0x00000000U /*!< ADC group injected sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
  812. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS ( ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 2 ranks in the sequence */
  813. #define LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS (ADC_JSQR_JL_1 ) /*!< ADC group injected sequencer enable with 3 ranks in the sequence */
  814. #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 */
  815. /**
  816. * @}
  817. */
  818. /** @defgroup ADC_LL_EC_INJ_SEQ_DISCONT_MODE ADC group injected - Sequencer discontinuous mode
  819. * @{
  820. */
  821. #define LL_ADC_INJ_SEQ_DISCONT_DISABLE 0x00000000U /*!< ADC group injected sequencer discontinuous mode disable */
  822. #define LL_ADC_INJ_SEQ_DISCONT_1RANK (ADC_CR1_JDISCEN) /*!< ADC group injected sequencer discontinuous mode enable with sequence interruption every rank */
  823. /**
  824. * @}
  825. */
  826. /** @defgroup ADC_LL_EC_INJ_SEQ_RANKS ADC group injected - Sequencer ranks
  827. * @{
  828. */
  829. #define LL_ADC_INJ_RANK_1 (ADC_JDR1_REGOFFSET | ADC_JOFR1_REGOFFSET | ADC_INJ_RANK_1_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 1 */
  830. #define LL_ADC_INJ_RANK_2 (ADC_JDR2_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_INJ_RANK_2_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 2 */
  831. #define LL_ADC_INJ_RANK_3 (ADC_JDR3_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_INJ_RANK_3_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 3 */
  832. #define LL_ADC_INJ_RANK_4 (ADC_JDR4_REGOFFSET | ADC_JOFR4_REGOFFSET | ADC_INJ_RANK_4_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 4 */
  833. /**
  834. * @}
  835. */
  836. /** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time
  837. * @{
  838. */
  839. #define LL_ADC_SAMPLINGTIME_4CYCLES 0x00000000U /*!< Sampling time 4 ADC clock cycles */
  840. #define LL_ADC_SAMPLINGTIME_9CYCLES (ADC_SMPR3_SMP0_0) /*!< Sampling time 9 ADC clock cycles */
  841. #define LL_ADC_SAMPLINGTIME_16CYCLES (ADC_SMPR3_SMP0_1) /*!< Sampling time 16 ADC clock cycles */
  842. #define LL_ADC_SAMPLINGTIME_24CYCLES (ADC_SMPR3_SMP0_1 | ADC_SMPR3_SMP0_0) /*!< Sampling time 24 ADC clock cycles */
  843. #define LL_ADC_SAMPLINGTIME_48CYCLES (ADC_SMPR3_SMP0_2) /*!< Sampling time 48 ADC clock cycles */
  844. #define LL_ADC_SAMPLINGTIME_96CYCLES (ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_0) /*!< Sampling time 96 ADC clock cycles */
  845. #define LL_ADC_SAMPLINGTIME_192CYCLES (ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_1) /*!< Sampling time 192 ADC clock cycles */
  846. #define LL_ADC_SAMPLINGTIME_384CYCLES (ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_1 | ADC_SMPR3_SMP0_0) /*!< Sampling time 384 ADC clock cycles */
  847. /**
  848. * @}
  849. */
  850. #if defined(COMP_CSR_FCH3)
  851. /** @defgroup ADC_LL_EC_CHANNEL_ROUTING_LIST Channel - Routing channels list
  852. * @{
  853. */
  854. #define LL_ADC_CHANNEL_3_ROUTING (COMP_CSR_FCH3) /*!< ADC channel 3 routing. Used as ADC direct channel (fast channel) if OPAMP1 is in power down mode. */
  855. #define LL_ADC_CHANNEL_8_ROUTING (COMP_CSR_FCH8) /*!< ADC channel 8 routing. Used as ADC direct channel (fast channel) if OPAMP2 is in power down mode. */
  856. #define LL_ADC_CHANNEL_13_ROUTING (COMP_CSR_RCH13) /*!< ADC channel 13 routing. Used as ADC re-routed channel if OPAMP3 is in power down mode. Otherwise, channel 13 is connected to OPAMP3 output and routed through switches COMP1_SW1 and VCOMP to ADC switch matrix. (Note: OPAMP3 is available on STM32L1 Cat.4 only). */
  857. /**
  858. * @}
  859. */
  860. /** @defgroup ADC_LL_EC_CHANNEL_ROUTING_SELECTION Channel - Routing selection
  861. * @{
  862. */
  863. #define LL_ADC_CHANNEL_ROUTING_DEFAULT 0x00000000U /*!< ADC channel routing default: slow channel */
  864. #define LL_ADC_CHANNEL_ROUTING_DIRECT 0x00000001U /*!< ADC channel routing direct: fast channel. */
  865. /**
  866. * @}
  867. */
  868. #endif
  869. /** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
  870. * @{
  871. */
  872. #define LL_ADC_AWD1 (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
  873. /**
  874. * @}
  875. */
  876. /** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
  877. * @{
  878. */
  879. #define LL_ADC_AWD_DISABLE 0x00000000U /*!< ADC analog watchdog monitoring disabled */
  880. #define LL_ADC_AWD_ALL_CHANNELS_REG ( ADC_CR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
  881. #define LL_ADC_AWD_ALL_CHANNELS_INJ ( ADC_CR1_JAWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group injected only */
  882. #define LL_ADC_AWD_ALL_CHANNELS_REG_INJ ( ADC_CR1_JAWDEN | ADC_CR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by either group regular or injected */
  883. #define LL_ADC_AWD_CHANNEL_0_REG ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group regular only */
  884. #define LL_ADC_AWD_CHANNEL_0_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group injected only */
  885. #define LL_ADC_AWD_CHANNEL_0_REG_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by either group regular or injected */
  886. #define LL_ADC_AWD_CHANNEL_1_REG ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group regular only */
  887. #define LL_ADC_AWD_CHANNEL_1_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group injected only */
  888. #define LL_ADC_AWD_CHANNEL_1_REG_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by either group regular or injected */
  889. #define LL_ADC_AWD_CHANNEL_2_REG ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group regular only */
  890. #define LL_ADC_AWD_CHANNEL_2_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group injected only */
  891. #define LL_ADC_AWD_CHANNEL_2_REG_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by either group regular or injected */
  892. #define LL_ADC_AWD_CHANNEL_3_REG ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group regular only */
  893. #define LL_ADC_AWD_CHANNEL_3_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group injected only */
  894. #define LL_ADC_AWD_CHANNEL_3_REG_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by either group regular or injected */
  895. #define LL_ADC_AWD_CHANNEL_4_REG ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group regular only */
  896. #define LL_ADC_AWD_CHANNEL_4_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group injected only */
  897. #define LL_ADC_AWD_CHANNEL_4_REG_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by either group regular or injected */
  898. #define LL_ADC_AWD_CHANNEL_5_REG ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group regular only */
  899. #define LL_ADC_AWD_CHANNEL_5_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group injected only */
  900. #define LL_ADC_AWD_CHANNEL_5_REG_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by either group regular or injected */
  901. #define LL_ADC_AWD_CHANNEL_6_REG ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group regular only */
  902. #define LL_ADC_AWD_CHANNEL_6_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group injected only */
  903. #define LL_ADC_AWD_CHANNEL_6_REG_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by either group regular or injected */
  904. #define LL_ADC_AWD_CHANNEL_7_REG ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group regular only */
  905. #define LL_ADC_AWD_CHANNEL_7_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group injected only */
  906. #define LL_ADC_AWD_CHANNEL_7_REG_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by either group regular or injected */
  907. #define LL_ADC_AWD_CHANNEL_8_REG ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group regular only */
  908. #define LL_ADC_AWD_CHANNEL_8_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group injected only */
  909. #define LL_ADC_AWD_CHANNEL_8_REG_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by either group regular or injected */
  910. #define LL_ADC_AWD_CHANNEL_9_REG ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group regular only */
  911. #define LL_ADC_AWD_CHANNEL_9_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group injected only */
  912. #define LL_ADC_AWD_CHANNEL_9_REG_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by either group regular or injected */
  913. #define LL_ADC_AWD_CHANNEL_10_REG ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group regular only */
  914. #define LL_ADC_AWD_CHANNEL_10_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group injected only */
  915. #define LL_ADC_AWD_CHANNEL_10_REG_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by either group regular or injected */
  916. #define LL_ADC_AWD_CHANNEL_11_REG ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group regular only */
  917. #define LL_ADC_AWD_CHANNEL_11_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group injected only */
  918. #define LL_ADC_AWD_CHANNEL_11_REG_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by either group regular or injected */
  919. #define LL_ADC_AWD_CHANNEL_12_REG ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group regular only */
  920. #define LL_ADC_AWD_CHANNEL_12_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group injected only */
  921. #define LL_ADC_AWD_CHANNEL_12_REG_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by either group regular or injected */
  922. #define LL_ADC_AWD_CHANNEL_13_REG ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group regular only */
  923. #define LL_ADC_AWD_CHANNEL_13_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group injected only */
  924. #define LL_ADC_AWD_CHANNEL_13_REG_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by either group regular or injected */
  925. #define LL_ADC_AWD_CHANNEL_14_REG ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group regular only */
  926. #define LL_ADC_AWD_CHANNEL_14_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group injected only */
  927. #define LL_ADC_AWD_CHANNEL_14_REG_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by either group regular or injected */
  928. #define LL_ADC_AWD_CHANNEL_15_REG ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group regular only */
  929. #define LL_ADC_AWD_CHANNEL_15_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group injected only */
  930. #define LL_ADC_AWD_CHANNEL_15_REG_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by either group regular or injected */
  931. #define LL_ADC_AWD_CHANNEL_16_REG ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group regular only */
  932. #define LL_ADC_AWD_CHANNEL_16_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group injected only */
  933. #define LL_ADC_AWD_CHANNEL_16_REG_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by either group regular or injected */
  934. #define LL_ADC_AWD_CHANNEL_17_REG ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group regular only */
  935. #define LL_ADC_AWD_CHANNEL_17_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group injected only */
  936. #define LL_ADC_AWD_CHANNEL_17_REG_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by either group regular or injected */
  937. #define LL_ADC_AWD_CHANNEL_18_REG ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group regular only */
  938. #define LL_ADC_AWD_CHANNEL_18_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group injected only */
  939. #define LL_ADC_AWD_CHANNEL_18_REG_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by either group regular or injected */
  940. #define LL_ADC_AWD_CHANNEL_19_REG ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by group regular only */
  941. #define LL_ADC_AWD_CHANNEL_19_INJ ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by group injected only */
  942. #define LL_ADC_AWD_CHANNEL_19_REG_INJ ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by either group regular or injected */
  943. #define LL_ADC_AWD_CHANNEL_20_REG ((LL_ADC_CHANNEL_20 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN20, converted by group regular only */
  944. #define LL_ADC_AWD_CHANNEL_20_INJ ((LL_ADC_CHANNEL_20 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN20, converted by group injected only */
  945. #define LL_ADC_AWD_CHANNEL_20_REG_INJ ((LL_ADC_CHANNEL_20 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN20, converted by either group regular or injected */
  946. #define LL_ADC_AWD_CHANNEL_21_REG ((LL_ADC_CHANNEL_21 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN21, converted by group regular only */
  947. #define LL_ADC_AWD_CHANNEL_21_INJ ((LL_ADC_CHANNEL_21 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN21, converted by group injected only */
  948. #define LL_ADC_AWD_CHANNEL_21_REG_INJ ((LL_ADC_CHANNEL_21 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN21, converted by either group regular or injected */
  949. #define LL_ADC_AWD_CHANNEL_22_REG ((LL_ADC_CHANNEL_22 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN22, converted by group regular only */
  950. #define LL_ADC_AWD_CHANNEL_22_INJ ((LL_ADC_CHANNEL_22 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN22, converted by group injected only */
  951. #define LL_ADC_AWD_CHANNEL_22_REG_INJ ((LL_ADC_CHANNEL_22 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN22, converted by either group regular or injected */
  952. #define LL_ADC_AWD_CHANNEL_23_REG ((LL_ADC_CHANNEL_23 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN23, converted by group regular only */
  953. #define LL_ADC_AWD_CHANNEL_23_INJ ((LL_ADC_CHANNEL_23 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN23, converted by group injected only */
  954. #define LL_ADC_AWD_CHANNEL_23_REG_INJ ((LL_ADC_CHANNEL_23 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN23, converted by either group regular or injected */
  955. #define LL_ADC_AWD_CHANNEL_24_REG ((LL_ADC_CHANNEL_24 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN24, converted by group regular only */
  956. #define LL_ADC_AWD_CHANNEL_24_INJ ((LL_ADC_CHANNEL_24 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN24, converted by group injected only */
  957. #define LL_ADC_AWD_CHANNEL_24_REG_INJ ((LL_ADC_CHANNEL_24 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN24, converted by either group regular or injected */
  958. #define LL_ADC_AWD_CHANNEL_25_REG ((LL_ADC_CHANNEL_25 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN25, converted by group regular only */
  959. #define LL_ADC_AWD_CHANNEL_25_INJ ((LL_ADC_CHANNEL_25 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN25, converted by group injected only */
  960. #define LL_ADC_AWD_CHANNEL_25_REG_INJ ((LL_ADC_CHANNEL_25 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN25, converted by either group regular or injected */
  961. #define LL_ADC_AWD_CHANNEL_26_REG ((LL_ADC_CHANNEL_26 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN26, converted by group regular only */
  962. #define LL_ADC_AWD_CHANNEL_26_INJ ((LL_ADC_CHANNEL_26 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN26, converted by group injected only */
  963. #define LL_ADC_AWD_CHANNEL_26_REG_INJ ((LL_ADC_CHANNEL_26 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN26, converted by either group regular or injected */
  964. #if defined(ADC_SMPR0_SMP31)
  965. #define LL_ADC_AWD_CHANNEL_27_REG ((LL_ADC_CHANNEL_27 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN27, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  966. #define LL_ADC_AWD_CHANNEL_27_INJ ((LL_ADC_CHANNEL_27 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN27, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  967. #define LL_ADC_AWD_CHANNEL_27_REG_INJ ((LL_ADC_CHANNEL_27 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN27, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  968. #define LL_ADC_AWD_CHANNEL_28_REG ((LL_ADC_CHANNEL_28 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN28, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  969. #define LL_ADC_AWD_CHANNEL_28_INJ ((LL_ADC_CHANNEL_28 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN28, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  970. #define LL_ADC_AWD_CHANNEL_28_REG_INJ ((LL_ADC_CHANNEL_28 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN28, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  971. #define LL_ADC_AWD_CHANNEL_29_REG ((LL_ADC_CHANNEL_29 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN29, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  972. #define LL_ADC_AWD_CHANNEL_29_INJ ((LL_ADC_CHANNEL_29 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN29, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  973. #define LL_ADC_AWD_CHANNEL_29_REG_INJ ((LL_ADC_CHANNEL_29 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN29, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  974. #define LL_ADC_AWD_CHANNEL_30_REG ((LL_ADC_CHANNEL_30 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN30, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  975. #define LL_ADC_AWD_CHANNEL_30_INJ ((LL_ADC_CHANNEL_30 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN30, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  976. #define LL_ADC_AWD_CHANNEL_30_REG_INJ ((LL_ADC_CHANNEL_30 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN30, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  977. #define LL_ADC_AWD_CHANNEL_31_REG ((LL_ADC_CHANNEL_31 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN31, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  978. #define LL_ADC_AWD_CHANNEL_31_INJ ((LL_ADC_CHANNEL_31 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN31, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  979. #define LL_ADC_AWD_CHANNEL_31_REG_INJ ((LL_ADC_CHANNEL_31 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN31, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
  980. #endif /* ADC_SMPR0_SMP31 */
  981. #define LL_ADC_AWD_CH_VREFINT_REG ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group regular only. Channel common to both bank A and bank B. */
  982. #define LL_ADC_AWD_CH_VREFINT_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group injected only. Channel common to both bank A and bank B. */
  983. #define LL_ADC_AWD_CH_VREFINT_REG_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by either group regular or injected. Channel common to both bank A and bank B. */
  984. #define LL_ADC_AWD_CH_TEMPSENSOR_REG ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group regular only. Channel common to both bank A and bank B. */
  985. #define LL_ADC_AWD_CH_TEMPSENSOR_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group injected only. Channel common to both bank A and bank B. */
  986. #define LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by either group regular or injected. Channel common to both bank A and bank B. */
  987. #define LL_ADC_AWD_CH_VCOMP_REG ((LL_ADC_CHANNEL_VCOMP & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
  988. #define LL_ADC_AWD_CH_VCOMP_INJ ((LL_ADC_CHANNEL_VCOMP & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
  989. #define LL_ADC_AWD_CH_VCOMP_REG_INJ ((LL_ADC_CHANNEL_VCOMP & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
  990. #if defined(OPAMP_CSR_OPA1PD) || defined (OPAMP_CSR_OPA2PD) || defined (OPAMP_CSR_OPA3PD)
  991. #define LL_ADC_AWD_CH_VOPAMP1_REG ((LL_ADC_CHANNEL_VOPAMP1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
  992. #define LL_ADC_AWD_CH_VOPAMP1_INJ ((LL_ADC_CHANNEL_VOPAMP1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
  993. #define LL_ADC_AWD_CH_VOPAMP1_REG_INJ ((LL_ADC_CHANNEL_VOPAMP1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
  994. #define LL_ADC_AWD_CH_VOPAMP2_REG ((LL_ADC_CHANNEL_VOPAMP2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
  995. #define LL_ADC_AWD_CH_VOPAMP2_INJ ((LL_ADC_CHANNEL_VOPAMP2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
  996. #define LL_ADC_AWD_CH_VOPAMP2_REG_INJ ((LL_ADC_CHANNEL_VOPAMP2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
  997. #if defined(OPAMP_CSR_OPA3PD)
  998. #define LL_ADC_AWD_CH_VOPAMP3_REG ((LL_ADC_CHANNEL_VOPAMP3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
  999. #define LL_ADC_AWD_CH_VOPAMP3_INJ ((LL_ADC_CHANNEL_VOPAMP3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
  1000. #define LL_ADC_AWD_CH_VOPAMP3_REG_INJ ((LL_ADC_CHANNEL_VOPAMP3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
  1001. #endif /* OPAMP_CSR_OPA3PD */
  1002. #endif /* OPAMP_CSR_OPA1PD || OPAMP_CSR_OPA2PD || OPAMP_CSR_OPA3PD */
  1003. /**
  1004. * @}
  1005. */
  1006. /** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
  1007. * @{
  1008. */
  1009. #define LL_ADC_AWD_THRESHOLD_HIGH (ADC_AWD_TR1_HIGH_REGOFFSET) /*!< ADC analog watchdog threshold high */
  1010. #define LL_ADC_AWD_THRESHOLD_LOW (ADC_AWD_TR1_LOW_REGOFFSET) /*!< ADC analog watchdog threshold low */
  1011. /**
  1012. * @}
  1013. */
  1014. /** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
  1015. * @note Only ADC IP HW delays are defined in ADC LL driver driver,
  1016. * not timeout values.
  1017. * For details on delays values, refer to descriptions in source code
  1018. * above each literal definition.
  1019. * @{
  1020. */
  1021. /* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
  1022. /* not timeout values. */
  1023. /* Timeout values for ADC operations are dependent to device clock */
  1024. /* configuration (system clock versus ADC clock), */
  1025. /* and therefore must be defined in user application. */
  1026. /* Indications for estimation of ADC timeout delays, for this */
  1027. /* STM32 serie: */
  1028. /* - ADC enable time: maximum delay is 3.5us */
  1029. /* (refer to device datasheet, parameter "tSTAB") */
  1030. /* - ADC conversion time: duration depending on ADC clock and ADC */
  1031. /* configuration. */
  1032. /* (refer to device reference manual, section "Timing") */
  1033. /* Delay for internal voltage reference stabilization time. */
  1034. /* Delay set to maximum value (refer to device datasheet, */
  1035. /* parameter "TADC_BUF"). */
  1036. /* Unit: us */
  1037. #define LL_ADC_DELAY_VREFINT_STAB_US ( 10U) /*!< Delay for internal voltage reference stabilization time */
  1038. /* Delay for temperature sensor stabilization time. */
  1039. /* Literal set to maximum value (refer to device datasheet, */
  1040. /* parameter "tSTART"). */
  1041. /* Unit: us */
  1042. #define LL_ADC_DELAY_TEMPSENSOR_STAB_US ( 10U) /*!< Delay for internal voltage reference stabilization time */
  1043. /**
  1044. * @}
  1045. */
  1046. /**
  1047. * @}
  1048. */
  1049. /* Exported macro ------------------------------------------------------------*/
  1050. /** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
  1051. * @{
  1052. */
  1053. /** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
  1054. * @{
  1055. */
  1056. /**
  1057. * @brief Write a value in ADC register
  1058. * @param __INSTANCE__ ADC Instance
  1059. * @param __REG__ Register to be written
  1060. * @param __VALUE__ Value to be written in the register
  1061. * @retval None
  1062. */
  1063. #define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  1064. /**
  1065. * @brief Read a value in ADC register
  1066. * @param __INSTANCE__ ADC Instance
  1067. * @param __REG__ Register to be read
  1068. * @retval Register value
  1069. */
  1070. #define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  1071. /**
  1072. * @}
  1073. */
  1074. /** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
  1075. * @{
  1076. */
  1077. /**
  1078. * @brief Helper macro to get ADC channel number in decimal format
  1079. * from literals LL_ADC_CHANNEL_x.
  1080. * @note Example:
  1081. * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
  1082. * will return decimal number "4".
  1083. * @note The input can be a value from functions where a channel
  1084. * number is returned, either defined with number
  1085. * or with bitfield (only one bit must be set).
  1086. * @param __CHANNEL__ This parameter can be one of the following values:
  1087. * @arg @ref LL_ADC_CHANNEL_0 (2)
  1088. * @arg @ref LL_ADC_CHANNEL_1 (2)
  1089. * @arg @ref LL_ADC_CHANNEL_2 (2)
  1090. * @arg @ref LL_ADC_CHANNEL_3 (2)
  1091. * @arg @ref LL_ADC_CHANNEL_4 (1)
  1092. * @arg @ref LL_ADC_CHANNEL_5 (1)
  1093. * @arg @ref LL_ADC_CHANNEL_6 (2)
  1094. * @arg @ref LL_ADC_CHANNEL_7 (2)
  1095. * @arg @ref LL_ADC_CHANNEL_8 (2)
  1096. * @arg @ref LL_ADC_CHANNEL_9 (2)
  1097. * @arg @ref LL_ADC_CHANNEL_10 (2)
  1098. * @arg @ref LL_ADC_CHANNEL_11 (2)
  1099. * @arg @ref LL_ADC_CHANNEL_12 (2)
  1100. * @arg @ref LL_ADC_CHANNEL_13 (3)
  1101. * @arg @ref LL_ADC_CHANNEL_14 (3)
  1102. * @arg @ref LL_ADC_CHANNEL_15 (3)
  1103. * @arg @ref LL_ADC_CHANNEL_16 (3)
  1104. * @arg @ref LL_ADC_CHANNEL_17 (3)
  1105. * @arg @ref LL_ADC_CHANNEL_18 (3)
  1106. * @arg @ref LL_ADC_CHANNEL_19 (3)
  1107. * @arg @ref LL_ADC_CHANNEL_20 (3)
  1108. * @arg @ref LL_ADC_CHANNEL_21 (3)
  1109. * @arg @ref LL_ADC_CHANNEL_22 (1)
  1110. * @arg @ref LL_ADC_CHANNEL_23 (1)
  1111. * @arg @ref LL_ADC_CHANNEL_24 (1)
  1112. * @arg @ref LL_ADC_CHANNEL_25 (1)
  1113. * @arg @ref LL_ADC_CHANNEL_26 (3)
  1114. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  1115. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  1116. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  1117. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  1118. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  1119. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  1120. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  1121. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  1122. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  1123. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  1124. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  1125. *
  1126. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1127. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1128. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1129. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1130. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  1131. * @retval Value between Min_Data=0 and Max_Data=18
  1132. */
  1133. #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
  1134. (((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
  1135. /**
  1136. * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
  1137. * from number in decimal format.
  1138. * @note Example:
  1139. * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
  1140. * will return a data equivalent to "LL_ADC_CHANNEL_4".
  1141. * @param __DECIMAL_NB__ Value between Min_Data=0 and Max_Data=18
  1142. * @retval Returned value can be one of the following values:
  1143. * @arg @ref LL_ADC_CHANNEL_0 (2)
  1144. * @arg @ref LL_ADC_CHANNEL_1 (2)
  1145. * @arg @ref LL_ADC_CHANNEL_2 (2)
  1146. * @arg @ref LL_ADC_CHANNEL_3 (2)
  1147. * @arg @ref LL_ADC_CHANNEL_4 (1)
  1148. * @arg @ref LL_ADC_CHANNEL_5 (1)
  1149. * @arg @ref LL_ADC_CHANNEL_6 (2)
  1150. * @arg @ref LL_ADC_CHANNEL_7 (2)
  1151. * @arg @ref LL_ADC_CHANNEL_8 (2)
  1152. * @arg @ref LL_ADC_CHANNEL_9 (2)
  1153. * @arg @ref LL_ADC_CHANNEL_10 (2)
  1154. * @arg @ref LL_ADC_CHANNEL_11 (2)
  1155. * @arg @ref LL_ADC_CHANNEL_12 (2)
  1156. * @arg @ref LL_ADC_CHANNEL_13 (3)
  1157. * @arg @ref LL_ADC_CHANNEL_14 (3)
  1158. * @arg @ref LL_ADC_CHANNEL_15 (3)
  1159. * @arg @ref LL_ADC_CHANNEL_16 (3)
  1160. * @arg @ref LL_ADC_CHANNEL_17 (3)
  1161. * @arg @ref LL_ADC_CHANNEL_18 (3)
  1162. * @arg @ref LL_ADC_CHANNEL_19 (3)
  1163. * @arg @ref LL_ADC_CHANNEL_20 (3)
  1164. * @arg @ref LL_ADC_CHANNEL_21 (3)
  1165. * @arg @ref LL_ADC_CHANNEL_22 (1)
  1166. * @arg @ref LL_ADC_CHANNEL_23 (1)
  1167. * @arg @ref LL_ADC_CHANNEL_24 (1)
  1168. * @arg @ref LL_ADC_CHANNEL_25 (1)
  1169. * @arg @ref LL_ADC_CHANNEL_26 (3)
  1170. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  1171. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  1172. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  1173. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  1174. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  1175. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)(6)
  1176. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
  1177. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)(6)
  1178. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  1179. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  1180. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  1181. *
  1182. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1183. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1184. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1185. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1186. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
  1187. * (6) For ADC channel read back from ADC register,
  1188. * comparison with internal channel parameter to be done
  1189. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1190. */
  1191. #if defined(ADC_SMPR0_SMP31)
  1192. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  1193. (((__DECIMAL_NB__) <= 9U) \
  1194. ? ( \
  1195. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1196. (ADC_SMPR3_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1197. ) \
  1198. : \
  1199. (((__DECIMAL_NB__) <= 19U) \
  1200. ? ( \
  1201. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1202. (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1203. ) \
  1204. : \
  1205. (((__DECIMAL_NB__) <= 28U) \
  1206. ? ( \
  1207. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1208. (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -20U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1209. ) \
  1210. : \
  1211. ( \
  1212. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1213. (ADC_SMPR0_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) - 30U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1214. ) \
  1215. ) \
  1216. ) \
  1217. )
  1218. #else
  1219. #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  1220. (((__DECIMAL_NB__) <= 9U) \
  1221. ? ( \
  1222. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1223. (ADC_SMPR3_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1224. ) \
  1225. : \
  1226. (((__DECIMAL_NB__) <= 19U) \
  1227. ? ( \
  1228. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1229. (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1230. ) \
  1231. : \
  1232. ( \
  1233. ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
  1234. (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -20U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
  1235. ) \
  1236. ) \
  1237. )
  1238. #endif /* ADC_SMPR0_SMP31 */
  1239. /**
  1240. * @brief Helper macro to determine whether the selected channel
  1241. * corresponds to literal definitions of driver.
  1242. * @note The different literal definitions of ADC channels are:
  1243. * - ADC internal channel:
  1244. * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
  1245. * - ADC external channel (channel connected to a GPIO pin):
  1246. * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
  1247. * @note The channel parameter must be a value defined from literal
  1248. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1249. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1250. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
  1251. * must not be a value from functions where a channel number is
  1252. * returned from ADC registers,
  1253. * because internal and external channels share the same channel
  1254. * number in ADC registers. The differentiation is made only with
  1255. * parameters definitions of driver.
  1256. * @param __CHANNEL__ This parameter can be one of the following values:
  1257. * @arg @ref LL_ADC_CHANNEL_0 (2)
  1258. * @arg @ref LL_ADC_CHANNEL_1 (2)
  1259. * @arg @ref LL_ADC_CHANNEL_2 (2)
  1260. * @arg @ref LL_ADC_CHANNEL_3 (2)
  1261. * @arg @ref LL_ADC_CHANNEL_4 (1)
  1262. * @arg @ref LL_ADC_CHANNEL_5 (1)
  1263. * @arg @ref LL_ADC_CHANNEL_6 (2)
  1264. * @arg @ref LL_ADC_CHANNEL_7 (2)
  1265. * @arg @ref LL_ADC_CHANNEL_8 (2)
  1266. * @arg @ref LL_ADC_CHANNEL_9 (2)
  1267. * @arg @ref LL_ADC_CHANNEL_10 (2)
  1268. * @arg @ref LL_ADC_CHANNEL_11 (2)
  1269. * @arg @ref LL_ADC_CHANNEL_12 (2)
  1270. * @arg @ref LL_ADC_CHANNEL_13 (3)
  1271. * @arg @ref LL_ADC_CHANNEL_14 (3)
  1272. * @arg @ref LL_ADC_CHANNEL_15 (3)
  1273. * @arg @ref LL_ADC_CHANNEL_16 (3)
  1274. * @arg @ref LL_ADC_CHANNEL_17 (3)
  1275. * @arg @ref LL_ADC_CHANNEL_18 (3)
  1276. * @arg @ref LL_ADC_CHANNEL_19 (3)
  1277. * @arg @ref LL_ADC_CHANNEL_20 (3)
  1278. * @arg @ref LL_ADC_CHANNEL_21 (3)
  1279. * @arg @ref LL_ADC_CHANNEL_22 (1)
  1280. * @arg @ref LL_ADC_CHANNEL_23 (1)
  1281. * @arg @ref LL_ADC_CHANNEL_24 (1)
  1282. * @arg @ref LL_ADC_CHANNEL_25 (1)
  1283. * @arg @ref LL_ADC_CHANNEL_26 (3)
  1284. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  1285. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  1286. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  1287. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  1288. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  1289. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  1290. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  1291. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  1292. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  1293. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  1294. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  1295. *
  1296. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1297. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1298. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1299. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1300. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  1301. * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin).
  1302. * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
  1303. */
  1304. #define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
  1305. (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0U)
  1306. /**
  1307. * @brief Helper macro to convert a channel defined from parameter
  1308. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1309. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1310. * to its equivalent parameter definition of a ADC external channel
  1311. * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
  1312. * @note The channel parameter can be, additionally to a value
  1313. * defined from parameter definition of a ADC internal channel
  1314. * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1315. * a value defined from parameter definition of
  1316. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1317. * or a value from functions where a channel number is returned
  1318. * from ADC registers.
  1319. * @param __CHANNEL__ This parameter can be one of the following values:
  1320. * @arg @ref LL_ADC_CHANNEL_0 (2)
  1321. * @arg @ref LL_ADC_CHANNEL_1 (2)
  1322. * @arg @ref LL_ADC_CHANNEL_2 (2)
  1323. * @arg @ref LL_ADC_CHANNEL_3 (2)
  1324. * @arg @ref LL_ADC_CHANNEL_4 (1)
  1325. * @arg @ref LL_ADC_CHANNEL_5 (1)
  1326. * @arg @ref LL_ADC_CHANNEL_6 (2)
  1327. * @arg @ref LL_ADC_CHANNEL_7 (2)
  1328. * @arg @ref LL_ADC_CHANNEL_8 (2)
  1329. * @arg @ref LL_ADC_CHANNEL_9 (2)
  1330. * @arg @ref LL_ADC_CHANNEL_10 (2)
  1331. * @arg @ref LL_ADC_CHANNEL_11 (2)
  1332. * @arg @ref LL_ADC_CHANNEL_12 (2)
  1333. * @arg @ref LL_ADC_CHANNEL_13 (3)
  1334. * @arg @ref LL_ADC_CHANNEL_14 (3)
  1335. * @arg @ref LL_ADC_CHANNEL_15 (3)
  1336. * @arg @ref LL_ADC_CHANNEL_16 (3)
  1337. * @arg @ref LL_ADC_CHANNEL_17 (3)
  1338. * @arg @ref LL_ADC_CHANNEL_18 (3)
  1339. * @arg @ref LL_ADC_CHANNEL_19 (3)
  1340. * @arg @ref LL_ADC_CHANNEL_20 (3)
  1341. * @arg @ref LL_ADC_CHANNEL_21 (3)
  1342. * @arg @ref LL_ADC_CHANNEL_22 (1)
  1343. * @arg @ref LL_ADC_CHANNEL_23 (1)
  1344. * @arg @ref LL_ADC_CHANNEL_24 (1)
  1345. * @arg @ref LL_ADC_CHANNEL_25 (1)
  1346. * @arg @ref LL_ADC_CHANNEL_26 (3)
  1347. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  1348. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  1349. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  1350. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  1351. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  1352. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  1353. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  1354. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  1355. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  1356. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  1357. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  1358. *
  1359. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1360. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1361. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1362. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1363. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  1364. * @retval Returned value can be one of the following values:
  1365. * @arg @ref LL_ADC_CHANNEL_0
  1366. * @arg @ref LL_ADC_CHANNEL_1
  1367. * @arg @ref LL_ADC_CHANNEL_2
  1368. * @arg @ref LL_ADC_CHANNEL_3
  1369. * @arg @ref LL_ADC_CHANNEL_4
  1370. * @arg @ref LL_ADC_CHANNEL_5
  1371. * @arg @ref LL_ADC_CHANNEL_6
  1372. * @arg @ref LL_ADC_CHANNEL_7
  1373. * @arg @ref LL_ADC_CHANNEL_8
  1374. * @arg @ref LL_ADC_CHANNEL_9
  1375. * @arg @ref LL_ADC_CHANNEL_10
  1376. * @arg @ref LL_ADC_CHANNEL_11
  1377. * @arg @ref LL_ADC_CHANNEL_12
  1378. * @arg @ref LL_ADC_CHANNEL_13
  1379. * @arg @ref LL_ADC_CHANNEL_14
  1380. * @arg @ref LL_ADC_CHANNEL_15
  1381. * @arg @ref LL_ADC_CHANNEL_16
  1382. * @arg @ref LL_ADC_CHANNEL_17
  1383. * @arg @ref LL_ADC_CHANNEL_18
  1384. */
  1385. #define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
  1386. ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
  1387. /**
  1388. * @brief Helper macro to determine whether the internal channel
  1389. * selected is available on the ADC instance selected.
  1390. * @note The channel parameter must be a value defined from parameter
  1391. * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
  1392. * LL_ADC_CHANNEL_TEMPSENSOR, ...),
  1393. * must not be a value defined from parameter definition of
  1394. * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
  1395. * or a value from functions where a channel number is
  1396. * returned from ADC registers,
  1397. * because internal and external channels share the same channel
  1398. * number in ADC registers. The differentiation is made only with
  1399. * parameters definitions of driver.
  1400. * @param __ADC_INSTANCE__ ADC instance
  1401. * @param __CHANNEL__ This parameter can be one of the following values:
  1402. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  1403. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  1404. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  1405. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  1406. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  1407. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  1408. *
  1409. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1410. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1411. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1412. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1413. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  1414. * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
  1415. * Value "1" if the internal channel selected is available on the ADC instance selected.
  1416. */
  1417. #if defined (OPAMP_CSR_OPA3PD)
  1418. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1419. ( \
  1420. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1421. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1422. ((__CHANNEL__) == LL_ADC_CHANNEL_VCOMP) || \
  1423. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) || \
  1424. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2) || \
  1425. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP3) \
  1426. )
  1427. #elif defined(OPAMP_CSR_OPA1PD) || defined (OPAMP_CSR_OPA2PD)
  1428. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1429. ( \
  1430. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1431. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1432. ((__CHANNEL__) == LL_ADC_CHANNEL_VCOMP) || \
  1433. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) || \
  1434. ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2) \
  1435. )
  1436. #else
  1437. #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
  1438. ( \
  1439. ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
  1440. ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
  1441. ((__CHANNEL__) == LL_ADC_CHANNEL_VCOMP) \
  1442. )
  1443. #endif
  1444. /**
  1445. * @brief Helper macro to define ADC analog watchdog parameter:
  1446. * define a single channel to monitor with analog watchdog
  1447. * from sequencer channel and groups definition.
  1448. * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
  1449. * Example:
  1450. * LL_ADC_SetAnalogWDMonitChannels(
  1451. * ADC1, LL_ADC_AWD1,
  1452. * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
  1453. * @param __CHANNEL__ This parameter can be one of the following values:
  1454. * @arg @ref LL_ADC_CHANNEL_0 (2)
  1455. * @arg @ref LL_ADC_CHANNEL_1 (2)
  1456. * @arg @ref LL_ADC_CHANNEL_2 (2)
  1457. * @arg @ref LL_ADC_CHANNEL_3 (2)
  1458. * @arg @ref LL_ADC_CHANNEL_4 (1)
  1459. * @arg @ref LL_ADC_CHANNEL_5 (1)
  1460. * @arg @ref LL_ADC_CHANNEL_6 (2)
  1461. * @arg @ref LL_ADC_CHANNEL_7 (2)
  1462. * @arg @ref LL_ADC_CHANNEL_8 (2)
  1463. * @arg @ref LL_ADC_CHANNEL_9 (2)
  1464. * @arg @ref LL_ADC_CHANNEL_10 (2)
  1465. * @arg @ref LL_ADC_CHANNEL_11 (2)
  1466. * @arg @ref LL_ADC_CHANNEL_12 (2)
  1467. * @arg @ref LL_ADC_CHANNEL_13 (3)
  1468. * @arg @ref LL_ADC_CHANNEL_14 (3)
  1469. * @arg @ref LL_ADC_CHANNEL_15 (3)
  1470. * @arg @ref LL_ADC_CHANNEL_16 (3)
  1471. * @arg @ref LL_ADC_CHANNEL_17 (3)
  1472. * @arg @ref LL_ADC_CHANNEL_18 (3)
  1473. * @arg @ref LL_ADC_CHANNEL_19 (3)
  1474. * @arg @ref LL_ADC_CHANNEL_20 (3)
  1475. * @arg @ref LL_ADC_CHANNEL_21 (3)
  1476. * @arg @ref LL_ADC_CHANNEL_22 (1)
  1477. * @arg @ref LL_ADC_CHANNEL_23 (1)
  1478. * @arg @ref LL_ADC_CHANNEL_24 (1)
  1479. * @arg @ref LL_ADC_CHANNEL_25 (1)
  1480. * @arg @ref LL_ADC_CHANNEL_26 (3)
  1481. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  1482. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  1483. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  1484. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  1485. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  1486. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)(6)
  1487. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
  1488. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)(6)
  1489. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  1490. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  1491. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  1492. *
  1493. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1494. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1495. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1496. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1497. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
  1498. * (6) For ADC channel read back from ADC register,
  1499. * comparison with internal channel parameter to be done
  1500. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  1501. * @param __GROUP__ This parameter can be one of the following values:
  1502. * @arg @ref LL_ADC_GROUP_REGULAR
  1503. * @arg @ref LL_ADC_GROUP_INJECTED
  1504. * @arg @ref LL_ADC_GROUP_REGULAR_INJECTED
  1505. * @retval Returned value can be one of the following values:
  1506. * @arg @ref LL_ADC_AWD_DISABLE
  1507. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  1508. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  1509. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  1510. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (2)
  1511. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (2)
  1512. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ (2)
  1513. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (2)
  1514. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (2)
  1515. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ (2)
  1516. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (2)
  1517. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (2)
  1518. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ (2)
  1519. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (2)
  1520. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (2)
  1521. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ (2)
  1522. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (1)
  1523. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (1)
  1524. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ (1)
  1525. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (1)
  1526. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (1)
  1527. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ (1)
  1528. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (2)
  1529. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (2)
  1530. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ (2)
  1531. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (2)
  1532. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (2)
  1533. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ (2)
  1534. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (2)
  1535. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (2)
  1536. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ (2)
  1537. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (2)
  1538. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (2)
  1539. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ (2)
  1540. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (2)
  1541. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (2)
  1542. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ (2)
  1543. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (2)
  1544. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (2)
  1545. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ (2)
  1546. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (2)
  1547. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (2)
  1548. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ (2)
  1549. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (3)
  1550. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (3)
  1551. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ (3)
  1552. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (3)
  1553. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (3)
  1554. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ (3)
  1555. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (3)
  1556. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (3)
  1557. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ (3)
  1558. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (3)
  1559. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (3)
  1560. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ (3)
  1561. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (3)
  1562. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (3)
  1563. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ (3)
  1564. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (3)
  1565. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (3)
  1566. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ (3)
  1567. * @arg @ref LL_ADC_AWD_CHANNEL_19_REG (3)
  1568. * @arg @ref LL_ADC_AWD_CHANNEL_19_INJ (3)
  1569. * @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ (3)
  1570. * @arg @ref LL_ADC_AWD_CHANNEL_20_REG (3)
  1571. * @arg @ref LL_ADC_AWD_CHANNEL_20_INJ (3)
  1572. * @arg @ref LL_ADC_AWD_CHANNEL_20_REG_INJ (3)
  1573. * @arg @ref LL_ADC_AWD_CHANNEL_21_REG (3)
  1574. * @arg @ref LL_ADC_AWD_CHANNEL_21_INJ (3)
  1575. * @arg @ref LL_ADC_AWD_CHANNEL_21_REG_INJ (3)
  1576. * @arg @ref LL_ADC_AWD_CHANNEL_22_REG (1)
  1577. * @arg @ref LL_ADC_AWD_CHANNEL_22_INJ (1)
  1578. * @arg @ref LL_ADC_AWD_CHANNEL_22_REG_INJ (1)
  1579. * @arg @ref LL_ADC_AWD_CHANNEL_23_REG (1)
  1580. * @arg @ref LL_ADC_AWD_CHANNEL_23_INJ (1)
  1581. * @arg @ref LL_ADC_AWD_CHANNEL_23_REG_INJ (1)
  1582. * @arg @ref LL_ADC_AWD_CHANNEL_24_REG (1)
  1583. * @arg @ref LL_ADC_AWD_CHANNEL_24_INJ (1)
  1584. * @arg @ref LL_ADC_AWD_CHANNEL_24_REG_INJ (1)
  1585. * @arg @ref LL_ADC_AWD_CHANNEL_25_REG (1)
  1586. * @arg @ref LL_ADC_AWD_CHANNEL_25_INJ (1)
  1587. * @arg @ref LL_ADC_AWD_CHANNEL_25_REG_INJ (1)
  1588. * @arg @ref LL_ADC_AWD_CHANNEL_26_REG (3)
  1589. * @arg @ref LL_ADC_AWD_CHANNEL_26_INJ (3)
  1590. * @arg @ref LL_ADC_AWD_CHANNEL_26_REG_INJ (3)
  1591. * @arg @ref LL_ADC_AWD_CHANNEL_27_REG (3)(4)
  1592. * @arg @ref LL_ADC_AWD_CHANNEL_27_INJ (3)(4)
  1593. * @arg @ref LL_ADC_AWD_CHANNEL_27_REG_INJ (3)(4)
  1594. * @arg @ref LL_ADC_AWD_CHANNEL_28_REG (3)(4)
  1595. * @arg @ref LL_ADC_AWD_CHANNEL_28_INJ (3)(4)
  1596. * @arg @ref LL_ADC_AWD_CHANNEL_28_REG_INJ (3)(4)
  1597. * @arg @ref LL_ADC_AWD_CHANNEL_29_REG (3)(4)
  1598. * @arg @ref LL_ADC_AWD_CHANNEL_29_INJ (3)(4)
  1599. * @arg @ref LL_ADC_AWD_CHANNEL_29_REG_INJ (3)(4)
  1600. * @arg @ref LL_ADC_AWD_CHANNEL_30_REG (3)(4)
  1601. * @arg @ref LL_ADC_AWD_CHANNEL_30_INJ (3)(4)
  1602. * @arg @ref LL_ADC_AWD_CHANNEL_30_REG_INJ (3)(4)
  1603. * @arg @ref LL_ADC_AWD_CHANNEL_31_REG (3)(4)
  1604. * @arg @ref LL_ADC_AWD_CHANNEL_31_INJ (3)(4)
  1605. * @arg @ref LL_ADC_AWD_CHANNEL_31_REG_INJ (3)(4)
  1606. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (3)
  1607. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (3)
  1608. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (3)
  1609. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (3)
  1610. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (3)
  1611. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (3)
  1612. * @arg @ref LL_ADC_AWD_CH_VCOMP_REG (3)
  1613. * @arg @ref LL_ADC_AWD_CH_VCOMP_INJ (3)
  1614. * @arg @ref LL_ADC_AWD_CH_VCOMP_REG_INJ (3)
  1615. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG (3)(5)
  1616. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_INJ (3)(5)
  1617. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG_INJ (3)(5)
  1618. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG (3)(5)
  1619. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_INJ (3)(5)
  1620. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG_INJ (3)(5)
  1621. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG (3)(5)
  1622. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_INJ (3)(5)
  1623. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG_INJ (3)(5)
  1624. *
  1625. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  1626. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  1627. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  1628. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  1629. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  1630. */
  1631. #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \
  1632. (((__GROUP__) == LL_ADC_GROUP_REGULAR) \
  1633. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
  1634. : \
  1635. ((__GROUP__) == LL_ADC_GROUP_INJECTED) \
  1636. ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) \
  1637. : \
  1638. (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
  1639. )
  1640. /**
  1641. * @brief Helper macro to set the value of ADC analog watchdog threshold high
  1642. * or low in function of ADC resolution, when ADC resolution is
  1643. * different of 12 bits.
  1644. * @note To be used with function @ref LL_ADC_SetAnalogWDThresholds().
  1645. * Example, with a ADC resolution of 8 bits, to set the value of
  1646. * analog watchdog threshold high (on 8 bits):
  1647. * LL_ADC_SetAnalogWDThresholds
  1648. * (< ADCx param >,
  1649. * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
  1650. * );
  1651. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1652. * @arg @ref LL_ADC_RESOLUTION_12B
  1653. * @arg @ref LL_ADC_RESOLUTION_10B
  1654. * @arg @ref LL_ADC_RESOLUTION_8B
  1655. * @arg @ref LL_ADC_RESOLUTION_6B
  1656. * @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1657. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1658. */
  1659. #define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
  1660. ((__AWD_THRESHOLD__) << ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U )))
  1661. /**
  1662. * @brief Helper macro to get the value of ADC analog watchdog threshold high
  1663. * or low in function of ADC resolution, when ADC resolution is
  1664. * different of 12 bits.
  1665. * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
  1666. * Example, with a ADC resolution of 8 bits, to get the value of
  1667. * analog watchdog threshold high (on 8 bits):
  1668. * < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
  1669. * (LL_ADC_RESOLUTION_8B,
  1670. * LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
  1671. * );
  1672. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1673. * @arg @ref LL_ADC_RESOLUTION_12B
  1674. * @arg @ref LL_ADC_RESOLUTION_10B
  1675. * @arg @ref LL_ADC_RESOLUTION_8B
  1676. * @arg @ref LL_ADC_RESOLUTION_6B
  1677. * @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
  1678. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1679. */
  1680. #define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
  1681. ((__AWD_THRESHOLD_12_BITS__) >> ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U )))
  1682. /**
  1683. * @brief Helper macro to select the ADC common instance
  1684. * to which is belonging the selected ADC instance.
  1685. * @note ADC common register instance can be used for:
  1686. * - Set parameters common to several ADC instances
  1687. * - Multimode (for devices with several ADC instances)
  1688. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  1689. * @param __ADCx__ ADC instance
  1690. * @retval ADC common register instance
  1691. */
  1692. #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
  1693. (ADC1_COMMON)
  1694. /**
  1695. * @brief Helper macro to check if all ADC instances sharing the same
  1696. * ADC common instance are disabled.
  1697. * @note This check is required by functions with setting conditioned to
  1698. * ADC state:
  1699. * All ADC instances of the ADC common group must be disabled.
  1700. * Refer to functions having argument "ADCxy_COMMON" as parameter.
  1701. * @note On devices with only 1 ADC common instance, parameter of this macro
  1702. * is useless and can be ignored (parameter kept for compatibility
  1703. * with devices featuring several ADC common instances).
  1704. * @param __ADCXY_COMMON__ ADC common instance
  1705. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1706. * @retval Value "0" if all ADC instances sharing the same ADC common instance
  1707. * are disabled.
  1708. * Value "1" if at least one ADC instance sharing the same ADC common instance
  1709. * is enabled.
  1710. */
  1711. #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
  1712. LL_ADC_IsEnabled(ADC1)
  1713. /**
  1714. * @brief Helper macro to define the ADC conversion data full-scale digital
  1715. * value corresponding to the selected ADC resolution.
  1716. * @note ADC conversion data full-scale corresponds to voltage range
  1717. * determined by analog voltage references Vref+ and Vref-
  1718. * (refer to reference manual).
  1719. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1720. * @arg @ref LL_ADC_RESOLUTION_12B
  1721. * @arg @ref LL_ADC_RESOLUTION_10B
  1722. * @arg @ref LL_ADC_RESOLUTION_8B
  1723. * @arg @ref LL_ADC_RESOLUTION_6B
  1724. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  1725. */
  1726. #define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  1727. (0xFFFU >> ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U)))
  1728. /**
  1729. * @brief Helper macro to convert the ADC conversion data from
  1730. * a resolution to another resolution.
  1731. * @param __DATA__ ADC conversion data to be converted
  1732. * @param __ADC_RESOLUTION_CURRENT__ Resolution of to the data to be converted
  1733. * This parameter can be one of the following values:
  1734. * @arg @ref LL_ADC_RESOLUTION_12B
  1735. * @arg @ref LL_ADC_RESOLUTION_10B
  1736. * @arg @ref LL_ADC_RESOLUTION_8B
  1737. * @arg @ref LL_ADC_RESOLUTION_6B
  1738. * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
  1739. * This parameter can be one of the following values:
  1740. * @arg @ref LL_ADC_RESOLUTION_12B
  1741. * @arg @ref LL_ADC_RESOLUTION_10B
  1742. * @arg @ref LL_ADC_RESOLUTION_8B
  1743. * @arg @ref LL_ADC_RESOLUTION_6B
  1744. * @retval ADC conversion data to the requested resolution
  1745. */
  1746. #define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__, __ADC_RESOLUTION_CURRENT__, __ADC_RESOLUTION_TARGET__) \
  1747. (((__DATA__) \
  1748. << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U))) \
  1749. >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U)) \
  1750. )
  1751. /**
  1752. * @brief Helper macro to calculate the voltage (unit: mVolt)
  1753. * corresponding to a ADC conversion data (unit: digital value).
  1754. * @note Analog reference voltage (Vref+) must be either known from
  1755. * user board environment or can be calculated using ADC measurement
  1756. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1757. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  1758. * @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
  1759. * (unit: digital value).
  1760. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1761. * @arg @ref LL_ADC_RESOLUTION_12B
  1762. * @arg @ref LL_ADC_RESOLUTION_10B
  1763. * @arg @ref LL_ADC_RESOLUTION_8B
  1764. * @arg @ref LL_ADC_RESOLUTION_6B
  1765. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  1766. */
  1767. #define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
  1768. __ADC_DATA__,\
  1769. __ADC_RESOLUTION__) \
  1770. ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) \
  1771. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
  1772. )
  1773. /**
  1774. * @brief Helper macro to calculate analog reference voltage (Vref+)
  1775. * (unit: mVolt) from ADC conversion data of internal voltage
  1776. * reference VrefInt.
  1777. * @note Computation is using VrefInt calibration value
  1778. * stored in system memory for each device during production.
  1779. * @note This voltage depends on user board environment: voltage level
  1780. * connected to pin Vref+.
  1781. * On devices with small package, the pin Vref+ is not present
  1782. * and internally bonded to pin Vdda.
  1783. * @note On this STM32 serie, calibration data of internal voltage reference
  1784. * VrefInt corresponds to a resolution of 12 bits,
  1785. * this is the recommended ADC resolution to convert voltage of
  1786. * internal voltage reference VrefInt.
  1787. * Otherwise, this macro performs the processing to scale
  1788. * ADC conversion data to 12 bits.
  1789. * @param __VREFINT_ADC_DATA__ ADC conversion data (resolution 12 bits)
  1790. * of internal voltage reference VrefInt (unit: digital value).
  1791. * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
  1792. * @arg @ref LL_ADC_RESOLUTION_12B
  1793. * @arg @ref LL_ADC_RESOLUTION_10B
  1794. * @arg @ref LL_ADC_RESOLUTION_8B
  1795. * @arg @ref LL_ADC_RESOLUTION_6B
  1796. * @retval Analog reference voltage (unit: mV)
  1797. */
  1798. #define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,\
  1799. __ADC_RESOLUTION__) \
  1800. (((uint32_t)(*VREFINT_CAL_ADDR) * VREFINT_CAL_VREF) \
  1801. / __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__), \
  1802. (__ADC_RESOLUTION__), \
  1803. LL_ADC_RESOLUTION_12B) \
  1804. )
  1805. /**
  1806. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  1807. * from ADC conversion data of internal temperature sensor.
  1808. * @note Computation is using temperature sensor calibration values
  1809. * stored in system memory for each device during production.
  1810. * @note Calculation formula:
  1811. * Temperature = ((TS_ADC_DATA - TS_CAL1)
  1812. * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
  1813. * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
  1814. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  1815. * Avg_Slope = (TS_CAL2 - TS_CAL1)
  1816. * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
  1817. * TS_CAL1 = equivalent TS_ADC_DATA at temperature
  1818. * TEMP_DEGC_CAL1 (calibrated in factory)
  1819. * TS_CAL2 = equivalent TS_ADC_DATA at temperature
  1820. * TEMP_DEGC_CAL2 (calibrated in factory)
  1821. * Caution: Calculation relevancy under reserve that calibration
  1822. * parameters are correct (address and data).
  1823. * To calculate temperature using temperature sensor
  1824. * datasheet typical values (generic values less, therefore
  1825. * less accurate than calibrated values),
  1826. * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
  1827. * @note As calculation input, the analog reference voltage (Vref+) must be
  1828. * defined as it impacts the ADC LSB equivalent voltage.
  1829. * @note Analog reference voltage (Vref+) must be either known from
  1830. * user board environment or can be calculated using ADC measurement
  1831. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1832. * @note On this STM32 serie, calibration data of temperature sensor
  1833. * corresponds to a resolution of 12 bits,
  1834. * this is the recommended ADC resolution to convert voltage of
  1835. * temperature sensor.
  1836. * Otherwise, this macro performs the processing to scale
  1837. * ADC conversion data to 12 bits.
  1838. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  1839. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
  1840. * temperature sensor (unit: digital value).
  1841. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
  1842. * sensor voltage has been measured.
  1843. * This parameter can be one of the following values:
  1844. * @arg @ref LL_ADC_RESOLUTION_12B
  1845. * @arg @ref LL_ADC_RESOLUTION_10B
  1846. * @arg @ref LL_ADC_RESOLUTION_8B
  1847. * @arg @ref LL_ADC_RESOLUTION_6B
  1848. * @retval Temperature (unit: degree Celsius)
  1849. */
  1850. #define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
  1851. __TEMPSENSOR_ADC_DATA__,\
  1852. __ADC_RESOLUTION__) \
  1853. (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
  1854. (__ADC_RESOLUTION__), \
  1855. LL_ADC_RESOLUTION_12B) \
  1856. * (__VREFANALOG_VOLTAGE__)) \
  1857. / TEMPSENSOR_CAL_VREFANALOG) \
  1858. - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
  1859. ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
  1860. ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
  1861. ) + TEMPSENSOR_CAL1_TEMP \
  1862. )
  1863. /**
  1864. * @brief Helper macro to calculate the temperature (unit: degree Celsius)
  1865. * from ADC conversion data of internal temperature sensor.
  1866. * @note Computation is using temperature sensor typical values
  1867. * (refer to device datasheet).
  1868. * @note Calculation formula:
  1869. * Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV)
  1870. * / Avg_Slope + CALx_TEMP
  1871. * with TS_ADC_DATA = temperature sensor raw data measured by ADC
  1872. * (unit: digital value)
  1873. * Avg_Slope = temperature sensor slope
  1874. * (unit: uV/Degree Celsius)
  1875. * TS_TYP_CALx_VOLT = temperature sensor digital value at
  1876. * temperature CALx_TEMP (unit: mV)
  1877. * Caution: Calculation relevancy under reserve the temperature sensor
  1878. * of the current device has characteristics in line with
  1879. * datasheet typical values.
  1880. * If temperature sensor calibration values are available on
  1881. * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
  1882. * temperature calculation will be more accurate using
  1883. * helper macro @ref __LL_ADC_CALC_TEMPERATURE().
  1884. * @note As calculation input, the analog reference voltage (Vref+) must be
  1885. * defined as it impacts the ADC LSB equivalent voltage.
  1886. * @note Analog reference voltage (Vref+) must be either known from
  1887. * user board environment or can be calculated using ADC measurement
  1888. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  1889. * @note ADC measurement data must correspond to a resolution of 12bits
  1890. * (full scale digital value 4095). If not the case, the data must be
  1891. * preliminarily rescaled to an equivalent resolution of 12 bits.
  1892. * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius).
  1893. * On STM32L1, refer to device datasheet parameter "Avg_Slope".
  1894. * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV).
  1895. * On STM32L1, refer to device datasheet parameter "V110" (corresponding to TS_CAL2).
  1896. * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: mV)
  1897. * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit: mV)
  1898. * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value).
  1899. * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
  1900. * This parameter can be one of the following values:
  1901. * @arg @ref LL_ADC_RESOLUTION_12B
  1902. * @arg @ref LL_ADC_RESOLUTION_10B
  1903. * @arg @ref LL_ADC_RESOLUTION_8B
  1904. * @arg @ref LL_ADC_RESOLUTION_6B
  1905. * @retval Temperature (unit: degree Celsius)
  1906. */
  1907. #define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
  1908. __TEMPSENSOR_TYP_CALX_V__,\
  1909. __TEMPSENSOR_CALX_TEMP__,\
  1910. __VREFANALOG_VOLTAGE__,\
  1911. __TEMPSENSOR_ADC_DATA__,\
  1912. __ADC_RESOLUTION__) \
  1913. ((( ( \
  1914. (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
  1915. / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
  1916. * 1000) \
  1917. - \
  1918. (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
  1919. * 1000) \
  1920. ) \
  1921. ) / (__TEMPSENSOR_TYP_AVGSLOPE__) \
  1922. ) + (__TEMPSENSOR_CALX_TEMP__) \
  1923. )
  1924. /**
  1925. * @}
  1926. */
  1927. /**
  1928. * @}
  1929. */
  1930. /* Exported functions --------------------------------------------------------*/
  1931. /** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
  1932. * @{
  1933. */
  1934. /** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
  1935. * @{
  1936. */
  1937. /* Note: LL ADC functions to set DMA transfer are located into sections of */
  1938. /* configuration of ADC instance, groups and multimode (if available): */
  1939. /* @ref LL_ADC_REG_SetDMATransfer(), ... */
  1940. /**
  1941. * @brief Function to help to configure DMA transfer from ADC: retrieve the
  1942. * ADC register address from ADC instance and a list of ADC registers
  1943. * intended to be used (most commonly) with DMA transfer.
  1944. * @note These ADC registers are data registers:
  1945. * when ADC conversion data is available in ADC data registers,
  1946. * ADC generates a DMA transfer request.
  1947. * @note This macro is intended to be used with LL DMA driver, refer to
  1948. * function "LL_DMA_ConfigAddresses()".
  1949. * Example:
  1950. * LL_DMA_ConfigAddresses(DMA1,
  1951. * LL_DMA_CHANNEL_1,
  1952. * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
  1953. * (uint32_t)&< array or variable >,
  1954. * LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
  1955. * @note For devices with several ADC: in multimode, some devices
  1956. * use a different data register outside of ADC instance scope
  1957. * (common data register). This macro manages this register difference,
  1958. * only ADC instance has to be set as parameter.
  1959. * @rmtoll DR DATA LL_ADC_DMA_GetRegAddr
  1960. * @param ADCx ADC instance
  1961. * @param Register This parameter can be one of the following values:
  1962. * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
  1963. * @retval ADC register address
  1964. */
  1965. __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
  1966. {
  1967. /* Retrieve address of register DR */
  1968. return (uint32_t)&(ADCx->DR);
  1969. }
  1970. /**
  1971. * @}
  1972. */
  1973. /** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
  1974. * @{
  1975. */
  1976. /**
  1977. * @brief Set parameter common to several ADC: Clock source and prescaler.
  1978. * @note On this STM32 serie, HSI RC oscillator is the only clock source for ADC.
  1979. * Therefore, HSI RC oscillator must be preliminarily enabled at RCC top level.
  1980. * @note On this STM32 serie, some clock ratio constraints between ADC clock and APB clock
  1981. * must be respected:
  1982. * - In all cases: if APB clock frequency is too low compared ADC clock frequency, a delay between conversions must be inserted.
  1983. * - If ADC group injected is used: ADC clock frequency should be lower than APB clock frequency /4 for resolution 12 or 10 bits, APB clock frequency /3 for resolution 8 bits, APB clock frequency /2 for resolution 6 bits.
  1984. * Refer to reference manual.
  1985. * @rmtoll CCR ADCPRE LL_ADC_SetCommonClock
  1986. * @param ADCxy_COMMON ADC common instance
  1987. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  1988. * @param CommonClock This parameter can be one of the following values:
  1989. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
  1990. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2
  1991. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4
  1992. * @retval None
  1993. */
  1994. __STATIC_INLINE void LL_ADC_SetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t CommonClock)
  1995. {
  1996. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_ADCPRE, CommonClock);
  1997. }
  1998. /**
  1999. * @brief Get parameter common to several ADC: Clock source and prescaler.
  2000. * @rmtoll CCR ADCPRE LL_ADC_GetCommonClock
  2001. * @param ADCxy_COMMON ADC common instance
  2002. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2003. * @retval Returned value can be one of the following values:
  2004. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
  2005. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2
  2006. * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4
  2007. */
  2008. __STATIC_INLINE uint32_t LL_ADC_GetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON)
  2009. {
  2010. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_ADCPRE));
  2011. }
  2012. /**
  2013. * @brief Set parameter common to several ADC: measurement path to internal
  2014. * channels (VrefInt, temperature sensor, ...).
  2015. * @note One or several values can be selected.
  2016. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  2017. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  2018. * @note Stabilization time of measurement path to internal channel:
  2019. * After enabling internal paths, before starting ADC conversion,
  2020. * a delay is required for internal voltage reference and
  2021. * temperature sensor stabilization time.
  2022. * Refer to device datasheet.
  2023. * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
  2024. * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
  2025. * @note ADC internal channel sampling time constraint:
  2026. * For ADC conversion of internal channels,
  2027. * a sampling time minimum value is required.
  2028. * Refer to device datasheet.
  2029. * @rmtoll CCR TSVREFE LL_ADC_SetCommonPathInternalCh
  2030. * @param ADCxy_COMMON ADC common instance
  2031. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2032. * @param PathInternal This parameter can be a combination of the following values:
  2033. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  2034. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  2035. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  2036. * @retval None
  2037. */
  2038. __STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
  2039. {
  2040. MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_TSVREFE, PathInternal);
  2041. }
  2042. /**
  2043. * @brief Get parameter common to several ADC: measurement path to internal
  2044. * channels (VrefInt, temperature sensor, ...).
  2045. * @note One or several values can be selected.
  2046. * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
  2047. * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
  2048. * @rmtoll CCR TSVREFE LL_ADC_GetCommonPathInternalCh
  2049. * @param ADCxy_COMMON ADC common instance
  2050. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
  2051. * @retval Returned value can be a combination of the following values:
  2052. * @arg @ref LL_ADC_PATH_INTERNAL_NONE
  2053. * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
  2054. * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
  2055. */
  2056. __STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
  2057. {
  2058. return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_TSVREFE));
  2059. }
  2060. /**
  2061. * @}
  2062. */
  2063. /** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
  2064. * @{
  2065. */
  2066. /**
  2067. * @brief Set ADC resolution.
  2068. * Refer to reference manual for alignments formats
  2069. * dependencies to ADC resolutions.
  2070. * @rmtoll CR1 RES LL_ADC_SetResolution
  2071. * @param ADCx ADC instance
  2072. * @param Resolution This parameter can be one of the following values:
  2073. * @arg @ref LL_ADC_RESOLUTION_12B
  2074. * @arg @ref LL_ADC_RESOLUTION_10B
  2075. * @arg @ref LL_ADC_RESOLUTION_8B
  2076. * @arg @ref LL_ADC_RESOLUTION_6B
  2077. * @retval None
  2078. */
  2079. __STATIC_INLINE void LL_ADC_SetResolution(ADC_TypeDef *ADCx, uint32_t Resolution)
  2080. {
  2081. MODIFY_REG(ADCx->CR1, ADC_CR1_RES, Resolution);
  2082. }
  2083. /**
  2084. * @brief Get ADC resolution.
  2085. * Refer to reference manual for alignments formats
  2086. * dependencies to ADC resolutions.
  2087. * @rmtoll CR1 RES LL_ADC_GetResolution
  2088. * @param ADCx ADC instance
  2089. * @retval Returned value can be one of the following values:
  2090. * @arg @ref LL_ADC_RESOLUTION_12B
  2091. * @arg @ref LL_ADC_RESOLUTION_10B
  2092. * @arg @ref LL_ADC_RESOLUTION_8B
  2093. * @arg @ref LL_ADC_RESOLUTION_6B
  2094. */
  2095. __STATIC_INLINE uint32_t LL_ADC_GetResolution(ADC_TypeDef *ADCx)
  2096. {
  2097. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_RES));
  2098. }
  2099. /**
  2100. * @brief Set ADC conversion data alignment.
  2101. * @note Refer to reference manual for alignments formats
  2102. * dependencies to ADC resolutions.
  2103. * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
  2104. * @param ADCx ADC instance
  2105. * @param DataAlignment This parameter can be one of the following values:
  2106. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  2107. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  2108. * @retval None
  2109. */
  2110. __STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
  2111. {
  2112. MODIFY_REG(ADCx->CR2, ADC_CR2_ALIGN, DataAlignment);
  2113. }
  2114. /**
  2115. * @brief Get ADC conversion data alignment.
  2116. * @note Refer to reference manual for alignments formats
  2117. * dependencies to ADC resolutions.
  2118. * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
  2119. * @param ADCx ADC instance
  2120. * @retval Returned value can be one of the following values:
  2121. * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
  2122. * @arg @ref LL_ADC_DATA_ALIGN_LEFT
  2123. */
  2124. __STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
  2125. {
  2126. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_ALIGN));
  2127. }
  2128. /**
  2129. * @brief Set ADC low power mode auto wait.
  2130. * @note Description of ADC low power modes:
  2131. * - ADC low power mode "auto wait": Dynamic low power mode,
  2132. * ADC conversions occurrences are limited to the minimum necessary
  2133. * in order to reduce power consumption.
  2134. * New ADC conversion starts only when the previous
  2135. * unitary conversion data (for ADC group regular)
  2136. * or previous sequence conversions data (for ADC group injected)
  2137. * has been retrieved by user software.
  2138. * In the meantime, ADC remains idle: does not performs any
  2139. * other conversion.
  2140. * This mode allows to automatically adapt the ADC conversions
  2141. * triggers to the speed of the software that reads the data.
  2142. * Moreover, this avoids risk of overrun for low frequency
  2143. * applications.
  2144. * How to use this low power mode:
  2145. * - Do not use with interruption or DMA since these modes
  2146. * have to clear immediately the EOC flag to free the
  2147. * IRQ vector sequencer.
  2148. * - Do use with polling: 1. Start conversion,
  2149. * 2. Later on, when conversion data is needed: poll for end of
  2150. * conversion to ensure that conversion is completed and
  2151. * retrieve ADC conversion data. This will trig another
  2152. * ADC conversion start.
  2153. * - ADC low power mode "auto power-off":
  2154. * refer to function @ref LL_ADC_SetLowPowerModeAutoPowerOff().
  2155. * @note With ADC low power mode "auto wait", the ADC conversion data read
  2156. * is corresponding to previous ADC conversion start, independently
  2157. * of delay during which ADC was idle.
  2158. * Therefore, the ADC conversion data may be outdated: does not
  2159. * correspond to the current voltage level on the selected
  2160. * ADC channel.
  2161. * @rmtoll CR2 DELS LL_ADC_SetLowPowerModeAutoWait
  2162. * @param ADCx ADC instance
  2163. * @param LowPowerModeAutoWait This parameter can be one of the following values:
  2164. * @arg @ref LL_ADC_LP_AUTOWAIT_NONE
  2165. * @arg @ref LL_ADC_LP_AUTOWAIT
  2166. * @arg @ref LL_ADC_LP_AUTOWAIT_7_APBCLOCKCYCLES
  2167. * @arg @ref LL_ADC_LP_AUTOWAIT_15_APBCLOCKCYCLES
  2168. * @arg @ref LL_ADC_LP_AUTOWAIT_31_APBCLOCKCYCLES
  2169. * @arg @ref LL_ADC_LP_AUTOWAIT_63_APBCLOCKCYCLES
  2170. * @arg @ref LL_ADC_LP_AUTOWAIT_127_APBCLOCKCYCLES
  2171. * @arg @ref LL_ADC_LP_AUTOWAIT_255_APBCLOCKCYCLES
  2172. * @retval None
  2173. */
  2174. __STATIC_INLINE void LL_ADC_SetLowPowerModeAutoWait(ADC_TypeDef *ADCx, uint32_t LowPowerModeAutoWait)
  2175. {
  2176. MODIFY_REG(ADCx->CR2, ADC_CR2_DELS, LowPowerModeAutoWait);
  2177. }
  2178. /**
  2179. * @brief Get ADC low power mode auto wait.
  2180. * @note Description of ADC low power modes:
  2181. * - ADC low power mode "auto wait": Dynamic low power mode,
  2182. * ADC conversions occurrences are limited to the minimum necessary
  2183. * in order to reduce power consumption.
  2184. * New ADC conversion starts only when the previous
  2185. * unitary conversion data (for ADC group regular)
  2186. * or previous sequence conversions data (for ADC group injected)
  2187. * has been retrieved by user software.
  2188. * In the meantime, ADC remains idle: does not performs any
  2189. * other conversion.
  2190. * This mode allows to automatically adapt the ADC conversions
  2191. * triggers to the speed of the software that reads the data.
  2192. * Moreover, this avoids risk of overrun for low frequency
  2193. * applications.
  2194. * How to use this low power mode:
  2195. * - Do not use with interruption or DMA since these modes
  2196. * have to clear immediately the EOC flag to free the
  2197. * IRQ vector sequencer.
  2198. * - Do use with polling: 1. Start conversion,
  2199. * 2. Later on, when conversion data is needed: poll for end of
  2200. * conversion to ensure that conversion is completed and
  2201. * retrieve ADC conversion data. This will trig another
  2202. * ADC conversion start.
  2203. * - ADC low power mode "auto power-off":
  2204. * refer to function @ref LL_ADC_SetLowPowerModeAutoPowerOff().
  2205. * @note With ADC low power mode "auto wait", the ADC conversion data read
  2206. * is corresponding to previous ADC conversion start, independently
  2207. * of delay during which ADC was idle.
  2208. * Therefore, the ADC conversion data may be outdated: does not
  2209. * correspond to the current voltage level on the selected
  2210. * ADC channel.
  2211. * @rmtoll CR2 DELS LL_ADC_GetLowPowerModeAutoWait
  2212. * @param ADCx ADC instance
  2213. * @retval Returned value can be one of the following values:
  2214. * @arg @ref LL_ADC_LP_AUTOWAIT_NONE
  2215. * @arg @ref LL_ADC_LP_AUTOWAIT
  2216. * @arg @ref LL_ADC_LP_AUTOWAIT_7_APBCLOCKCYCLES
  2217. * @arg @ref LL_ADC_LP_AUTOWAIT_15_APBCLOCKCYCLES
  2218. * @arg @ref LL_ADC_LP_AUTOWAIT_31_APBCLOCKCYCLES
  2219. * @arg @ref LL_ADC_LP_AUTOWAIT_63_APBCLOCKCYCLES
  2220. * @arg @ref LL_ADC_LP_AUTOWAIT_127_APBCLOCKCYCLES
  2221. * @arg @ref LL_ADC_LP_AUTOWAIT_255_APBCLOCKCYCLES
  2222. */
  2223. __STATIC_INLINE uint32_t LL_ADC_GetLowPowerModeAutoWait(ADC_TypeDef *ADCx)
  2224. {
  2225. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_DELS));
  2226. }
  2227. /**
  2228. * @brief Set ADC low power mode auto power-off.
  2229. * @note Description of ADC low power modes:
  2230. * - ADC low power mode "auto wait":
  2231. * refer to function @ref LL_ADC_SetLowPowerModeAutoWait().
  2232. * - ADC low power mode "auto power-off":
  2233. * the ADC automatically powers-off after a conversion and
  2234. * automatically wakes up when a new conversion is triggered
  2235. * (with startup time between trigger and start of sampling).
  2236. * This feature can be combined with low power mode "auto wait".
  2237. * @rmtoll CR1 PDI LL_ADC_GetLowPowerModeAutoPowerOff\n
  2238. * CR1 PDD LL_ADC_GetLowPowerModeAutoPowerOff
  2239. * @param ADCx ADC instance
  2240. * @param LowPowerModeAutoPowerOff This parameter can be one of the following values:
  2241. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_NONE
  2242. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_PHASE
  2243. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_AUTOWAIT_PHASE
  2244. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_AUTOWAIT_PHASES
  2245. * @retval None
  2246. */
  2247. __STATIC_INLINE void LL_ADC_SetLowPowerModeAutoPowerOff(ADC_TypeDef *ADCx, uint32_t LowPowerModeAutoPowerOff)
  2248. {
  2249. MODIFY_REG(ADCx->CR1, (ADC_CR1_PDI | ADC_CR1_PDD), LowPowerModeAutoPowerOff);
  2250. }
  2251. /**
  2252. * @brief Get ADC low power mode auto power-off.
  2253. * @note Description of ADC low power modes:
  2254. * - ADC low power mode "auto wait":
  2255. * refer to function @ref LL_ADC_SetLowPowerModeAutoWait().
  2256. * - ADC low power mode "auto power-off":
  2257. * the ADC automatically powers-off after a conversion and
  2258. * automatically wakes up when a new conversion is triggered
  2259. * (with startup time between trigger and start of sampling).
  2260. * This feature can be combined with low power mode "auto wait".
  2261. * @rmtoll CR1 PDI LL_ADC_GetLowPowerModeAutoPowerOff\n
  2262. * CR1 PDD LL_ADC_GetLowPowerModeAutoPowerOff
  2263. * @param ADCx ADC instance
  2264. * @retval Returned value can be one of the following values:
  2265. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_NONE
  2266. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_PHASE
  2267. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_AUTOWAIT_PHASE
  2268. * @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_AUTOWAIT_PHASES
  2269. */
  2270. __STATIC_INLINE uint32_t LL_ADC_GetLowPowerModeAutoPowerOff(ADC_TypeDef *ADCx)
  2271. {
  2272. return (uint32_t)(READ_BIT(ADCx->CR1, (ADC_CR1_PDI | ADC_CR1_PDD)));
  2273. }
  2274. /**
  2275. * @brief Set ADC sequencers scan mode, for all ADC groups
  2276. * (group regular, group injected).
  2277. * @note According to sequencers scan mode :
  2278. * - If disabled: ADC conversion is performed in unitary conversion
  2279. * mode (one channel converted, that defined in rank 1).
  2280. * Configuration of sequencers of all ADC groups
  2281. * (sequencer scan length, ...) is discarded: equivalent to
  2282. * scan length of 1 rank.
  2283. * - If enabled: ADC conversions are performed in sequence conversions
  2284. * mode, according to configuration of sequencers of
  2285. * each ADC group (sequencer scan length, ...).
  2286. * Refer to function @ref LL_ADC_REG_SetSequencerLength()
  2287. * and to function @ref LL_ADC_INJ_SetSequencerLength().
  2288. * @note On this STM32 serie, setting of this feature is conditioned to
  2289. * ADC state:
  2290. * ADC must be disabled or enabled without conversion on going
  2291. * on either groups regular or injected.
  2292. * @rmtoll CR1 SCAN LL_ADC_SetSequencersScanMode
  2293. * @param ADCx ADC instance
  2294. * @param ScanMode This parameter can be one of the following values:
  2295. * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
  2296. * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
  2297. * @retval None
  2298. */
  2299. __STATIC_INLINE void LL_ADC_SetSequencersScanMode(ADC_TypeDef *ADCx, uint32_t ScanMode)
  2300. {
  2301. MODIFY_REG(ADCx->CR1, ADC_CR1_SCAN, ScanMode);
  2302. }
  2303. /**
  2304. * @brief Get ADC sequencers scan mode, for all ADC groups
  2305. * (group regular, group injected).
  2306. * @note According to sequencers scan mode :
  2307. * - If disabled: ADC conversion is performed in unitary conversion
  2308. * mode (one channel converted, that defined in rank 1).
  2309. * Configuration of sequencers of all ADC groups
  2310. * (sequencer scan length, ...) is discarded: equivalent to
  2311. * scan length of 1 rank.
  2312. * - If enabled: ADC conversions are performed in sequence conversions
  2313. * mode, according to configuration of sequencers of
  2314. * each ADC group (sequencer scan length, ...).
  2315. * Refer to function @ref LL_ADC_REG_SetSequencerLength()
  2316. * and to function @ref LL_ADC_INJ_SetSequencerLength().
  2317. * @rmtoll CR1 SCAN LL_ADC_GetSequencersScanMode
  2318. * @param ADCx ADC instance
  2319. * @retval Returned value can be one of the following values:
  2320. * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
  2321. * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
  2322. */
  2323. __STATIC_INLINE uint32_t LL_ADC_GetSequencersScanMode(ADC_TypeDef *ADCx)
  2324. {
  2325. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_SCAN));
  2326. }
  2327. #if defined(ADC_CR2_CFG)
  2328. /**
  2329. * @brief Set ADC channels bank.
  2330. * @note Bank selected applies to ADC scope, on all channels
  2331. * (independently of channel mapped on ADC group regular
  2332. * or group injected).
  2333. * @note Banks availability depends on devices categories.
  2334. * @note On this STM32 serie, setting of this feature is conditioned to
  2335. * ADC state:
  2336. * ADC must be disabled or enabled without conversion on going
  2337. * on either groups regular or injected.
  2338. * @rmtoll CR2 ADC_CFG LL_ADC_SetChannelsBank
  2339. * @param ADCx ADC instance
  2340. * @param ChannelsBank This parameter can be one of the following values:
  2341. * @arg @ref LL_ADC_CHANNELS_BANK_A
  2342. * @arg @ref LL_ADC_CHANNELS_BANK_B
  2343. * @retval None
  2344. */
  2345. __STATIC_INLINE void LL_ADC_SetChannelsBank(ADC_TypeDef *ADCx, uint32_t ChannelsBank)
  2346. {
  2347. MODIFY_REG(ADCx->CR2, ADC_CR2_CFG, ChannelsBank);
  2348. }
  2349. /**
  2350. * @brief Get ADC channels bank.
  2351. * @note Bank selected applies to ADC scope, on all channels
  2352. * (independently of channel mapped on ADC group regular
  2353. * or group injected).
  2354. * @note Banks availability depends on devices categories.
  2355. * @rmtoll CR2 ADC_CFG LL_ADC_GetChannelsBank
  2356. * @param ADCx ADC instance
  2357. * @retval Returned value can be one of the following values:
  2358. * @arg @ref LL_ADC_CHANNELS_BANK_A
  2359. * @arg @ref LL_ADC_CHANNELS_BANK_B
  2360. */
  2361. __STATIC_INLINE uint32_t LL_ADC_GetChannelsBank(ADC_TypeDef *ADCx)
  2362. {
  2363. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_CFG));
  2364. }
  2365. #endif
  2366. /**
  2367. * @}
  2368. */
  2369. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
  2370. * @{
  2371. */
  2372. /**
  2373. * @brief Set ADC group regular conversion trigger source:
  2374. * internal (SW start) or from external IP (timer event,
  2375. * external interrupt line).
  2376. * @note On this STM32 serie, setting of external trigger edge is performed
  2377. * using function @ref LL_ADC_REG_StartConversionExtTrig().
  2378. * @note Availability of parameters of trigger sources from timer
  2379. * depends on timers availability on the selected device.
  2380. * @rmtoll CR2 EXTSEL LL_ADC_REG_SetTriggerSource\n
  2381. * CR2 EXTEN LL_ADC_REG_SetTriggerSource
  2382. * @param ADCx ADC instance
  2383. * @param TriggerSource This parameter can be one of the following values:
  2384. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  2385. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
  2386. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3
  2387. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  2388. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  2389. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1
  2390. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH3
  2391. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO
  2392. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4
  2393. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO
  2394. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_CH2
  2395. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_TRGO
  2396. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  2397. * @retval None
  2398. */
  2399. __STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  2400. {
  2401. /* Note: On this STM32 serie, ADC group regular external trigger edge */
  2402. /* is used to perform a ADC conversion start. */
  2403. /* This function does not set external trigger edge. */
  2404. /* This feature is set using function */
  2405. /* @ref LL_ADC_REG_StartConversionExtTrig(). */
  2406. MODIFY_REG(ADCx->CR2, ADC_CR2_EXTSEL, (TriggerSource & ADC_CR2_EXTSEL));
  2407. }
  2408. /**
  2409. * @brief Get ADC group regular conversion trigger source:
  2410. * internal (SW start) or from external IP (timer event,
  2411. * external interrupt line).
  2412. * @note To determine whether group regular trigger source is
  2413. * internal (SW start) or external, without detail
  2414. * of which peripheral is selected as external trigger,
  2415. * (equivalent to
  2416. * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
  2417. * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
  2418. * @note Availability of parameters of trigger sources from timer
  2419. * depends on timers availability on the selected device.
  2420. * @rmtoll CR2 EXTSEL LL_ADC_REG_GetTriggerSource\n
  2421. * CR2 EXTEN LL_ADC_REG_GetTriggerSource
  2422. * @param ADCx ADC instance
  2423. * @retval Returned value can be one of the following values:
  2424. * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
  2425. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
  2426. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3
  2427. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
  2428. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
  2429. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1
  2430. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH3
  2431. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO
  2432. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4
  2433. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO
  2434. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_CH2
  2435. * @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_TRGO
  2436. * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
  2437. */
  2438. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
  2439. {
  2440. uint32_t TriggerSource = READ_BIT(ADCx->CR2, ADC_CR2_EXTSEL | ADC_CR2_EXTEN);
  2441. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  2442. /* corresponding to ADC_CR2_EXTEN {0; 1; 2; 3}. */
  2443. uint32_t ShiftExten = ((TriggerSource & ADC_CR2_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2U));
  2444. /* Set bitfield corresponding to ADC_CR2_EXTEN and ADC_CR2_EXTSEL */
  2445. /* to match with triggers literals definition. */
  2446. return ((TriggerSource
  2447. & (ADC_REG_TRIG_SOURCE_MASK << ShiftExten) & ADC_CR2_EXTSEL)
  2448. | ((ADC_REG_TRIG_EDGE_MASK << ShiftExten) & ADC_CR2_EXTEN)
  2449. );
  2450. }
  2451. /**
  2452. * @brief Get ADC group regular conversion trigger source internal (SW start)
  2453. or external.
  2454. * @note In case of group regular trigger source set to external trigger,
  2455. * to determine which peripheral is selected as external trigger,
  2456. * use function @ref LL_ADC_REG_GetTriggerSource().
  2457. * @rmtoll CR2 EXTEN LL_ADC_REG_IsTriggerSourceSWStart
  2458. * @param ADCx ADC instance
  2459. * @retval Value "0" if trigger source external trigger
  2460. * Value "1" if trigger source SW start.
  2461. */
  2462. __STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  2463. {
  2464. return (READ_BIT(ADCx->CR2, ADC_CR2_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTEN));
  2465. }
  2466. /**
  2467. * @brief Get ADC group regular conversion trigger polarity.
  2468. * @note Applicable only for trigger source set to external trigger.
  2469. * @note On this STM32 serie, setting of external trigger edge is performed
  2470. * using function @ref LL_ADC_REG_StartConversionExtTrig().
  2471. * @rmtoll CR2 EXTEN LL_ADC_REG_GetTriggerEdge
  2472. * @param ADCx ADC instance
  2473. * @retval Returned value can be one of the following values:
  2474. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  2475. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  2476. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  2477. */
  2478. __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerEdge(ADC_TypeDef *ADCx)
  2479. {
  2480. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_EXTEN));
  2481. }
  2482. /**
  2483. * @brief Set ADC group regular sequencer length and scan direction.
  2484. * @note Description of ADC group regular sequencer features:
  2485. * - For devices with sequencer fully configurable
  2486. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  2487. * sequencer length and each rank affectation to a channel
  2488. * are configurable.
  2489. * This function performs configuration of:
  2490. * - Sequence length: Number of ranks in the scan sequence.
  2491. * - Sequence direction: Unless specified in parameters, sequencer
  2492. * scan direction is forward (from rank 1 to rank n).
  2493. * Sequencer ranks are selected using
  2494. * function "LL_ADC_REG_SetSequencerRanks()".
  2495. * - For devices with sequencer not fully configurable
  2496. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  2497. * sequencer length and each rank affectation to a channel
  2498. * are defined by channel number.
  2499. * This function performs configuration of:
  2500. * - Sequence length: Number of ranks in the scan sequence is
  2501. * defined by number of channels set in the sequence,
  2502. * rank of each channel is fixed by channel HW number.
  2503. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  2504. * - Sequence direction: Unless specified in parameters, sequencer
  2505. * scan direction is forward (from lowest channel number to
  2506. * highest channel number).
  2507. * Sequencer ranks are selected using
  2508. * function "LL_ADC_REG_SetSequencerChannels()".
  2509. * @note On this STM32 serie, group regular sequencer configuration
  2510. * is conditioned to ADC instance sequencer mode.
  2511. * If ADC instance sequencer mode is disabled, sequencers of
  2512. * all groups (group regular, group injected) can be configured
  2513. * but their execution is disabled (limited to rank 1).
  2514. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  2515. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  2516. * ADC conversion on only 1 channel.
  2517. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  2518. * @param ADCx ADC instance
  2519. * @param SequencerNbRanks This parameter can be one of the following values:
  2520. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  2521. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  2522. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  2523. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  2524. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  2525. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  2526. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  2527. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  2528. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  2529. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  2530. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  2531. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  2532. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  2533. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  2534. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  2535. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  2536. * @retval None
  2537. */
  2538. __STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  2539. {
  2540. MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks);
  2541. }
  2542. /**
  2543. * @brief Get ADC group regular sequencer length and scan direction.
  2544. * @note Description of ADC group regular sequencer features:
  2545. * - For devices with sequencer fully configurable
  2546. * (function "LL_ADC_REG_SetSequencerRanks()" available):
  2547. * sequencer length and each rank affectation to a channel
  2548. * are configurable.
  2549. * This function retrieves:
  2550. * - Sequence length: Number of ranks in the scan sequence.
  2551. * - Sequence direction: Unless specified in parameters, sequencer
  2552. * scan direction is forward (from rank 1 to rank n).
  2553. * Sequencer ranks are selected using
  2554. * function "LL_ADC_REG_SetSequencerRanks()".
  2555. * - For devices with sequencer not fully configurable
  2556. * (function "LL_ADC_REG_SetSequencerChannels()" available):
  2557. * sequencer length and each rank affectation to a channel
  2558. * are defined by channel number.
  2559. * This function retrieves:
  2560. * - Sequence length: Number of ranks in the scan sequence is
  2561. * defined by number of channels set in the sequence,
  2562. * rank of each channel is fixed by channel HW number.
  2563. * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
  2564. * - Sequence direction: Unless specified in parameters, sequencer
  2565. * scan direction is forward (from lowest channel number to
  2566. * highest channel number).
  2567. * Sequencer ranks are selected using
  2568. * function "LL_ADC_REG_SetSequencerChannels()".
  2569. * @note On this STM32 serie, group regular sequencer configuration
  2570. * is conditioned to ADC instance sequencer mode.
  2571. * If ADC instance sequencer mode is disabled, sequencers of
  2572. * all groups (group regular, group injected) can be configured
  2573. * but their execution is disabled (limited to rank 1).
  2574. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  2575. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  2576. * ADC conversion on only 1 channel.
  2577. * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
  2578. * @param ADCx ADC instance
  2579. * @retval Returned value can be one of the following values:
  2580. * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
  2581. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
  2582. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
  2583. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
  2584. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
  2585. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
  2586. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
  2587. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
  2588. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
  2589. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
  2590. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
  2591. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
  2592. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
  2593. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
  2594. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
  2595. * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
  2596. */
  2597. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerLength(ADC_TypeDef *ADCx)
  2598. {
  2599. return (uint32_t)(READ_BIT(ADCx->SQR1, ADC_SQR1_L));
  2600. }
  2601. /**
  2602. * @brief Set ADC group regular sequencer discontinuous mode:
  2603. * sequence subdivided and scan conversions interrupted every selected
  2604. * number of ranks.
  2605. * @note It is not possible to enable both ADC group regular
  2606. * continuous mode and sequencer discontinuous mode.
  2607. * @note It is not possible to enable both ADC auto-injected mode
  2608. * and ADC group regular sequencer discontinuous mode.
  2609. * @rmtoll CR1 DISCEN LL_ADC_REG_SetSequencerDiscont\n
  2610. * CR1 DISCNUM LL_ADC_REG_SetSequencerDiscont
  2611. * @param ADCx ADC instance
  2612. * @param SeqDiscont This parameter can be one of the following values:
  2613. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  2614. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  2615. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  2616. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  2617. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  2618. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  2619. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  2620. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  2621. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  2622. * @retval None
  2623. */
  2624. __STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  2625. {
  2626. MODIFY_REG(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM, SeqDiscont);
  2627. }
  2628. /**
  2629. * @brief Get ADC group regular sequencer discontinuous mode:
  2630. * sequence subdivided and scan conversions interrupted every selected
  2631. * number of ranks.
  2632. * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont\n
  2633. * CR1 DISCNUM LL_ADC_REG_GetSequencerDiscont
  2634. * @param ADCx ADC instance
  2635. * @retval Returned value can be one of the following values:
  2636. * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
  2637. * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
  2638. * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
  2639. * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
  2640. * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
  2641. * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
  2642. * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
  2643. * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
  2644. * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
  2645. */
  2646. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
  2647. {
  2648. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM));
  2649. }
  2650. /**
  2651. * @brief Set ADC group regular sequence: channel on the selected
  2652. * scan sequence rank.
  2653. * @note This function performs configuration of:
  2654. * - Channels ordering into each rank of scan sequence:
  2655. * whatever channel can be placed into whatever rank.
  2656. * @note On this STM32 serie, ADC group regular sequencer is
  2657. * fully configurable: sequencer length and each rank
  2658. * affectation to a channel are configurable.
  2659. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  2660. * @note Depending on devices and packages, some channels may not be available.
  2661. * Refer to device datasheet for channels availability.
  2662. * @note On this STM32 serie, to measure internal channels (VrefInt,
  2663. * TempSensor, ...), measurement paths to internal channels must be
  2664. * enabled separately.
  2665. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  2666. * @rmtoll SQR5 SQ1 LL_ADC_REG_SetSequencerRanks\n
  2667. * SQR5 SQ2 LL_ADC_REG_SetSequencerRanks\n
  2668. * SQR5 SQ3 LL_ADC_REG_SetSequencerRanks\n
  2669. * SQR5 SQ4 LL_ADC_REG_SetSequencerRanks\n
  2670. * SQR5 SQ5 LL_ADC_REG_SetSequencerRanks\n
  2671. * SQR5 SQ6 LL_ADC_REG_SetSequencerRanks\n
  2672. * SQR4 SQ7 LL_ADC_REG_SetSequencerRanks\n
  2673. * SQR4 SQ8 LL_ADC_REG_SetSequencerRanks\n
  2674. * SQR4 SQ9 LL_ADC_REG_SetSequencerRanks\n
  2675. * SQR4 SQ10 LL_ADC_REG_SetSequencerRanks\n
  2676. * SQR4 SQ11 LL_ADC_REG_SetSequencerRanks\n
  2677. * SQR4 SQ12 LL_ADC_REG_SetSequencerRanks\n
  2678. * SQR3 SQ13 LL_ADC_REG_SetSequencerRanks\n
  2679. * SQR3 SQ14 LL_ADC_REG_SetSequencerRanks\n
  2680. * SQR3 SQ15 LL_ADC_REG_SetSequencerRanks\n
  2681. * SQR3 SQ16 LL_ADC_REG_SetSequencerRanks\n
  2682. * SQR3 SQ17 LL_ADC_REG_SetSequencerRanks\n
  2683. * SQR3 SQ18 LL_ADC_REG_SetSequencerRanks\n
  2684. * SQR2 SQ19 LL_ADC_REG_SetSequencerRanks\n
  2685. * SQR2 SQ20 LL_ADC_REG_SetSequencerRanks\n
  2686. * SQR2 SQ21 LL_ADC_REG_SetSequencerRanks\n
  2687. * SQR2 SQ22 LL_ADC_REG_SetSequencerRanks\n
  2688. * SQR2 SQ23 LL_ADC_REG_SetSequencerRanks\n
  2689. * SQR2 SQ24 LL_ADC_REG_SetSequencerRanks\n
  2690. * SQR1 SQ25 LL_ADC_REG_SetSequencerRanks\n
  2691. * SQR1 SQ26 LL_ADC_REG_SetSequencerRanks\n
  2692. * SQR1 SQ27 LL_ADC_REG_SetSequencerRanks\n
  2693. * SQR1 SQ28 LL_ADC_REG_SetSequencerRanks
  2694. * @param ADCx ADC instance
  2695. * @param Rank This parameter can be one of the following values:
  2696. * @arg @ref LL_ADC_REG_RANK_1
  2697. * @arg @ref LL_ADC_REG_RANK_2
  2698. * @arg @ref LL_ADC_REG_RANK_3
  2699. * @arg @ref LL_ADC_REG_RANK_4
  2700. * @arg @ref LL_ADC_REG_RANK_5
  2701. * @arg @ref LL_ADC_REG_RANK_6
  2702. * @arg @ref LL_ADC_REG_RANK_7
  2703. * @arg @ref LL_ADC_REG_RANK_8
  2704. * @arg @ref LL_ADC_REG_RANK_9
  2705. * @arg @ref LL_ADC_REG_RANK_10
  2706. * @arg @ref LL_ADC_REG_RANK_11
  2707. * @arg @ref LL_ADC_REG_RANK_12
  2708. * @arg @ref LL_ADC_REG_RANK_13
  2709. * @arg @ref LL_ADC_REG_RANK_14
  2710. * @arg @ref LL_ADC_REG_RANK_15
  2711. * @arg @ref LL_ADC_REG_RANK_16
  2712. * @arg @ref LL_ADC_REG_RANK_17
  2713. * @arg @ref LL_ADC_REG_RANK_18
  2714. * @arg @ref LL_ADC_REG_RANK_19
  2715. * @arg @ref LL_ADC_REG_RANK_20
  2716. * @arg @ref LL_ADC_REG_RANK_21
  2717. * @arg @ref LL_ADC_REG_RANK_22
  2718. * @arg @ref LL_ADC_REG_RANK_23
  2719. * @arg @ref LL_ADC_REG_RANK_24
  2720. * @arg @ref LL_ADC_REG_RANK_25
  2721. * @arg @ref LL_ADC_REG_RANK_26
  2722. * @arg @ref LL_ADC_REG_RANK_27
  2723. * @arg @ref LL_ADC_REG_RANK_28 (1)
  2724. *
  2725. * (1) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.3, Cat.4 and Cat.5.
  2726. * @param Channel This parameter can be one of the following values:
  2727. * @arg @ref LL_ADC_CHANNEL_0 (2)
  2728. * @arg @ref LL_ADC_CHANNEL_1 (2)
  2729. * @arg @ref LL_ADC_CHANNEL_2 (2)
  2730. * @arg @ref LL_ADC_CHANNEL_3 (2)
  2731. * @arg @ref LL_ADC_CHANNEL_4 (1)
  2732. * @arg @ref LL_ADC_CHANNEL_5 (1)
  2733. * @arg @ref LL_ADC_CHANNEL_6 (2)
  2734. * @arg @ref LL_ADC_CHANNEL_7 (2)
  2735. * @arg @ref LL_ADC_CHANNEL_8 (2)
  2736. * @arg @ref LL_ADC_CHANNEL_9 (2)
  2737. * @arg @ref LL_ADC_CHANNEL_10 (2)
  2738. * @arg @ref LL_ADC_CHANNEL_11 (2)
  2739. * @arg @ref LL_ADC_CHANNEL_12 (2)
  2740. * @arg @ref LL_ADC_CHANNEL_13 (3)
  2741. * @arg @ref LL_ADC_CHANNEL_14 (3)
  2742. * @arg @ref LL_ADC_CHANNEL_15 (3)
  2743. * @arg @ref LL_ADC_CHANNEL_16 (3)
  2744. * @arg @ref LL_ADC_CHANNEL_17 (3)
  2745. * @arg @ref LL_ADC_CHANNEL_18 (3)
  2746. * @arg @ref LL_ADC_CHANNEL_19 (3)
  2747. * @arg @ref LL_ADC_CHANNEL_20 (3)
  2748. * @arg @ref LL_ADC_CHANNEL_21 (3)
  2749. * @arg @ref LL_ADC_CHANNEL_22 (1)
  2750. * @arg @ref LL_ADC_CHANNEL_23 (1)
  2751. * @arg @ref LL_ADC_CHANNEL_24 (1)
  2752. * @arg @ref LL_ADC_CHANNEL_25 (1)
  2753. * @arg @ref LL_ADC_CHANNEL_26 (3)
  2754. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  2755. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  2756. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  2757. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  2758. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  2759. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  2760. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  2761. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  2762. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  2763. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  2764. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  2765. *
  2766. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  2767. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  2768. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  2769. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  2770. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  2771. * @retval None
  2772. */
  2773. __STATIC_INLINE void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  2774. {
  2775. /* Set bits with content of parameter "Channel" with bits position */
  2776. /* in register and register position depending on parameter "Rank". */
  2777. /* Parameters "Rank" and "Channel" are used with masks because containing */
  2778. /* other bits reserved for other purpose. */
  2779. uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  2780. MODIFY_REG(*preg,
  2781. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK),
  2782. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_REG_RANK_ID_SQRX_MASK));
  2783. }
  2784. /**
  2785. * @brief Get ADC group regular sequence: channel on the selected
  2786. * scan sequence rank.
  2787. * @note On this STM32 serie, ADC group regular sequencer is
  2788. * fully configurable: sequencer length and each rank
  2789. * affectation to a channel are configurable.
  2790. * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
  2791. * @note Depending on devices and packages, some channels may not be available.
  2792. * Refer to device datasheet for channels availability.
  2793. * @note Usage of the returned channel number:
  2794. * - To reinject this channel into another function LL_ADC_xxx:
  2795. * the returned channel number is only partly formatted on definition
  2796. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  2797. * with parts of literals LL_ADC_CHANNEL_x or using
  2798. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2799. * Then the selected literal LL_ADC_CHANNEL_x can be used
  2800. * as parameter for another function.
  2801. * - To get the channel number in decimal format:
  2802. * process the returned value with the helper macro
  2803. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  2804. * @rmtoll SQR5 SQ1 LL_ADC_REG_GetSequencerRanks\n
  2805. * SQR5 SQ2 LL_ADC_REG_GetSequencerRanks\n
  2806. * SQR5 SQ3 LL_ADC_REG_GetSequencerRanks\n
  2807. * SQR5 SQ4 LL_ADC_REG_GetSequencerRanks\n
  2808. * SQR5 SQ5 LL_ADC_REG_GetSequencerRanks\n
  2809. * SQR5 SQ6 LL_ADC_REG_GetSequencerRanks\n
  2810. * SQR4 SQ7 LL_ADC_REG_GetSequencerRanks\n
  2811. * SQR4 SQ8 LL_ADC_REG_GetSequencerRanks\n
  2812. * SQR4 SQ9 LL_ADC_REG_GetSequencerRanks\n
  2813. * SQR4 SQ10 LL_ADC_REG_GetSequencerRanks\n
  2814. * SQR4 SQ11 LL_ADC_REG_GetSequencerRanks\n
  2815. * SQR4 SQ12 LL_ADC_REG_GetSequencerRanks\n
  2816. * SQR3 SQ13 LL_ADC_REG_GetSequencerRanks\n
  2817. * SQR3 SQ14 LL_ADC_REG_GetSequencerRanks\n
  2818. * SQR3 SQ15 LL_ADC_REG_GetSequencerRanks\n
  2819. * SQR3 SQ16 LL_ADC_REG_GetSequencerRanks\n
  2820. * SQR3 SQ17 LL_ADC_REG_GetSequencerRanks\n
  2821. * SQR3 SQ18 LL_ADC_REG_GetSequencerRanks\n
  2822. * SQR2 SQ19 LL_ADC_REG_GetSequencerRanks\n
  2823. * SQR2 SQ20 LL_ADC_REG_GetSequencerRanks\n
  2824. * SQR2 SQ21 LL_ADC_REG_GetSequencerRanks\n
  2825. * SQR2 SQ22 LL_ADC_REG_GetSequencerRanks\n
  2826. * SQR2 SQ23 LL_ADC_REG_GetSequencerRanks\n
  2827. * SQR2 SQ24 LL_ADC_REG_GetSequencerRanks\n
  2828. * SQR1 SQ25 LL_ADC_REG_GetSequencerRanks\n
  2829. * SQR1 SQ26 LL_ADC_REG_GetSequencerRanks\n
  2830. * SQR1 SQ27 LL_ADC_REG_GetSequencerRanks\n
  2831. * SQR1 SQ28 LL_ADC_REG_GetSequencerRanks
  2832. * @param ADCx ADC instance
  2833. * @param Rank This parameter can be one of the following values:
  2834. * @arg @ref LL_ADC_REG_RANK_1
  2835. * @arg @ref LL_ADC_REG_RANK_2
  2836. * @arg @ref LL_ADC_REG_RANK_3
  2837. * @arg @ref LL_ADC_REG_RANK_4
  2838. * @arg @ref LL_ADC_REG_RANK_5
  2839. * @arg @ref LL_ADC_REG_RANK_6
  2840. * @arg @ref LL_ADC_REG_RANK_7
  2841. * @arg @ref LL_ADC_REG_RANK_8
  2842. * @arg @ref LL_ADC_REG_RANK_9
  2843. * @arg @ref LL_ADC_REG_RANK_10
  2844. * @arg @ref LL_ADC_REG_RANK_11
  2845. * @arg @ref LL_ADC_REG_RANK_12
  2846. * @arg @ref LL_ADC_REG_RANK_13
  2847. * @arg @ref LL_ADC_REG_RANK_14
  2848. * @arg @ref LL_ADC_REG_RANK_15
  2849. * @arg @ref LL_ADC_REG_RANK_16
  2850. * @arg @ref LL_ADC_REG_RANK_17
  2851. * @arg @ref LL_ADC_REG_RANK_18
  2852. * @arg @ref LL_ADC_REG_RANK_19
  2853. * @arg @ref LL_ADC_REG_RANK_20
  2854. * @arg @ref LL_ADC_REG_RANK_21
  2855. * @arg @ref LL_ADC_REG_RANK_22
  2856. * @arg @ref LL_ADC_REG_RANK_23
  2857. * @arg @ref LL_ADC_REG_RANK_24
  2858. * @arg @ref LL_ADC_REG_RANK_25
  2859. * @arg @ref LL_ADC_REG_RANK_26
  2860. * @arg @ref LL_ADC_REG_RANK_27
  2861. * @arg @ref LL_ADC_REG_RANK_28 (1)
  2862. *
  2863. * (1) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.3, Cat.4 and Cat.5.
  2864. * @retval Returned value can be one of the following values:
  2865. * @arg @ref LL_ADC_CHANNEL_0 (2)
  2866. * @arg @ref LL_ADC_CHANNEL_1 (2)
  2867. * @arg @ref LL_ADC_CHANNEL_2 (2)
  2868. * @arg @ref LL_ADC_CHANNEL_3 (2)
  2869. * @arg @ref LL_ADC_CHANNEL_4 (1)
  2870. * @arg @ref LL_ADC_CHANNEL_5 (1)
  2871. * @arg @ref LL_ADC_CHANNEL_6 (2)
  2872. * @arg @ref LL_ADC_CHANNEL_7 (2)
  2873. * @arg @ref LL_ADC_CHANNEL_8 (2)
  2874. * @arg @ref LL_ADC_CHANNEL_9 (2)
  2875. * @arg @ref LL_ADC_CHANNEL_10 (2)
  2876. * @arg @ref LL_ADC_CHANNEL_11 (2)
  2877. * @arg @ref LL_ADC_CHANNEL_12 (2)
  2878. * @arg @ref LL_ADC_CHANNEL_13 (3)
  2879. * @arg @ref LL_ADC_CHANNEL_14 (3)
  2880. * @arg @ref LL_ADC_CHANNEL_15 (3)
  2881. * @arg @ref LL_ADC_CHANNEL_16 (3)
  2882. * @arg @ref LL_ADC_CHANNEL_17 (3)
  2883. * @arg @ref LL_ADC_CHANNEL_18 (3)
  2884. * @arg @ref LL_ADC_CHANNEL_19 (3)
  2885. * @arg @ref LL_ADC_CHANNEL_20 (3)
  2886. * @arg @ref LL_ADC_CHANNEL_21 (3)
  2887. * @arg @ref LL_ADC_CHANNEL_22 (1)
  2888. * @arg @ref LL_ADC_CHANNEL_23 (1)
  2889. * @arg @ref LL_ADC_CHANNEL_24 (1)
  2890. * @arg @ref LL_ADC_CHANNEL_25 (1)
  2891. * @arg @ref LL_ADC_CHANNEL_26 (3)
  2892. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  2893. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  2894. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  2895. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  2896. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  2897. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)(6)
  2898. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
  2899. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)(6)
  2900. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  2901. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  2902. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  2903. *
  2904. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  2905. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  2906. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  2907. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  2908. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
  2909. * (6) For ADC channel read back from ADC register,
  2910. * comparison with internal channel parameter to be done
  2911. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  2912. */
  2913. __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  2914. {
  2915. uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
  2916. return (uint32_t) (READ_BIT(*preg,
  2917. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK))
  2918. >> (Rank & ADC_REG_RANK_ID_SQRX_MASK)
  2919. );
  2920. }
  2921. /**
  2922. * @brief Set ADC continuous conversion mode on ADC group regular.
  2923. * @note Description of ADC continuous conversion mode:
  2924. * - single mode: one conversion per trigger
  2925. * - continuous mode: after the first trigger, following
  2926. * conversions launched successively automatically.
  2927. * @note It is not possible to enable both ADC group regular
  2928. * continuous mode and sequencer discontinuous mode.
  2929. * @rmtoll CR2 CONT LL_ADC_REG_SetContinuousMode
  2930. * @param ADCx ADC instance
  2931. * @param Continuous This parameter can be one of the following values:
  2932. * @arg @ref LL_ADC_REG_CONV_SINGLE
  2933. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  2934. * @retval None
  2935. */
  2936. __STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
  2937. {
  2938. MODIFY_REG(ADCx->CR2, ADC_CR2_CONT, Continuous);
  2939. }
  2940. /**
  2941. * @brief Get ADC continuous conversion mode on ADC group regular.
  2942. * @note Description of ADC continuous conversion mode:
  2943. * - single mode: one conversion per trigger
  2944. * - continuous mode: after the first trigger, following
  2945. * conversions launched successively automatically.
  2946. * @rmtoll CR2 CONT LL_ADC_REG_GetContinuousMode
  2947. * @param ADCx ADC instance
  2948. * @retval Returned value can be one of the following values:
  2949. * @arg @ref LL_ADC_REG_CONV_SINGLE
  2950. * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
  2951. */
  2952. __STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
  2953. {
  2954. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_CONT));
  2955. }
  2956. /**
  2957. * @brief Set ADC group regular conversion data transfer: no transfer or
  2958. * transfer by DMA, and DMA requests mode.
  2959. * @note If transfer by DMA selected, specifies the DMA requests
  2960. * mode:
  2961. * - Limited mode (One shot mode): DMA transfer requests are stopped
  2962. * when number of DMA data transfers (number of
  2963. * ADC conversions) is reached.
  2964. * This ADC mode is intended to be used with DMA mode non-circular.
  2965. * - Unlimited mode: DMA transfer requests are unlimited,
  2966. * whatever number of DMA data transfers (number of
  2967. * ADC conversions).
  2968. * This ADC mode is intended to be used with DMA mode circular.
  2969. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  2970. * mode non-circular:
  2971. * when DMA transfers size will be reached, DMA will stop transfers of
  2972. * ADC conversions data ADC will raise an overrun error
  2973. * (overrun flag and interruption if enabled).
  2974. * @note To configure DMA source address (peripheral address),
  2975. * use function @ref LL_ADC_DMA_GetRegAddr().
  2976. * @rmtoll CR2 DMA LL_ADC_REG_SetDMATransfer\n
  2977. * CR2 DDS LL_ADC_REG_SetDMATransfer
  2978. * @param ADCx ADC instance
  2979. * @param DMATransfer This parameter can be one of the following values:
  2980. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  2981. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  2982. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  2983. * @retval None
  2984. */
  2985. __STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
  2986. {
  2987. MODIFY_REG(ADCx->CR2, ADC_CR2_DMA | ADC_CR2_DDS, DMATransfer);
  2988. }
  2989. /**
  2990. * @brief Get ADC group regular conversion data transfer: no transfer or
  2991. * transfer by DMA, and DMA requests mode.
  2992. * @note If transfer by DMA selected, specifies the DMA requests
  2993. * mode:
  2994. * - Limited mode (One shot mode): DMA transfer requests are stopped
  2995. * when number of DMA data transfers (number of
  2996. * ADC conversions) is reached.
  2997. * This ADC mode is intended to be used with DMA mode non-circular.
  2998. * - Unlimited mode: DMA transfer requests are unlimited,
  2999. * whatever number of DMA data transfers (number of
  3000. * ADC conversions).
  3001. * This ADC mode is intended to be used with DMA mode circular.
  3002. * @note If ADC DMA requests mode is set to unlimited and DMA is set to
  3003. * mode non-circular:
  3004. * when DMA transfers size will be reached, DMA will stop transfers of
  3005. * ADC conversions data ADC will raise an overrun error
  3006. * (overrun flag and interruption if enabled).
  3007. * @note To configure DMA source address (peripheral address),
  3008. * use function @ref LL_ADC_DMA_GetRegAddr().
  3009. * @rmtoll CR2 DMA LL_ADC_REG_GetDMATransfer\n
  3010. * CR2 DDS LL_ADC_REG_GetDMATransfer
  3011. * @param ADCx ADC instance
  3012. * @retval Returned value can be one of the following values:
  3013. * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
  3014. * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
  3015. * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
  3016. */
  3017. __STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
  3018. {
  3019. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_DMA | ADC_CR2_DDS));
  3020. }
  3021. /**
  3022. * @brief Specify which ADC flag between EOC (end of unitary conversion)
  3023. * or EOS (end of sequence conversions) is used to indicate
  3024. * the end of conversion.
  3025. * @note This feature is aimed to be set when using ADC with
  3026. * programming model by polling or interruption
  3027. * (programming model by DMA usually uses DMA interruptions
  3028. * to indicate end of conversion and data transfer).
  3029. * @note For ADC group injected, end of conversion (flag&IT) is raised
  3030. * only at the end of the sequence.
  3031. * @rmtoll CR2 EOCS LL_ADC_REG_SetFlagEndOfConversion
  3032. * @param ADCx ADC instance
  3033. * @param EocSelection This parameter can be one of the following values:
  3034. * @arg @ref LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV
  3035. * @arg @ref LL_ADC_REG_FLAG_EOC_UNITARY_CONV
  3036. * @retval None
  3037. */
  3038. __STATIC_INLINE void LL_ADC_REG_SetFlagEndOfConversion(ADC_TypeDef *ADCx, uint32_t EocSelection)
  3039. {
  3040. MODIFY_REG(ADCx->CR2, ADC_CR2_EOCS, EocSelection);
  3041. }
  3042. /**
  3043. * @brief Get which ADC flag between EOC (end of unitary conversion)
  3044. * or EOS (end of sequence conversions) is used to indicate
  3045. * the end of conversion.
  3046. * @rmtoll CR2 EOCS LL_ADC_REG_GetFlagEndOfConversion
  3047. * @param ADCx ADC instance
  3048. * @retval Returned value can be one of the following values:
  3049. * @arg @ref LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV
  3050. * @arg @ref LL_ADC_REG_FLAG_EOC_UNITARY_CONV
  3051. */
  3052. __STATIC_INLINE uint32_t LL_ADC_REG_GetFlagEndOfConversion(ADC_TypeDef *ADCx)
  3053. {
  3054. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_EOCS));
  3055. }
  3056. /**
  3057. * @}
  3058. */
  3059. /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected
  3060. * @{
  3061. */
  3062. /**
  3063. * @brief Set ADC group injected conversion trigger source:
  3064. * internal (SW start) or from external IP (timer event,
  3065. * external interrupt line).
  3066. * @note On this STM32 serie, setting of external trigger edge is performed
  3067. * using function @ref LL_ADC_INJ_StartConversionExtTrig().
  3068. * @note Availability of parameters of trigger sources from timer
  3069. * depends on timers availability on the selected device.
  3070. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_SetTriggerSource\n
  3071. * CR2 JEXTEN LL_ADC_INJ_SetTriggerSource
  3072. * @param ADCx ADC instance
  3073. * @param TriggerSource This parameter can be one of the following values:
  3074. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  3075. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_CH1
  3076. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_TRGO
  3077. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  3078. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  3079. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
  3080. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
  3081. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH1
  3082. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH2
  3083. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3
  3084. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM10_CH1
  3085. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO
  3086. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  3087. * @retval None
  3088. */
  3089. __STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
  3090. {
  3091. /* Note: On this STM32 serie, ADC group injected external trigger edge */
  3092. /* is used to perform a ADC conversion start. */
  3093. /* This function does not set external trigger edge. */
  3094. /* This feature is set using function */
  3095. /* @ref LL_ADC_INJ_StartConversionExtTrig(). */
  3096. MODIFY_REG(ADCx->CR2, ADC_CR2_JEXTSEL, (TriggerSource & ADC_CR2_JEXTSEL));
  3097. }
  3098. /**
  3099. * @brief Get ADC group injected conversion trigger source:
  3100. * internal (SW start) or from external IP (timer event,
  3101. * external interrupt line).
  3102. * @note To determine whether group injected trigger source is
  3103. * internal (SW start) or external, without detail
  3104. * of which peripheral is selected as external trigger,
  3105. * (equivalent to
  3106. * "if(LL_ADC_INJ_GetTriggerSource(ADC1) == LL_ADC_INJ_TRIG_SOFTWARE)")
  3107. * use function @ref LL_ADC_INJ_IsTriggerSourceSWStart.
  3108. * @note Availability of parameters of trigger sources from timer
  3109. * depends on timers availability on the selected device.
  3110. * @rmtoll CR2 JEXTSEL LL_ADC_INJ_GetTriggerSource\n
  3111. * CR2 JEXTEN LL_ADC_INJ_GetTriggerSource
  3112. * @param ADCx ADC instance
  3113. * @retval Returned value can be one of the following values:
  3114. * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
  3115. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_CH1
  3116. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_TRGO
  3117. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
  3118. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
  3119. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
  3120. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
  3121. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH1
  3122. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH2
  3123. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3
  3124. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM10_CH1
  3125. * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO
  3126. * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
  3127. */
  3128. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerSource(ADC_TypeDef *ADCx)
  3129. {
  3130. uint32_t TriggerSource = READ_BIT(ADCx->CR2, ADC_CR2_JEXTSEL | ADC_CR2_JEXTEN);
  3131. /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
  3132. /* corresponding to ADC_CR2_JEXTEN {0; 1; 2; 3}. */
  3133. uint32_t ShiftExten = ((TriggerSource & ADC_CR2_JEXTEN) >> (ADC_INJ_TRIG_EXTEN_BITOFFSET_POS - 2U));
  3134. /* Set bitfield corresponding to ADC_CR2_JEXTEN and ADC_CR2_JEXTSEL */
  3135. /* to match with triggers literals definition. */
  3136. return ((TriggerSource
  3137. & (ADC_INJ_TRIG_SOURCE_MASK << ShiftExten) & ADC_CR2_JEXTSEL)
  3138. | ((ADC_INJ_TRIG_EDGE_MASK << ShiftExten) & ADC_CR2_JEXTEN)
  3139. );
  3140. }
  3141. /**
  3142. * @brief Get ADC group injected conversion trigger source internal (SW start)
  3143. or external
  3144. * @note In case of group injected trigger source set to external trigger,
  3145. * to determine which peripheral is selected as external trigger,
  3146. * use function @ref LL_ADC_INJ_GetTriggerSource.
  3147. * @rmtoll CR2 JEXTEN LL_ADC_INJ_IsTriggerSourceSWStart
  3148. * @param ADCx ADC instance
  3149. * @retval Value "0" if trigger source external trigger
  3150. * Value "1" if trigger source SW start.
  3151. */
  3152. __STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
  3153. {
  3154. return (READ_BIT(ADCx->CR2, ADC_CR2_JEXTEN) == (LL_ADC_INJ_TRIG_SOFTWARE & ADC_CR2_JEXTEN));
  3155. }
  3156. /**
  3157. * @brief Get ADC group injected conversion trigger polarity.
  3158. * Applicable only for trigger source set to external trigger.
  3159. * @rmtoll CR2 JEXTEN LL_ADC_INJ_GetTriggerEdge
  3160. * @param ADCx ADC instance
  3161. * @retval Returned value can be one of the following values:
  3162. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  3163. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  3164. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  3165. */
  3166. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerEdge(ADC_TypeDef *ADCx)
  3167. {
  3168. return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_JEXTEN));
  3169. }
  3170. /**
  3171. * @brief Set ADC group injected sequencer length and scan direction.
  3172. * @note This function performs configuration of:
  3173. * - Sequence length: Number of ranks in the scan sequence.
  3174. * - Sequence direction: Unless specified in parameters, sequencer
  3175. * scan direction is forward (from rank 1 to rank n).
  3176. * @note On this STM32 serie, group injected sequencer configuration
  3177. * is conditioned to ADC instance sequencer mode.
  3178. * If ADC instance sequencer mode is disabled, sequencers of
  3179. * all groups (group regular, group injected) can be configured
  3180. * but their execution is disabled (limited to rank 1).
  3181. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  3182. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3183. * ADC conversion on only 1 channel.
  3184. * @rmtoll JSQR JL LL_ADC_INJ_SetSequencerLength
  3185. * @param ADCx ADC instance
  3186. * @param SequencerNbRanks This parameter can be one of the following values:
  3187. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  3188. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  3189. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  3190. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  3191. * @retval None
  3192. */
  3193. __STATIC_INLINE void LL_ADC_INJ_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  3194. {
  3195. MODIFY_REG(ADCx->JSQR, ADC_JSQR_JL, SequencerNbRanks);
  3196. }
  3197. /**
  3198. * @brief Get ADC group injected sequencer length and scan direction.
  3199. * @note This function retrieves:
  3200. * - Sequence length: Number of ranks in the scan sequence.
  3201. * - Sequence direction: Unless specified in parameters, sequencer
  3202. * scan direction is forward (from rank 1 to rank n).
  3203. * @note On this STM32 serie, group injected sequencer configuration
  3204. * is conditioned to ADC instance sequencer mode.
  3205. * If ADC instance sequencer mode is disabled, sequencers of
  3206. * all groups (group regular, group injected) can be configured
  3207. * but their execution is disabled (limited to rank 1).
  3208. * Refer to function @ref LL_ADC_SetSequencersScanMode().
  3209. * @note Sequencer disabled is equivalent to sequencer of 1 rank:
  3210. * ADC conversion on only 1 channel.
  3211. * @rmtoll JSQR JL LL_ADC_INJ_GetSequencerLength
  3212. * @param ADCx ADC instance
  3213. * @retval Returned value can be one of the following values:
  3214. * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
  3215. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
  3216. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
  3217. * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
  3218. */
  3219. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerLength(ADC_TypeDef *ADCx)
  3220. {
  3221. return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JL));
  3222. }
  3223. /**
  3224. * @brief Set ADC group injected sequencer discontinuous mode:
  3225. * sequence subdivided and scan conversions interrupted every selected
  3226. * number of ranks.
  3227. * @note It is not possible to enable both ADC group injected
  3228. * auto-injected mode and sequencer discontinuous mode.
  3229. * @rmtoll CR1 DISCEN LL_ADC_INJ_SetSequencerDiscont
  3230. * @param ADCx ADC instance
  3231. * @param SeqDiscont This parameter can be one of the following values:
  3232. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  3233. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  3234. * @retval None
  3235. */
  3236. __STATIC_INLINE void LL_ADC_INJ_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
  3237. {
  3238. MODIFY_REG(ADCx->CR1, ADC_CR1_JDISCEN, SeqDiscont);
  3239. }
  3240. /**
  3241. * @brief Get ADC group injected sequencer discontinuous mode:
  3242. * sequence subdivided and scan conversions interrupted every selected
  3243. * number of ranks.
  3244. * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont
  3245. * @param ADCx ADC instance
  3246. * @retval Returned value can be one of the following values:
  3247. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
  3248. * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
  3249. */
  3250. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerDiscont(ADC_TypeDef *ADCx)
  3251. {
  3252. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JDISCEN));
  3253. }
  3254. /**
  3255. * @brief Set ADC group injected sequence: channel on the selected
  3256. * sequence rank.
  3257. * @note Depending on devices and packages, some channels may not be available.
  3258. * Refer to device datasheet for channels availability.
  3259. * @note On this STM32 serie, to measure internal channels (VrefInt,
  3260. * TempSensor, ...), measurement paths to internal channels must be
  3261. * enabled separately.
  3262. * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
  3263. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  3264. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  3265. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  3266. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  3267. * @param ADCx ADC instance
  3268. * @param Rank This parameter can be one of the following values:
  3269. * @arg @ref LL_ADC_INJ_RANK_1
  3270. * @arg @ref LL_ADC_INJ_RANK_2
  3271. * @arg @ref LL_ADC_INJ_RANK_3
  3272. * @arg @ref LL_ADC_INJ_RANK_4
  3273. * @param Channel This parameter can be one of the following values:
  3274. * @arg @ref LL_ADC_CHANNEL_0 (2)
  3275. * @arg @ref LL_ADC_CHANNEL_1 (2)
  3276. * @arg @ref LL_ADC_CHANNEL_2 (2)
  3277. * @arg @ref LL_ADC_CHANNEL_3 (2)
  3278. * @arg @ref LL_ADC_CHANNEL_4 (1)
  3279. * @arg @ref LL_ADC_CHANNEL_5 (1)
  3280. * @arg @ref LL_ADC_CHANNEL_6 (2)
  3281. * @arg @ref LL_ADC_CHANNEL_7 (2)
  3282. * @arg @ref LL_ADC_CHANNEL_8 (2)
  3283. * @arg @ref LL_ADC_CHANNEL_9 (2)
  3284. * @arg @ref LL_ADC_CHANNEL_10 (2)
  3285. * @arg @ref LL_ADC_CHANNEL_11 (2)
  3286. * @arg @ref LL_ADC_CHANNEL_12 (2)
  3287. * @arg @ref LL_ADC_CHANNEL_13 (3)
  3288. * @arg @ref LL_ADC_CHANNEL_14 (3)
  3289. * @arg @ref LL_ADC_CHANNEL_15 (3)
  3290. * @arg @ref LL_ADC_CHANNEL_16 (3)
  3291. * @arg @ref LL_ADC_CHANNEL_17 (3)
  3292. * @arg @ref LL_ADC_CHANNEL_18 (3)
  3293. * @arg @ref LL_ADC_CHANNEL_19 (3)
  3294. * @arg @ref LL_ADC_CHANNEL_20 (3)
  3295. * @arg @ref LL_ADC_CHANNEL_21 (3)
  3296. * @arg @ref LL_ADC_CHANNEL_22 (1)
  3297. * @arg @ref LL_ADC_CHANNEL_23 (1)
  3298. * @arg @ref LL_ADC_CHANNEL_24 (1)
  3299. * @arg @ref LL_ADC_CHANNEL_25 (1)
  3300. * @arg @ref LL_ADC_CHANNEL_26 (3)
  3301. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  3302. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  3303. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  3304. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  3305. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  3306. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  3307. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  3308. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  3309. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  3310. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  3311. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  3312. *
  3313. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  3314. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  3315. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  3316. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  3317. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  3318. * @retval None
  3319. */
  3320. __STATIC_INLINE void LL_ADC_INJ_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
  3321. {
  3322. /* Set bits with content of parameter "Channel" with bits position */
  3323. /* in register depending on parameter "Rank". */
  3324. /* Parameters "Rank" and "Channel" are used with masks because containing */
  3325. /* other bits reserved for other purpose. */
  3326. MODIFY_REG(ADCx->JSQR,
  3327. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_INJ_RANK_ID_JSQR_MASK),
  3328. (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK));
  3329. }
  3330. /**
  3331. * @brief Get ADC group injected sequence: channel on the selected
  3332. * sequence rank.
  3333. * @note Depending on devices and packages, some channels may not be available.
  3334. * Refer to device datasheet for channels availability.
  3335. * @note Usage of the returned channel number:
  3336. * - To reinject this channel into another function LL_ADC_xxx:
  3337. * the returned channel number is only partly formatted on definition
  3338. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  3339. * with parts of literals LL_ADC_CHANNEL_x or using
  3340. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3341. * Then the selected literal LL_ADC_CHANNEL_x can be used
  3342. * as parameter for another function.
  3343. * - To get the channel number in decimal format:
  3344. * process the returned value with the helper macro
  3345. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3346. * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
  3347. * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
  3348. * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
  3349. * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
  3350. * @param ADCx ADC instance
  3351. * @param Rank This parameter can be one of the following values:
  3352. * @arg @ref LL_ADC_INJ_RANK_1
  3353. * @arg @ref LL_ADC_INJ_RANK_2
  3354. * @arg @ref LL_ADC_INJ_RANK_3
  3355. * @arg @ref LL_ADC_INJ_RANK_4
  3356. * @retval Returned value can be one of the following values:
  3357. * @arg @ref LL_ADC_CHANNEL_0 (2)
  3358. * @arg @ref LL_ADC_CHANNEL_1 (2)
  3359. * @arg @ref LL_ADC_CHANNEL_2 (2)
  3360. * @arg @ref LL_ADC_CHANNEL_3 (2)
  3361. * @arg @ref LL_ADC_CHANNEL_4 (1)
  3362. * @arg @ref LL_ADC_CHANNEL_5 (1)
  3363. * @arg @ref LL_ADC_CHANNEL_6 (2)
  3364. * @arg @ref LL_ADC_CHANNEL_7 (2)
  3365. * @arg @ref LL_ADC_CHANNEL_8 (2)
  3366. * @arg @ref LL_ADC_CHANNEL_9 (2)
  3367. * @arg @ref LL_ADC_CHANNEL_10 (2)
  3368. * @arg @ref LL_ADC_CHANNEL_11 (2)
  3369. * @arg @ref LL_ADC_CHANNEL_12 (2)
  3370. * @arg @ref LL_ADC_CHANNEL_13 (3)
  3371. * @arg @ref LL_ADC_CHANNEL_14 (3)
  3372. * @arg @ref LL_ADC_CHANNEL_15 (3)
  3373. * @arg @ref LL_ADC_CHANNEL_16 (3)
  3374. * @arg @ref LL_ADC_CHANNEL_17 (3)
  3375. * @arg @ref LL_ADC_CHANNEL_18 (3)
  3376. * @arg @ref LL_ADC_CHANNEL_19 (3)
  3377. * @arg @ref LL_ADC_CHANNEL_20 (3)
  3378. * @arg @ref LL_ADC_CHANNEL_21 (3)
  3379. * @arg @ref LL_ADC_CHANNEL_22 (1)
  3380. * @arg @ref LL_ADC_CHANNEL_23 (1)
  3381. * @arg @ref LL_ADC_CHANNEL_24 (1)
  3382. * @arg @ref LL_ADC_CHANNEL_25 (1)
  3383. * @arg @ref LL_ADC_CHANNEL_26 (3)
  3384. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  3385. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  3386. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  3387. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  3388. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  3389. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)(6)
  3390. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
  3391. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)(6)
  3392. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  3393. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  3394. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  3395. *
  3396. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  3397. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  3398. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  3399. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  3400. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
  3401. * (6) For ADC channel read back from ADC register,
  3402. * comparison with internal channel parameter to be done
  3403. * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
  3404. */
  3405. __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
  3406. {
  3407. return (uint32_t)(READ_BIT(ADCx->JSQR,
  3408. ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_INJ_RANK_ID_JSQR_MASK))
  3409. >> (Rank & ADC_INJ_RANK_ID_JSQR_MASK)
  3410. );
  3411. }
  3412. /**
  3413. * @brief Set ADC group injected conversion trigger:
  3414. * independent or from ADC group regular.
  3415. * @note This mode can be used to extend number of data registers
  3416. * updated after one ADC conversion trigger and with data
  3417. * permanently kept (not erased by successive conversions of scan of
  3418. * ADC sequencer ranks), up to 5 data registers:
  3419. * 1 data register on ADC group regular, 4 data registers
  3420. * on ADC group injected.
  3421. * @note If ADC group injected injected trigger source is set to an
  3422. * external trigger, this feature must be must be set to
  3423. * independent trigger.
  3424. * ADC group injected automatic trigger is compliant only with
  3425. * group injected trigger source set to SW start, without any
  3426. * further action on ADC group injected conversion start or stop:
  3427. * in this case, ADC group injected is controlled only
  3428. * from ADC group regular.
  3429. * @note It is not possible to enable both ADC group injected
  3430. * auto-injected mode and sequencer discontinuous mode.
  3431. * @rmtoll CR1 JAUTO LL_ADC_INJ_SetTrigAuto
  3432. * @param ADCx ADC instance
  3433. * @param TrigAuto This parameter can be one of the following values:
  3434. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  3435. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  3436. * @retval None
  3437. */
  3438. __STATIC_INLINE void LL_ADC_INJ_SetTrigAuto(ADC_TypeDef *ADCx, uint32_t TrigAuto)
  3439. {
  3440. MODIFY_REG(ADCx->CR1, ADC_CR1_JAUTO, TrigAuto);
  3441. }
  3442. /**
  3443. * @brief Get ADC group injected conversion trigger:
  3444. * independent or from ADC group regular.
  3445. * @rmtoll CR1 JAUTO LL_ADC_INJ_GetTrigAuto
  3446. * @param ADCx ADC instance
  3447. * @retval Returned value can be one of the following values:
  3448. * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
  3449. * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
  3450. */
  3451. __STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx)
  3452. {
  3453. return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JAUTO));
  3454. }
  3455. /**
  3456. * @brief Set ADC group injected offset.
  3457. * @note It sets:
  3458. * - ADC group injected rank to which the offset programmed
  3459. * will be applied
  3460. * - Offset level (offset to be subtracted from the raw
  3461. * converted data).
  3462. * Caution: Offset format is dependent to ADC resolution:
  3463. * offset has to be left-aligned on bit 11, the LSB (right bits)
  3464. * are set to 0.
  3465. * @note Offset cannot be enabled or disabled.
  3466. * To emulate offset disabled, set an offset value equal to 0.
  3467. * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_SetOffset\n
  3468. * JOFR2 JOFFSET2 LL_ADC_INJ_SetOffset\n
  3469. * JOFR3 JOFFSET3 LL_ADC_INJ_SetOffset\n
  3470. * JOFR4 JOFFSET4 LL_ADC_INJ_SetOffset
  3471. * @param ADCx ADC instance
  3472. * @param Rank This parameter can be one of the following values:
  3473. * @arg @ref LL_ADC_INJ_RANK_1
  3474. * @arg @ref LL_ADC_INJ_RANK_2
  3475. * @arg @ref LL_ADC_INJ_RANK_3
  3476. * @arg @ref LL_ADC_INJ_RANK_4
  3477. * @param OffsetLevel Value between Min_Data=0x000 and Max_Data=0xFFF
  3478. * @retval None
  3479. */
  3480. __STATIC_INLINE void LL_ADC_INJ_SetOffset(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t OffsetLevel)
  3481. {
  3482. uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
  3483. MODIFY_REG(*preg,
  3484. ADC_JOFR1_JOFFSET1,
  3485. OffsetLevel);
  3486. }
  3487. /**
  3488. * @brief Get ADC group injected offset.
  3489. * @note It gives offset level (offset to be subtracted from the raw converted data).
  3490. * Caution: Offset format is dependent to ADC resolution:
  3491. * offset has to be left-aligned on bit 11, the LSB (right bits)
  3492. * are set to 0.
  3493. * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_GetOffset\n
  3494. * JOFR2 JOFFSET2 LL_ADC_INJ_GetOffset\n
  3495. * JOFR3 JOFFSET3 LL_ADC_INJ_GetOffset\n
  3496. * JOFR4 JOFFSET4 LL_ADC_INJ_GetOffset
  3497. * @param ADCx ADC instance
  3498. * @param Rank This parameter can be one of the following values:
  3499. * @arg @ref LL_ADC_INJ_RANK_1
  3500. * @arg @ref LL_ADC_INJ_RANK_2
  3501. * @arg @ref LL_ADC_INJ_RANK_3
  3502. * @arg @ref LL_ADC_INJ_RANK_4
  3503. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  3504. */
  3505. __STATIC_INLINE uint32_t LL_ADC_INJ_GetOffset(ADC_TypeDef *ADCx, uint32_t Rank)
  3506. {
  3507. uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
  3508. return (uint32_t)(READ_BIT(*preg,
  3509. ADC_JOFR1_JOFFSET1)
  3510. );
  3511. }
  3512. /**
  3513. * @}
  3514. */
  3515. /** @defgroup ADC_LL_EF_Configuration_Channels Configuration of ADC hierarchical scope: channels
  3516. * @{
  3517. */
  3518. /**
  3519. * @brief Set sampling time of the selected ADC channel
  3520. * Unit: ADC clock cycles.
  3521. * @note On this device, sampling time is on channel scope: independently
  3522. * of channel mapped on ADC group regular or injected.
  3523. * @note In case of internal channel (VrefInt, TempSensor, ...) to be
  3524. * converted:
  3525. * sampling time constraints must be respected (sampling time can be
  3526. * adjusted in function of ADC clock frequency and sampling time
  3527. * setting).
  3528. * Refer to device datasheet for timings values (parameters TS_vrefint,
  3529. * TS_temp, ...).
  3530. * @note Conversion time is the addition of sampling time and processing time.
  3531. * Refer to reference manual for ADC processing time of
  3532. * this STM32 serie.
  3533. * @note In case of ADC conversion of internal channel (VrefInt,
  3534. * temperature sensor, ...), a sampling time minimum value
  3535. * is required.
  3536. * Refer to device datasheet.
  3537. * @rmtoll SMPR0 SMP31 LL_ADC_SetChannelSamplingTime\n
  3538. * SMPR0 SMP30 LL_ADC_SetChannelSamplingTime\n
  3539. * SMPR1 SMP29 LL_ADC_SetChannelSamplingTime\n
  3540. * SMPR1 SMP28 LL_ADC_SetChannelSamplingTime\n
  3541. * SMPR1 SMP27 LL_ADC_SetChannelSamplingTime\n
  3542. * SMPR1 SMP26 LL_ADC_SetChannelSamplingTime\n
  3543. * SMPR1 SMP25 LL_ADC_SetChannelSamplingTime\n
  3544. * SMPR1 SMP24 LL_ADC_SetChannelSamplingTime\n
  3545. * SMPR1 SMP23 LL_ADC_SetChannelSamplingTime\n
  3546. * SMPR1 SMP22 LL_ADC_SetChannelSamplingTime\n
  3547. * SMPR1 SMP21 LL_ADC_SetChannelSamplingTime\n
  3548. * SMPR1 SMP20 LL_ADC_SetChannelSamplingTime\n
  3549. * SMPR2 SMP19 LL_ADC_SetChannelSamplingTime\n
  3550. * SMPR2 SMP18 LL_ADC_SetChannelSamplingTime\n
  3551. * SMPR2 SMP17 LL_ADC_SetChannelSamplingTime\n
  3552. * SMPR2 SMP16 LL_ADC_SetChannelSamplingTime\n
  3553. * SMPR2 SMP15 LL_ADC_SetChannelSamplingTime\n
  3554. * SMPR2 SMP14 LL_ADC_SetChannelSamplingTime\n
  3555. * SMPR2 SMP13 LL_ADC_SetChannelSamplingTime\n
  3556. * SMPR2 SMP12 LL_ADC_SetChannelSamplingTime\n
  3557. * SMPR2 SMP11 LL_ADC_SetChannelSamplingTime\n
  3558. * SMPR2 SMP10 LL_ADC_SetChannelSamplingTime\n
  3559. * SMPR3 SMP9 LL_ADC_SetChannelSamplingTime\n
  3560. * SMPR3 SMP8 LL_ADC_SetChannelSamplingTime\n
  3561. * SMPR3 SMP7 LL_ADC_SetChannelSamplingTime\n
  3562. * SMPR3 SMP6 LL_ADC_SetChannelSamplingTime\n
  3563. * SMPR3 SMP5 LL_ADC_SetChannelSamplingTime\n
  3564. * SMPR3 SMP4 LL_ADC_SetChannelSamplingTime\n
  3565. * SMPR3 SMP3 LL_ADC_SetChannelSamplingTime\n
  3566. * SMPR3 SMP2 LL_ADC_SetChannelSamplingTime\n
  3567. * SMPR3 SMP1 LL_ADC_SetChannelSamplingTime\n
  3568. * SMPR3 SMP0 LL_ADC_SetChannelSamplingTime
  3569. * @param ADCx ADC instance
  3570. * @param Channel This parameter can be one of the following values:
  3571. * @arg @ref LL_ADC_CHANNEL_0 (2)
  3572. * @arg @ref LL_ADC_CHANNEL_1 (2)
  3573. * @arg @ref LL_ADC_CHANNEL_2 (2)
  3574. * @arg @ref LL_ADC_CHANNEL_3 (2)
  3575. * @arg @ref LL_ADC_CHANNEL_4 (1)
  3576. * @arg @ref LL_ADC_CHANNEL_5 (1)
  3577. * @arg @ref LL_ADC_CHANNEL_6 (2)
  3578. * @arg @ref LL_ADC_CHANNEL_7 (2)
  3579. * @arg @ref LL_ADC_CHANNEL_8 (2)
  3580. * @arg @ref LL_ADC_CHANNEL_9 (2)
  3581. * @arg @ref LL_ADC_CHANNEL_10 (2)
  3582. * @arg @ref LL_ADC_CHANNEL_11 (2)
  3583. * @arg @ref LL_ADC_CHANNEL_12 (2)
  3584. * @arg @ref LL_ADC_CHANNEL_13 (3)
  3585. * @arg @ref LL_ADC_CHANNEL_14 (3)
  3586. * @arg @ref LL_ADC_CHANNEL_15 (3)
  3587. * @arg @ref LL_ADC_CHANNEL_16 (3)
  3588. * @arg @ref LL_ADC_CHANNEL_17 (3)
  3589. * @arg @ref LL_ADC_CHANNEL_18 (3)
  3590. * @arg @ref LL_ADC_CHANNEL_19 (3)
  3591. * @arg @ref LL_ADC_CHANNEL_20 (3)
  3592. * @arg @ref LL_ADC_CHANNEL_21 (3)
  3593. * @arg @ref LL_ADC_CHANNEL_22 (1)
  3594. * @arg @ref LL_ADC_CHANNEL_23 (1)
  3595. * @arg @ref LL_ADC_CHANNEL_24 (1)
  3596. * @arg @ref LL_ADC_CHANNEL_25 (1)
  3597. * @arg @ref LL_ADC_CHANNEL_26 (3)
  3598. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  3599. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  3600. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  3601. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  3602. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  3603. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  3604. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  3605. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  3606. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  3607. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  3608. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  3609. *
  3610. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  3611. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  3612. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  3613. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  3614. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  3615. * @param SamplingTime This parameter can be one of the following values:
  3616. * @arg @ref LL_ADC_SAMPLINGTIME_4CYCLES
  3617. * @arg @ref LL_ADC_SAMPLINGTIME_9CYCLES
  3618. * @arg @ref LL_ADC_SAMPLINGTIME_16CYCLES
  3619. * @arg @ref LL_ADC_SAMPLINGTIME_24CYCLES
  3620. * @arg @ref LL_ADC_SAMPLINGTIME_48CYCLES
  3621. * @arg @ref LL_ADC_SAMPLINGTIME_96CYCLES
  3622. * @arg @ref LL_ADC_SAMPLINGTIME_192CYCLES
  3623. * @arg @ref LL_ADC_SAMPLINGTIME_384CYCLES
  3624. * @retval None
  3625. */
  3626. __STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTime)
  3627. {
  3628. /* Set bits with content of parameter "SamplingTime" with bits position */
  3629. /* in register and register position depending on parameter "Channel". */
  3630. /* Parameter "Channel" is used with masks because containing */
  3631. /* other bits reserved for other purpose. */
  3632. uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  3633. MODIFY_REG(*preg,
  3634. ADC_SMPR3_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK),
  3635. SamplingTime << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK));
  3636. }
  3637. /**
  3638. * @brief Get sampling time of the selected ADC channel
  3639. * Unit: ADC clock cycles.
  3640. * @note On this device, sampling time is on channel scope: independently
  3641. * of channel mapped on ADC group regular or injected.
  3642. * @note Conversion time is the addition of sampling time and processing time.
  3643. * Refer to reference manual for ADC processing time of
  3644. * this STM32 serie.
  3645. * @rmtoll SMPR0 SMP31 LL_ADC_GetChannelSamplingTime\n
  3646. * SMPR0 SMP30 LL_ADC_GetChannelSamplingTime\n
  3647. * SMPR1 SMP29 LL_ADC_GetChannelSamplingTime\n
  3648. * SMPR1 SMP28 LL_ADC_GetChannelSamplingTime\n
  3649. * SMPR1 SMP27 LL_ADC_GetChannelSamplingTime\n
  3650. * SMPR1 SMP26 LL_ADC_GetChannelSamplingTime\n
  3651. * SMPR1 SMP25 LL_ADC_GetChannelSamplingTime\n
  3652. * SMPR1 SMP24 LL_ADC_GetChannelSamplingTime\n
  3653. * SMPR1 SMP23 LL_ADC_GetChannelSamplingTime\n
  3654. * SMPR1 SMP22 LL_ADC_GetChannelSamplingTime\n
  3655. * SMPR1 SMP21 LL_ADC_GetChannelSamplingTime\n
  3656. * SMPR1 SMP20 LL_ADC_GetChannelSamplingTime\n
  3657. * SMPR2 SMP19 LL_ADC_GetChannelSamplingTime\n
  3658. * SMPR2 SMP18 LL_ADC_GetChannelSamplingTime\n
  3659. * SMPR2 SMP17 LL_ADC_GetChannelSamplingTime\n
  3660. * SMPR2 SMP16 LL_ADC_GetChannelSamplingTime\n
  3661. * SMPR2 SMP15 LL_ADC_GetChannelSamplingTime\n
  3662. * SMPR2 SMP14 LL_ADC_GetChannelSamplingTime\n
  3663. * SMPR2 SMP13 LL_ADC_GetChannelSamplingTime\n
  3664. * SMPR2 SMP12 LL_ADC_GetChannelSamplingTime\n
  3665. * SMPR2 SMP11 LL_ADC_GetChannelSamplingTime\n
  3666. * SMPR2 SMP10 LL_ADC_GetChannelSamplingTime\n
  3667. * SMPR3 SMP9 LL_ADC_GetChannelSamplingTime\n
  3668. * SMPR3 SMP8 LL_ADC_GetChannelSamplingTime\n
  3669. * SMPR3 SMP7 LL_ADC_GetChannelSamplingTime\n
  3670. * SMPR3 SMP6 LL_ADC_GetChannelSamplingTime\n
  3671. * SMPR3 SMP5 LL_ADC_GetChannelSamplingTime\n
  3672. * SMPR3 SMP4 LL_ADC_GetChannelSamplingTime\n
  3673. * SMPR3 SMP3 LL_ADC_GetChannelSamplingTime\n
  3674. * SMPR3 SMP2 LL_ADC_GetChannelSamplingTime\n
  3675. * SMPR3 SMP1 LL_ADC_GetChannelSamplingTime\n
  3676. * SMPR3 SMP0 LL_ADC_GetChannelSamplingTime
  3677. * @param ADCx ADC instance
  3678. * @param Channel This parameter can be one of the following values:
  3679. * @arg @ref LL_ADC_CHANNEL_0 (2)
  3680. * @arg @ref LL_ADC_CHANNEL_1 (2)
  3681. * @arg @ref LL_ADC_CHANNEL_2 (2)
  3682. * @arg @ref LL_ADC_CHANNEL_3 (2)
  3683. * @arg @ref LL_ADC_CHANNEL_4 (1)
  3684. * @arg @ref LL_ADC_CHANNEL_5 (1)
  3685. * @arg @ref LL_ADC_CHANNEL_6 (2)
  3686. * @arg @ref LL_ADC_CHANNEL_7 (2)
  3687. * @arg @ref LL_ADC_CHANNEL_8 (2)
  3688. * @arg @ref LL_ADC_CHANNEL_9 (2)
  3689. * @arg @ref LL_ADC_CHANNEL_10 (2)
  3690. * @arg @ref LL_ADC_CHANNEL_11 (2)
  3691. * @arg @ref LL_ADC_CHANNEL_12 (2)
  3692. * @arg @ref LL_ADC_CHANNEL_13 (3)
  3693. * @arg @ref LL_ADC_CHANNEL_14 (3)
  3694. * @arg @ref LL_ADC_CHANNEL_15 (3)
  3695. * @arg @ref LL_ADC_CHANNEL_16 (3)
  3696. * @arg @ref LL_ADC_CHANNEL_17 (3)
  3697. * @arg @ref LL_ADC_CHANNEL_18 (3)
  3698. * @arg @ref LL_ADC_CHANNEL_19 (3)
  3699. * @arg @ref LL_ADC_CHANNEL_20 (3)
  3700. * @arg @ref LL_ADC_CHANNEL_21 (3)
  3701. * @arg @ref LL_ADC_CHANNEL_22 (1)
  3702. * @arg @ref LL_ADC_CHANNEL_23 (1)
  3703. * @arg @ref LL_ADC_CHANNEL_24 (1)
  3704. * @arg @ref LL_ADC_CHANNEL_25 (1)
  3705. * @arg @ref LL_ADC_CHANNEL_26 (3)
  3706. * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
  3707. * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
  3708. * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
  3709. * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
  3710. * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
  3711. * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
  3712. * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
  3713. * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
  3714. * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
  3715. * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
  3716. * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
  3717. *
  3718. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  3719. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  3720. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  3721. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  3722. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  3723. * @retval Returned value can be one of the following values:
  3724. * @arg @ref LL_ADC_SAMPLINGTIME_4CYCLES
  3725. * @arg @ref LL_ADC_SAMPLINGTIME_9CYCLES
  3726. * @arg @ref LL_ADC_SAMPLINGTIME_16CYCLES
  3727. * @arg @ref LL_ADC_SAMPLINGTIME_24CYCLES
  3728. * @arg @ref LL_ADC_SAMPLINGTIME_48CYCLES
  3729. * @arg @ref LL_ADC_SAMPLINGTIME_96CYCLES
  3730. * @arg @ref LL_ADC_SAMPLINGTIME_192CYCLES
  3731. * @arg @ref LL_ADC_SAMPLINGTIME_384CYCLES
  3732. */
  3733. __STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel)
  3734. {
  3735. uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
  3736. return (uint32_t)(READ_BIT(*preg,
  3737. ADC_SMPR3_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK))
  3738. >> __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK)
  3739. );
  3740. }
  3741. #if defined(COMP_CSR_FCH3)
  3742. /**
  3743. * @brief Set ADC channels routing.
  3744. * @note Channel routing set configuration between ADC IP and GPIO pads,
  3745. * it is used to increase ADC channels speed (setting of
  3746. * direct channel).
  3747. * @note This feature is specific to STM32L1, on devices
  3748. * category Cat.3, Cat.4, Cat.5.
  3749. * To use this function, COMP RCC clock domain must be enabled.
  3750. * Refer to @ref LL_APB1_GRP1_PERIPH_COMP.
  3751. * @rmtoll CSR FCH3 LL_ADC_SetChannelRouting
  3752. * @rmtoll CSR FCH8 LL_ADC_SetChannelRouting
  3753. * @rmtoll CSR RCH13 LL_ADC_SetChannelRouting
  3754. * @param ADCx ADC instance
  3755. * @param Channel This parameter can be one of the following values:
  3756. * @arg @ref LL_ADC_CHANNEL_3_ROUTING (1)
  3757. * @arg @ref LL_ADC_CHANNEL_8_ROUTING (2)
  3758. * @arg @ref LL_ADC_CHANNEL_13_ROUTING (3)
  3759. *
  3760. * (1) Used as ADC direct channel (fast channel) if OPAMP1 is
  3761. * in power down mode.\n
  3762. * (2) Used as ADC direct channel (fast channel) if OPAMP2 is
  3763. * in power down mode.\n
  3764. * (3) Used as ADC re-routed channel if OPAMP3 is
  3765. * in power down mode.
  3766. * Otherwise, channel 13 is connected to OPAMP3 output and routed
  3767. * through switches COMP1_SW1 and VCOMP to ADC switch matrix.
  3768. * (Note: OPAMP3 is available on STM32L1 Cat.4 only).
  3769. * @param Routing This parameter can be one of the following values:
  3770. * @arg @ref LL_ADC_CHANNEL_ROUTING_DEFAULT
  3771. * @arg @ref LL_ADC_CHANNEL_ROUTING_DIRECT
  3772. */
  3773. __STATIC_INLINE void LL_ADC_SetChannelRouting(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t Routing)
  3774. {
  3775. /* Note: Bit is located in comparator IP, but dedicated to ADC */
  3776. MODIFY_REG(COMP->CSR, Channel, (Routing << POSITION_VAL(Channel)));
  3777. }
  3778. /**
  3779. * @brief Get ADC channels speed.
  3780. * @note Channel routing set configuration between ADC IP and GPIO pads,
  3781. * it is used to increase ADC channels speed (setting of
  3782. * direct channel).
  3783. * @note This feature is specific to STM32L1, on devices
  3784. * category Cat.3, Cat.4, Cat.5.
  3785. * To use this function, COMP RCC clock domain must be enabled.
  3786. * Refer to @ref LL_APB1_GRP1_PERIPH_COMP.
  3787. * @rmtoll CSR FCH3 LL_ADC_GetChannelRouting
  3788. * @rmtoll CSR FCH8 LL_ADC_GetChannelRouting
  3789. * @rmtoll CSR RCH13 LL_ADC_GetChannelRouting
  3790. * @param ADCx ADC instance
  3791. * @param Channel This parameter can be one of the following values:
  3792. * @arg @ref LL_ADC_CHANNEL_3_ROUTING (1)
  3793. * @arg @ref LL_ADC_CHANNEL_8_ROUTING (2)
  3794. * @arg @ref LL_ADC_CHANNEL_13_ROUTING (3)
  3795. *
  3796. * (1) Used as ADC direct channel (fast channel) if OPAMP1 is
  3797. * in power down mode.\n
  3798. * (2) Used as ADC direct channel (fast channel) if OPAMP2 is
  3799. * in power down mode.\n
  3800. * (3) Used as ADC re-routed channel if OPAMP3 is
  3801. * in power down mode.
  3802. * Otherwise, channel 13 is connected to OPAMP3 output and routed
  3803. * through switches COMP1_SW1 and VCOMP to ADC switch matrix.
  3804. * (Note: OPAMP3 is available on STM32L1 Cat.4 only).
  3805. * @retval Returned value can be one of the following values:
  3806. * @arg @ref LL_ADC_CHANNEL_ROUTING_DEFAULT
  3807. * @arg @ref LL_ADC_CHANNEL_ROUTING_DIRECT
  3808. */
  3809. __STATIC_INLINE uint32_t LL_ADC_GetChannelRouting(ADC_TypeDef *ADCx, uint32_t Channel)
  3810. {
  3811. /* Note: Bit is located in comparator IP, but dedicated to ADC */
  3812. return (uint32_t)(READ_BIT(COMP->CSR, Channel) >> POSITION_VAL(Channel));
  3813. }
  3814. #endif
  3815. /**
  3816. * @}
  3817. */
  3818. /** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
  3819. * @{
  3820. */
  3821. /**
  3822. * @brief Set ADC analog watchdog monitored channels:
  3823. * a single channel or all channels,
  3824. * on ADC groups regular and-or injected.
  3825. * @note Once monitored channels are selected, analog watchdog
  3826. * is enabled.
  3827. * @note In case of need to define a single channel to monitor
  3828. * with analog watchdog from sequencer channel definition,
  3829. * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
  3830. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  3831. * instance:
  3832. * - AWD standard (instance AWD1):
  3833. * - channels monitored: can monitor 1 channel or all channels.
  3834. * - groups monitored: ADC groups regular and-or injected.
  3835. * - resolution: resolution is not limited (corresponds to
  3836. * ADC resolution configured).
  3837. * @rmtoll CR1 AWD1CH LL_ADC_SetAnalogWDMonitChannels\n
  3838. * CR1 AWD1SGL LL_ADC_SetAnalogWDMonitChannels\n
  3839. * CR1 AWD1EN LL_ADC_SetAnalogWDMonitChannels
  3840. * @param ADCx ADC instance
  3841. * @param AWDChannelGroup This parameter can be one of the following values:
  3842. * @arg @ref LL_ADC_AWD_DISABLE
  3843. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  3844. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  3845. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  3846. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (2)
  3847. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (2)
  3848. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ (2)
  3849. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (2)
  3850. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (2)
  3851. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ (2)
  3852. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (2)
  3853. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (2)
  3854. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ (2)
  3855. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (2)
  3856. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (2)
  3857. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ (2)
  3858. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (1)
  3859. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (1)
  3860. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ (1)
  3861. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (1)
  3862. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (1)
  3863. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ (1)
  3864. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (2)
  3865. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (2)
  3866. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ (2)
  3867. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (2)
  3868. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (2)
  3869. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ (2)
  3870. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (2)
  3871. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (2)
  3872. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ (2)
  3873. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (2)
  3874. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (2)
  3875. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ (2)
  3876. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (2)
  3877. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (2)
  3878. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ (2)
  3879. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (2)
  3880. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (2)
  3881. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ (2)
  3882. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (2)
  3883. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (2)
  3884. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ (2)
  3885. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (3)
  3886. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (3)
  3887. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ (3)
  3888. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (3)
  3889. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (3)
  3890. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ (3)
  3891. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (3)
  3892. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (3)
  3893. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ (3)
  3894. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (3)
  3895. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (3)
  3896. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ (3)
  3897. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (3)
  3898. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (3)
  3899. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ (3)
  3900. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (3)
  3901. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (3)
  3902. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ (3)
  3903. * @arg @ref LL_ADC_AWD_CHANNEL_19_REG (3)
  3904. * @arg @ref LL_ADC_AWD_CHANNEL_19_INJ (3)
  3905. * @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ (3)
  3906. * @arg @ref LL_ADC_AWD_CHANNEL_20_REG (3)
  3907. * @arg @ref LL_ADC_AWD_CHANNEL_20_INJ (3)
  3908. * @arg @ref LL_ADC_AWD_CHANNEL_20_REG_INJ (3)
  3909. * @arg @ref LL_ADC_AWD_CHANNEL_21_REG (3)
  3910. * @arg @ref LL_ADC_AWD_CHANNEL_21_INJ (3)
  3911. * @arg @ref LL_ADC_AWD_CHANNEL_21_REG_INJ (3)
  3912. * @arg @ref LL_ADC_AWD_CHANNEL_22_REG (1)
  3913. * @arg @ref LL_ADC_AWD_CHANNEL_22_INJ (1)
  3914. * @arg @ref LL_ADC_AWD_CHANNEL_22_REG_INJ (1)
  3915. * @arg @ref LL_ADC_AWD_CHANNEL_23_REG (1)
  3916. * @arg @ref LL_ADC_AWD_CHANNEL_23_INJ (1)
  3917. * @arg @ref LL_ADC_AWD_CHANNEL_23_REG_INJ (1)
  3918. * @arg @ref LL_ADC_AWD_CHANNEL_24_REG (1)
  3919. * @arg @ref LL_ADC_AWD_CHANNEL_24_INJ (1)
  3920. * @arg @ref LL_ADC_AWD_CHANNEL_24_REG_INJ (1)
  3921. * @arg @ref LL_ADC_AWD_CHANNEL_25_REG (1)
  3922. * @arg @ref LL_ADC_AWD_CHANNEL_25_INJ (1)
  3923. * @arg @ref LL_ADC_AWD_CHANNEL_25_REG_INJ (1)
  3924. * @arg @ref LL_ADC_AWD_CHANNEL_26_REG (3)
  3925. * @arg @ref LL_ADC_AWD_CHANNEL_26_INJ (3)
  3926. * @arg @ref LL_ADC_AWD_CHANNEL_26_REG_INJ (3)
  3927. * @arg @ref LL_ADC_AWD_CHANNEL_27_REG (3)(4)
  3928. * @arg @ref LL_ADC_AWD_CHANNEL_27_INJ (3)(4)
  3929. * @arg @ref LL_ADC_AWD_CHANNEL_27_REG_INJ (3)(4)
  3930. * @arg @ref LL_ADC_AWD_CHANNEL_28_REG (3)(4)
  3931. * @arg @ref LL_ADC_AWD_CHANNEL_28_INJ (3)(4)
  3932. * @arg @ref LL_ADC_AWD_CHANNEL_28_REG_INJ (3)(4)
  3933. * @arg @ref LL_ADC_AWD_CHANNEL_29_REG (3)(4)
  3934. * @arg @ref LL_ADC_AWD_CHANNEL_29_INJ (3)(4)
  3935. * @arg @ref LL_ADC_AWD_CHANNEL_29_REG_INJ (3)(4)
  3936. * @arg @ref LL_ADC_AWD_CHANNEL_30_REG (3)(4)
  3937. * @arg @ref LL_ADC_AWD_CHANNEL_30_INJ (3)(4)
  3938. * @arg @ref LL_ADC_AWD_CHANNEL_30_REG_INJ (3)(4)
  3939. * @arg @ref LL_ADC_AWD_CHANNEL_31_REG (3)(4)
  3940. * @arg @ref LL_ADC_AWD_CHANNEL_31_INJ (3)(4)
  3941. * @arg @ref LL_ADC_AWD_CHANNEL_31_REG_INJ (3)(4)
  3942. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (3)
  3943. * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (3)
  3944. * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (3)
  3945. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (3)
  3946. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (3)
  3947. * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (3)
  3948. * @arg @ref LL_ADC_AWD_CH_VCOMP_REG (3)
  3949. * @arg @ref LL_ADC_AWD_CH_VCOMP_INJ (3)
  3950. * @arg @ref LL_ADC_AWD_CH_VCOMP_REG_INJ (3)
  3951. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG (3)(5)
  3952. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_INJ (3)(5)
  3953. * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG_INJ (3)(5)
  3954. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG (3)(5)
  3955. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_INJ (3)(5)
  3956. * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG_INJ (3)(5)
  3957. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG (3)(5)
  3958. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_INJ (3)(5)
  3959. * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG_INJ (3)(5)
  3960. *
  3961. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  3962. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  3963. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  3964. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
  3965. * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
  3966. * @retval None
  3967. */
  3968. __STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDChannelGroup)
  3969. {
  3970. MODIFY_REG(ADCx->CR1,
  3971. (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH),
  3972. AWDChannelGroup);
  3973. }
  3974. /**
  3975. * @brief Get ADC analog watchdog monitored channel.
  3976. * @note Usage of the returned channel number:
  3977. * - To reinject this channel into another function LL_ADC_xxx:
  3978. * the returned channel number is only partly formatted on definition
  3979. * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
  3980. * with parts of literals LL_ADC_CHANNEL_x or using
  3981. * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3982. * Then the selected literal LL_ADC_CHANNEL_x can be used
  3983. * as parameter for another function.
  3984. * - To get the channel number in decimal format:
  3985. * process the returned value with the helper macro
  3986. * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
  3987. * Applicable only when the analog watchdog is set to monitor
  3988. * one channel.
  3989. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  3990. * instance:
  3991. * - AWD standard (instance AWD1):
  3992. * - channels monitored: can monitor 1 channel or all channels.
  3993. * - groups monitored: ADC groups regular and-or injected.
  3994. * - resolution: resolution is not limited (corresponds to
  3995. * ADC resolution configured).
  3996. * @rmtoll CR1 AWD1CH LL_ADC_GetAnalogWDMonitChannels\n
  3997. * CR1 AWD1SGL LL_ADC_GetAnalogWDMonitChannels\n
  3998. * CR1 AWD1EN LL_ADC_GetAnalogWDMonitChannels
  3999. * @param ADCx ADC instance
  4000. * @retval Returned value can be one of the following values:
  4001. * @arg @ref LL_ADC_AWD_DISABLE
  4002. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
  4003. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
  4004. * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
  4005. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (2)
  4006. * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (2)
  4007. * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ (2)
  4008. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (2)
  4009. * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (2)
  4010. * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ (2)
  4011. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (2)
  4012. * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (2)
  4013. * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ (2)
  4014. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (2)
  4015. * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (2)
  4016. * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ (2)
  4017. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (1)
  4018. * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (1)
  4019. * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ (1)
  4020. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (1)
  4021. * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (1)
  4022. * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ (1)
  4023. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (2)
  4024. * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (2)
  4025. * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ (2)
  4026. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (2)
  4027. * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (2)
  4028. * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ (2)
  4029. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (2)
  4030. * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (2)
  4031. * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ (2)
  4032. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (2)
  4033. * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (2)
  4034. * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ (2)
  4035. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (2)
  4036. * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (2)
  4037. * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ (2)
  4038. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (2)
  4039. * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (2)
  4040. * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ (2)
  4041. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (2)
  4042. * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (2)
  4043. * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ (2)
  4044. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (3)
  4045. * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (3)
  4046. * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ (3)
  4047. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (3)
  4048. * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (3)
  4049. * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ (3)
  4050. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (3)
  4051. * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (3)
  4052. * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ (3)
  4053. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (3)
  4054. * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (3)
  4055. * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ (3)
  4056. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (3)
  4057. * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (3)
  4058. * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ (3)
  4059. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (3)
  4060. * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (3)
  4061. * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ (3)
  4062. * @arg @ref LL_ADC_AWD_CHANNEL_19_REG (3)
  4063. * @arg @ref LL_ADC_AWD_CHANNEL_19_INJ (3)
  4064. * @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ (3)
  4065. * @arg @ref LL_ADC_AWD_CHANNEL_20_REG (3)
  4066. * @arg @ref LL_ADC_AWD_CHANNEL_20_INJ (3)
  4067. * @arg @ref LL_ADC_AWD_CHANNEL_20_REG_INJ (3)
  4068. * @arg @ref LL_ADC_AWD_CHANNEL_21_REG (3)
  4069. * @arg @ref LL_ADC_AWD_CHANNEL_21_INJ (3)
  4070. * @arg @ref LL_ADC_AWD_CHANNEL_21_REG_INJ (3)
  4071. * @arg @ref LL_ADC_AWD_CHANNEL_22_REG (1)
  4072. * @arg @ref LL_ADC_AWD_CHANNEL_22_INJ (1)
  4073. * @arg @ref LL_ADC_AWD_CHANNEL_22_REG_INJ (1)
  4074. * @arg @ref LL_ADC_AWD_CHANNEL_23_REG (1)
  4075. * @arg @ref LL_ADC_AWD_CHANNEL_23_INJ (1)
  4076. * @arg @ref LL_ADC_AWD_CHANNEL_23_REG_INJ (1)
  4077. * @arg @ref LL_ADC_AWD_CHANNEL_24_REG (1)
  4078. * @arg @ref LL_ADC_AWD_CHANNEL_24_INJ (1)
  4079. * @arg @ref LL_ADC_AWD_CHANNEL_24_REG_INJ (1)
  4080. * @arg @ref LL_ADC_AWD_CHANNEL_25_REG (1)
  4081. * @arg @ref LL_ADC_AWD_CHANNEL_25_INJ (1)
  4082. * @arg @ref LL_ADC_AWD_CHANNEL_25_REG_INJ (1)
  4083. * @arg @ref LL_ADC_AWD_CHANNEL_26_REG (3)
  4084. * @arg @ref LL_ADC_AWD_CHANNEL_26_INJ (3)
  4085. * @arg @ref LL_ADC_AWD_CHANNEL_26_REG_INJ (3)
  4086. * @arg @ref LL_ADC_AWD_CHANNEL_27_REG (3)(4)
  4087. * @arg @ref LL_ADC_AWD_CHANNEL_27_INJ (3)(4)
  4088. * @arg @ref LL_ADC_AWD_CHANNEL_27_REG_INJ (3)(4)
  4089. * @arg @ref LL_ADC_AWD_CHANNEL_28_REG (3)(4)
  4090. * @arg @ref LL_ADC_AWD_CHANNEL_28_INJ (3)(4)
  4091. * @arg @ref LL_ADC_AWD_CHANNEL_28_REG_INJ (3)(4)
  4092. * @arg @ref LL_ADC_AWD_CHANNEL_29_REG (3)(4)
  4093. * @arg @ref LL_ADC_AWD_CHANNEL_29_INJ (3)(4)
  4094. * @arg @ref LL_ADC_AWD_CHANNEL_29_REG_INJ (3)(4)
  4095. * @arg @ref LL_ADC_AWD_CHANNEL_30_REG (3)(4)
  4096. * @arg @ref LL_ADC_AWD_CHANNEL_30_INJ (3)(4)
  4097. * @arg @ref LL_ADC_AWD_CHANNEL_30_REG_INJ (3)(4)
  4098. * @arg @ref LL_ADC_AWD_CHANNEL_31_REG (3)(4)
  4099. * @arg @ref LL_ADC_AWD_CHANNEL_31_INJ (3)(4)
  4100. * @arg @ref LL_ADC_AWD_CHANNEL_31_REG_INJ (3)(4)
  4101. *
  4102. * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
  4103. * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
  4104. * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
  4105. * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.
  4106. */
  4107. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx)
  4108. {
  4109. return (uint32_t)(READ_BIT(ADCx->CR1, (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH)));
  4110. }
  4111. /**
  4112. * @brief Set ADC analog watchdog threshold value of threshold
  4113. * high or low.
  4114. * @note In case of ADC resolution different of 12 bits,
  4115. * analog watchdog thresholds data require a specific shift.
  4116. * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
  4117. * @note On this STM32 serie, there is only 1 kind of analog watchdog
  4118. * instance:
  4119. * - AWD standard (instance AWD1):
  4120. * - channels monitored: can monitor 1 channel or all channels.
  4121. * - groups monitored: ADC groups regular and-or injected.
  4122. * - resolution: resolution is not limited (corresponds to
  4123. * ADC resolution configured).
  4124. * @rmtoll HTR HT LL_ADC_SetAnalogWDThresholds\n
  4125. * LTR LT LL_ADC_SetAnalogWDThresholds
  4126. * @param ADCx ADC instance
  4127. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  4128. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  4129. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  4130. * @param AWDThresholdValue Value between Min_Data=0x000 and Max_Data=0xFFF
  4131. * @retval None
  4132. */
  4133. __STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue)
  4134. {
  4135. uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
  4136. MODIFY_REG(*preg,
  4137. ADC_HTR_HT,
  4138. AWDThresholdValue);
  4139. }
  4140. /**
  4141. * @brief Get ADC analog watchdog threshold value of threshold high or
  4142. * threshold low.
  4143. * @note In case of ADC resolution different of 12 bits,
  4144. * analog watchdog thresholds data require a specific shift.
  4145. * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
  4146. * @rmtoll HTR HT LL_ADC_GetAnalogWDThresholds\n
  4147. * LTR LT LL_ADC_GetAnalogWDThresholds
  4148. * @param ADCx ADC instance
  4149. * @param AWDThresholdsHighLow This parameter can be one of the following values:
  4150. * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
  4151. * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
  4152. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  4153. */
  4154. __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow)
  4155. {
  4156. uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
  4157. return (uint32_t)(READ_BIT(*preg, ADC_HTR_HT));
  4158. }
  4159. /**
  4160. * @}
  4161. */
  4162. /** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
  4163. * @{
  4164. */
  4165. /**
  4166. * @brief Enable the selected ADC instance.
  4167. * @note On this STM32 serie, after ADC enable, a delay for
  4168. * ADC internal analog stabilization is required before performing a
  4169. * ADC conversion start.
  4170. * Refer to device datasheet, parameter tSTAB.
  4171. * @note Due to the latency introduced by the synchronization between
  4172. * two clock domains (ADC clock source asynchronous),
  4173. * some hardware constraints must be respected:
  4174. * - ADC must be enabled (@ref LL_ADC_Enable() ) only
  4175. * when ADC is not ready to convert.
  4176. * - ADC must be disabled (@ref LL_ADC_Disable() ) only
  4177. * when ADC is ready to convert.
  4178. * Status of ADC ready to convert can be checked using function
  4179. * @ref LL_ADC_IsActiveFlag_ADRDY().
  4180. * @rmtoll CR2 ADON LL_ADC_Enable
  4181. * @param ADCx ADC instance
  4182. * @retval None
  4183. */
  4184. __STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
  4185. {
  4186. SET_BIT(ADCx->CR2, ADC_CR2_ADON);
  4187. }
  4188. /**
  4189. * @brief Disable the selected ADC instance.
  4190. * @note Due to the latency introduced by the synchronization between
  4191. * two clock domains (ADC clock source asynchronous),
  4192. * some hardware constraints must be respected:
  4193. * - ADC must be enabled (@ref LL_ADC_Enable() ) only
  4194. * when ADC is not ready to convert.
  4195. * - ADC must be disabled (@ref LL_ADC_Disable() ) only
  4196. * when ADC is ready to convert.
  4197. * Status of ADC ready to convert can be checked using function
  4198. * @ref LL_ADC_IsActiveFlag_ADRDY().
  4199. * @rmtoll CR2 ADON LL_ADC_Disable
  4200. * @param ADCx ADC instance
  4201. * @retval None
  4202. */
  4203. __STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
  4204. {
  4205. CLEAR_BIT(ADCx->CR2, ADC_CR2_ADON);
  4206. }
  4207. /**
  4208. * @brief Get the selected ADC instance enable state.
  4209. * @rmtoll CR2 ADON LL_ADC_IsEnabled
  4210. * @param ADCx ADC instance
  4211. * @retval 0: ADC is disabled, 1: ADC is enabled.
  4212. */
  4213. __STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
  4214. {
  4215. return (READ_BIT(ADCx->CR2, ADC_CR2_ADON) == (ADC_CR2_ADON));
  4216. }
  4217. /**
  4218. * @}
  4219. */
  4220. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
  4221. * @{
  4222. */
  4223. /**
  4224. * @brief Start ADC group regular conversion.
  4225. * @note On this STM32 serie, this function is relevant only for
  4226. * internal trigger (SW start), not for external trigger:
  4227. * - If ADC trigger has been set to software start, ADC conversion
  4228. * starts immediately.
  4229. * - If ADC trigger has been set to external trigger, ADC conversion
  4230. * start must be performed using function
  4231. * @ref LL_ADC_REG_StartConversionExtTrig().
  4232. * (if external trigger edge would have been set during ADC other
  4233. * settings, ADC conversion would start at trigger event
  4234. * as soon as ADC is enabled).
  4235. * @rmtoll CR2 SWSTART LL_ADC_REG_StartConversionSWStart
  4236. * @param ADCx ADC instance
  4237. * @retval None
  4238. */
  4239. __STATIC_INLINE void LL_ADC_REG_StartConversionSWStart(ADC_TypeDef *ADCx)
  4240. {
  4241. SET_BIT(ADCx->CR2, ADC_CR2_SWSTART);
  4242. }
  4243. /**
  4244. * @brief Start ADC group regular conversion from external trigger.
  4245. * @note ADC conversion will start at next trigger event (on the selected
  4246. * trigger edge) following the ADC start conversion command.
  4247. * @note On this STM32 serie, this function is relevant for
  4248. * ADC conversion start from external trigger.
  4249. * If internal trigger (SW start) is needed, perform ADC conversion
  4250. * start using function @ref LL_ADC_REG_StartConversionSWStart().
  4251. * @rmtoll CR2 EXTEN LL_ADC_REG_StartConversionExtTrig
  4252. * @param ExternalTriggerEdge This parameter can be one of the following values:
  4253. * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
  4254. * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
  4255. * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
  4256. * @param ADCx ADC instance
  4257. * @retval None
  4258. */
  4259. __STATIC_INLINE void LL_ADC_REG_StartConversionExtTrig(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  4260. {
  4261. SET_BIT(ADCx->CR2, ExternalTriggerEdge);
  4262. }
  4263. /**
  4264. * @brief Stop ADC group regular conversion from external trigger.
  4265. * @note No more ADC conversion will start at next trigger event
  4266. * following the ADC stop conversion command.
  4267. * If a conversion is on-going, it will be completed.
  4268. * @note On this STM32 serie, there is no specific command
  4269. * to stop a conversion on-going or to stop ADC converting
  4270. * in continuous mode. These actions can be performed
  4271. * using function @ref LL_ADC_Disable().
  4272. * @rmtoll CR2 EXTEN LL_ADC_REG_StopConversionExtTrig
  4273. * @param ADCx ADC instance
  4274. * @retval None
  4275. */
  4276. __STATIC_INLINE void LL_ADC_REG_StopConversionExtTrig(ADC_TypeDef *ADCx)
  4277. {
  4278. CLEAR_BIT(ADCx->CR2, ADC_CR2_EXTEN);
  4279. }
  4280. /**
  4281. * @brief Get ADC group regular conversion data, range fit for
  4282. * all ADC configurations: all ADC resolutions and
  4283. * all oversampling increased data width (for devices
  4284. * with feature oversampling).
  4285. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData32
  4286. * @param ADCx ADC instance
  4287. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  4288. */
  4289. __STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
  4290. {
  4291. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  4292. }
  4293. /**
  4294. * @brief Get ADC group regular conversion data, range fit for
  4295. * ADC resolution 12 bits.
  4296. * @note For devices with feature oversampling: Oversampling
  4297. * can increase data width, function for extended range
  4298. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  4299. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData12
  4300. * @param ADCx ADC instance
  4301. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  4302. */
  4303. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
  4304. {
  4305. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  4306. }
  4307. /**
  4308. * @brief Get ADC group regular conversion data, range fit for
  4309. * ADC resolution 10 bits.
  4310. * @note For devices with feature oversampling: Oversampling
  4311. * can increase data width, function for extended range
  4312. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  4313. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData10
  4314. * @param ADCx ADC instance
  4315. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  4316. */
  4317. __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData10(ADC_TypeDef *ADCx)
  4318. {
  4319. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  4320. }
  4321. /**
  4322. * @brief Get ADC group regular conversion data, range fit for
  4323. * ADC resolution 8 bits.
  4324. * @note For devices with feature oversampling: Oversampling
  4325. * can increase data width, function for extended range
  4326. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  4327. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData8
  4328. * @param ADCx ADC instance
  4329. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  4330. */
  4331. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData8(ADC_TypeDef *ADCx)
  4332. {
  4333. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  4334. }
  4335. /**
  4336. * @brief Get ADC group regular conversion data, range fit for
  4337. * ADC resolution 6 bits.
  4338. * @note For devices with feature oversampling: Oversampling
  4339. * can increase data width, function for extended range
  4340. * may be needed: @ref LL_ADC_REG_ReadConversionData32.
  4341. * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData6
  4342. * @param ADCx ADC instance
  4343. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  4344. */
  4345. __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData6(ADC_TypeDef *ADCx)
  4346. {
  4347. return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
  4348. }
  4349. /**
  4350. * @}
  4351. */
  4352. /** @defgroup ADC_LL_EF_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected
  4353. * @{
  4354. */
  4355. /**
  4356. * @brief Start ADC group injected conversion.
  4357. * @note On this STM32 serie, this function is relevant only for
  4358. * internal trigger (SW start), not for external trigger:
  4359. * - If ADC trigger has been set to software start, ADC conversion
  4360. * starts immediately.
  4361. * - If ADC trigger has been set to external trigger, ADC conversion
  4362. * start must be performed using function
  4363. * @ref LL_ADC_INJ_StartConversionExtTrig().
  4364. * (if external trigger edge would have been set during ADC other
  4365. * settings, ADC conversion would start at trigger event
  4366. * as soon as ADC is enabled).
  4367. * @rmtoll CR2 JSWSTART LL_ADC_INJ_StartConversionSWStart
  4368. * @param ADCx ADC instance
  4369. * @retval None
  4370. */
  4371. __STATIC_INLINE void LL_ADC_INJ_StartConversionSWStart(ADC_TypeDef *ADCx)
  4372. {
  4373. SET_BIT(ADCx->CR2, ADC_CR2_JSWSTART);
  4374. }
  4375. /**
  4376. * @brief Start ADC group injected conversion from external trigger.
  4377. * @note ADC conversion will start at next trigger event (on the selected
  4378. * trigger edge) following the ADC start conversion command.
  4379. * @note On this STM32 serie, this function is relevant for
  4380. * ADC conversion start from external trigger.
  4381. * If internal trigger (SW start) is needed, perform ADC conversion
  4382. * start using function @ref LL_ADC_INJ_StartConversionSWStart().
  4383. * @rmtoll CR2 JEXTEN LL_ADC_INJ_StartConversionExtTrig
  4384. * @param ExternalTriggerEdge This parameter can be one of the following values:
  4385. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
  4386. * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
  4387. * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
  4388. * @param ADCx ADC instance
  4389. * @retval None
  4390. */
  4391. __STATIC_INLINE void LL_ADC_INJ_StartConversionExtTrig(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
  4392. {
  4393. SET_BIT(ADCx->CR2, ExternalTriggerEdge);
  4394. }
  4395. /**
  4396. * @brief Stop ADC group injected conversion from external trigger.
  4397. * @note No more ADC conversion will start at next trigger event
  4398. * following the ADC stop conversion command.
  4399. * If a conversion is on-going, it will be completed.
  4400. * @note On this STM32 serie, there is no specific command
  4401. * to stop a conversion on-going or to stop ADC converting
  4402. * in continuous mode. These actions can be performed
  4403. * using function @ref LL_ADC_Disable().
  4404. * @rmtoll CR2 JEXTEN LL_ADC_INJ_StopConversionExtTrig
  4405. * @param ADCx ADC instance
  4406. * @retval None
  4407. */
  4408. __STATIC_INLINE void LL_ADC_INJ_StopConversionExtTrig(ADC_TypeDef *ADCx)
  4409. {
  4410. CLEAR_BIT(ADCx->CR2, ADC_CR2_JEXTEN);
  4411. }
  4412. /**
  4413. * @brief Get ADC group regular conversion data, range fit for
  4414. * all ADC configurations: all ADC resolutions and
  4415. * all oversampling increased data width (for devices
  4416. * with feature oversampling).
  4417. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData32\n
  4418. * JDR2 JDATA LL_ADC_INJ_ReadConversionData32\n
  4419. * JDR3 JDATA LL_ADC_INJ_ReadConversionData32\n
  4420. * JDR4 JDATA LL_ADC_INJ_ReadConversionData32
  4421. * @param ADCx ADC instance
  4422. * @param Rank This parameter can be one of the following values:
  4423. * @arg @ref LL_ADC_INJ_RANK_1
  4424. * @arg @ref LL_ADC_INJ_RANK_2
  4425. * @arg @ref LL_ADC_INJ_RANK_3
  4426. * @arg @ref LL_ADC_INJ_RANK_4
  4427. * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
  4428. */
  4429. __STATIC_INLINE uint32_t LL_ADC_INJ_ReadConversionData32(ADC_TypeDef *ADCx, uint32_t Rank)
  4430. {
  4431. uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  4432. return (uint32_t)(READ_BIT(*preg,
  4433. ADC_JDR1_JDATA)
  4434. );
  4435. }
  4436. /**
  4437. * @brief Get ADC group injected conversion data, range fit for
  4438. * ADC resolution 12 bits.
  4439. * @note For devices with feature oversampling: Oversampling
  4440. * can increase data width, function for extended range
  4441. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  4442. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData12\n
  4443. * JDR2 JDATA LL_ADC_INJ_ReadConversionData12\n
  4444. * JDR3 JDATA LL_ADC_INJ_ReadConversionData12\n
  4445. * JDR4 JDATA LL_ADC_INJ_ReadConversionData12
  4446. * @param ADCx ADC instance
  4447. * @param Rank This parameter can be one of the following values:
  4448. * @arg @ref LL_ADC_INJ_RANK_1
  4449. * @arg @ref LL_ADC_INJ_RANK_2
  4450. * @arg @ref LL_ADC_INJ_RANK_3
  4451. * @arg @ref LL_ADC_INJ_RANK_4
  4452. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  4453. */
  4454. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData12(ADC_TypeDef *ADCx, uint32_t Rank)
  4455. {
  4456. uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  4457. return (uint16_t)(READ_BIT(*preg,
  4458. ADC_JDR1_JDATA)
  4459. );
  4460. }
  4461. /**
  4462. * @brief Get ADC group injected conversion data, range fit for
  4463. * ADC resolution 10 bits.
  4464. * @note For devices with feature oversampling: Oversampling
  4465. * can increase data width, function for extended range
  4466. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  4467. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData10\n
  4468. * JDR2 JDATA LL_ADC_INJ_ReadConversionData10\n
  4469. * JDR3 JDATA LL_ADC_INJ_ReadConversionData10\n
  4470. * JDR4 JDATA LL_ADC_INJ_ReadConversionData10
  4471. * @param ADCx ADC instance
  4472. * @param Rank This parameter can be one of the following values:
  4473. * @arg @ref LL_ADC_INJ_RANK_1
  4474. * @arg @ref LL_ADC_INJ_RANK_2
  4475. * @arg @ref LL_ADC_INJ_RANK_3
  4476. * @arg @ref LL_ADC_INJ_RANK_4
  4477. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  4478. */
  4479. __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData10(ADC_TypeDef *ADCx, uint32_t Rank)
  4480. {
  4481. uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  4482. return (uint16_t)(READ_BIT(*preg,
  4483. ADC_JDR1_JDATA)
  4484. );
  4485. }
  4486. /**
  4487. * @brief Get ADC group injected conversion data, range fit for
  4488. * ADC resolution 8 bits.
  4489. * @note For devices with feature oversampling: Oversampling
  4490. * can increase data width, function for extended range
  4491. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  4492. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData8\n
  4493. * JDR2 JDATA LL_ADC_INJ_ReadConversionData8\n
  4494. * JDR3 JDATA LL_ADC_INJ_ReadConversionData8\n
  4495. * JDR4 JDATA LL_ADC_INJ_ReadConversionData8
  4496. * @param ADCx ADC instance
  4497. * @param Rank This parameter can be one of the following values:
  4498. * @arg @ref LL_ADC_INJ_RANK_1
  4499. * @arg @ref LL_ADC_INJ_RANK_2
  4500. * @arg @ref LL_ADC_INJ_RANK_3
  4501. * @arg @ref LL_ADC_INJ_RANK_4
  4502. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  4503. */
  4504. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData8(ADC_TypeDef *ADCx, uint32_t Rank)
  4505. {
  4506. uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  4507. return (uint8_t)(READ_BIT(*preg,
  4508. ADC_JDR1_JDATA)
  4509. );
  4510. }
  4511. /**
  4512. * @brief Get ADC group injected conversion data, range fit for
  4513. * ADC resolution 6 bits.
  4514. * @note For devices with feature oversampling: Oversampling
  4515. * can increase data width, function for extended range
  4516. * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
  4517. * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData6\n
  4518. * JDR2 JDATA LL_ADC_INJ_ReadConversionData6\n
  4519. * JDR3 JDATA LL_ADC_INJ_ReadConversionData6\n
  4520. * JDR4 JDATA LL_ADC_INJ_ReadConversionData6
  4521. * @param ADCx ADC instance
  4522. * @param Rank This parameter can be one of the following values:
  4523. * @arg @ref LL_ADC_INJ_RANK_1
  4524. * @arg @ref LL_ADC_INJ_RANK_2
  4525. * @arg @ref LL_ADC_INJ_RANK_3
  4526. * @arg @ref LL_ADC_INJ_RANK_4
  4527. * @retval Value between Min_Data=0x00 and Max_Data=0x3F
  4528. */
  4529. __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData6(ADC_TypeDef *ADCx, uint32_t Rank)
  4530. {
  4531. uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
  4532. return (uint8_t)(READ_BIT(*preg,
  4533. ADC_JDR1_JDATA)
  4534. );
  4535. }
  4536. /**
  4537. * @}
  4538. */
  4539. /** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
  4540. * @{
  4541. */
  4542. /**
  4543. * @brief Get flag ADC ready.
  4544. * @rmtoll SR ADONS LL_ADC_IsActiveFlag_ADRDY
  4545. * @param ADCx ADC instance
  4546. * @retval State of bit (1 or 0).
  4547. */
  4548. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_ADRDY(ADC_TypeDef *ADCx)
  4549. {
  4550. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_ADRDY) == (LL_ADC_FLAG_ADRDY));
  4551. }
  4552. /**
  4553. * @brief Get flag ADC group regular end of unitary conversion
  4554. * or end of sequence conversions, depending on
  4555. * ADC configuration.
  4556. * @note To configure flag of end of conversion,
  4557. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4558. * @rmtoll SR EOC LL_ADC_IsActiveFlag_EOCS
  4559. * @param ADCx ADC instance
  4560. * @retval State of bit (1 or 0).
  4561. */
  4562. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOCS(ADC_TypeDef *ADCx)
  4563. {
  4564. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_EOCS) == (LL_ADC_FLAG_EOCS));
  4565. }
  4566. /**
  4567. * @brief Get flag ADC group regular overrun.
  4568. * @rmtoll SR OVR LL_ADC_IsActiveFlag_OVR
  4569. * @param ADCx ADC instance
  4570. * @retval State of bit (1 or 0).
  4571. */
  4572. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_OVR(ADC_TypeDef *ADCx)
  4573. {
  4574. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_OVR) == (LL_ADC_FLAG_OVR));
  4575. }
  4576. /**
  4577. * @brief Get flag ADC group injected end of sequence conversions.
  4578. * @rmtoll SR JEOC LL_ADC_IsActiveFlag_JEOS
  4579. * @param ADCx ADC instance
  4580. * @retval State of bit (1 or 0).
  4581. */
  4582. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOS(ADC_TypeDef *ADCx)
  4583. {
  4584. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4585. /* end of unitary conversion. */
  4586. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4587. /* in other STM32 families). */
  4588. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_JEOS) == (LL_ADC_FLAG_JEOS));
  4589. }
  4590. /**
  4591. * @brief Get flag ADC analog watchdog 1 flag
  4592. * @rmtoll SR AWD LL_ADC_IsActiveFlag_AWD1
  4593. * @param ADCx ADC instance
  4594. * @retval State of bit (1 or 0).
  4595. */
  4596. __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(ADC_TypeDef *ADCx)
  4597. {
  4598. return (READ_BIT(ADCx->SR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1));
  4599. }
  4600. /**
  4601. * @brief Clear flag ADC group regular end of unitary conversion
  4602. * or end of sequence conversions, depending on
  4603. * ADC configuration.
  4604. * @note To configure flag of end of conversion,
  4605. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4606. * @rmtoll SR EOC LL_ADC_ClearFlag_EOCS
  4607. * @param ADCx ADC instance
  4608. * @retval None
  4609. */
  4610. __STATIC_INLINE void LL_ADC_ClearFlag_EOCS(ADC_TypeDef *ADCx)
  4611. {
  4612. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_EOCS);
  4613. }
  4614. /**
  4615. * @brief Clear flag ADC group regular overrun.
  4616. * @rmtoll SR OVR LL_ADC_ClearFlag_OVR
  4617. * @param ADCx ADC instance
  4618. * @retval None
  4619. */
  4620. __STATIC_INLINE void LL_ADC_ClearFlag_OVR(ADC_TypeDef *ADCx)
  4621. {
  4622. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_OVR);
  4623. }
  4624. /**
  4625. * @brief Clear flag ADC group injected end of sequence conversions.
  4626. * @rmtoll SR JEOC LL_ADC_ClearFlag_JEOS
  4627. * @param ADCx ADC instance
  4628. * @retval None
  4629. */
  4630. __STATIC_INLINE void LL_ADC_ClearFlag_JEOS(ADC_TypeDef *ADCx)
  4631. {
  4632. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4633. /* end of unitary conversion. */
  4634. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4635. /* in other STM32 families). */
  4636. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_JEOS);
  4637. }
  4638. /**
  4639. * @brief Clear flag ADC analog watchdog 1.
  4640. * @rmtoll SR AWD LL_ADC_ClearFlag_AWD1
  4641. * @param ADCx ADC instance
  4642. * @retval None
  4643. */
  4644. __STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx)
  4645. {
  4646. WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_AWD1);
  4647. }
  4648. /**
  4649. * @}
  4650. */
  4651. /** @defgroup ADC_LL_EF_IT_Management ADC IT management
  4652. * @{
  4653. */
  4654. /**
  4655. * @brief Enable interruption ADC group regular end of unitary conversion
  4656. * or end of sequence conversions, depending on
  4657. * ADC configuration.
  4658. * @note To configure flag of end of conversion,
  4659. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4660. * @rmtoll CR1 EOCIE LL_ADC_EnableIT_EOCS
  4661. * @param ADCx ADC instance
  4662. * @retval None
  4663. */
  4664. __STATIC_INLINE void LL_ADC_EnableIT_EOCS(ADC_TypeDef *ADCx)
  4665. {
  4666. SET_BIT(ADCx->CR1, LL_ADC_IT_EOCS);
  4667. }
  4668. /**
  4669. * @brief Enable ADC group regular interruption overrun.
  4670. * @rmtoll CR1 OVRIE LL_ADC_EnableIT_OVR
  4671. * @param ADCx ADC instance
  4672. * @retval None
  4673. */
  4674. __STATIC_INLINE void LL_ADC_EnableIT_OVR(ADC_TypeDef *ADCx)
  4675. {
  4676. SET_BIT(ADCx->CR1, LL_ADC_IT_OVR);
  4677. }
  4678. /**
  4679. * @brief Enable interruption ADC group injected end of sequence conversions.
  4680. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  4681. * @param ADCx ADC instance
  4682. * @retval None
  4683. */
  4684. __STATIC_INLINE void LL_ADC_EnableIT_JEOS(ADC_TypeDef *ADCx)
  4685. {
  4686. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4687. /* end of unitary conversion. */
  4688. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4689. /* in other STM32 families). */
  4690. SET_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
  4691. }
  4692. /**
  4693. * @brief Enable interruption ADC analog watchdog 1.
  4694. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  4695. * @param ADCx ADC instance
  4696. * @retval None
  4697. */
  4698. __STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx)
  4699. {
  4700. SET_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
  4701. }
  4702. /**
  4703. * @brief Disable interruption ADC group regular end of unitary conversion
  4704. * or end of sequence conversions, depending on
  4705. * ADC configuration.
  4706. * @note To configure flag of end of conversion,
  4707. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4708. * @rmtoll CR1 EOCIE LL_ADC_DisableIT_EOCS
  4709. * @param ADCx ADC instance
  4710. * @retval None
  4711. */
  4712. __STATIC_INLINE void LL_ADC_DisableIT_EOCS(ADC_TypeDef *ADCx)
  4713. {
  4714. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_EOCS);
  4715. }
  4716. /**
  4717. * @brief Disable interruption ADC group regular overrun.
  4718. * @rmtoll CR1 OVRIE LL_ADC_DisableIT_OVR
  4719. * @param ADCx ADC instance
  4720. * @retval None
  4721. */
  4722. __STATIC_INLINE void LL_ADC_DisableIT_OVR(ADC_TypeDef *ADCx)
  4723. {
  4724. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_OVR);
  4725. }
  4726. /**
  4727. * @brief Disable interruption ADC group injected end of sequence conversions.
  4728. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  4729. * @param ADCx ADC instance
  4730. * @retval None
  4731. */
  4732. __STATIC_INLINE void LL_ADC_DisableIT_JEOS(ADC_TypeDef *ADCx)
  4733. {
  4734. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4735. /* end of unitary conversion. */
  4736. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4737. /* in other STM32 families). */
  4738. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
  4739. }
  4740. /**
  4741. * @brief Disable interruption ADC analog watchdog 1.
  4742. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  4743. * @param ADCx ADC instance
  4744. * @retval None
  4745. */
  4746. __STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx)
  4747. {
  4748. CLEAR_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
  4749. }
  4750. /**
  4751. * @brief Get state of interruption ADC group regular end of unitary conversion
  4752. * or end of sequence conversions, depending on
  4753. * ADC configuration.
  4754. * @note To configure flag of end of conversion,
  4755. * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
  4756. * (0: interrupt disabled, 1: interrupt enabled)
  4757. * @rmtoll CR1 EOCIE LL_ADC_IsEnabledIT_EOCS
  4758. * @param ADCx ADC instance
  4759. * @retval State of bit (1 or 0).
  4760. */
  4761. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOCS(ADC_TypeDef *ADCx)
  4762. {
  4763. return (READ_BIT(ADCx->CR1, LL_ADC_IT_EOCS) == (LL_ADC_IT_EOCS));
  4764. }
  4765. /**
  4766. * @brief Get state of interruption ADC group regular overrun
  4767. * (0: interrupt disabled, 1: interrupt enabled).
  4768. * @rmtoll CR1 OVRIE LL_ADC_IsEnabledIT_OVR
  4769. * @param ADCx ADC instance
  4770. * @retval State of bit (1 or 0).
  4771. */
  4772. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_OVR(ADC_TypeDef *ADCx)
  4773. {
  4774. return (READ_BIT(ADCx->CR1, LL_ADC_IT_OVR) == (LL_ADC_IT_OVR));
  4775. }
  4776. /**
  4777. * @brief Get state of interruption ADC group injected end of sequence conversions
  4778. * (0: interrupt disabled, 1: interrupt enabled).
  4779. * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
  4780. * @param ADCx ADC instance
  4781. * @retval State of bit (1 or 0).
  4782. */
  4783. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOS(ADC_TypeDef *ADCx)
  4784. {
  4785. /* Note: on this STM32 serie, there is no flag ADC group injected */
  4786. /* end of unitary conversion. */
  4787. /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
  4788. /* in other STM32 families). */
  4789. return (READ_BIT(ADCx->CR1, LL_ADC_IT_JEOS) == (LL_ADC_IT_JEOS));
  4790. }
  4791. /**
  4792. * @brief Get state of interruption ADC analog watchdog 1
  4793. * (0: interrupt disabled, 1: interrupt enabled).
  4794. * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
  4795. * @param ADCx ADC instance
  4796. * @retval State of bit (1 or 0).
  4797. */
  4798. __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(ADC_TypeDef *ADCx)
  4799. {
  4800. return (READ_BIT(ADCx->CR1, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1));
  4801. }
  4802. /**
  4803. * @}
  4804. */
  4805. #if defined(USE_FULL_LL_DRIVER)
  4806. /** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
  4807. * @{
  4808. */
  4809. /* Initialization of some features of ADC common parameters and multimode */
  4810. ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
  4811. ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  4812. void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
  4813. /* De-initialization of ADC instance, ADC group regular and ADC group injected */
  4814. /* (availability of ADC group injected depends on STM32 families) */
  4815. ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
  4816. /* Initialization of some features of ADC instance */
  4817. ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
  4818. void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
  4819. /* Initialization of some features of ADC instance and ADC group regular */
  4820. ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  4821. void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
  4822. /* Initialization of some features of ADC instance and ADC group injected */
  4823. ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  4824. void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
  4825. /**
  4826. * @}
  4827. */
  4828. #endif /* USE_FULL_LL_DRIVER */
  4829. /**
  4830. * @}
  4831. */
  4832. /**
  4833. * @}
  4834. */
  4835. #endif /* ADC1 */
  4836. /**
  4837. * @}
  4838. */
  4839. #ifdef __cplusplus
  4840. }
  4841. #endif
  4842. #endif /* __STM32L1xx_LL_ADC_H */
  4843. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/