训练营PLSR题目
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

4780 righe
278 KiB

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