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.
 
 
 

4693 lines
271 KiB

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