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.
 
 
 

4751 lines
274 KiB

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