mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
186:707f6e361f3e
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 158:b23ee177fd68 1 /**
Kojto 158:b23ee177fd68 2 ******************************************************************************
Kojto 158:b23ee177fd68 3 * @file stm32l0xx_ll_adc.h
Kojto 158:b23ee177fd68 4 * @author MCD Application Team
Kojto 158:b23ee177fd68 5 * @brief Header file of ADC LL module.
Kojto 158:b23ee177fd68 6 ******************************************************************************
Kojto 158:b23ee177fd68 7 * @attention
Kojto 158:b23ee177fd68 8 *
Kojto 158:b23ee177fd68 9 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 158:b23ee177fd68 10 *
Kojto 158:b23ee177fd68 11 * Redistribution and use in source and binary forms, with or without modification,
Kojto 158:b23ee177fd68 12 * are permitted provided that the following conditions are met:
Kojto 158:b23ee177fd68 13 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 158:b23ee177fd68 14 * this list of conditions and the following disclaimer.
Kojto 158:b23ee177fd68 15 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 158:b23ee177fd68 16 * this list of conditions and the following disclaimer in the documentation
Kojto 158:b23ee177fd68 17 * and/or other materials provided with the distribution.
Kojto 158:b23ee177fd68 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 158:b23ee177fd68 19 * may be used to endorse or promote products derived from this software
Kojto 158:b23ee177fd68 20 * without specific prior written permission.
Kojto 158:b23ee177fd68 21 *
Kojto 158:b23ee177fd68 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 158:b23ee177fd68 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 158:b23ee177fd68 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 158:b23ee177fd68 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 158:b23ee177fd68 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 158:b23ee177fd68 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 158:b23ee177fd68 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 158:b23ee177fd68 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 158:b23ee177fd68 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 158:b23ee177fd68 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 158:b23ee177fd68 32 *
Kojto 158:b23ee177fd68 33 ******************************************************************************
Kojto 158:b23ee177fd68 34 */
Kojto 158:b23ee177fd68 35
Kojto 158:b23ee177fd68 36 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 158:b23ee177fd68 37 #ifndef __STM32L0xx_LL_ADC_H
Kojto 158:b23ee177fd68 38 #define __STM32L0xx_LL_ADC_H
Kojto 158:b23ee177fd68 39
Kojto 158:b23ee177fd68 40 #ifdef __cplusplus
Kojto 158:b23ee177fd68 41 extern "C" {
Kojto 158:b23ee177fd68 42 #endif
Kojto 158:b23ee177fd68 43
Kojto 158:b23ee177fd68 44 /* Includes ------------------------------------------------------------------*/
Kojto 158:b23ee177fd68 45 #include "stm32l0xx.h"
Kojto 158:b23ee177fd68 46
Kojto 158:b23ee177fd68 47 /** @addtogroup STM32L0xx_LL_Driver
Kojto 158:b23ee177fd68 48 * @{
Kojto 158:b23ee177fd68 49 */
Kojto 158:b23ee177fd68 50
Kojto 158:b23ee177fd68 51 #if defined (ADC1)
Kojto 158:b23ee177fd68 52
Kojto 158:b23ee177fd68 53 /** @defgroup ADC_LL ADC
Kojto 158:b23ee177fd68 54 * @{
Kojto 158:b23ee177fd68 55 */
Kojto 158:b23ee177fd68 56
Kojto 158:b23ee177fd68 57 /* Private types -------------------------------------------------------------*/
Kojto 158:b23ee177fd68 58 /* Private variables ---------------------------------------------------------*/
Kojto 158:b23ee177fd68 59
Kojto 158:b23ee177fd68 60 /* Private constants ---------------------------------------------------------*/
Kojto 158:b23ee177fd68 61 /** @defgroup ADC_LL_Private_Constants ADC Private Constants
Kojto 158:b23ee177fd68 62 * @{
Kojto 158:b23ee177fd68 63 */
Kojto 158:b23ee177fd68 64
Kojto 158:b23ee177fd68 65 /* Internal mask for ADC group regular trigger: */
Kojto 158:b23ee177fd68 66 /* To select into literal LL_ADC_REG_TRIG_x the relevant bits for: */
Kojto 158:b23ee177fd68 67 /* - regular trigger source */
Kojto 158:b23ee177fd68 68 /* - regular trigger edge */
Kojto 158:b23ee177fd68 69 #define ADC_REG_TRIG_EXT_EDGE_DEFAULT (ADC_CFGR1_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) */
Kojto 158:b23ee177fd68 70
Kojto 158:b23ee177fd68 71 /* Mask containing trigger source masks for each of possible */
Kojto 158:b23ee177fd68 72 /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
Kojto 158:b23ee177fd68 73 /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
Kojto 158:b23ee177fd68 74 #define ADC_REG_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR1_EXTSEL) << (4U * 0U)) | \
Kojto 158:b23ee177fd68 75 ((ADC_CFGR1_EXTSEL) << (4U * 1U)) | \
Kojto 158:b23ee177fd68 76 ((ADC_CFGR1_EXTSEL) << (4U * 2U)) | \
Kojto 158:b23ee177fd68 77 ((ADC_CFGR1_EXTSEL) << (4U * 3U)) )
Kojto 158:b23ee177fd68 78
Kojto 158:b23ee177fd68 79 /* Mask containing trigger edge masks for each of possible */
Kojto 158:b23ee177fd68 80 /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
Kojto 158:b23ee177fd68 81 /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
Kojto 158:b23ee177fd68 82 #define ADC_REG_TRIG_EDGE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR1_EXTEN) << (4U * 0U)) | \
Kojto 158:b23ee177fd68 83 ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 1U)) | \
Kojto 158:b23ee177fd68 84 ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 2U)) | \
Kojto 158:b23ee177fd68 85 ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 3U)) )
Kojto 158:b23ee177fd68 86
Kojto 158:b23ee177fd68 87 /* Definition of ADC group regular trigger bits information. */
Kojto 158:b23ee177fd68 88 #define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_CFGR1_EXTSEL) */
Kojto 158:b23ee177fd68 89 #define ADC_REG_TRIG_EXTEN_BITOFFSET_POS ((uint32_t)10U) /* Value equivalent to POSITION_VAL(ADC_CFGR1_EXTEN) */
Kojto 158:b23ee177fd68 90
Kojto 158:b23ee177fd68 91
Kojto 158:b23ee177fd68 92
Kojto 158:b23ee177fd68 93 /* Internal mask for ADC channel: */
Kojto 158:b23ee177fd68 94 /* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
Kojto 158:b23ee177fd68 95 /* - channel identifier defined by number */
Kojto 158:b23ee177fd68 96 /* - channel identifier defined by bitfield */
Kojto 158:b23ee177fd68 97 /* - channel differentiation between external channels (connected to */
Kojto 158:b23ee177fd68 98 /* GPIO pins) and internal channels (connected to internal paths) */
Kojto 158:b23ee177fd68 99 #define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CFGR1_AWDCH)
Kojto 158:b23ee177fd68 100 #define ADC_CHANNEL_ID_BITFIELD_MASK (ADC_CHSELR_CHSEL)
Kojto 158:b23ee177fd68 101 #define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS ((uint32_t)26U)/* Value equivalent to POSITION_VAL(ADC_CHANNEL_ID_NUMBER_MASK) */
Kojto 158:b23ee177fd68 102 #define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_BITFIELD_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
Kojto 158:b23ee177fd68 103 /* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
Kojto 158:b23ee177fd68 104 #define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 ((uint32_t)0x0000001FU) /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> POSITION_VAL(ADC_CHANNEL_NUMBER_MASK)) */
Kojto 158:b23ee177fd68 105
Kojto 158:b23ee177fd68 106 /* Channel differentiation between external and internal channels */
Kojto 158:b23ee177fd68 107 #define ADC_CHANNEL_ID_INTERNAL_CH ((uint32_t)0x80000000U) /* Marker of internal channel */
Kojto 158:b23ee177fd68 108 #define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH)
Kojto 158:b23ee177fd68 109
Kojto 158:b23ee177fd68 110 /* Definition of channels ID number information to be inserted into */
Kojto 158:b23ee177fd68 111 /* channels literals definition. */
Kojto 158:b23ee177fd68 112 #define ADC_CHANNEL_0_NUMBER ((uint32_t)0x00000000U)
Kojto 158:b23ee177fd68 113 #define ADC_CHANNEL_1_NUMBER ( ADC_CFGR1_AWDCH_0)
Kojto 158:b23ee177fd68 114 #define ADC_CHANNEL_2_NUMBER ( ADC_CFGR1_AWDCH_1 )
Kojto 158:b23ee177fd68 115 #define ADC_CHANNEL_3_NUMBER ( ADC_CFGR1_AWDCH_1 | ADC_CFGR1_AWDCH_0)
Kojto 158:b23ee177fd68 116 #define ADC_CHANNEL_4_NUMBER ( ADC_CFGR1_AWDCH_2 )
Kojto 158:b23ee177fd68 117 #define ADC_CHANNEL_5_NUMBER ( ADC_CFGR1_AWDCH_2 | ADC_CFGR1_AWDCH_0)
Kojto 158:b23ee177fd68 118 #define ADC_CHANNEL_6_NUMBER ( ADC_CFGR1_AWDCH_2 | ADC_CFGR1_AWDCH_1 )
Kojto 158:b23ee177fd68 119 #define ADC_CHANNEL_7_NUMBER ( ADC_CFGR1_AWDCH_2 | ADC_CFGR1_AWDCH_1 | ADC_CFGR1_AWDCH_0)
Kojto 158:b23ee177fd68 120 #define ADC_CHANNEL_8_NUMBER ( ADC_CFGR1_AWDCH_3 )
Kojto 158:b23ee177fd68 121 #define ADC_CHANNEL_9_NUMBER ( ADC_CFGR1_AWDCH_3 | ADC_CFGR1_AWDCH_0)
Kojto 158:b23ee177fd68 122 #define ADC_CHANNEL_10_NUMBER ( ADC_CFGR1_AWDCH_3 | ADC_CFGR1_AWDCH_1 )
Kojto 158:b23ee177fd68 123 #define ADC_CHANNEL_11_NUMBER ( ADC_CFGR1_AWDCH_3 | ADC_CFGR1_AWDCH_1 | ADC_CFGR1_AWDCH_0)
Kojto 158:b23ee177fd68 124 #define ADC_CHANNEL_12_NUMBER ( ADC_CFGR1_AWDCH_3 | ADC_CFGR1_AWDCH_2 )
Kojto 158:b23ee177fd68 125 #define ADC_CHANNEL_13_NUMBER ( ADC_CFGR1_AWDCH_3 | ADC_CFGR1_AWDCH_2 | ADC_CFGR1_AWDCH_0)
Kojto 158:b23ee177fd68 126 #define ADC_CHANNEL_14_NUMBER ( ADC_CFGR1_AWDCH_3 | ADC_CFGR1_AWDCH_2 | ADC_CFGR1_AWDCH_1 )
Kojto 158:b23ee177fd68 127 #define ADC_CHANNEL_15_NUMBER ( ADC_CFGR1_AWDCH_3 | ADC_CFGR1_AWDCH_2 | ADC_CFGR1_AWDCH_1 | ADC_CFGR1_AWDCH_0)
Kojto 158:b23ee177fd68 128 #define ADC_CHANNEL_16_NUMBER (ADC_CFGR1_AWDCH_4 )
Kojto 158:b23ee177fd68 129 #define ADC_CHANNEL_17_NUMBER (ADC_CFGR1_AWDCH_4 | ADC_CFGR1_AWDCH_0)
Kojto 158:b23ee177fd68 130 #define ADC_CHANNEL_18_NUMBER (ADC_CFGR1_AWDCH_4 | ADC_CFGR1_AWDCH_1 )
Kojto 158:b23ee177fd68 131
Kojto 158:b23ee177fd68 132 /* Definition of channels ID bitfield information to be inserted into */
Kojto 158:b23ee177fd68 133 /* channels literals definition. */
Kojto 158:b23ee177fd68 134 #define ADC_CHANNEL_0_BITFIELD (ADC_CHSELR_CHSEL0)
Kojto 158:b23ee177fd68 135 #define ADC_CHANNEL_1_BITFIELD (ADC_CHSELR_CHSEL1)
Kojto 158:b23ee177fd68 136 #define ADC_CHANNEL_2_BITFIELD (ADC_CHSELR_CHSEL2)
Kojto 158:b23ee177fd68 137 #define ADC_CHANNEL_3_BITFIELD (ADC_CHSELR_CHSEL3)
Kojto 158:b23ee177fd68 138 #define ADC_CHANNEL_4_BITFIELD (ADC_CHSELR_CHSEL4)
Kojto 158:b23ee177fd68 139 #define ADC_CHANNEL_5_BITFIELD (ADC_CHSELR_CHSEL5)
Kojto 158:b23ee177fd68 140 #define ADC_CHANNEL_6_BITFIELD (ADC_CHSELR_CHSEL6)
Kojto 158:b23ee177fd68 141 #define ADC_CHANNEL_7_BITFIELD (ADC_CHSELR_CHSEL7)
Kojto 158:b23ee177fd68 142 #define ADC_CHANNEL_8_BITFIELD (ADC_CHSELR_CHSEL8)
Kojto 158:b23ee177fd68 143 #define ADC_CHANNEL_9_BITFIELD (ADC_CHSELR_CHSEL9)
Kojto 158:b23ee177fd68 144 #define ADC_CHANNEL_10_BITFIELD (ADC_CHSELR_CHSEL10)
Kojto 158:b23ee177fd68 145 #define ADC_CHANNEL_11_BITFIELD (ADC_CHSELR_CHSEL11)
Kojto 158:b23ee177fd68 146 #define ADC_CHANNEL_12_BITFIELD (ADC_CHSELR_CHSEL12)
Kojto 158:b23ee177fd68 147 #define ADC_CHANNEL_13_BITFIELD (ADC_CHSELR_CHSEL13)
Kojto 158:b23ee177fd68 148 #define ADC_CHANNEL_14_BITFIELD (ADC_CHSELR_CHSEL14)
Kojto 158:b23ee177fd68 149 #define ADC_CHANNEL_15_BITFIELD (ADC_CHSELR_CHSEL15)
Kojto 158:b23ee177fd68 150 #if defined(ADC_CCR_VLCDEN)
Kojto 158:b23ee177fd68 151 #define ADC_CHANNEL_16_BITFIELD (ADC_CHSELR_CHSEL16)
Kojto 158:b23ee177fd68 152 #endif
Kojto 158:b23ee177fd68 153 #define ADC_CHANNEL_17_BITFIELD (ADC_CHSELR_CHSEL17)
Kojto 158:b23ee177fd68 154 #define ADC_CHANNEL_18_BITFIELD (ADC_CHSELR_CHSEL18)
Kojto 158:b23ee177fd68 155
Kojto 158:b23ee177fd68 156 /* Internal mask for ADC analog watchdog: */
Kojto 158:b23ee177fd68 157 /* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
Kojto 158:b23ee177fd68 158 /* (concatenation of multiple bits used in different analog watchdogs, */
Kojto 158:b23ee177fd68 159 /* (feature of several watchdogs not available on all STM32 families)). */
Kojto 158:b23ee177fd68 160 /* - analog watchdog 1: monitored channel defined by number, */
Kojto 158:b23ee177fd68 161 /* selection of ADC group (ADC group regular). */
Kojto 158:b23ee177fd68 162
Kojto 158:b23ee177fd68 163 /* Internal register offset for ADC analog watchdog channel configuration */
Kojto 158:b23ee177fd68 164 #define ADC_AWD_CR1_REGOFFSET ((uint32_t)0x00000000U)
Kojto 158:b23ee177fd68 165
Kojto 158:b23ee177fd68 166 #define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET)
Kojto 158:b23ee177fd68 167
Kojto 158:b23ee177fd68 168 #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CFGR1_AWDCH | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL)
Kojto 158:b23ee177fd68 169 #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK)
Kojto 158:b23ee177fd68 170
Kojto 158:b23ee177fd68 171 /* Internal register offset for ADC analog watchdog threshold configuration */
Kojto 158:b23ee177fd68 172 #define ADC_AWD_TR1_REGOFFSET (ADC_AWD_CR1_REGOFFSET)
Kojto 158:b23ee177fd68 173 #define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_REGOFFSET)
Kojto 158:b23ee177fd68 174
Kojto 158:b23ee177fd68 175
Kojto 158:b23ee177fd68 176 /* ADC registers bits positions */
Kojto 158:b23ee177fd68 177 #define ADC_CFGR1_RES_BITOFFSET_POS ((uint32_t) 3U) /* Value equivalent to POSITION_VAL(ADC_CFGR1_RES) */
Kojto 158:b23ee177fd68 178 #define ADC_CFGR1_AWDSGL_BITOFFSET_POS ((uint32_t)22U) /* Value equivalent to POSITION_VAL(ADC_CFGR1_AWDSGL) */
Kojto 158:b23ee177fd68 179 #define ADC_TR_HT_BITOFFSET_POS ((uint32_t)16U) /* Value equivalent to POSITION_VAL(ADC_TR_HT) */
Kojto 158:b23ee177fd68 180 #define ADC_CHSELR_CHSEL0_BITOFFSET_POS ((uint32_t) 0U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL0) */
Kojto 158:b23ee177fd68 181 #define ADC_CHSELR_CHSEL1_BITOFFSET_POS ((uint32_t) 1U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL1) */
Kojto 158:b23ee177fd68 182 #define ADC_CHSELR_CHSEL2_BITOFFSET_POS ((uint32_t) 2U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL2) */
Kojto 158:b23ee177fd68 183 #define ADC_CHSELR_CHSEL3_BITOFFSET_POS ((uint32_t) 3U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL3) */
Kojto 158:b23ee177fd68 184 #define ADC_CHSELR_CHSEL4_BITOFFSET_POS ((uint32_t) 4U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL4) */
Kojto 158:b23ee177fd68 185 #define ADC_CHSELR_CHSEL5_BITOFFSET_POS ((uint32_t) 5U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL5) */
Kojto 158:b23ee177fd68 186 #define ADC_CHSELR_CHSEL6_BITOFFSET_POS ((uint32_t) 6U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL6) */
Kojto 158:b23ee177fd68 187 #define ADC_CHSELR_CHSEL7_BITOFFSET_POS ((uint32_t) 7U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL7) */
Kojto 158:b23ee177fd68 188 #define ADC_CHSELR_CHSEL8_BITOFFSET_POS ((uint32_t) 8U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL8) */
Kojto 158:b23ee177fd68 189 #define ADC_CHSELR_CHSEL9_BITOFFSET_POS ((uint32_t) 9U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL9) */
Kojto 158:b23ee177fd68 190 #define ADC_CHSELR_CHSEL10_BITOFFSET_POS ((uint32_t)10U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL10) */
Kojto 158:b23ee177fd68 191 #define ADC_CHSELR_CHSEL11_BITOFFSET_POS ((uint32_t)11U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL11) */
Kojto 158:b23ee177fd68 192 #define ADC_CHSELR_CHSEL12_BITOFFSET_POS ((uint32_t)12U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL12) */
Kojto 158:b23ee177fd68 193 #define ADC_CHSELR_CHSEL13_BITOFFSET_POS ((uint32_t)13U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL13) */
Kojto 158:b23ee177fd68 194 #define ADC_CHSELR_CHSEL14_BITOFFSET_POS ((uint32_t)14U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL14) */
Kojto 158:b23ee177fd68 195 #define ADC_CHSELR_CHSEL15_BITOFFSET_POS ((uint32_t)15U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL15) */
Kojto 158:b23ee177fd68 196 #if defined(ADC_CCR_VLCDEN)
Kojto 158:b23ee177fd68 197 #define ADC_CHSELR_CHSEL16_BITOFFSET_POS ((uint32_t)16U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL16) */
Kojto 158:b23ee177fd68 198 #endif
Kojto 158:b23ee177fd68 199 #define ADC_CHSELR_CHSEL17_BITOFFSET_POS ((uint32_t)17U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL17) */
Kojto 158:b23ee177fd68 200 #define ADC_CHSELR_CHSEL18_BITOFFSET_POS ((uint32_t)18U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL18) */
Kojto 158:b23ee177fd68 201
Kojto 158:b23ee177fd68 202
Kojto 158:b23ee177fd68 203 /* ADC registers bits groups */
Kojto 158:b23ee177fd68 204 #define ADC_CR_BITS_PROPERTY_RS (ADC_CR_ADCAL | ADC_CR_ADSTP | ADC_CR_ADSTART | ADC_CR_ADDIS | ADC_CR_ADEN) /* ADC register CR bits with HW property "rs": Software can read as well as set this bit. Writing '0' has no effect on the bit value. */
Kojto 158:b23ee177fd68 205
Kojto 158:b23ee177fd68 206
Kojto 158:b23ee177fd68 207 /* ADC internal channels related definitions */
Kojto 158:b23ee177fd68 208 /* Internal voltage reference VrefInt */
Kojto 158:b23ee177fd68 209 #define VREFINT_CAL_ADDR ((uint16_t*) ((uint32_t)0x1FF80078U)) /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
Kojto 158:b23ee177fd68 210 #define VREFINT_CAL_VREF ((uint32_t) 3000U) /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
Kojto 158:b23ee177fd68 211 /* Temperature sensor */
Anna Bridge 186:707f6e361f3e 212 /* Note: On device STM32L011, calibration parameter TS_CAL1 is not available. */
Anna Bridge 186:707f6e361f3e 213 #if !defined(STM32L011xx)
Kojto 158:b23ee177fd68 214 #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) ((uint32_t)0x1FF8007AU)) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32L0, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
Anna Bridge 186:707f6e361f3e 215 #endif
Kojto 158:b23ee177fd68 216 #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) ((uint32_t)0x1FF8007EU)) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32L0, temperature sensor ADC raw data acquired at temperature 130 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
Anna Bridge 186:707f6e361f3e 217 #if !defined(STM32L011xx)
Kojto 158:b23ee177fd68 218 #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). */
Anna Bridge 186:707f6e361f3e 219 #endif
Kojto 158:b23ee177fd68 220 #define TEMPSENSOR_CAL2_TEMP (( int32_t) 130) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
Kojto 158:b23ee177fd68 221 #define TEMPSENSOR_CAL_VREFANALOG ((uint32_t) 3000U) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
Kojto 158:b23ee177fd68 222
Kojto 158:b23ee177fd68 223
Kojto 158:b23ee177fd68 224 /**
Kojto 158:b23ee177fd68 225 * @}
Kojto 158:b23ee177fd68 226 */
Kojto 158:b23ee177fd68 227
Kojto 158:b23ee177fd68 228
Kojto 158:b23ee177fd68 229 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 230 /* Private macros ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 231 /** @defgroup ADC_LL_Private_Macros ADC Private Macros
Kojto 158:b23ee177fd68 232 * @{
Kojto 158:b23ee177fd68 233 */
Kojto 158:b23ee177fd68 234
Kojto 158:b23ee177fd68 235
Kojto 158:b23ee177fd68 236 /**
Kojto 158:b23ee177fd68 237 * @}
Kojto 158:b23ee177fd68 238 */
Kojto 158:b23ee177fd68 239
Kojto 158:b23ee177fd68 240 #endif
Kojto 158:b23ee177fd68 241
Kojto 158:b23ee177fd68 242 /* Exported types ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 243 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 244 /** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
Kojto 158:b23ee177fd68 245 * @{
Kojto 158:b23ee177fd68 246 */
Kojto 158:b23ee177fd68 247
Kojto 158:b23ee177fd68 248 /**
Kojto 158:b23ee177fd68 249 * @brief Structure definition of some features of ADC common parameters
Kojto 158:b23ee177fd68 250 * and multimode
Kojto 158:b23ee177fd68 251 * (all ADC instances belonging to the same ADC common instance).
Kojto 158:b23ee177fd68 252 * @note The setting of these parameters by function @ref LL_ADC_CommonInit()
Kojto 158:b23ee177fd68 253 * is conditioned to ADC instances state (all ADC instances
Kojto 158:b23ee177fd68 254 * sharing the same ADC common instance):
Kojto 158:b23ee177fd68 255 * All ADC instances sharing the same ADC common instance must be
Kojto 158:b23ee177fd68 256 * disabled.
Kojto 158:b23ee177fd68 257 */
Kojto 158:b23ee177fd68 258 typedef struct
Kojto 158:b23ee177fd68 259 {
Kojto 158:b23ee177fd68 260 uint32_t CommonClock; /*!< Set parameter common to several ADC: Clock source and prescaler.
Kojto 158:b23ee177fd68 261 This parameter can be a value of @ref ADC_LL_EC_COMMON_CLOCK_SOURCE
Kojto 158:b23ee177fd68 262
Kojto 158:b23ee177fd68 263 This feature can be modified afterwards using unitary function @ref LL_ADC_SetCommonClock(). */
Kojto 158:b23ee177fd68 264
Kojto 158:b23ee177fd68 265 } LL_ADC_CommonInitTypeDef;
Kojto 158:b23ee177fd68 266
Kojto 158:b23ee177fd68 267 /**
Kojto 158:b23ee177fd68 268 * @brief Structure definition of some features of ADC instance.
Kojto 158:b23ee177fd68 269 * @note These parameters have an impact on ADC scope: ADC instance.
Kojto 158:b23ee177fd68 270 * Refer to corresponding unitary functions into
Kojto 158:b23ee177fd68 271 * @ref ADC_LL_EF_Configuration_ADC_Instance .
Kojto 158:b23ee177fd68 272 * @note The setting of these parameters by function @ref LL_ADC_Init()
Kojto 158:b23ee177fd68 273 * is conditioned to ADC state:
Kojto 158:b23ee177fd68 274 * ADC instance must be disabled.
Kojto 158:b23ee177fd68 275 * This condition is applied to all ADC features, for efficiency
Kojto 158:b23ee177fd68 276 * and compatibility over all STM32 families. However, the different
Kojto 158:b23ee177fd68 277 * features can be set under different ADC state conditions
Kojto 158:b23ee177fd68 278 * (setting possible with ADC enabled without conversion on going,
Kojto 158:b23ee177fd68 279 * ADC enabled with conversion on going, ...)
Kojto 158:b23ee177fd68 280 * Each feature can be updated afterwards with a unitary function
Kojto 158:b23ee177fd68 281 * and potentially with ADC in a different state than disabled,
Kojto 158:b23ee177fd68 282 * refer to description of each function for setting
Kojto 158:b23ee177fd68 283 * conditioned to ADC state.
Kojto 158:b23ee177fd68 284 */
Kojto 158:b23ee177fd68 285 typedef struct
Kojto 158:b23ee177fd68 286 {
Kojto 158:b23ee177fd68 287 uint32_t Clock; /*!< Set ADC instance clock source and prescaler.
Kojto 158:b23ee177fd68 288 This parameter can be a value of @ref ADC_LL_EC_CLOCK_SOURCE
Kojto 158:b23ee177fd68 289 @note On this STM32 serie, this parameter has some clock ratio constraints:
Kojto 158:b23ee177fd68 290 ADC clock synchronous (from PCLK) with prescaler 1 must be enabled only if PCLK has a 50% duty clock cycle
Kojto 158:b23ee177fd68 291 (APB prescaler configured inside the RCC must be bypassed and the system clock must by 50% duty cycle).
Kojto 158:b23ee177fd68 292
Kojto 158:b23ee177fd68 293
Kojto 158:b23ee177fd68 294 This feature can be modified afterwards using unitary function @ref LL_ADC_SetClock().
Kojto 158:b23ee177fd68 295 For more details, refer to description of this function. */
Kojto 158:b23ee177fd68 296
Kojto 158:b23ee177fd68 297 uint32_t Resolution; /*!< Set ADC resolution.
Kojto 158:b23ee177fd68 298 This parameter can be a value of @ref ADC_LL_EC_RESOLUTION
Kojto 158:b23ee177fd68 299
Kojto 158:b23ee177fd68 300 This feature can be modified afterwards using unitary function @ref LL_ADC_SetResolution(). */
Kojto 158:b23ee177fd68 301
Kojto 158:b23ee177fd68 302 uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
Kojto 158:b23ee177fd68 303 This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
Kojto 158:b23ee177fd68 304
Kojto 158:b23ee177fd68 305 This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
Kojto 158:b23ee177fd68 306
Kojto 158:b23ee177fd68 307 uint32_t LowPowerMode; /*!< Set ADC low power mode.
Kojto 158:b23ee177fd68 308 This parameter can be a value of @ref ADC_LL_EC_LP_MODE
Kojto 158:b23ee177fd68 309
Kojto 158:b23ee177fd68 310 This feature can be modified afterwards using unitary function @ref LL_ADC_SetLowPowerMode(). */
Kojto 158:b23ee177fd68 311
Kojto 158:b23ee177fd68 312 } LL_ADC_InitTypeDef;
Kojto 158:b23ee177fd68 313
Kojto 158:b23ee177fd68 314 /**
Kojto 158:b23ee177fd68 315 * @brief Structure definition of some features of ADC group regular.
Kojto 158:b23ee177fd68 316 * @note These parameters have an impact on ADC scope: ADC group regular.
Kojto 158:b23ee177fd68 317 * Refer to corresponding unitary functions into
Kojto 158:b23ee177fd68 318 * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
Kojto 158:b23ee177fd68 319 * (functions with prefix "REG").
Kojto 158:b23ee177fd68 320 * @note The setting of these parameters by function @ref LL_ADC_REG_Init()
Kojto 158:b23ee177fd68 321 * is conditioned to ADC state:
Kojto 158:b23ee177fd68 322 * ADC instance must be disabled.
Kojto 158:b23ee177fd68 323 * This condition is applied to all ADC features, for efficiency
Kojto 158:b23ee177fd68 324 * and compatibility over all STM32 families. However, the different
Kojto 158:b23ee177fd68 325 * features can be set under different ADC state conditions
Kojto 158:b23ee177fd68 326 * (setting possible with ADC enabled without conversion on going,
Kojto 158:b23ee177fd68 327 * ADC enabled with conversion on going, ...)
Kojto 158:b23ee177fd68 328 * Each feature can be updated afterwards with a unitary function
Kojto 158:b23ee177fd68 329 * and potentially with ADC in a different state than disabled,
Kojto 158:b23ee177fd68 330 * refer to description of each function for setting
Kojto 158:b23ee177fd68 331 * conditioned to ADC state.
Kojto 158:b23ee177fd68 332 */
Kojto 158:b23ee177fd68 333 typedef struct
Kojto 158:b23ee177fd68 334 {
Kojto 158:b23ee177fd68 335 uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
Kojto 158:b23ee177fd68 336 This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
Kojto 158:b23ee177fd68 337 @note On this STM32 serie, setting trigger source to external trigger also set trigger polarity to rising edge
Kojto 158:b23ee177fd68 338 (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value).
Kojto 158:b23ee177fd68 339 In case of need to modify trigger edge, use function @ref LL_ADC_REG_SetTriggerEdge().
Kojto 158:b23ee177fd68 340
Kojto 158:b23ee177fd68 341 This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
Kojto 158:b23ee177fd68 342
Kojto 158:b23ee177fd68 343 uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
Kojto 158:b23ee177fd68 344 This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
Kojto 158:b23ee177fd68 345 @note This parameter has an effect only if group regular sequencer is enabled
Kojto 158:b23ee177fd68 346 (several ADC channels enabled in group regular sequencer).
Kojto 158:b23ee177fd68 347
Kojto 158:b23ee177fd68 348 This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
Kojto 158:b23ee177fd68 349
Kojto 158:b23ee177fd68 350 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).
Kojto 158:b23ee177fd68 351 This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
Kojto 158:b23ee177fd68 352 Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
Kojto 158:b23ee177fd68 353
Kojto 158:b23ee177fd68 354 This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
Kojto 158:b23ee177fd68 355
Kojto 158:b23ee177fd68 356 uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
Kojto 158:b23ee177fd68 357 This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
Kojto 158:b23ee177fd68 358
Kojto 158:b23ee177fd68 359 This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
Kojto 158:b23ee177fd68 360
Kojto 158:b23ee177fd68 361 uint32_t Overrun; /*!< Set ADC group regular behavior in case of overrun:
Kojto 158:b23ee177fd68 362 data preserved or overwritten.
Kojto 158:b23ee177fd68 363 This parameter can be a value of @ref ADC_LL_EC_REG_OVR_DATA_BEHAVIOR
Kojto 158:b23ee177fd68 364
Kojto 158:b23ee177fd68 365 This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetOverrun(). */
Kojto 158:b23ee177fd68 366
Kojto 158:b23ee177fd68 367 } LL_ADC_REG_InitTypeDef;
Kojto 158:b23ee177fd68 368
Kojto 158:b23ee177fd68 369 /**
Kojto 158:b23ee177fd68 370 * @}
Kojto 158:b23ee177fd68 371 */
Kojto 158:b23ee177fd68 372 #endif /* USE_FULL_LL_DRIVER */
Kojto 158:b23ee177fd68 373
Kojto 158:b23ee177fd68 374 /* Exported constants --------------------------------------------------------*/
Kojto 158:b23ee177fd68 375 /** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
Kojto 158:b23ee177fd68 376 * @{
Kojto 158:b23ee177fd68 377 */
Kojto 158:b23ee177fd68 378
Kojto 158:b23ee177fd68 379 /** @defgroup ADC_LL_EC_FLAG ADC flags
Kojto 158:b23ee177fd68 380 * @brief Flags defines which can be used with LL_ADC_ReadReg function
Kojto 158:b23ee177fd68 381 * @{
Kojto 158:b23ee177fd68 382 */
Kojto 158:b23ee177fd68 383 #define LL_ADC_FLAG_ADRDY ADC_ISR_ADRDY /*!< ADC flag ADC instance ready */
Kojto 158:b23ee177fd68 384 #define LL_ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC flag ADC group regular end of unitary conversion */
Kojto 158:b23ee177fd68 385 #define LL_ADC_FLAG_EOS ADC_ISR_EOS /*!< ADC flag ADC group regular end of sequence conversions */
Kojto 158:b23ee177fd68 386 #define LL_ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC flag ADC group regular overrun */
Kojto 158:b23ee177fd68 387 #define LL_ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC flag ADC group regular end of sampling phase */
Kojto 158:b23ee177fd68 388 #define LL_ADC_FLAG_AWD1 ADC_ISR_AWD /*!< ADC flag ADC analog watchdog 1 */
Kojto 158:b23ee177fd68 389 #define LL_ADC_FLAG_EOCAL ADC_ISR_EOCAL /*!< ADC flag end of calibration */
Kojto 158:b23ee177fd68 390 /**
Kojto 158:b23ee177fd68 391 * @}
Kojto 158:b23ee177fd68 392 */
Kojto 158:b23ee177fd68 393
Kojto 158:b23ee177fd68 394 /** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
Kojto 158:b23ee177fd68 395 * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
Kojto 158:b23ee177fd68 396 * @{
Kojto 158:b23ee177fd68 397 */
Kojto 158:b23ee177fd68 398 #define LL_ADC_IT_ADRDY ADC_IER_ADRDYIE /*!< ADC interruption ADC instance ready */
Kojto 158:b23ee177fd68 399 #define LL_ADC_IT_EOC ADC_IER_EOCIE /*!< ADC interruption ADC group regular end of unitary conversion */
Kojto 158:b23ee177fd68 400 #define LL_ADC_IT_EOS ADC_IER_EOSIE /*!< ADC interruption ADC group regular end of sequence conversions */
Kojto 158:b23ee177fd68 401 #define LL_ADC_IT_OVR ADC_IER_OVRIE /*!< ADC interruption ADC group regular overrun */
Kojto 158:b23ee177fd68 402 #define LL_ADC_IT_EOSMP ADC_IER_EOSMPIE /*!< ADC interruption ADC group regular end of sampling phase */
Kojto 158:b23ee177fd68 403 #define LL_ADC_IT_AWD1 ADC_IER_AWDIE /*!< ADC interruption ADC analog watchdog 1 */
Kojto 158:b23ee177fd68 404 #define LL_ADC_IT_EOCAL ADC_IER_EOCALIE /*!< ADC interruption ADC end of calibration */
Kojto 158:b23ee177fd68 405 /**
Kojto 158:b23ee177fd68 406 * @}
Kojto 158:b23ee177fd68 407 */
Kojto 158:b23ee177fd68 408
Kojto 158:b23ee177fd68 409 /** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
Kojto 158:b23ee177fd68 410 * @{
Kojto 158:b23ee177fd68 411 */
Kojto 158:b23ee177fd68 412 /* List of ADC registers intended to be used (most commonly) with */
Kojto 158:b23ee177fd68 413 /* DMA transfer. */
Kojto 158:b23ee177fd68 414 /* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
Kojto 158:b23ee177fd68 415 #define LL_ADC_DMA_REG_REGULAR_DATA ((uint32_t)0x00000000U) /* ADC group regular conversion data register (corresponding to register DR) to be used with ADC configured in independent mode. Without DMA transfer, register accessed by LL function @ref LL_ADC_REG_ReadConversionData32() and other functions @ref LL_ADC_REG_ReadConversionDatax() */
Kojto 158:b23ee177fd68 416 /**
Kojto 158:b23ee177fd68 417 * @}
Kojto 158:b23ee177fd68 418 */
Kojto 158:b23ee177fd68 419
Kojto 158:b23ee177fd68 420 /** @defgroup ADC_LL_EC_COMMON_CLOCK_SOURCE ADC common - Clock source
Kojto 158:b23ee177fd68 421 * @{
Kojto 158:b23ee177fd68 422 */
Kojto 158:b23ee177fd68 423 #define LL_ADC_CLOCK_ASYNC_DIV1 ((uint32_t)0x00000000U) /*!< ADC asynchronous clock without prescaler */
Kojto 158:b23ee177fd68 424 #define LL_ADC_CLOCK_ASYNC_DIV2 (ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 2. ADC common clock asynchonous prescaler is applied to each ADC instance if the corresponding ADC instance clock is set to clock source asynchronous (refer to function @ref LL_ADC_SetClock() ). */
Kojto 158:b23ee177fd68 425 #define LL_ADC_CLOCK_ASYNC_DIV4 (ADC_CCR_PRESC_1 ) /*!< ADC asynchronous clock with prescaler division by 4. ADC common clock asynchonous prescaler is applied to each ADC instance if the corresponding ADC instance clock is set to clock source asynchronous (refer to function @ref LL_ADC_SetClock() ). */
Kojto 158:b23ee177fd68 426 #define LL_ADC_CLOCK_ASYNC_DIV6 (ADC_CCR_PRESC_1 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 6. ADC common clock asynchonous prescaler is applied to each ADC instance if the corresponding ADC instance clock is set to clock source asynchronous (refer to function @ref LL_ADC_SetClock() ). */
Kojto 158:b23ee177fd68 427 #define LL_ADC_CLOCK_ASYNC_DIV8 (ADC_CCR_PRESC_2 ) /*!< ADC asynchronous clock with prescaler division by 8. ADC common clock asynchonous prescaler is applied to each ADC instance if the corresponding ADC instance clock is set to clock source asynchronous (refer to function @ref LL_ADC_SetClock() ). */
Kojto 158:b23ee177fd68 428 #define LL_ADC_CLOCK_ASYNC_DIV10 (ADC_CCR_PRESC_2 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 10. ADC common clock asynchonous prescaler is applied to each ADC instance if the corresponding ADC instance clock is set to clock source asynchronous (refer to function @ref LL_ADC_SetClock() ). */
Kojto 158:b23ee177fd68 429 #define LL_ADC_CLOCK_ASYNC_DIV12 (ADC_CCR_PRESC_2 | ADC_CCR_PRESC_1 ) /*!< ADC asynchronous clock with prescaler division by 12. ADC common clock asynchonous prescaler is applied to each ADC instance if the corresponding ADC instance clock is set to clock source asynchronous (refer to function @ref LL_ADC_SetClock() ). */
Kojto 158:b23ee177fd68 430 #define LL_ADC_CLOCK_ASYNC_DIV16 (ADC_CCR_PRESC_2 | ADC_CCR_PRESC_1 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 16. ADC common clock asynchonous prescaler is applied to each ADC instance if the corresponding ADC instance clock is set to clock source asynchronous (refer to function @ref LL_ADC_SetClock() ). */
Kojto 158:b23ee177fd68 431 #define LL_ADC_CLOCK_ASYNC_DIV32 (ADC_CCR_PRESC_3) /*!< ADC asynchronous clock with prescaler division by 32. ADC common clock asynchonous prescaler is applied to each ADC instance if the corresponding ADC instance clock is set to clock source asynchronous (refer to function @ref LL_ADC_SetClock() ). */
Kojto 158:b23ee177fd68 432 #define LL_ADC_CLOCK_ASYNC_DIV64 (ADC_CCR_PRESC_3 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 64. ADC common clock asynchonous prescaler is applied to each ADC instance if the corresponding ADC instance clock is set to clock source asynchronous (refer to function @ref LL_ADC_SetClock() ). */
Kojto 158:b23ee177fd68 433 #define LL_ADC_CLOCK_ASYNC_DIV128 (ADC_CCR_PRESC_3 | ADC_CCR_PRESC_1) /*!< ADC asynchronous clock with prescaler division by 128. ADC common clock asynchonous prescaler is applied to each ADC instance if the corresponding ADC instance clock is set to clock source asynchronous (refer to function @ref LL_ADC_SetClock() ). */
Kojto 158:b23ee177fd68 434 #define LL_ADC_CLOCK_ASYNC_DIV256 (ADC_CCR_PRESC_3 | ADC_CCR_PRESC_1 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 256. ADC common clock asynchonous prescaler is applied to each ADC instance if the corresponding ADC instance clock is set to clock source asynchronous (refer to function @ref LL_ADC_SetClock() ). */
Kojto 158:b23ee177fd68 435 /**
Kojto 158:b23ee177fd68 436 * @}
Kojto 158:b23ee177fd68 437 */
Kojto 158:b23ee177fd68 438
Kojto 158:b23ee177fd68 439 /** @defgroup ADC_LL_EC_COMMON_CLOCK_FREQ_MODE ADC common - Clock frequency mode
Kojto 158:b23ee177fd68 440 * @{
Kojto 158:b23ee177fd68 441 */
Kojto 158:b23ee177fd68 442 #define LL_ADC_CLOCK_FREQ_MODE_HIGH ((uint32_t)0x00000000U)/*!< ADC clock mode to high frequency. On STM32L0, ADC clock frequency above 2.8MHz. */
Kojto 158:b23ee177fd68 443 #define LL_ADC_CLOCK_FREQ_MODE_LOW (ADC_CCR_LFMEN) /*!< ADC clock mode to low frequency. On STM32L0, ADC clock frequency below 2.8MHz. */
Kojto 158:b23ee177fd68 444 /**
Kojto 158:b23ee177fd68 445 * @}
Kojto 158:b23ee177fd68 446 */
Kojto 158:b23ee177fd68 447
Kojto 158:b23ee177fd68 448 /** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
Kojto 158:b23ee177fd68 449 * @{
Kojto 158:b23ee177fd68 450 */
Kojto 158:b23ee177fd68 451 /* Note: Other measurement paths to internal channels may be available */
Kojto 158:b23ee177fd68 452 /* (connections to other peripherals). */
Kojto 158:b23ee177fd68 453 /* If they are not listed below, they do not require any specific */
Kojto 158:b23ee177fd68 454 /* path enable. In this case, Access to measurement path is done */
Kojto 158:b23ee177fd68 455 /* only by selecting the corresponding ADC internal channel. */
Kojto 158:b23ee177fd68 456 #define LL_ADC_PATH_INTERNAL_NONE ((uint32_t)0x00000000U)/*!< ADC measurement pathes all disabled */
Kojto 158:b23ee177fd68 457 #define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CCR_VREFEN) /*!< ADC measurement path to internal channel VrefInt */
Kojto 158:b23ee177fd68 458 #define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CCR_TSEN) /*!< ADC measurement path to internal channel temperature sensor */
Kojto 158:b23ee177fd68 459 #define LL_ADC_PATH_INTERNAL_VLCD (ADC_CCR_VLCDEN) /*!< ADC measurement path to internal channel Vlcd */
Kojto 158:b23ee177fd68 460 /**
Kojto 158:b23ee177fd68 461 * @}
Kojto 158:b23ee177fd68 462 */
Kojto 158:b23ee177fd68 463
Kojto 158:b23ee177fd68 464 /** @defgroup ADC_LL_EC_CLOCK_SOURCE ADC instance - Clock source
Kojto 158:b23ee177fd68 465 * @{
Kojto 158:b23ee177fd68 466 */
Kojto 158:b23ee177fd68 467 #define LL_ADC_CLOCK_SYNC_PCLK_DIV4 (ADC_CFGR2_CKMODE_1) /*!< ADC synchronous clock derived from AHB clock divided by 4 */
Kojto 158:b23ee177fd68 468 #define LL_ADC_CLOCK_SYNC_PCLK_DIV2 (ADC_CFGR2_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock divided by 2 */
Kojto 158:b23ee177fd68 469 #define LL_ADC_CLOCK_SYNC_PCLK_DIV1 (ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock not divided */
Kojto 158:b23ee177fd68 470 #define LL_ADC_CLOCK_ASYNC ((uint32_t)0x00000000U) /*!< ADC asynchronous clock. Asynchronous clock prescaler can be configured using function @ref LL_ADC_SetCommonClock(). */
Kojto 158:b23ee177fd68 471 /**
Kojto 158:b23ee177fd68 472 * @}
Kojto 158:b23ee177fd68 473 */
Kojto 158:b23ee177fd68 474
Kojto 158:b23ee177fd68 475 /** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
Kojto 158:b23ee177fd68 476 * @{
Kojto 158:b23ee177fd68 477 */
Kojto 158:b23ee177fd68 478 #define LL_ADC_RESOLUTION_12B ((uint32_t)0x00000000U) /*!< ADC resolution 12 bits */
Kojto 158:b23ee177fd68 479 #define LL_ADC_RESOLUTION_10B ( ADC_CFGR1_RES_0) /*!< ADC resolution 10 bits */
Kojto 158:b23ee177fd68 480 #define LL_ADC_RESOLUTION_8B (ADC_CFGR1_RES_1 ) /*!< ADC resolution 8 bits */
Kojto 158:b23ee177fd68 481 #define LL_ADC_RESOLUTION_6B (ADC_CFGR1_RES_1 | ADC_CFGR1_RES_0) /*!< ADC resolution 6 bits */
Kojto 158:b23ee177fd68 482 /**
Kojto 158:b23ee177fd68 483 * @}
Kojto 158:b23ee177fd68 484 */
Kojto 158:b23ee177fd68 485
Kojto 158:b23ee177fd68 486 /** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
Kojto 158:b23ee177fd68 487 * @{
Kojto 158:b23ee177fd68 488 */
Kojto 158:b23ee177fd68 489 #define LL_ADC_DATA_ALIGN_RIGHT ((uint32_t)0x00000000U)/*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
Kojto 158:b23ee177fd68 490 #define LL_ADC_DATA_ALIGN_LEFT (ADC_CFGR1_ALIGN) /*!< ADC conversion data alignment: left aligned (aligment on data register MSB bit 15)*/
Kojto 158:b23ee177fd68 491 /**
Kojto 158:b23ee177fd68 492 * @}
Kojto 158:b23ee177fd68 493 */
Kojto 158:b23ee177fd68 494
Kojto 158:b23ee177fd68 495 /** @defgroup ADC_LL_EC_LP_MODE ADC instance - Low power mode
Kojto 158:b23ee177fd68 496 * @{
Kojto 158:b23ee177fd68 497 */
Anna Bridge 186:707f6e361f3e 498 #define LL_ADC_LP_MODE_NONE ((uint32_t)0x00000000U) /*!< No ADC low power mode activated */
Kojto 158:b23ee177fd68 499 #define LL_ADC_LP_AUTOWAIT (ADC_CFGR1_WAIT) /*!< ADC low power mode auto delay: Dynamic low power mode, ADC conversions are performed only when necessary (when previous ADC conversion data is read). See description with function @ref LL_ADC_SetLowPowerMode(). */
Kojto 158:b23ee177fd68 500 #define LL_ADC_LP_AUTOPOWEROFF (ADC_CFGR1_AUTOFF) /*!< ADC low power mode auto power-off: the ADC automatically powers-off after a ADC conversion and automatically wakes up when a new ADC conversion is triggered (with startup time between trigger and start of sampling). See description with function @ref LL_ADC_SetLowPowerMode(). */
Kojto 158:b23ee177fd68 501 #define LL_ADC_LP_AUTOWAIT_AUTOPOWEROFF (ADC_CFGR1_WAIT | ADC_CFGR1_AUTOFF) /*!< ADC low power modes auto wait and auto power-off combined. See description with function @ref LL_ADC_SetLowPowerMode(). */
Kojto 158:b23ee177fd68 502 /**
Kojto 158:b23ee177fd68 503 * @}
Kojto 158:b23ee177fd68 504 */
Kojto 158:b23ee177fd68 505
Kojto 158:b23ee177fd68 506 /** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
Kojto 158:b23ee177fd68 507 * @{
Kojto 158:b23ee177fd68 508 */
Kojto 158:b23ee177fd68 509 #define LL_ADC_GROUP_REGULAR ((uint32_t)0x00000001U) /*!< ADC group regular (available on all STM32 devices) */
Kojto 158:b23ee177fd68 510 /**
Kojto 158:b23ee177fd68 511 * @}
Kojto 158:b23ee177fd68 512 */
Kojto 158:b23ee177fd68 513
Kojto 158:b23ee177fd68 514 /** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
Kojto 158:b23ee177fd68 515 * @{
Kojto 158:b23ee177fd68 516 */
Kojto 158:b23ee177fd68 517 #define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 */
Kojto 158:b23ee177fd68 518 #define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 */
Kojto 158:b23ee177fd68 519 #define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 */
Kojto 158:b23ee177fd68 520 #define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 */
Kojto 158:b23ee177fd68 521 #define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 */
Kojto 158:b23ee177fd68 522 #define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 */
Kojto 158:b23ee177fd68 523 #define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 */
Kojto 158:b23ee177fd68 524 #define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 */
Kojto 158:b23ee177fd68 525 #define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 */
Kojto 158:b23ee177fd68 526 #define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 */
Kojto 158:b23ee177fd68 527 #define LL_ADC_CHANNEL_10 (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10 */
Kojto 158:b23ee177fd68 528 #define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11 */
Kojto 158:b23ee177fd68 529 #define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12 */
Kojto 158:b23ee177fd68 530 #define LL_ADC_CHANNEL_13 (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN13 */
Kojto 158:b23ee177fd68 531 #define LL_ADC_CHANNEL_14 (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN14 */
Kojto 158:b23ee177fd68 532 #define LL_ADC_CHANNEL_15 (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN15 */
Kojto 158:b23ee177fd68 533 #define LL_ADC_CHANNEL_17 (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN17 */
Kojto 158:b23ee177fd68 534 #define LL_ADC_CHANNEL_18 (ADC_CHANNEL_18_NUMBER | ADC_CHANNEL_18_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN18 */
Kojto 158:b23ee177fd68 535 #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. */
Kojto 158:b23ee177fd68 536 #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_18 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. */
Kojto 158:b23ee177fd68 537 #if defined(ADC_CCR_VLCDEN)
Kojto 158:b23ee177fd68 538 #define LL_ADC_CHANNEL_16 (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN16 */
Kojto 158:b23ee177fd68 539 #define LL_ADC_CHANNEL_VLCD (LL_ADC_CHANNEL_16 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Vlcd: Vlcd voltage through a divider ladder of factor 1/4, 1/3 or 1/2 (set by LCD voltage generator biasing), to have Vlcd always below Vdda. */
Kojto 158:b23ee177fd68 540 #endif
Kojto 158:b23ee177fd68 541 /**
Kojto 158:b23ee177fd68 542 * @}
Kojto 158:b23ee177fd68 543 */
Kojto 158:b23ee177fd68 544
Kojto 158:b23ee177fd68 545 /** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source
Kojto 158:b23ee177fd68 546 * @{
Kojto 158:b23ee177fd68 547 */
Kojto 158:b23ee177fd68 548 #define LL_ADC_REG_TRIG_SOFTWARE ((uint32_t)0x00000000U) /*!< ADC group regular conversion trigger internal: SW start. */
Kojto 158:b23ee177fd68 549 #define LL_ADC_REG_TRIG_EXT_TIM6_TRGO (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM6 TRGO. Trigger edge set to rising edge (default setting). */
Kojto 158:b23ee177fd68 550 #define LL_ADC_REG_TRIG_EXT_TIM21_CH2 (ADC_CFGR1_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM21 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
Kojto 158:b23ee177fd68 551 #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO (ADC_CFGR1_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). */
Kojto 158:b23ee177fd68 552 #define LL_ADC_REG_TRIG_EXT_TIM2_CH4 (ADC_CFGR1_EXTSEL_1 | ADC_CFGR1_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). */
Kojto 158:b23ee177fd68 553 #define LL_ADC_REG_TRIG_EXT_TIM22_TRGO (ADC_CFGR1_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM22 TRGO. Trigger edge set to rising edge (default setting). */
Kojto 158:b23ee177fd68 554 #define LL_ADC_REG_TRIG_EXT_TIM2_CH3 (ADC_CFGR1_EXTSEL_2 | ADC_CFGR1_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). */
Kojto 158:b23ee177fd68 555 #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CFGR1_EXTSEL_2 | ADC_CFGR1_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 TRG0. Trigger edge set to rising edge (default setting). */
Anna Bridge 186:707f6e361f3e 556 #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CFGR1_EXTSEL_2 | ADC_CFGR1_EXTSEL_1 | ADC_CFGR1_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). */
Kojto 158:b23ee177fd68 557 /**
Kojto 158:b23ee177fd68 558 * @}
Kojto 158:b23ee177fd68 559 */
Kojto 158:b23ee177fd68 560
Kojto 158:b23ee177fd68 561 /** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
Kojto 158:b23ee177fd68 562 * @{
Kojto 158:b23ee177fd68 563 */
Kojto 158:b23ee177fd68 564 #define LL_ADC_REG_TRIG_EXT_RISING ( ADC_CFGR1_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to rising edge */
Kojto 158:b23ee177fd68 565 #define LL_ADC_REG_TRIG_EXT_FALLING (ADC_CFGR1_EXTEN_1 ) /*!< ADC group regular conversion trigger polarity set to falling edge */
Kojto 158:b23ee177fd68 566 #define LL_ADC_REG_TRIG_EXT_RISINGFALLING (ADC_CFGR1_EXTEN_1 | ADC_CFGR1_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to both rising and falling edges */
Kojto 158:b23ee177fd68 567 /**
Kojto 158:b23ee177fd68 568 * @}
Kojto 158:b23ee177fd68 569 */
Kojto 158:b23ee177fd68 570
Kojto 158:b23ee177fd68 571 /** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
Kojto 158:b23ee177fd68 572 * @{
Kojto 158:b23ee177fd68 573 */
Kojto 158:b23ee177fd68 574 #define LL_ADC_REG_CONV_SINGLE ((uint32_t)0x00000000U) /*!< ADC conversions are performed in single mode: one conversion per trigger */
Kojto 158:b23ee177fd68 575 #define LL_ADC_REG_CONV_CONTINUOUS (ADC_CFGR1_CONT) /*!< ADC conversions are performed in continuous mode: after the first trigger, following conversions launched successively automatically */
Kojto 158:b23ee177fd68 576 /**
Kojto 158:b23ee177fd68 577 * @}
Kojto 158:b23ee177fd68 578 */
Kojto 158:b23ee177fd68 579
Kojto 158:b23ee177fd68 580 /** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer of ADC conversion data
Kojto 158:b23ee177fd68 581 * @{
Kojto 158:b23ee177fd68 582 */
Kojto 158:b23ee177fd68 583 #define LL_ADC_REG_DMA_TRANSFER_NONE ((uint32_t)0x00000000U) /*!< ADC conversions are not transferred by DMA */
Kojto 158:b23ee177fd68 584 #define LL_ADC_REG_DMA_TRANSFER_LIMITED ( ADC_CFGR1_DMAEN) /*!< 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. */
Kojto 158:b23ee177fd68 585 #define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CFGR1_DMACFG | ADC_CFGR1_DMAEN) /*!< 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. */
Kojto 158:b23ee177fd68 586 /**
Kojto 158:b23ee177fd68 587 * @}
Kojto 158:b23ee177fd68 588 */
Kojto 158:b23ee177fd68 589
Kojto 158:b23ee177fd68 590 /** @defgroup ADC_LL_EC_REG_OVR_DATA_BEHAVIOR ADC group regular - Overrun behavior on conversion data
Kojto 158:b23ee177fd68 591 * @{
Kojto 158:b23ee177fd68 592 */
Kojto 158:b23ee177fd68 593 #define LL_ADC_REG_OVR_DATA_PRESERVED ((uint32_t)0x00000000U)/*!< ADC group regular behavior in case of overrun: data preserved */
Kojto 158:b23ee177fd68 594 #define LL_ADC_REG_OVR_DATA_OVERWRITTEN (ADC_CFGR1_OVRMOD) /*!< ADC group regular behavior in case of overrun: data overwritten */
Kojto 158:b23ee177fd68 595 /**
Kojto 158:b23ee177fd68 596 * @}
Kojto 158:b23ee177fd68 597 */
Kojto 158:b23ee177fd68 598
Kojto 158:b23ee177fd68 599 /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_DIRECTION ADC group regular - Sequencer scan direction
Kojto 158:b23ee177fd68 600 * @{
Kojto 158:b23ee177fd68 601 */
Kojto 158:b23ee177fd68 602 #define LL_ADC_REG_SEQ_SCAN_DIR_FORWARD ((uint32_t)0x00000000U)/*!< ADC group regular sequencer scan direction forward: from lowest channel number to highest channel number (scan of all ranks, ADC conversion of ranks with channels enabled in sequencer). On some other STM32 families, this setting is not available and the default scan direction is forward. */
Kojto 158:b23ee177fd68 603 #define LL_ADC_REG_SEQ_SCAN_DIR_BACKWARD (ADC_CFGR1_SCANDIR) /*!< ADC group regular sequencer scan direction backward: from highest channel number to lowest channel number (scan of all ranks, ADC conversion of ranks with channels enabled in sequencer) */
Kojto 158:b23ee177fd68 604 /**
Kojto 158:b23ee177fd68 605 * @}
Kojto 158:b23ee177fd68 606 */
Kojto 158:b23ee177fd68 607
Kojto 158:b23ee177fd68 608 /** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
Kojto 158:b23ee177fd68 609 * @{
Kojto 158:b23ee177fd68 610 */
Kojto 158:b23ee177fd68 611 #define LL_ADC_REG_SEQ_DISCONT_DISABLE ((uint32_t)0x00000000U) /*!< ADC group regular sequencer discontinuous mode disable */
Kojto 158:b23ee177fd68 612 #define LL_ADC_REG_SEQ_DISCONT_1RANK (ADC_CFGR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
Kojto 158:b23ee177fd68 613 /**
Kojto 158:b23ee177fd68 614 * @}
Kojto 158:b23ee177fd68 615 */
Kojto 158:b23ee177fd68 616
Kojto 158:b23ee177fd68 617 /** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time
Kojto 158:b23ee177fd68 618 * @{
Kojto 158:b23ee177fd68 619 */
Kojto 158:b23ee177fd68 620 #define LL_ADC_SAMPLINGTIME_1CYCLE_5 ((uint32_t)0x00000000U) /*!< Sampling time 1.5 ADC clock cycle */
Anna Bridge 186:707f6e361f3e 621 #define LL_ADC_SAMPLINGTIME_3CYCLES_5 (ADC_SMPR_SMP_0) /*!< Sampling time 3.5 ADC clock cycles */
Anna Bridge 186:707f6e361f3e 622 #define LL_ADC_SAMPLINGTIME_7CYCLES_5 (ADC_SMPR_SMP_1) /*!< Sampling time 7.5 ADC clock cycles */
Anna Bridge 186:707f6e361f3e 623 #define LL_ADC_SAMPLINGTIME_12CYCLES_5 (ADC_SMPR_SMP_1 | ADC_SMPR_SMP_0) /*!< Sampling time 12.5 ADC clock cycles */
Anna Bridge 186:707f6e361f3e 624 #define LL_ADC_SAMPLINGTIME_19CYCLES_5 (ADC_SMPR_SMP_2) /*!< Sampling time 19.5 ADC clock cycles */
Anna Bridge 186:707f6e361f3e 625 #define LL_ADC_SAMPLINGTIME_39CYCLES_5 (ADC_SMPR_SMP_2 | ADC_SMPR_SMP_0) /*!< Sampling time 39.5 ADC clock cycles */
Anna Bridge 186:707f6e361f3e 626 #define LL_ADC_SAMPLINGTIME_79CYCLES_5 (ADC_SMPR_SMP_2 | ADC_SMPR_SMP_1) /*!< Sampling time 79.5 ADC clock cycles */
Anna Bridge 186:707f6e361f3e 627 #define LL_ADC_SAMPLINGTIME_160CYCLES_5 (ADC_SMPR_SMP_2 | ADC_SMPR_SMP_1 | ADC_SMPR_SMP_0) /*!< Sampling time 160.5 ADC clock cycles */
Kojto 158:b23ee177fd68 628 /**
Kojto 158:b23ee177fd68 629 * @}
Kojto 158:b23ee177fd68 630 */
Kojto 158:b23ee177fd68 631
Kojto 158:b23ee177fd68 632 /** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
Kojto 158:b23ee177fd68 633 * @{
Kojto 158:b23ee177fd68 634 */
Kojto 158:b23ee177fd68 635 #define LL_ADC_AWD1 (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
Kojto 158:b23ee177fd68 636 /**
Kojto 158:b23ee177fd68 637 * @}
Kojto 158:b23ee177fd68 638 */
Kojto 158:b23ee177fd68 639
Kojto 158:b23ee177fd68 640 /** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
Kojto 158:b23ee177fd68 641 * @{
Kojto 158:b23ee177fd68 642 */
Kojto 158:b23ee177fd68 643 #define LL_ADC_AWD_DISABLE ((uint32_t)0x00000000U) /*!< ADC analog watchdog monitoring disabled */
Kojto 158:b23ee177fd68 644 #define LL_ADC_AWD_ALL_CHANNELS_REG ( ADC_CFGR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
Kojto 158:b23ee177fd68 645 #define LL_ADC_AWD_CHANNEL_0_REG ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group regular only */
Kojto 158:b23ee177fd68 646 #define LL_ADC_AWD_CHANNEL_1_REG ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group regular only */
Kojto 158:b23ee177fd68 647 #define LL_ADC_AWD_CHANNEL_2_REG ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group regular only */
Kojto 158:b23ee177fd68 648 #define LL_ADC_AWD_CHANNEL_3_REG ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group regular only */
Kojto 158:b23ee177fd68 649 #define LL_ADC_AWD_CHANNEL_4_REG ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group regular only */
Kojto 158:b23ee177fd68 650 #define LL_ADC_AWD_CHANNEL_5_REG ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group regular only */
Kojto 158:b23ee177fd68 651 #define LL_ADC_AWD_CHANNEL_6_REG ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group regular only */
Kojto 158:b23ee177fd68 652 #define LL_ADC_AWD_CHANNEL_7_REG ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group regular only */
Kojto 158:b23ee177fd68 653 #define LL_ADC_AWD_CHANNEL_8_REG ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group regular only */
Kojto 158:b23ee177fd68 654 #define LL_ADC_AWD_CHANNEL_9_REG ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group regular only */
Kojto 158:b23ee177fd68 655 #define LL_ADC_AWD_CHANNEL_10_REG ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group regular only */
Kojto 158:b23ee177fd68 656 #define LL_ADC_AWD_CHANNEL_11_REG ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group regular only */
Kojto 158:b23ee177fd68 657 #define LL_ADC_AWD_CHANNEL_12_REG ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group regular only */
Kojto 158:b23ee177fd68 658 #define LL_ADC_AWD_CHANNEL_13_REG ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group regular only */
Kojto 158:b23ee177fd68 659 #define LL_ADC_AWD_CHANNEL_14_REG ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group regular only */
Kojto 158:b23ee177fd68 660 #define LL_ADC_AWD_CHANNEL_15_REG ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group regular only */
Kojto 158:b23ee177fd68 661 #define LL_ADC_AWD_CHANNEL_17_REG ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group regular only */
Kojto 158:b23ee177fd68 662 #define LL_ADC_AWD_CHANNEL_18_REG ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group regular only */
Kojto 158:b23ee177fd68 663 #define LL_ADC_AWD_CH_VREFINT_REG ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group regular only */
Kojto 158:b23ee177fd68 664 #define LL_ADC_AWD_CH_TEMPSENSOR_REG ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group regular only */
Kojto 158:b23ee177fd68 665 #if defined(ADC_CCR_VLCDEN)
Kojto 158:b23ee177fd68 666 #define LL_ADC_AWD_CHANNEL_16_REG ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group regular only */
Kojto 158:b23ee177fd68 667 #define LL_ADC_AWD_CH_VLCD_REG ((LL_ADC_CHANNEL_VLCD & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_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 */
Kojto 158:b23ee177fd68 668 #endif
Kojto 158:b23ee177fd68 669 /**
Kojto 158:b23ee177fd68 670 * @}
Kojto 158:b23ee177fd68 671 */
Kojto 158:b23ee177fd68 672
Kojto 158:b23ee177fd68 673 /** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
Kojto 158:b23ee177fd68 674 * @{
Kojto 158:b23ee177fd68 675 */
Kojto 158:b23ee177fd68 676 #define LL_ADC_AWD_THRESHOLD_HIGH (ADC_TR_HT ) /*!< ADC analog watchdog threshold high */
Kojto 158:b23ee177fd68 677 #define LL_ADC_AWD_THRESHOLD_LOW ( ADC_TR_LT) /*!< ADC analog watchdog threshold low */
Kojto 158:b23ee177fd68 678 #define LL_ADC_AWD_THRESHOLDS_HIGH_LOW (ADC_TR_HT | ADC_TR_LT) /*!< ADC analog watchdog both thresholds high and low concatenated into the same data */
Kojto 158:b23ee177fd68 679 /**
Kojto 158:b23ee177fd68 680 * @}
Kojto 158:b23ee177fd68 681 */
Kojto 158:b23ee177fd68 682
Kojto 158:b23ee177fd68 683 /** @defgroup ADC_LL_EC_OVS_SCOPE Oversampling - Oversampling scope
Kojto 158:b23ee177fd68 684 * @{
Kojto 158:b23ee177fd68 685 */
Kojto 158:b23ee177fd68 686 #define LL_ADC_OVS_DISABLE ((uint32_t)0x00000000U) /*!< ADC oversampling disabled. */
Kojto 158:b23ee177fd68 687 #define LL_ADC_OVS_GRP_REGULAR_CONTINUED ( ADC_CFGR2_OVSE) /*!< ADC oversampling on conversions of ADC group regular. Literal suffix "continued" is kept for compatibility with other STM32 devices featuring ADC group injected, in this case other oversampling scope parameters are available. */
Kojto 158:b23ee177fd68 688 /**
Kojto 158:b23ee177fd68 689 * @}
Kojto 158:b23ee177fd68 690 */
Kojto 158:b23ee177fd68 691
Kojto 158:b23ee177fd68 692 /** @defgroup ADC_LL_EC_OVS_DISCONT_MODE Oversampling - Discontinuous mode
Kojto 158:b23ee177fd68 693 * @{
Kojto 158:b23ee177fd68 694 */
Kojto 158:b23ee177fd68 695 #define LL_ADC_OVS_REG_CONT ((uint32_t)0x00000000U)/*!< ADC oversampling discontinuous mode: continuous mode (all conversions of oversampling ratio are done from 1 trigger) */
Kojto 158:b23ee177fd68 696 #define LL_ADC_OVS_REG_DISCONT (ADC_CFGR2_TOVS) /*!< ADC oversampling discontinuous mode: discontinuous mode (each conversion of oversampling ratio needs a trigger) */
Kojto 158:b23ee177fd68 697 /**
Kojto 158:b23ee177fd68 698 * @}
Kojto 158:b23ee177fd68 699 */
Kojto 158:b23ee177fd68 700
Kojto 158:b23ee177fd68 701 /** @defgroup ADC_LL_EC_OVS_RATIO Oversampling - Ratio
Kojto 158:b23ee177fd68 702 * @{
Kojto 158:b23ee177fd68 703 */
Kojto 158:b23ee177fd68 704 #define LL_ADC_OVS_RATIO_2 ((uint32_t)0x00000000U) /*!< ADC oversampling ratio of 2 (2 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
Kojto 158:b23ee177fd68 705 #define LL_ADC_OVS_RATIO_4 ( ADC_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 4 (4 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
Kojto 158:b23ee177fd68 706 #define LL_ADC_OVS_RATIO_8 ( ADC_CFGR2_OVSR_1 ) /*!< ADC oversampling ratio of 8 (8 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
Kojto 158:b23ee177fd68 707 #define LL_ADC_OVS_RATIO_16 ( ADC_CFGR2_OVSR_1 | ADC_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 16 (16 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
Kojto 158:b23ee177fd68 708 #define LL_ADC_OVS_RATIO_32 (ADC_CFGR2_OVSR_2 ) /*!< ADC oversampling ratio of 32 (32 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
Kojto 158:b23ee177fd68 709 #define LL_ADC_OVS_RATIO_64 (ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 64 (64 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
Kojto 158:b23ee177fd68 710 #define LL_ADC_OVS_RATIO_128 (ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_1 ) /*!< ADC oversampling ratio of 128 (128 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
Kojto 158:b23ee177fd68 711 #define LL_ADC_OVS_RATIO_256 (ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_1 | ADC_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 256 (256 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */
Kojto 158:b23ee177fd68 712 /**
Kojto 158:b23ee177fd68 713 * @}
Kojto 158:b23ee177fd68 714 */
Kojto 158:b23ee177fd68 715
Kojto 158:b23ee177fd68 716 /** @defgroup ADC_LL_EC_OVS_SHIFT Oversampling - Data shift
Kojto 158:b23ee177fd68 717 * @{
Kojto 158:b23ee177fd68 718 */
Kojto 158:b23ee177fd68 719 #define LL_ADC_OVS_SHIFT_NONE ((uint32_t)0x00000000U) /*!< ADC oversampling no shift (sum of the ADC conversions data is not divided to result as the ADC oversampling conversion data) */
Kojto 158:b23ee177fd68 720 #define LL_ADC_OVS_SHIFT_RIGHT_1 ( ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 1 (sum of the ADC conversions data is divided by 2 to result as the ADC oversampling conversion data) */
Kojto 158:b23ee177fd68 721 #define LL_ADC_OVS_SHIFT_RIGHT_2 ( ADC_CFGR2_OVSS_1 ) /*!< ADC oversampling shift of 2 (sum of the ADC conversions data is divided by 4 to result as the ADC oversampling conversion data) */
Kojto 158:b23ee177fd68 722 #define LL_ADC_OVS_SHIFT_RIGHT_3 ( ADC_CFGR2_OVSS_1 | ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 3 (sum of the ADC conversions data is divided by 8 to result as the ADC oversampling conversion data) */
Kojto 158:b23ee177fd68 723 #define LL_ADC_OVS_SHIFT_RIGHT_4 ( ADC_CFGR2_OVSS_2 ) /*!< ADC oversampling shift of 4 (sum of the ADC conversions data is divided by 16 to result as the ADC oversampling conversion data) */
Kojto 158:b23ee177fd68 724 #define LL_ADC_OVS_SHIFT_RIGHT_5 ( ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 5 (sum of the ADC conversions data is divided by 32 to result as the ADC oversampling conversion data) */
Kojto 158:b23ee177fd68 725 #define LL_ADC_OVS_SHIFT_RIGHT_6 ( ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_1 ) /*!< ADC oversampling shift of 6 (sum of the ADC conversions data is divided by 64 to result as the ADC oversampling conversion data) */
Kojto 158:b23ee177fd68 726 #define LL_ADC_OVS_SHIFT_RIGHT_7 ( ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_1 | ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 7 (sum of the ADC conversions data is divided by 128 to result as the ADC oversampling conversion data) */
Kojto 158:b23ee177fd68 727 #define LL_ADC_OVS_SHIFT_RIGHT_8 (ADC_CFGR2_OVSS_3 ) /*!< ADC oversampling shift of 8 (sum of the ADC conversions data is divided by 256 to result as the ADC oversampling conversion data) */
Kojto 158:b23ee177fd68 728 /**
Kojto 158:b23ee177fd68 729 * @}
Kojto 158:b23ee177fd68 730 */
Kojto 158:b23ee177fd68 731
Kojto 158:b23ee177fd68 732
Kojto 158:b23ee177fd68 733 /** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
Kojto 158:b23ee177fd68 734 * @note Only ADC IP HW delays are defined in ADC LL driver driver,
Kojto 158:b23ee177fd68 735 * not timeout values.
Kojto 158:b23ee177fd68 736 * For details on delays values, refer to descriptions in source code
Kojto 158:b23ee177fd68 737 * above each literal definition.
Kojto 158:b23ee177fd68 738 * @{
Kojto 158:b23ee177fd68 739 */
Kojto 158:b23ee177fd68 740
Kojto 158:b23ee177fd68 741 /* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
Kojto 158:b23ee177fd68 742 /* not timeout values. */
Kojto 158:b23ee177fd68 743 /* Timeout values for ADC operations are dependent to device clock */
Kojto 158:b23ee177fd68 744 /* configuration (system clock versus ADC clock), */
Kojto 158:b23ee177fd68 745 /* and therefore must be defined in user application. */
Kojto 158:b23ee177fd68 746 /* Indications for estimation of ADC timeout delays, for this */
Kojto 158:b23ee177fd68 747 /* STM32 serie: */
Kojto 158:b23ee177fd68 748 /* - ADC calibration time: maximum delay is 83/fADC. */
Kojto 158:b23ee177fd68 749 /* (refer to device datasheet, parameter "tCAL") */
Kojto 158:b23ee177fd68 750 /* - ADC enable time: maximum delay is 1 conversion cycle. */
Kojto 158:b23ee177fd68 751 /* (refer to device datasheet, parameter "tSTAB") */
Kojto 158:b23ee177fd68 752 /* - ADC disable time: maximum delay should be a few ADC clock cycles */
Kojto 158:b23ee177fd68 753 /* - ADC stop conversion time: maximum delay should be a few ADC clock */
Kojto 158:b23ee177fd68 754 /* cycles */
Kojto 158:b23ee177fd68 755 /* - ADC conversion time: duration depending on ADC clock and ADC */
Kojto 158:b23ee177fd68 756 /* configuration. */
Kojto 158:b23ee177fd68 757 /* (refer to device reference manual, section "Timing") */
Kojto 158:b23ee177fd68 758
Kojto 158:b23ee177fd68 759 /* Delay for ADC stabilization time (ADC voltage regulator start-up time) */
Kojto 158:b23ee177fd68 760 /* Delay set to maximum value (refer to device datasheet, */
Kojto 158:b23ee177fd68 761 /* parameter "tUP_LDO"). */
Kojto 158:b23ee177fd68 762 #define LL_ADC_DELAY_INTERNAL_REGUL_STAB_US ((uint32_t) 10U) /*!< Delay for ADC stabilization time (ADC voltage regulator start-up time) */
Kojto 158:b23ee177fd68 763
Kojto 158:b23ee177fd68 764 /* Delay for internal voltage reference stabilization time. */
Kojto 158:b23ee177fd68 765 /* Delay set to maximum value (refer to device datasheet, */
Kojto 158:b23ee177fd68 766 /* parameter "TADC_BUF"). */
Kojto 158:b23ee177fd68 767 /* Unit: us */
Kojto 158:b23ee177fd68 768 #define LL_ADC_DELAY_VREFINT_STAB_US ((uint32_t) 10U) /*!< Delay for internal voltage reference stabilization time */
Kojto 158:b23ee177fd68 769
Kojto 158:b23ee177fd68 770 /* Delay for temperature sensor stabilization time. */
Kojto 158:b23ee177fd68 771 /* Literal set to maximum value (refer to device datasheet, */
Kojto 158:b23ee177fd68 772 /* parameter "tSTART"). */
Kojto 158:b23ee177fd68 773 /* Unit: us */
Kojto 158:b23ee177fd68 774 #define LL_ADC_DELAY_TEMPSENSOR_STAB_US ((uint32_t) 10U) /*!< Delay for temperature sensor stabilization time */
Kojto 158:b23ee177fd68 775
Kojto 158:b23ee177fd68 776 /* Delay required between ADC end of calibration and ADC enable. */
Kojto 158:b23ee177fd68 777 /* Note: On this STM32 serie, a minimum number of ADC clock cycles */
Kojto 158:b23ee177fd68 778 /* are required between ADC end of calibration and ADC enable. */
Kojto 158:b23ee177fd68 779 /* Wait time can be computed in user application by waiting for the */
Kojto 158:b23ee177fd68 780 /* equivalent number of CPU cycles, by taking into account */
Kojto 158:b23ee177fd68 781 /* ratio of CPU clock versus ADC clock prescalers. */
Kojto 158:b23ee177fd68 782 /* Unit: ADC clock cycles. */
Kojto 158:b23ee177fd68 783 #define LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES ((uint32_t) 2U) /*!< Delay required between ADC end of calibration and ADC enable */
Kojto 158:b23ee177fd68 784
Kojto 158:b23ee177fd68 785 /**
Kojto 158:b23ee177fd68 786 * @}
Kojto 158:b23ee177fd68 787 */
Kojto 158:b23ee177fd68 788
Kojto 158:b23ee177fd68 789 /**
Kojto 158:b23ee177fd68 790 * @}
Kojto 158:b23ee177fd68 791 */
Kojto 158:b23ee177fd68 792
Kojto 158:b23ee177fd68 793
Kojto 158:b23ee177fd68 794 /* Exported macro ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 795 /** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
Kojto 158:b23ee177fd68 796 * @{
Kojto 158:b23ee177fd68 797 */
Kojto 158:b23ee177fd68 798
Kojto 158:b23ee177fd68 799 /** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
Kojto 158:b23ee177fd68 800 * @{
Kojto 158:b23ee177fd68 801 */
Kojto 158:b23ee177fd68 802
Kojto 158:b23ee177fd68 803 /**
Kojto 158:b23ee177fd68 804 * @brief Write a value in ADC register
Kojto 158:b23ee177fd68 805 * @param __INSTANCE__ ADC Instance
Kojto 158:b23ee177fd68 806 * @param __REG__ Register to be written
Kojto 158:b23ee177fd68 807 * @param __VALUE__ Value to be written in the register
Kojto 158:b23ee177fd68 808 * @retval None
Kojto 158:b23ee177fd68 809 */
Kojto 158:b23ee177fd68 810 #define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
Kojto 158:b23ee177fd68 811
Kojto 158:b23ee177fd68 812 /**
Kojto 158:b23ee177fd68 813 * @brief Read a value in ADC register
Kojto 158:b23ee177fd68 814 * @param __INSTANCE__ ADC Instance
Kojto 158:b23ee177fd68 815 * @param __REG__ Register to be read
Kojto 158:b23ee177fd68 816 * @retval Register value
Kojto 158:b23ee177fd68 817 */
Kojto 158:b23ee177fd68 818 #define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
Kojto 158:b23ee177fd68 819 /**
Kojto 158:b23ee177fd68 820 * @}
Kojto 158:b23ee177fd68 821 */
Kojto 158:b23ee177fd68 822
Kojto 158:b23ee177fd68 823 /** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
Kojto 158:b23ee177fd68 824 * @{
Kojto 158:b23ee177fd68 825 */
Kojto 158:b23ee177fd68 826
Kojto 158:b23ee177fd68 827 /**
Kojto 158:b23ee177fd68 828 * @brief Helper macro to get ADC channel number in decimal format
Kojto 158:b23ee177fd68 829 * from literals LL_ADC_CHANNEL_x.
Kojto 158:b23ee177fd68 830 * @note Example:
Kojto 158:b23ee177fd68 831 * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
Kojto 158:b23ee177fd68 832 * will return decimal number "4".
Kojto 158:b23ee177fd68 833 * @note The input can be a value from functions where a channel
Kojto 158:b23ee177fd68 834 * number is returned, either defined with number
Kojto 158:b23ee177fd68 835 * or with bitfield (only one bit must be set).
Kojto 158:b23ee177fd68 836 * @param __CHANNEL__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 837 * @arg @ref LL_ADC_CHANNEL_0
Kojto 158:b23ee177fd68 838 * @arg @ref LL_ADC_CHANNEL_1
Kojto 158:b23ee177fd68 839 * @arg @ref LL_ADC_CHANNEL_2
Kojto 158:b23ee177fd68 840 * @arg @ref LL_ADC_CHANNEL_3
Kojto 158:b23ee177fd68 841 * @arg @ref LL_ADC_CHANNEL_4
Kojto 158:b23ee177fd68 842 * @arg @ref LL_ADC_CHANNEL_5
Kojto 158:b23ee177fd68 843 * @arg @ref LL_ADC_CHANNEL_6
Kojto 158:b23ee177fd68 844 * @arg @ref LL_ADC_CHANNEL_7
Kojto 158:b23ee177fd68 845 * @arg @ref LL_ADC_CHANNEL_8
Kojto 158:b23ee177fd68 846 * @arg @ref LL_ADC_CHANNEL_9
Kojto 158:b23ee177fd68 847 * @arg @ref LL_ADC_CHANNEL_10
Kojto 158:b23ee177fd68 848 * @arg @ref LL_ADC_CHANNEL_11
Kojto 158:b23ee177fd68 849 * @arg @ref LL_ADC_CHANNEL_12
Kojto 158:b23ee177fd68 850 * @arg @ref LL_ADC_CHANNEL_13
Kojto 158:b23ee177fd68 851 * @arg @ref LL_ADC_CHANNEL_14
Kojto 158:b23ee177fd68 852 * @arg @ref LL_ADC_CHANNEL_15
Kojto 158:b23ee177fd68 853 * @arg @ref LL_ADC_CHANNEL_16 (1)
Kojto 158:b23ee177fd68 854 * @arg @ref LL_ADC_CHANNEL_17
Kojto 158:b23ee177fd68 855 * @arg @ref LL_ADC_CHANNEL_18
Kojto 158:b23ee177fd68 856 * @arg @ref LL_ADC_CHANNEL_VREFINT
Kojto 158:b23ee177fd68 857 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
Kojto 158:b23ee177fd68 858 * @arg @ref LL_ADC_CHANNEL_VLCD (1)
Kojto 158:b23ee177fd68 859 *
Kojto 158:b23ee177fd68 860 * (1) On STM32L0, parameter not available on all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.
Kojto 158:b23ee177fd68 861 * @retval Value between Min_Data=0 and Max_Data=18
Kojto 158:b23ee177fd68 862 */
Kojto 158:b23ee177fd68 863 #if defined(ADC_CCR_VLCDEN)
Kojto 158:b23ee177fd68 864 #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
Kojto 158:b23ee177fd68 865 ((((__CHANNEL__) & ADC_CHANNEL_ID_BITFIELD_MASK) == 0U) \
Kojto 158:b23ee177fd68 866 ? ( \
Kojto 158:b23ee177fd68 867 ((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS \
Kojto 158:b23ee177fd68 868 ) \
Kojto 158:b23ee177fd68 869 : \
Kojto 158:b23ee177fd68 870 ( \
Kojto 158:b23ee177fd68 871 (((__CHANNEL__) & ADC_CHSELR_CHSEL0) == ADC_CHSELR_CHSEL0) ? (0U) : \
Kojto 158:b23ee177fd68 872 ( \
Kojto 158:b23ee177fd68 873 (((__CHANNEL__) & ADC_CHSELR_CHSEL1) == ADC_CHSELR_CHSEL1) ? (1U) : \
Kojto 158:b23ee177fd68 874 ( \
Kojto 158:b23ee177fd68 875 (((__CHANNEL__) & ADC_CHSELR_CHSEL2) == ADC_CHSELR_CHSEL2) ? (2U) : \
Kojto 158:b23ee177fd68 876 ( \
Kojto 158:b23ee177fd68 877 (((__CHANNEL__) & ADC_CHSELR_CHSEL3) == ADC_CHSELR_CHSEL3) ? (3U) : \
Kojto 158:b23ee177fd68 878 ( \
Kojto 158:b23ee177fd68 879 (((__CHANNEL__) & ADC_CHSELR_CHSEL4) == ADC_CHSELR_CHSEL4) ? (4U) : \
Kojto 158:b23ee177fd68 880 ( \
Kojto 158:b23ee177fd68 881 (((__CHANNEL__) & ADC_CHSELR_CHSEL5) == ADC_CHSELR_CHSEL5) ? (5U) : \
Kojto 158:b23ee177fd68 882 ( \
Kojto 158:b23ee177fd68 883 (((__CHANNEL__) & ADC_CHSELR_CHSEL6) == ADC_CHSELR_CHSEL6) ? (6U) : \
Kojto 158:b23ee177fd68 884 ( \
Kojto 158:b23ee177fd68 885 (((__CHANNEL__) & ADC_CHSELR_CHSEL7) == ADC_CHSELR_CHSEL7) ? (7U) : \
Kojto 158:b23ee177fd68 886 ( \
Kojto 158:b23ee177fd68 887 (((__CHANNEL__) & ADC_CHSELR_CHSEL8) == ADC_CHSELR_CHSEL8) ? (8U) : \
Kojto 158:b23ee177fd68 888 ( \
Kojto 158:b23ee177fd68 889 (((__CHANNEL__) & ADC_CHSELR_CHSEL9) == ADC_CHSELR_CHSEL9) ? (9U) : \
Kojto 158:b23ee177fd68 890 ( \
Kojto 158:b23ee177fd68 891 (((__CHANNEL__) & ADC_CHSELR_CHSEL10) == ADC_CHSELR_CHSEL10) ? (10U) : \
Kojto 158:b23ee177fd68 892 ( \
Kojto 158:b23ee177fd68 893 (((__CHANNEL__) & ADC_CHSELR_CHSEL11) == ADC_CHSELR_CHSEL11) ? (11U) : \
Kojto 158:b23ee177fd68 894 ( \
Kojto 158:b23ee177fd68 895 (((__CHANNEL__) & ADC_CHSELR_CHSEL12) == ADC_CHSELR_CHSEL12) ? (12U) : \
Kojto 158:b23ee177fd68 896 ( \
Kojto 158:b23ee177fd68 897 (((__CHANNEL__) & ADC_CHSELR_CHSEL13) == ADC_CHSELR_CHSEL13) ? (13U) : \
Kojto 158:b23ee177fd68 898 ( \
Kojto 158:b23ee177fd68 899 (((__CHANNEL__) & ADC_CHSELR_CHSEL14) == ADC_CHSELR_CHSEL14) ? (14U) : \
Kojto 158:b23ee177fd68 900 ( \
Kojto 158:b23ee177fd68 901 (((__CHANNEL__) & ADC_CHSELR_CHSEL15) == ADC_CHSELR_CHSEL15) ? (15U) : \
Kojto 158:b23ee177fd68 902 ( \
Kojto 158:b23ee177fd68 903 (((__CHANNEL__) & ADC_CHSELR_CHSEL16) == ADC_CHSELR_CHSEL16) ? (16U) : \
Kojto 158:b23ee177fd68 904 ( \
Kojto 158:b23ee177fd68 905 (((__CHANNEL__) & ADC_CHSELR_CHSEL17) == ADC_CHSELR_CHSEL17) ? (17U) : \
Kojto 158:b23ee177fd68 906 ( \
Kojto 158:b23ee177fd68 907 (((__CHANNEL__) & ADC_CHSELR_CHSEL18) == ADC_CHSELR_CHSEL18) ? (18U) : \
Kojto 158:b23ee177fd68 908 (0U) \
Kojto 158:b23ee177fd68 909 ) \
Kojto 158:b23ee177fd68 910 ) \
Kojto 158:b23ee177fd68 911 ) \
Kojto 158:b23ee177fd68 912 ) \
Kojto 158:b23ee177fd68 913 ) \
Kojto 158:b23ee177fd68 914 ) \
Kojto 158:b23ee177fd68 915 ) \
Kojto 158:b23ee177fd68 916 ) \
Kojto 158:b23ee177fd68 917 ) \
Kojto 158:b23ee177fd68 918 ) \
Kojto 158:b23ee177fd68 919 ) \
Kojto 158:b23ee177fd68 920 ) \
Kojto 158:b23ee177fd68 921 ) \
Kojto 158:b23ee177fd68 922 ) \
Kojto 158:b23ee177fd68 923 ) \
Kojto 158:b23ee177fd68 924 ) \
Kojto 158:b23ee177fd68 925 ) \
Kojto 158:b23ee177fd68 926 ) \
Kojto 158:b23ee177fd68 927 ) \
Kojto 158:b23ee177fd68 928 )
Kojto 158:b23ee177fd68 929 #else
Kojto 158:b23ee177fd68 930 #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
Kojto 158:b23ee177fd68 931 ((((__CHANNEL__) & ADC_CHANNEL_ID_BITFIELD_MASK) == 0U) \
Kojto 158:b23ee177fd68 932 ? ( \
Kojto 158:b23ee177fd68 933 ((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS \
Kojto 158:b23ee177fd68 934 ) \
Kojto 158:b23ee177fd68 935 : \
Kojto 158:b23ee177fd68 936 ( \
Kojto 158:b23ee177fd68 937 (((__CHANNEL__) & ADC_CHSELR_CHSEL0) == ADC_CHSELR_CHSEL0) ? (0U) : \
Kojto 158:b23ee177fd68 938 ( \
Kojto 158:b23ee177fd68 939 (((__CHANNEL__) & ADC_CHSELR_CHSEL1) == ADC_CHSELR_CHSEL1) ? (1U) : \
Kojto 158:b23ee177fd68 940 ( \
Kojto 158:b23ee177fd68 941 (((__CHANNEL__) & ADC_CHSELR_CHSEL2) == ADC_CHSELR_CHSEL2) ? (2U) : \
Kojto 158:b23ee177fd68 942 ( \
Kojto 158:b23ee177fd68 943 (((__CHANNEL__) & ADC_CHSELR_CHSEL3) == ADC_CHSELR_CHSEL3) ? (3U) : \
Kojto 158:b23ee177fd68 944 ( \
Kojto 158:b23ee177fd68 945 (((__CHANNEL__) & ADC_CHSELR_CHSEL4) == ADC_CHSELR_CHSEL4) ? (4U) : \
Kojto 158:b23ee177fd68 946 ( \
Kojto 158:b23ee177fd68 947 (((__CHANNEL__) & ADC_CHSELR_CHSEL5) == ADC_CHSELR_CHSEL5) ? (5U) : \
Kojto 158:b23ee177fd68 948 ( \
Kojto 158:b23ee177fd68 949 (((__CHANNEL__) & ADC_CHSELR_CHSEL6) == ADC_CHSELR_CHSEL6) ? (6U) : \
Kojto 158:b23ee177fd68 950 ( \
Kojto 158:b23ee177fd68 951 (((__CHANNEL__) & ADC_CHSELR_CHSEL7) == ADC_CHSELR_CHSEL7) ? (7U) : \
Kojto 158:b23ee177fd68 952 ( \
Kojto 158:b23ee177fd68 953 (((__CHANNEL__) & ADC_CHSELR_CHSEL8) == ADC_CHSELR_CHSEL8) ? (8U) : \
Kojto 158:b23ee177fd68 954 ( \
Kojto 158:b23ee177fd68 955 (((__CHANNEL__) & ADC_CHSELR_CHSEL9) == ADC_CHSELR_CHSEL9) ? (9U) : \
Kojto 158:b23ee177fd68 956 ( \
Kojto 158:b23ee177fd68 957 (((__CHANNEL__) & ADC_CHSELR_CHSEL10) == ADC_CHSELR_CHSEL10) ? (10U) : \
Kojto 158:b23ee177fd68 958 ( \
Kojto 158:b23ee177fd68 959 (((__CHANNEL__) & ADC_CHSELR_CHSEL11) == ADC_CHSELR_CHSEL11) ? (11U) : \
Kojto 158:b23ee177fd68 960 ( \
Kojto 158:b23ee177fd68 961 (((__CHANNEL__) & ADC_CHSELR_CHSEL12) == ADC_CHSELR_CHSEL12) ? (12U) : \
Kojto 158:b23ee177fd68 962 ( \
Kojto 158:b23ee177fd68 963 (((__CHANNEL__) & ADC_CHSELR_CHSEL13) == ADC_CHSELR_CHSEL13) ? (13U) : \
Kojto 158:b23ee177fd68 964 ( \
Kojto 158:b23ee177fd68 965 (((__CHANNEL__) & ADC_CHSELR_CHSEL14) == ADC_CHSELR_CHSEL14) ? (14U) : \
Kojto 158:b23ee177fd68 966 ( \
Kojto 158:b23ee177fd68 967 (((__CHANNEL__) & ADC_CHSELR_CHSEL15) == ADC_CHSELR_CHSEL15) ? (15U) : \
Kojto 158:b23ee177fd68 968 ( \
Kojto 158:b23ee177fd68 969 (((__CHANNEL__) & ADC_CHSELR_CHSEL17) == ADC_CHSELR_CHSEL17) ? (17U) : \
Kojto 158:b23ee177fd68 970 ( \
Kojto 158:b23ee177fd68 971 (((__CHANNEL__) & ADC_CHSELR_CHSEL18) == ADC_CHSELR_CHSEL18) ? (18U) : \
Kojto 158:b23ee177fd68 972 (0U) \
Kojto 158:b23ee177fd68 973 ) \
Kojto 158:b23ee177fd68 974 ) \
Kojto 158:b23ee177fd68 975 ) \
Kojto 158:b23ee177fd68 976 ) \
Kojto 158:b23ee177fd68 977 ) \
Kojto 158:b23ee177fd68 978 ) \
Kojto 158:b23ee177fd68 979 ) \
Kojto 158:b23ee177fd68 980 ) \
Kojto 158:b23ee177fd68 981 ) \
Kojto 158:b23ee177fd68 982 ) \
Kojto 158:b23ee177fd68 983 ) \
Kojto 158:b23ee177fd68 984 ) \
Kojto 158:b23ee177fd68 985 ) \
Kojto 158:b23ee177fd68 986 ) \
Kojto 158:b23ee177fd68 987 ) \
Kojto 158:b23ee177fd68 988 ) \
Kojto 158:b23ee177fd68 989 ) \
Kojto 158:b23ee177fd68 990 ) \
Kojto 158:b23ee177fd68 991 )
Kojto 158:b23ee177fd68 992 #endif
Kojto 158:b23ee177fd68 993
Kojto 158:b23ee177fd68 994 /**
Kojto 158:b23ee177fd68 995 * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
Kojto 158:b23ee177fd68 996 * from number in decimal format.
Kojto 158:b23ee177fd68 997 * @note Example:
Kojto 158:b23ee177fd68 998 * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
Kojto 158:b23ee177fd68 999 * will return a data equivalent to "LL_ADC_CHANNEL_4".
Kojto 158:b23ee177fd68 1000 * @param __DECIMAL_NB__: Value between Min_Data=0 and Max_Data=18
Kojto 158:b23ee177fd68 1001 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1002 * @arg @ref LL_ADC_CHANNEL_0
Kojto 158:b23ee177fd68 1003 * @arg @ref LL_ADC_CHANNEL_1
Kojto 158:b23ee177fd68 1004 * @arg @ref LL_ADC_CHANNEL_2
Kojto 158:b23ee177fd68 1005 * @arg @ref LL_ADC_CHANNEL_3
Kojto 158:b23ee177fd68 1006 * @arg @ref LL_ADC_CHANNEL_4
Kojto 158:b23ee177fd68 1007 * @arg @ref LL_ADC_CHANNEL_5
Kojto 158:b23ee177fd68 1008 * @arg @ref LL_ADC_CHANNEL_6
Kojto 158:b23ee177fd68 1009 * @arg @ref LL_ADC_CHANNEL_7
Kojto 158:b23ee177fd68 1010 * @arg @ref LL_ADC_CHANNEL_8
Kojto 158:b23ee177fd68 1011 * @arg @ref LL_ADC_CHANNEL_9
Kojto 158:b23ee177fd68 1012 * @arg @ref LL_ADC_CHANNEL_10
Kojto 158:b23ee177fd68 1013 * @arg @ref LL_ADC_CHANNEL_11
Kojto 158:b23ee177fd68 1014 * @arg @ref LL_ADC_CHANNEL_12
Kojto 158:b23ee177fd68 1015 * @arg @ref LL_ADC_CHANNEL_13
Kojto 158:b23ee177fd68 1016 * @arg @ref LL_ADC_CHANNEL_14
Kojto 158:b23ee177fd68 1017 * @arg @ref LL_ADC_CHANNEL_15
Kojto 158:b23ee177fd68 1018 * @arg @ref LL_ADC_CHANNEL_16 (1)
Kojto 158:b23ee177fd68 1019 * @arg @ref LL_ADC_CHANNEL_17
Kojto 158:b23ee177fd68 1020 * @arg @ref LL_ADC_CHANNEL_18
Kojto 158:b23ee177fd68 1021 * @arg @ref LL_ADC_CHANNEL_VREFINT (2)
Kojto 158:b23ee177fd68 1022 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (2)
Kojto 158:b23ee177fd68 1023 * @arg @ref LL_ADC_CHANNEL_VLCD (1)(2)
Kojto 158:b23ee177fd68 1024 *
Kojto 158:b23ee177fd68 1025 * (1) On STM32L0, parameter not available on all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.\n
Kojto 158:b23ee177fd68 1026 * (2) For ADC channel read back from ADC register,
Kojto 158:b23ee177fd68 1027 * comparison with internal channel parameter to be done
Kojto 158:b23ee177fd68 1028 * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
Kojto 158:b23ee177fd68 1029 */
Kojto 158:b23ee177fd68 1030 #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
Kojto 158:b23ee177fd68 1031 ( \
Kojto 158:b23ee177fd68 1032 ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
Kojto 158:b23ee177fd68 1033 (ADC_CHSELR_CHSEL0 << (__DECIMAL_NB__)) \
Kojto 158:b23ee177fd68 1034 )
Kojto 158:b23ee177fd68 1035
Kojto 158:b23ee177fd68 1036 /**
Kojto 158:b23ee177fd68 1037 * @brief Helper macro to determine whether the selected channel
Kojto 158:b23ee177fd68 1038 * corresponds to literal definitions of driver.
Kojto 158:b23ee177fd68 1039 * @note The different literal definitions of ADC channels are:
Kojto 158:b23ee177fd68 1040 * - ADC internal channel:
Kojto 158:b23ee177fd68 1041 * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
Kojto 158:b23ee177fd68 1042 * - ADC external channel (channel connected to a GPIO pin):
Kojto 158:b23ee177fd68 1043 * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
Kojto 158:b23ee177fd68 1044 * @note The channel parameter must be a value defined from literal
Kojto 158:b23ee177fd68 1045 * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
Kojto 158:b23ee177fd68 1046 * LL_ADC_CHANNEL_TEMPSENSOR, ...),
Kojto 158:b23ee177fd68 1047 * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
Kojto 158:b23ee177fd68 1048 * must not be a value from functions where a channel number is
Kojto 158:b23ee177fd68 1049 * returned from ADC registers,
Kojto 158:b23ee177fd68 1050 * because internal and external channels share the same channel
Kojto 158:b23ee177fd68 1051 * number in ADC registers. The differentiation is made only with
Kojto 158:b23ee177fd68 1052 * parameters definitions of driver.
Kojto 158:b23ee177fd68 1053 * @param __CHANNEL__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1054 * @arg @ref LL_ADC_CHANNEL_0
Kojto 158:b23ee177fd68 1055 * @arg @ref LL_ADC_CHANNEL_1
Kojto 158:b23ee177fd68 1056 * @arg @ref LL_ADC_CHANNEL_2
Kojto 158:b23ee177fd68 1057 * @arg @ref LL_ADC_CHANNEL_3
Kojto 158:b23ee177fd68 1058 * @arg @ref LL_ADC_CHANNEL_4
Kojto 158:b23ee177fd68 1059 * @arg @ref LL_ADC_CHANNEL_5
Kojto 158:b23ee177fd68 1060 * @arg @ref LL_ADC_CHANNEL_6
Kojto 158:b23ee177fd68 1061 * @arg @ref LL_ADC_CHANNEL_7
Kojto 158:b23ee177fd68 1062 * @arg @ref LL_ADC_CHANNEL_8
Kojto 158:b23ee177fd68 1063 * @arg @ref LL_ADC_CHANNEL_9
Kojto 158:b23ee177fd68 1064 * @arg @ref LL_ADC_CHANNEL_10
Kojto 158:b23ee177fd68 1065 * @arg @ref LL_ADC_CHANNEL_11
Kojto 158:b23ee177fd68 1066 * @arg @ref LL_ADC_CHANNEL_12
Kojto 158:b23ee177fd68 1067 * @arg @ref LL_ADC_CHANNEL_13
Kojto 158:b23ee177fd68 1068 * @arg @ref LL_ADC_CHANNEL_14
Kojto 158:b23ee177fd68 1069 * @arg @ref LL_ADC_CHANNEL_15
Kojto 158:b23ee177fd68 1070 * @arg @ref LL_ADC_CHANNEL_16 (1)
Kojto 158:b23ee177fd68 1071 * @arg @ref LL_ADC_CHANNEL_17
Kojto 158:b23ee177fd68 1072 * @arg @ref LL_ADC_CHANNEL_18
Kojto 158:b23ee177fd68 1073 * @arg @ref LL_ADC_CHANNEL_VREFINT
Kojto 158:b23ee177fd68 1074 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
Kojto 158:b23ee177fd68 1075 * @arg @ref LL_ADC_CHANNEL_VLCD (1)
Kojto 158:b23ee177fd68 1076 *
Kojto 158:b23ee177fd68 1077 * (1) On STM32L0, parameter not available on all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.
Anna Bridge 186:707f6e361f3e 1078 * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin).
Anna Bridge 186:707f6e361f3e 1079 * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
Kojto 158:b23ee177fd68 1080 */
Kojto 158:b23ee177fd68 1081 #define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
Kojto 158:b23ee177fd68 1082 (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0U)
Kojto 158:b23ee177fd68 1083
Kojto 158:b23ee177fd68 1084 /**
Kojto 158:b23ee177fd68 1085 * @brief Helper macro to convert a channel defined from parameter
Kojto 158:b23ee177fd68 1086 * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
Kojto 158:b23ee177fd68 1087 * LL_ADC_CHANNEL_TEMPSENSOR, ...),
Kojto 158:b23ee177fd68 1088 * to its equivalent parameter definition of a ADC external channel
Kojto 158:b23ee177fd68 1089 * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
Kojto 158:b23ee177fd68 1090 * @note The channel parameter can be, additionally to a value
Kojto 158:b23ee177fd68 1091 * defined from parameter definition of a ADC internal channel
Kojto 158:b23ee177fd68 1092 * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
Kojto 158:b23ee177fd68 1093 * a value defined from parameter definition of
Kojto 158:b23ee177fd68 1094 * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
Kojto 158:b23ee177fd68 1095 * or a value from functions where a channel number is returned
Kojto 158:b23ee177fd68 1096 * from ADC registers.
Kojto 158:b23ee177fd68 1097 * @param __CHANNEL__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1098 * @arg @ref LL_ADC_CHANNEL_0
Kojto 158:b23ee177fd68 1099 * @arg @ref LL_ADC_CHANNEL_1
Kojto 158:b23ee177fd68 1100 * @arg @ref LL_ADC_CHANNEL_2
Kojto 158:b23ee177fd68 1101 * @arg @ref LL_ADC_CHANNEL_3
Kojto 158:b23ee177fd68 1102 * @arg @ref LL_ADC_CHANNEL_4
Kojto 158:b23ee177fd68 1103 * @arg @ref LL_ADC_CHANNEL_5
Kojto 158:b23ee177fd68 1104 * @arg @ref LL_ADC_CHANNEL_6
Kojto 158:b23ee177fd68 1105 * @arg @ref LL_ADC_CHANNEL_7
Kojto 158:b23ee177fd68 1106 * @arg @ref LL_ADC_CHANNEL_8
Kojto 158:b23ee177fd68 1107 * @arg @ref LL_ADC_CHANNEL_9
Kojto 158:b23ee177fd68 1108 * @arg @ref LL_ADC_CHANNEL_10
Kojto 158:b23ee177fd68 1109 * @arg @ref LL_ADC_CHANNEL_11
Kojto 158:b23ee177fd68 1110 * @arg @ref LL_ADC_CHANNEL_12
Kojto 158:b23ee177fd68 1111 * @arg @ref LL_ADC_CHANNEL_13
Kojto 158:b23ee177fd68 1112 * @arg @ref LL_ADC_CHANNEL_14
Kojto 158:b23ee177fd68 1113 * @arg @ref LL_ADC_CHANNEL_15
Kojto 158:b23ee177fd68 1114 * @arg @ref LL_ADC_CHANNEL_16 (1)
Kojto 158:b23ee177fd68 1115 * @arg @ref LL_ADC_CHANNEL_17
Kojto 158:b23ee177fd68 1116 * @arg @ref LL_ADC_CHANNEL_18
Kojto 158:b23ee177fd68 1117 * @arg @ref LL_ADC_CHANNEL_VREFINT
Kojto 158:b23ee177fd68 1118 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
Kojto 158:b23ee177fd68 1119 * @arg @ref LL_ADC_CHANNEL_VLCD (1)
Kojto 158:b23ee177fd68 1120 *
Kojto 158:b23ee177fd68 1121 * (1) On STM32L0, parameter not available on all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.
Kojto 158:b23ee177fd68 1122 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1123 * @arg @ref LL_ADC_CHANNEL_0
Kojto 158:b23ee177fd68 1124 * @arg @ref LL_ADC_CHANNEL_1
Kojto 158:b23ee177fd68 1125 * @arg @ref LL_ADC_CHANNEL_2
Kojto 158:b23ee177fd68 1126 * @arg @ref LL_ADC_CHANNEL_3
Kojto 158:b23ee177fd68 1127 * @arg @ref LL_ADC_CHANNEL_4
Kojto 158:b23ee177fd68 1128 * @arg @ref LL_ADC_CHANNEL_5
Kojto 158:b23ee177fd68 1129 * @arg @ref LL_ADC_CHANNEL_6
Kojto 158:b23ee177fd68 1130 * @arg @ref LL_ADC_CHANNEL_7
Kojto 158:b23ee177fd68 1131 * @arg @ref LL_ADC_CHANNEL_8
Kojto 158:b23ee177fd68 1132 * @arg @ref LL_ADC_CHANNEL_9
Kojto 158:b23ee177fd68 1133 * @arg @ref LL_ADC_CHANNEL_10
Kojto 158:b23ee177fd68 1134 * @arg @ref LL_ADC_CHANNEL_11
Kojto 158:b23ee177fd68 1135 * @arg @ref LL_ADC_CHANNEL_12
Kojto 158:b23ee177fd68 1136 * @arg @ref LL_ADC_CHANNEL_13
Kojto 158:b23ee177fd68 1137 * @arg @ref LL_ADC_CHANNEL_14
Kojto 158:b23ee177fd68 1138 * @arg @ref LL_ADC_CHANNEL_15
Kojto 158:b23ee177fd68 1139 * @arg @ref LL_ADC_CHANNEL_16
Kojto 158:b23ee177fd68 1140 * @arg @ref LL_ADC_CHANNEL_17
Kojto 158:b23ee177fd68 1141 * @arg @ref LL_ADC_CHANNEL_18
Kojto 158:b23ee177fd68 1142 */
Kojto 158:b23ee177fd68 1143 #define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
Kojto 158:b23ee177fd68 1144 ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
Kojto 158:b23ee177fd68 1145
Kojto 158:b23ee177fd68 1146 /**
Kojto 158:b23ee177fd68 1147 * @brief Helper macro to determine whether the internal channel
Kojto 158:b23ee177fd68 1148 * selected is available on the ADC instance selected.
Kojto 158:b23ee177fd68 1149 * @note The channel parameter must be a value defined from parameter
Kojto 158:b23ee177fd68 1150 * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
Kojto 158:b23ee177fd68 1151 * LL_ADC_CHANNEL_TEMPSENSOR, ...),
Kojto 158:b23ee177fd68 1152 * must not be a value defined from parameter definition of
Kojto 158:b23ee177fd68 1153 * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
Kojto 158:b23ee177fd68 1154 * or a value from functions where a channel number is
Kojto 158:b23ee177fd68 1155 * returned from ADC registers,
Kojto 158:b23ee177fd68 1156 * because internal and external channels share the same channel
Kojto 158:b23ee177fd68 1157 * number in ADC registers. The differentiation is made only with
Kojto 158:b23ee177fd68 1158 * parameters definitions of driver.
Kojto 158:b23ee177fd68 1159 * @param __ADC_INSTANCE__ ADC instance
Kojto 158:b23ee177fd68 1160 * @param __CHANNEL__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1161 * @arg @ref LL_ADC_CHANNEL_VREFINT
Kojto 158:b23ee177fd68 1162 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
Kojto 158:b23ee177fd68 1163 * @arg @ref LL_ADC_CHANNEL_VLCD (1)
Kojto 158:b23ee177fd68 1164 *
Kojto 158:b23ee177fd68 1165 * (1) On STM32L0, parameter not available on all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.
Kojto 158:b23ee177fd68 1166
Anna Bridge 186:707f6e361f3e 1167 * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
Anna Bridge 186:707f6e361f3e 1168 * Value "1" if the internal channel selected is available on the ADC instance selected.
Kojto 158:b23ee177fd68 1169 */
Kojto 158:b23ee177fd68 1170 #if defined(ADC_CCR_VLCDEN)
Kojto 158:b23ee177fd68 1171 #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
Kojto 158:b23ee177fd68 1172 ( \
Kojto 158:b23ee177fd68 1173 ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
Kojto 158:b23ee177fd68 1174 ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
Kojto 158:b23ee177fd68 1175 ((__CHANNEL__) == LL_ADC_CHANNEL_VLCD) \
Kojto 158:b23ee177fd68 1176 )
Kojto 158:b23ee177fd68 1177 #else
Kojto 158:b23ee177fd68 1178 #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
Kojto 158:b23ee177fd68 1179 ( \
Kojto 158:b23ee177fd68 1180 ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
Kojto 158:b23ee177fd68 1181 ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) \
Kojto 158:b23ee177fd68 1182 )
Kojto 158:b23ee177fd68 1183 #endif
Kojto 158:b23ee177fd68 1184
Kojto 158:b23ee177fd68 1185 /**
Kojto 158:b23ee177fd68 1186 * @brief Helper macro to define ADC analog watchdog parameter:
Kojto 158:b23ee177fd68 1187 * define a single channel to monitor with analog watchdog
Kojto 158:b23ee177fd68 1188 * from sequencer channel and groups definition.
Kojto 158:b23ee177fd68 1189 * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
Kojto 158:b23ee177fd68 1190 * Example:
Kojto 158:b23ee177fd68 1191 * LL_ADC_SetAnalogWDMonitChannels(
Kojto 158:b23ee177fd68 1192 * ADC1, LL_ADC_AWD1,
Kojto 158:b23ee177fd68 1193 * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
Kojto 158:b23ee177fd68 1194 * @param __CHANNEL__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1195 * @arg @ref LL_ADC_CHANNEL_0
Kojto 158:b23ee177fd68 1196 * @arg @ref LL_ADC_CHANNEL_1
Kojto 158:b23ee177fd68 1197 * @arg @ref LL_ADC_CHANNEL_2
Kojto 158:b23ee177fd68 1198 * @arg @ref LL_ADC_CHANNEL_3
Kojto 158:b23ee177fd68 1199 * @arg @ref LL_ADC_CHANNEL_4
Kojto 158:b23ee177fd68 1200 * @arg @ref LL_ADC_CHANNEL_5
Kojto 158:b23ee177fd68 1201 * @arg @ref LL_ADC_CHANNEL_6
Kojto 158:b23ee177fd68 1202 * @arg @ref LL_ADC_CHANNEL_7
Kojto 158:b23ee177fd68 1203 * @arg @ref LL_ADC_CHANNEL_8
Kojto 158:b23ee177fd68 1204 * @arg @ref LL_ADC_CHANNEL_9
Kojto 158:b23ee177fd68 1205 * @arg @ref LL_ADC_CHANNEL_10
Kojto 158:b23ee177fd68 1206 * @arg @ref LL_ADC_CHANNEL_11
Kojto 158:b23ee177fd68 1207 * @arg @ref LL_ADC_CHANNEL_12
Kojto 158:b23ee177fd68 1208 * @arg @ref LL_ADC_CHANNEL_13
Kojto 158:b23ee177fd68 1209 * @arg @ref LL_ADC_CHANNEL_14
Kojto 158:b23ee177fd68 1210 * @arg @ref LL_ADC_CHANNEL_15
Kojto 158:b23ee177fd68 1211 * @arg @ref LL_ADC_CHANNEL_16 (1)
Kojto 158:b23ee177fd68 1212 * @arg @ref LL_ADC_CHANNEL_17
Kojto 158:b23ee177fd68 1213 * @arg @ref LL_ADC_CHANNEL_18
Kojto 158:b23ee177fd68 1214 * @arg @ref LL_ADC_CHANNEL_VREFINT (2)
Kojto 158:b23ee177fd68 1215 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (2)
Kojto 158:b23ee177fd68 1216 * @arg @ref LL_ADC_CHANNEL_VLCD (1)(2)
Kojto 158:b23ee177fd68 1217 *
Kojto 158:b23ee177fd68 1218 * (1) On STM32L0, parameter not available on all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.\n
Kojto 158:b23ee177fd68 1219 * (2) For ADC channel read back from ADC register,
Kojto 158:b23ee177fd68 1220 * comparison with internal channel parameter to be done
Kojto 158:b23ee177fd68 1221 * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
Kojto 158:b23ee177fd68 1222 * @param __GROUP__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1223 * @arg @ref LL_ADC_GROUP_REGULAR
Kojto 158:b23ee177fd68 1224 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1225 * @arg @ref LL_ADC_AWD_DISABLE
Kojto 158:b23ee177fd68 1226 * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
Kojto 158:b23ee177fd68 1227 * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
Kojto 158:b23ee177fd68 1228 * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
Kojto 158:b23ee177fd68 1229 * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
Kojto 158:b23ee177fd68 1230 * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
Kojto 158:b23ee177fd68 1231 * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
Kojto 158:b23ee177fd68 1232 * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
Kojto 158:b23ee177fd68 1233 * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
Kojto 158:b23ee177fd68 1234 * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
Kojto 158:b23ee177fd68 1235 * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
Kojto 158:b23ee177fd68 1236 * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
Kojto 158:b23ee177fd68 1237 * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
Kojto 158:b23ee177fd68 1238 * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
Kojto 158:b23ee177fd68 1239 * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
Kojto 158:b23ee177fd68 1240 * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
Kojto 158:b23ee177fd68 1241 * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
Kojto 158:b23ee177fd68 1242 * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
Kojto 158:b23ee177fd68 1243 * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (1)
Kojto 158:b23ee177fd68 1244 * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
Kojto 158:b23ee177fd68 1245 * @arg @ref LL_ADC_AWD_CHANNEL_18_REG
Kojto 158:b23ee177fd68 1246 * @arg @ref LL_ADC_AWD_CH_VREFINT_REG
Kojto 158:b23ee177fd68 1247 * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG
Kojto 158:b23ee177fd68 1248 * @arg @ref LL_ADC_AWD_CH_VLCD_REG (1)
Kojto 158:b23ee177fd68 1249 *
Kojto 158:b23ee177fd68 1250 * (1) On STM32L0, parameter not available on all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.
Kojto 158:b23ee177fd68 1251 */
Kojto 158:b23ee177fd68 1252 #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \
Kojto 158:b23ee177fd68 1253 (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL)
Kojto 158:b23ee177fd68 1254
Kojto 158:b23ee177fd68 1255 /**
Kojto 158:b23ee177fd68 1256 * @brief Helper macro to set the value of ADC analog watchdog threshold high
Kojto 158:b23ee177fd68 1257 * or low in function of ADC resolution, when ADC resolution is
Kojto 158:b23ee177fd68 1258 * different of 12 bits.
Kojto 158:b23ee177fd68 1259 * @note To be used with function @ref LL_ADC_ConfigAnalogWDThresholds()
Kojto 158:b23ee177fd68 1260 * or @ref LL_ADC_SetAnalogWDThresholds().
Kojto 158:b23ee177fd68 1261 * Example, with a ADC resolution of 8 bits, to set the value of
Kojto 158:b23ee177fd68 1262 * analog watchdog threshold high (on 8 bits):
Kojto 158:b23ee177fd68 1263 * LL_ADC_SetAnalogWDThresholds
Kojto 158:b23ee177fd68 1264 * (< ADCx param >,
Kojto 158:b23ee177fd68 1265 * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
Kojto 158:b23ee177fd68 1266 * );
Kojto 158:b23ee177fd68 1267 * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1268 * @arg @ref LL_ADC_RESOLUTION_12B
Kojto 158:b23ee177fd68 1269 * @arg @ref LL_ADC_RESOLUTION_10B
Kojto 158:b23ee177fd68 1270 * @arg @ref LL_ADC_RESOLUTION_8B
Kojto 158:b23ee177fd68 1271 * @arg @ref LL_ADC_RESOLUTION_6B
Kojto 158:b23ee177fd68 1272 * @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1273 * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1274 */
Kojto 158:b23ee177fd68 1275 #define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
Kojto 158:b23ee177fd68 1276 ((__AWD_THRESHOLD__) << ((__ADC_RESOLUTION__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U )))
Kojto 158:b23ee177fd68 1277
Kojto 158:b23ee177fd68 1278 /**
Kojto 158:b23ee177fd68 1279 * @brief Helper macro to get the value of ADC analog watchdog threshold high
Kojto 158:b23ee177fd68 1280 * or low in function of ADC resolution, when ADC resolution is
Kojto 158:b23ee177fd68 1281 * different of 12 bits.
Kojto 158:b23ee177fd68 1282 * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
Kojto 158:b23ee177fd68 1283 * Example, with a ADC resolution of 8 bits, to get the value of
Kojto 158:b23ee177fd68 1284 * analog watchdog threshold high (on 8 bits):
Kojto 158:b23ee177fd68 1285 * < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
Kojto 158:b23ee177fd68 1286 * (LL_ADC_RESOLUTION_8B,
Kojto 158:b23ee177fd68 1287 * LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
Kojto 158:b23ee177fd68 1288 * );
Kojto 158:b23ee177fd68 1289 * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1290 * @arg @ref LL_ADC_RESOLUTION_12B
Kojto 158:b23ee177fd68 1291 * @arg @ref LL_ADC_RESOLUTION_10B
Kojto 158:b23ee177fd68 1292 * @arg @ref LL_ADC_RESOLUTION_8B
Kojto 158:b23ee177fd68 1293 * @arg @ref LL_ADC_RESOLUTION_6B
Kojto 158:b23ee177fd68 1294 * @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1295 * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1296 */
Kojto 158:b23ee177fd68 1297 #define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
Kojto 158:b23ee177fd68 1298 ((__AWD_THRESHOLD_12_BITS__) >> ((__ADC_RESOLUTION__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U )))
Kojto 158:b23ee177fd68 1299
Kojto 158:b23ee177fd68 1300 /**
Kojto 158:b23ee177fd68 1301 * @brief Helper macro to get the ADC analog watchdog threshold high
Kojto 158:b23ee177fd68 1302 * or low from raw value containing both thresholds concatenated.
Kojto 158:b23ee177fd68 1303 * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
Kojto 158:b23ee177fd68 1304 * Example, to get analog watchdog threshold high from the register raw value:
Kojto 158:b23ee177fd68 1305 * __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(LL_ADC_AWD_THRESHOLD_HIGH, <raw_value_with_both_thresholds>);
Kojto 158:b23ee177fd68 1306 * @param __AWD_THRESHOLD_TYPE__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1307 * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
Kojto 158:b23ee177fd68 1308 * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
Kojto 158:b23ee177fd68 1309 * @param __AWD_THRESHOLDS__ Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
Kojto 158:b23ee177fd68 1310 * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1311 */
Kojto 158:b23ee177fd68 1312 #define __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(__AWD_THRESHOLD_TYPE__, __AWD_THRESHOLDS__) \
Kojto 158:b23ee177fd68 1313 (((__AWD_THRESHOLD_TYPE__) == LL_ADC_AWD_THRESHOLD_LOW) \
Kojto 158:b23ee177fd68 1314 ? ( \
Kojto 158:b23ee177fd68 1315 (__AWD_THRESHOLDS__) & LL_ADC_AWD_THRESHOLD_LOW \
Kojto 158:b23ee177fd68 1316 ) \
Kojto 158:b23ee177fd68 1317 : \
Kojto 158:b23ee177fd68 1318 ( \
Kojto 158:b23ee177fd68 1319 ((__AWD_THRESHOLDS__) >> ADC_TR_HT_BITOFFSET_POS) & LL_ADC_AWD_THRESHOLD_LOW \
Kojto 158:b23ee177fd68 1320 ) \
Kojto 158:b23ee177fd68 1321 )
Kojto 158:b23ee177fd68 1322
Kojto 158:b23ee177fd68 1323 /**
Kojto 158:b23ee177fd68 1324 * @brief Helper macro to select the ADC common instance
Kojto 158:b23ee177fd68 1325 * to which is belonging the selected ADC instance.
Kojto 158:b23ee177fd68 1326 * @note ADC common register instance can be used for:
Kojto 158:b23ee177fd68 1327 * - Set parameters common to several ADC instances
Kojto 158:b23ee177fd68 1328 * - Multimode (for devices with several ADC instances)
Kojto 158:b23ee177fd68 1329 * Refer to functions having argument "ADCxy_COMMON" as parameter.
Kojto 158:b23ee177fd68 1330 * @param __ADCx__ ADC instance
Kojto 158:b23ee177fd68 1331 * @retval ADC common register instance
Kojto 158:b23ee177fd68 1332 */
Kojto 158:b23ee177fd68 1333 #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
Kojto 158:b23ee177fd68 1334 (ADC1_COMMON)
Kojto 158:b23ee177fd68 1335
Kojto 158:b23ee177fd68 1336 /**
Kojto 158:b23ee177fd68 1337 * @brief Helper macro to check if all ADC instances sharing the same
Kojto 158:b23ee177fd68 1338 * ADC common instance are disabled.
Kojto 158:b23ee177fd68 1339 * @note This check is required by functions with setting conditioned to
Kojto 158:b23ee177fd68 1340 * ADC state:
Kojto 158:b23ee177fd68 1341 * All ADC instances of the ADC common group must be disabled.
Kojto 158:b23ee177fd68 1342 * Refer to functions having argument "ADCxy_COMMON" as parameter.
Kojto 158:b23ee177fd68 1343 * @note On devices with only 1 ADC common instance, parameter of this macro
Kojto 158:b23ee177fd68 1344 * is useless and can be ignored (parameter kept for compatibility
Kojto 158:b23ee177fd68 1345 * with devices featuring several ADC common instances).
Kojto 158:b23ee177fd68 1346 * @param __ADCXY_COMMON__ ADC common instance
Kojto 158:b23ee177fd68 1347 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
Anna Bridge 186:707f6e361f3e 1348 * @retval Value "0" if all ADC instances sharing the same ADC common instance
Anna Bridge 186:707f6e361f3e 1349 * are disabled.
Anna Bridge 186:707f6e361f3e 1350 * Value "1" if at least one ADC instance sharing the same ADC common instance
Anna Bridge 186:707f6e361f3e 1351 * is enabled.
Kojto 158:b23ee177fd68 1352 */
Kojto 158:b23ee177fd68 1353 #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
Kojto 158:b23ee177fd68 1354 LL_ADC_IsEnabled(ADC1)
Kojto 158:b23ee177fd68 1355
Kojto 158:b23ee177fd68 1356 /**
Kojto 158:b23ee177fd68 1357 * @brief Helper macro to define the ADC conversion data full-scale digital
Kojto 158:b23ee177fd68 1358 * value corresponding to the selected ADC resolution.
Kojto 158:b23ee177fd68 1359 * @note ADC conversion data full-scale corresponds to voltage range
Kojto 158:b23ee177fd68 1360 * determined by analog voltage references Vref+ and Vref-
Kojto 158:b23ee177fd68 1361 * (refer to reference manual).
Kojto 158:b23ee177fd68 1362 * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1363 * @arg @ref LL_ADC_RESOLUTION_12B
Kojto 158:b23ee177fd68 1364 * @arg @ref LL_ADC_RESOLUTION_10B
Kojto 158:b23ee177fd68 1365 * @arg @ref LL_ADC_RESOLUTION_8B
Kojto 158:b23ee177fd68 1366 * @arg @ref LL_ADC_RESOLUTION_6B
Kojto 158:b23ee177fd68 1367 * @retval ADC conversion data equivalent voltage value (unit: mVolt)
Kojto 158:b23ee177fd68 1368 */
Kojto 158:b23ee177fd68 1369 #define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
Kojto 158:b23ee177fd68 1370 (((uint32_t)0xFFFU) >> ((__ADC_RESOLUTION__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U)))
Kojto 158:b23ee177fd68 1371
Kojto 158:b23ee177fd68 1372 /**
Kojto 158:b23ee177fd68 1373 * @brief Helper macro to convert the ADC conversion data from
Kojto 158:b23ee177fd68 1374 * a resolution to another resolution.
Kojto 158:b23ee177fd68 1375 * @param __DATA__ ADC conversion data to be converted
Kojto 158:b23ee177fd68 1376 * @param __ADC_RESOLUTION_CURRENT__ Resolution of to the data to be converted
Kojto 158:b23ee177fd68 1377 * This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1378 * @arg @ref LL_ADC_RESOLUTION_12B
Kojto 158:b23ee177fd68 1379 * @arg @ref LL_ADC_RESOLUTION_10B
Kojto 158:b23ee177fd68 1380 * @arg @ref LL_ADC_RESOLUTION_8B
Kojto 158:b23ee177fd68 1381 * @arg @ref LL_ADC_RESOLUTION_6B
Kojto 158:b23ee177fd68 1382 * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
Kojto 158:b23ee177fd68 1383 * This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1384 * @arg @ref LL_ADC_RESOLUTION_12B
Kojto 158:b23ee177fd68 1385 * @arg @ref LL_ADC_RESOLUTION_10B
Kojto 158:b23ee177fd68 1386 * @arg @ref LL_ADC_RESOLUTION_8B
Kojto 158:b23ee177fd68 1387 * @arg @ref LL_ADC_RESOLUTION_6B
Kojto 158:b23ee177fd68 1388 * @retval ADC conversion data to the requested resolution
Kojto 158:b23ee177fd68 1389 */
Kojto 158:b23ee177fd68 1390 #define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__, __ADC_RESOLUTION_CURRENT__, __ADC_RESOLUTION_TARGET__) \
Kojto 158:b23ee177fd68 1391 (((__DATA__) \
Kojto 158:b23ee177fd68 1392 << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U))) \
Kojto 158:b23ee177fd68 1393 >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U)) \
Kojto 158:b23ee177fd68 1394 )
Kojto 158:b23ee177fd68 1395
Kojto 158:b23ee177fd68 1396 /**
Kojto 158:b23ee177fd68 1397 * @brief Helper macro to calculate the voltage (unit: mVolt)
Kojto 158:b23ee177fd68 1398 * corresponding to a ADC conversion data (unit: digital value).
Kojto 158:b23ee177fd68 1399 * @note Analog reference voltage (Vref+) must be either known from
Kojto 158:b23ee177fd68 1400 * user board environment or can be calculated using ADC measurement
Kojto 158:b23ee177fd68 1401 * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
Kojto 158:b23ee177fd68 1402 * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
Kojto 158:b23ee177fd68 1403 * @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
Kojto 158:b23ee177fd68 1404 * (unit: digital value).
Kojto 158:b23ee177fd68 1405 * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1406 * @arg @ref LL_ADC_RESOLUTION_12B
Kojto 158:b23ee177fd68 1407 * @arg @ref LL_ADC_RESOLUTION_10B
Kojto 158:b23ee177fd68 1408 * @arg @ref LL_ADC_RESOLUTION_8B
Kojto 158:b23ee177fd68 1409 * @arg @ref LL_ADC_RESOLUTION_6B
Kojto 158:b23ee177fd68 1410 * @retval ADC conversion data equivalent voltage value (unit: mVolt)
Kojto 158:b23ee177fd68 1411 */
Kojto 158:b23ee177fd68 1412 #define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
Kojto 158:b23ee177fd68 1413 __ADC_DATA__,\
Kojto 158:b23ee177fd68 1414 __ADC_RESOLUTION__) \
Kojto 158:b23ee177fd68 1415 ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) \
Kojto 158:b23ee177fd68 1416 / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
Kojto 158:b23ee177fd68 1417 )
Kojto 158:b23ee177fd68 1418
Kojto 158:b23ee177fd68 1419 /**
Kojto 158:b23ee177fd68 1420 * @brief Helper macro to calculate analog reference voltage (Vref+)
Kojto 158:b23ee177fd68 1421 * (unit: mVolt) from ADC conversion data of internal voltage
Kojto 158:b23ee177fd68 1422 * reference VrefInt.
Kojto 158:b23ee177fd68 1423 * @note Computation is using VrefInt calibration value
Kojto 158:b23ee177fd68 1424 * stored in system memory for each device during production.
Kojto 158:b23ee177fd68 1425 * @note This voltage depends on user board environment: voltage level
Kojto 158:b23ee177fd68 1426 * connected to pin Vref+.
Kojto 158:b23ee177fd68 1427 * On devices with small package, the pin Vref+ is not present
Kojto 158:b23ee177fd68 1428 * and internally bonded to pin Vdda.
Kojto 158:b23ee177fd68 1429 * @note On this STM32 serie, calibration data of internal voltage reference
Kojto 158:b23ee177fd68 1430 * VrefInt corresponds to a resolution of 12 bits,
Kojto 158:b23ee177fd68 1431 * this is the recommended ADC resolution to convert voltage of
Kojto 158:b23ee177fd68 1432 * internal voltage reference VrefInt.
Kojto 158:b23ee177fd68 1433 * Otherwise, this macro performs the processing to scale
Kojto 158:b23ee177fd68 1434 * ADC conversion data to 12 bits.
Kojto 158:b23ee177fd68 1435 * @param __VREFINT_ADC_DATA__: ADC conversion data (resolution 12 bits)
Kojto 158:b23ee177fd68 1436 * of internal voltage reference VrefInt (unit: digital value).
Kojto 158:b23ee177fd68 1437 * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1438 * @arg @ref LL_ADC_RESOLUTION_12B
Kojto 158:b23ee177fd68 1439 * @arg @ref LL_ADC_RESOLUTION_10B
Kojto 158:b23ee177fd68 1440 * @arg @ref LL_ADC_RESOLUTION_8B
Kojto 158:b23ee177fd68 1441 * @arg @ref LL_ADC_RESOLUTION_6B
Kojto 158:b23ee177fd68 1442 * @retval Analog reference voltage (unit: mV)
Kojto 158:b23ee177fd68 1443 */
Kojto 158:b23ee177fd68 1444 #define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,\
Kojto 158:b23ee177fd68 1445 __ADC_RESOLUTION__) \
Kojto 158:b23ee177fd68 1446 (((uint32_t)(*VREFINT_CAL_ADDR) * VREFINT_CAL_VREF) \
Kojto 158:b23ee177fd68 1447 / __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__), \
Kojto 158:b23ee177fd68 1448 (__ADC_RESOLUTION__), \
Kojto 158:b23ee177fd68 1449 LL_ADC_RESOLUTION_12B) \
Kojto 158:b23ee177fd68 1450 )
Kojto 158:b23ee177fd68 1451
Anna Bridge 186:707f6e361f3e 1452 /* Note: On device STM32L011, calibration parameter TS_CAL1 is not available. */
Anna Bridge 186:707f6e361f3e 1453 /* Therefore, helper macro __LL_ADC_CALC_TEMPERATURE() is not available.*/
Anna Bridge 186:707f6e361f3e 1454 /* Use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(). */
Anna Bridge 186:707f6e361f3e 1455 #if !defined(STM32L011xx)
Kojto 158:b23ee177fd68 1456 /**
Kojto 158:b23ee177fd68 1457 * @brief Helper macro to calculate the temperature (unit: degree Celsius)
Kojto 158:b23ee177fd68 1458 * from ADC conversion data of internal temperature sensor.
Kojto 158:b23ee177fd68 1459 * @note Computation is using temperature sensor calibration values
Kojto 158:b23ee177fd68 1460 * stored in system memory for each device during production.
Kojto 158:b23ee177fd68 1461 * @note Calculation formula:
Kojto 158:b23ee177fd68 1462 * Temperature = ((TS_ADC_DATA - TS_CAL1)
Kojto 158:b23ee177fd68 1463 * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
Kojto 158:b23ee177fd68 1464 * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
Kojto 158:b23ee177fd68 1465 * with TS_ADC_DATA = temperature sensor raw data measured by ADC
Kojto 158:b23ee177fd68 1466 * Avg_Slope = (TS_CAL2 - TS_CAL1)
Kojto 158:b23ee177fd68 1467 * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
Kojto 158:b23ee177fd68 1468 * TS_CAL1 = equivalent TS_ADC_DATA at temperature
Kojto 158:b23ee177fd68 1469 * TEMP_DEGC_CAL1 (calibrated in factory)
Kojto 158:b23ee177fd68 1470 * TS_CAL2 = equivalent TS_ADC_DATA at temperature
Kojto 158:b23ee177fd68 1471 * TEMP_DEGC_CAL2 (calibrated in factory)
Kojto 158:b23ee177fd68 1472 * Caution: Calculation relevancy under reserve that calibration
Kojto 158:b23ee177fd68 1473 * parameters are correct (address and data).
Kojto 158:b23ee177fd68 1474 * To calculate temperature using temperature sensor
Kojto 158:b23ee177fd68 1475 * datasheet typical values (generic values less, therefore
Kojto 158:b23ee177fd68 1476 * less accurate than calibrated values),
Kojto 158:b23ee177fd68 1477 * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
Kojto 158:b23ee177fd68 1478 * @note As calculation input, the analog reference voltage (Vref+) must be
Kojto 158:b23ee177fd68 1479 * defined as it impacts the ADC LSB equivalent voltage.
Kojto 158:b23ee177fd68 1480 * @note Analog reference voltage (Vref+) must be either known from
Kojto 158:b23ee177fd68 1481 * user board environment or can be calculated using ADC measurement
Kojto 158:b23ee177fd68 1482 * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
Kojto 158:b23ee177fd68 1483 * @note On this STM32 serie, calibration data of temperature sensor
Kojto 158:b23ee177fd68 1484 * corresponds to a resolution of 12 bits,
Kojto 158:b23ee177fd68 1485 * this is the recommended ADC resolution to convert voltage of
Kojto 158:b23ee177fd68 1486 * temperature sensor.
Kojto 158:b23ee177fd68 1487 * Otherwise, this macro performs the processing to scale
Kojto 158:b23ee177fd68 1488 * ADC conversion data to 12 bits.
Kojto 158:b23ee177fd68 1489 * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
Kojto 158:b23ee177fd68 1490 * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
Kojto 158:b23ee177fd68 1491 * temperature sensor (unit: digital value).
Kojto 158:b23ee177fd68 1492 * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
Kojto 158:b23ee177fd68 1493 * sensor voltage has been measured.
Kojto 158:b23ee177fd68 1494 * This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1495 * @arg @ref LL_ADC_RESOLUTION_12B
Kojto 158:b23ee177fd68 1496 * @arg @ref LL_ADC_RESOLUTION_10B
Kojto 158:b23ee177fd68 1497 * @arg @ref LL_ADC_RESOLUTION_8B
Kojto 158:b23ee177fd68 1498 * @arg @ref LL_ADC_RESOLUTION_6B
Kojto 158:b23ee177fd68 1499 * @retval Temperature (unit: degree Celsius)
Kojto 158:b23ee177fd68 1500 */
Kojto 158:b23ee177fd68 1501 #define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
Kojto 158:b23ee177fd68 1502 __TEMPSENSOR_ADC_DATA__,\
Kojto 158:b23ee177fd68 1503 __ADC_RESOLUTION__) \
Kojto 158:b23ee177fd68 1504 (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
Kojto 158:b23ee177fd68 1505 (__ADC_RESOLUTION__), \
Kojto 158:b23ee177fd68 1506 LL_ADC_RESOLUTION_12B) \
Kojto 158:b23ee177fd68 1507 * (__VREFANALOG_VOLTAGE__)) \
Kojto 158:b23ee177fd68 1508 / TEMPSENSOR_CAL_VREFANALOG) \
Kojto 158:b23ee177fd68 1509 - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
Kojto 158:b23ee177fd68 1510 ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
Kojto 158:b23ee177fd68 1511 ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
Kojto 158:b23ee177fd68 1512 ) + TEMPSENSOR_CAL1_TEMP \
Kojto 158:b23ee177fd68 1513 )
Anna Bridge 186:707f6e361f3e 1514 #endif
Kojto 158:b23ee177fd68 1515
Kojto 158:b23ee177fd68 1516 /**
Kojto 158:b23ee177fd68 1517 * @brief Helper macro to calculate the temperature (unit: degree Celsius)
Kojto 158:b23ee177fd68 1518 * from ADC conversion data of internal temperature sensor.
Kojto 158:b23ee177fd68 1519 * @note Computation is using temperature sensor typical values
Kojto 158:b23ee177fd68 1520 * (refer to device datasheet).
Kojto 158:b23ee177fd68 1521 * @note Calculation formula:
Kojto 158:b23ee177fd68 1522 * Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV)
Kojto 158:b23ee177fd68 1523 * / Avg_Slope + CALx_TEMP
Kojto 158:b23ee177fd68 1524 * with TS_ADC_DATA = temperature sensor raw data measured by ADC
Kojto 158:b23ee177fd68 1525 * (unit: digital value)
Kojto 158:b23ee177fd68 1526 * Avg_Slope = temperature sensor slope
Kojto 158:b23ee177fd68 1527 * (unit: uV/Degree Celsius)
Kojto 158:b23ee177fd68 1528 * TS_TYP_CALx_VOLT = temperature sensor digital value at
Kojto 158:b23ee177fd68 1529 * temperature CALx_TEMP (unit: mV)
Kojto 158:b23ee177fd68 1530 * Caution: Calculation relevancy under reserve the temperature sensor
Kojto 158:b23ee177fd68 1531 * of the current device has characteristics in line with
Kojto 158:b23ee177fd68 1532 * datasheet typical values.
Kojto 158:b23ee177fd68 1533 * If temperature sensor calibration values are available on
Kojto 158:b23ee177fd68 1534 * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
Kojto 158:b23ee177fd68 1535 * temperature calculation will be more accurate using
Kojto 158:b23ee177fd68 1536 * helper macro @ref __LL_ADC_CALC_TEMPERATURE().
Kojto 158:b23ee177fd68 1537 * @note As calculation input, the analog reference voltage (Vref+) must be
Kojto 158:b23ee177fd68 1538 * defined as it impacts the ADC LSB equivalent voltage.
Kojto 158:b23ee177fd68 1539 * @note Analog reference voltage (Vref+) must be either known from
Kojto 158:b23ee177fd68 1540 * user board environment or can be calculated using ADC measurement
Kojto 158:b23ee177fd68 1541 * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
Kojto 158:b23ee177fd68 1542 * @note ADC measurement data must correspond to a resolution of 12bits
Kojto 158:b23ee177fd68 1543 * (full scale digital value 4095). If not the case, the data must be
Kojto 158:b23ee177fd68 1544 * preliminarily rescaled to an equivalent resolution of 12 bits.
Kojto 158:b23ee177fd68 1545 * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius).
Kojto 158:b23ee177fd68 1546 * On STM32L0, refer to device datasheet parameter "Avg_Slope".
Kojto 158:b23ee177fd68 1547 * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV).
Kojto 158:b23ee177fd68 1548 * On STM32L0, refer to device datasheet parameter "V130" (corresponding to TS_CAL2).
Kojto 158:b23ee177fd68 1549 * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: mV)
Kojto 158:b23ee177fd68 1550 * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit: mV)
Kojto 158:b23ee177fd68 1551 * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value).
Kojto 158:b23ee177fd68 1552 * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
Kojto 158:b23ee177fd68 1553 * This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1554 * @arg @ref LL_ADC_RESOLUTION_12B
Kojto 158:b23ee177fd68 1555 * @arg @ref LL_ADC_RESOLUTION_10B
Kojto 158:b23ee177fd68 1556 * @arg @ref LL_ADC_RESOLUTION_8B
Kojto 158:b23ee177fd68 1557 * @arg @ref LL_ADC_RESOLUTION_6B
Kojto 158:b23ee177fd68 1558 * @retval Temperature (unit: degree Celsius)
Kojto 158:b23ee177fd68 1559 */
Kojto 158:b23ee177fd68 1560 #define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
Kojto 158:b23ee177fd68 1561 __TEMPSENSOR_TYP_CALX_V__,\
Kojto 158:b23ee177fd68 1562 __TEMPSENSOR_CALX_TEMP__,\
Kojto 158:b23ee177fd68 1563 __VREFANALOG_VOLTAGE__,\
Kojto 158:b23ee177fd68 1564 __TEMPSENSOR_ADC_DATA__,\
Kojto 158:b23ee177fd68 1565 __ADC_RESOLUTION__) \
Kojto 158:b23ee177fd68 1566 ((( ( \
Kojto 158:b23ee177fd68 1567 (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
Kojto 158:b23ee177fd68 1568 / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
Kojto 158:b23ee177fd68 1569 * 1000) \
Kojto 158:b23ee177fd68 1570 - \
Kojto 158:b23ee177fd68 1571 (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
Kojto 158:b23ee177fd68 1572 * 1000) \
Kojto 158:b23ee177fd68 1573 ) \
Kojto 158:b23ee177fd68 1574 ) / (__TEMPSENSOR_TYP_AVGSLOPE__) \
Kojto 158:b23ee177fd68 1575 ) + (__TEMPSENSOR_CALX_TEMP__) \
Kojto 158:b23ee177fd68 1576 )
Kojto 158:b23ee177fd68 1577
Kojto 158:b23ee177fd68 1578 /**
Kojto 158:b23ee177fd68 1579 * @}
Kojto 158:b23ee177fd68 1580 */
Kojto 158:b23ee177fd68 1581
Kojto 158:b23ee177fd68 1582 /**
Kojto 158:b23ee177fd68 1583 * @}
Kojto 158:b23ee177fd68 1584 */
Kojto 158:b23ee177fd68 1585
Kojto 158:b23ee177fd68 1586
Kojto 158:b23ee177fd68 1587 /* Exported functions --------------------------------------------------------*/
Kojto 158:b23ee177fd68 1588 /** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
Kojto 158:b23ee177fd68 1589 * @{
Kojto 158:b23ee177fd68 1590 */
Kojto 158:b23ee177fd68 1591
Kojto 158:b23ee177fd68 1592 /** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
Kojto 158:b23ee177fd68 1593 * @{
Kojto 158:b23ee177fd68 1594 */
Kojto 158:b23ee177fd68 1595 /* Note: LL ADC functions to set DMA transfer are located into sections of */
Kojto 158:b23ee177fd68 1596 /* configuration of ADC instance, groups and multimode (if available): */
Kojto 158:b23ee177fd68 1597 /* @ref LL_ADC_REG_SetDMATransfer(), ... */
Kojto 158:b23ee177fd68 1598
Kojto 158:b23ee177fd68 1599 /**
Kojto 158:b23ee177fd68 1600 * @brief Function to help to configure DMA transfer from ADC: retrieve the
Kojto 158:b23ee177fd68 1601 * ADC register address from ADC instance and a list of ADC registers
Kojto 158:b23ee177fd68 1602 * intended to be used (most commonly) with DMA transfer.
Kojto 158:b23ee177fd68 1603 * @note These ADC registers are data registers:
Kojto 158:b23ee177fd68 1604 * when ADC conversion data is available in ADC data registers,
Kojto 158:b23ee177fd68 1605 * ADC generates a DMA transfer request.
Kojto 158:b23ee177fd68 1606 * @note This macro is intended to be used with LL DMA driver, refer to
Kojto 158:b23ee177fd68 1607 * function "LL_DMA_ConfigAddresses()".
Kojto 158:b23ee177fd68 1608 * Example:
Kojto 158:b23ee177fd68 1609 * LL_DMA_ConfigAddresses(DMA1,
Kojto 158:b23ee177fd68 1610 * LL_DMA_CHANNEL_1,
Kojto 158:b23ee177fd68 1611 * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
Kojto 158:b23ee177fd68 1612 * (uint32_t)&< array or variable >,
Kojto 158:b23ee177fd68 1613 * LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
Kojto 158:b23ee177fd68 1614 * @note For devices with several ADC: in multimode, some devices
Kojto 158:b23ee177fd68 1615 * use a different data register outside of ADC instance scope
Kojto 158:b23ee177fd68 1616 * (common data register). This macro manages this register difference,
Kojto 158:b23ee177fd68 1617 * only ADC instance has to be set as parameter.
Kojto 158:b23ee177fd68 1618 * @rmtoll DR DATA LL_ADC_DMA_GetRegAddr
Kojto 158:b23ee177fd68 1619 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 1620 * @param Register This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1621 * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
Kojto 158:b23ee177fd68 1622 * @retval ADC register address
Kojto 158:b23ee177fd68 1623 */
Kojto 158:b23ee177fd68 1624 __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
Kojto 158:b23ee177fd68 1625 {
Kojto 158:b23ee177fd68 1626 /* Retrieve address of register DR */
Kojto 158:b23ee177fd68 1627 return (uint32_t)&(ADCx->DR);
Kojto 158:b23ee177fd68 1628 }
Kojto 158:b23ee177fd68 1629
Kojto 158:b23ee177fd68 1630 /**
Kojto 158:b23ee177fd68 1631 * @}
Kojto 158:b23ee177fd68 1632 */
Kojto 158:b23ee177fd68 1633
Kojto 158:b23ee177fd68 1634 /** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
Kojto 158:b23ee177fd68 1635 * @{
Kojto 158:b23ee177fd68 1636 */
Kojto 158:b23ee177fd68 1637
Kojto 158:b23ee177fd68 1638 /**
Kojto 158:b23ee177fd68 1639 * @brief Set parameter common to several ADC: Clock source and prescaler.
Kojto 158:b23ee177fd68 1640 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 1641 * ADC state:
Kojto 158:b23ee177fd68 1642 * All ADC instances of the ADC common group must be disabled.
Kojto 158:b23ee177fd68 1643 * This check can be done with function @ref LL_ADC_IsEnabled() for each
Kojto 158:b23ee177fd68 1644 * ADC instance or by using helper macro helper macro
Kojto 158:b23ee177fd68 1645 * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
Kojto 158:b23ee177fd68 1646 * @rmtoll CCR PRESC LL_ADC_SetCommonClock
Kojto 158:b23ee177fd68 1647 * @param ADCxy_COMMON ADC common instance
Kojto 158:b23ee177fd68 1648 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
Kojto 158:b23ee177fd68 1649 * @param CommonClock This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1650 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1 (1)
Kojto 158:b23ee177fd68 1651 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2 (1)
Kojto 158:b23ee177fd68 1652 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4 (1)
Kojto 158:b23ee177fd68 1653 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV6 (1)
Kojto 158:b23ee177fd68 1654 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV8 (1)
Kojto 158:b23ee177fd68 1655 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV10 (1)
Kojto 158:b23ee177fd68 1656 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV12 (1)
Kojto 158:b23ee177fd68 1657 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV16 (1)
Kojto 158:b23ee177fd68 1658 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV32 (1)
Kojto 158:b23ee177fd68 1659 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV64 (1)
Kojto 158:b23ee177fd68 1660 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV128 (1)
Kojto 158:b23ee177fd68 1661 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV256 (1)
Kojto 158:b23ee177fd68 1662 *
Kojto 158:b23ee177fd68 1663 * (1) ADC common clock asynchonous prescaler is applied to
Kojto 158:b23ee177fd68 1664 * each ADC instance if the corresponding ADC instance clock
Kojto 158:b23ee177fd68 1665 * is set to clock source asynchronous.
Kojto 158:b23ee177fd68 1666 * (refer to function @ref LL_ADC_SetClock() ).
Kojto 158:b23ee177fd68 1667 * @retval None
Kojto 158:b23ee177fd68 1668 */
Kojto 158:b23ee177fd68 1669 __STATIC_INLINE void LL_ADC_SetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t CommonClock)
Kojto 158:b23ee177fd68 1670 {
Kojto 158:b23ee177fd68 1671 MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_PRESC, CommonClock);
Kojto 158:b23ee177fd68 1672 }
Kojto 158:b23ee177fd68 1673
Kojto 158:b23ee177fd68 1674 /**
Kojto 158:b23ee177fd68 1675 * @brief Get parameter common to several ADC: Clock source and prescaler.
Kojto 158:b23ee177fd68 1676 * @rmtoll CCR PRESC LL_ADC_GetCommonClock
Kojto 158:b23ee177fd68 1677 * @param ADCxy_COMMON ADC common instance
Kojto 158:b23ee177fd68 1678 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
Kojto 158:b23ee177fd68 1679 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1680 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1 (1)
Kojto 158:b23ee177fd68 1681 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2 (1)
Kojto 158:b23ee177fd68 1682 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4 (1)
Kojto 158:b23ee177fd68 1683 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV6 (1)
Kojto 158:b23ee177fd68 1684 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV8 (1)
Kojto 158:b23ee177fd68 1685 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV10 (1)
Kojto 158:b23ee177fd68 1686 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV12 (1)
Kojto 158:b23ee177fd68 1687 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV16 (1)
Kojto 158:b23ee177fd68 1688 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV32 (1)
Kojto 158:b23ee177fd68 1689 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV64 (1)
Kojto 158:b23ee177fd68 1690 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV128 (1)
Kojto 158:b23ee177fd68 1691 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV256 (1)
Kojto 158:b23ee177fd68 1692 *
Kojto 158:b23ee177fd68 1693 * (1) ADC common clock asynchonous prescaler is applied to
Kojto 158:b23ee177fd68 1694 * each ADC instance if the corresponding ADC instance clock
Kojto 158:b23ee177fd68 1695 * is set to clock source asynchronous.
Kojto 158:b23ee177fd68 1696 * (refer to function @ref LL_ADC_SetClock() ).
Kojto 158:b23ee177fd68 1697 */
Kojto 158:b23ee177fd68 1698 __STATIC_INLINE uint32_t LL_ADC_GetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON)
Kojto 158:b23ee177fd68 1699 {
Kojto 158:b23ee177fd68 1700 return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_PRESC));
Kojto 158:b23ee177fd68 1701 }
Kojto 158:b23ee177fd68 1702
Kojto 158:b23ee177fd68 1703 /**
Kojto 158:b23ee177fd68 1704 * @brief Set parameter common to several ADC: Clock low frequency mode.
Kojto 158:b23ee177fd68 1705 * Refer to reference manual for alignments formats
Kojto 158:b23ee177fd68 1706 * dependencies to ADC resolutions.
Kojto 158:b23ee177fd68 1707 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 1708 * ADC state:
Kojto 158:b23ee177fd68 1709 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 1710 * on group regular.
Kojto 158:b23ee177fd68 1711 * @rmtoll CCR LFMEN LL_ADC_SetCommonFrequencyMode
Kojto 158:b23ee177fd68 1712 * @param ADCxy_COMMON ADC common instance
Kojto 158:b23ee177fd68 1713 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
Kojto 158:b23ee177fd68 1714 * @param Resolution This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1715 * @arg @ref LL_ADC_CLOCK_FREQ_MODE_HIGH
Kojto 158:b23ee177fd68 1716 * @arg @ref LL_ADC_CLOCK_FREQ_MODE_LOW
Kojto 158:b23ee177fd68 1717 * @retval None
Kojto 158:b23ee177fd68 1718 */
Kojto 158:b23ee177fd68 1719 __STATIC_INLINE void LL_ADC_SetCommonFrequencyMode(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t Resolution)
Kojto 158:b23ee177fd68 1720 {
Kojto 158:b23ee177fd68 1721 MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_LFMEN, Resolution);
Kojto 158:b23ee177fd68 1722 }
Kojto 158:b23ee177fd68 1723
Kojto 158:b23ee177fd68 1724 /**
Kojto 158:b23ee177fd68 1725 * @brief Get parameter common to several ADC: Clock low frequency mode.
Kojto 158:b23ee177fd68 1726 * Refer to reference manual for alignments formats
Kojto 158:b23ee177fd68 1727 * dependencies to ADC resolutions.
Kojto 158:b23ee177fd68 1728 * @rmtoll CCR LFMEN LL_ADC_GetCommonFrequencyMode
Kojto 158:b23ee177fd68 1729 * @param ADCxy_COMMON ADC common instance
Kojto 158:b23ee177fd68 1730 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
Kojto 158:b23ee177fd68 1731 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1732 * @arg @ref LL_ADC_CLOCK_FREQ_MODE_HIGH
Kojto 158:b23ee177fd68 1733 * @arg @ref LL_ADC_CLOCK_FREQ_MODE_LOW
Kojto 158:b23ee177fd68 1734 */
Kojto 158:b23ee177fd68 1735 __STATIC_INLINE uint32_t LL_ADC_GetCommonFrequencyMode(ADC_Common_TypeDef *ADCxy_COMMON)
Kojto 158:b23ee177fd68 1736 {
Kojto 158:b23ee177fd68 1737 return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_LFMEN));
Kojto 158:b23ee177fd68 1738 }
Kojto 158:b23ee177fd68 1739
Kojto 158:b23ee177fd68 1740 /**
Kojto 158:b23ee177fd68 1741 * @brief Set parameter common to several ADC: measurement path to internal
Kojto 158:b23ee177fd68 1742 * channels (VrefInt, temperature sensor, ...).
Kojto 158:b23ee177fd68 1743 * @note One or several values can be selected.
Kojto 158:b23ee177fd68 1744 * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
Kojto 158:b23ee177fd68 1745 * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
Kojto 158:b23ee177fd68 1746 * @note Stabilization time of measurement path to internal channel:
Kojto 158:b23ee177fd68 1747 * After enabling internal paths, before starting ADC conversion,
Kojto 158:b23ee177fd68 1748 * a delay is required for internal voltage reference and
Kojto 158:b23ee177fd68 1749 * temperature sensor stabilization time.
Kojto 158:b23ee177fd68 1750 * Refer to device datasheet.
Kojto 158:b23ee177fd68 1751 * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
Kojto 158:b23ee177fd68 1752 * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
Kojto 158:b23ee177fd68 1753 * @note ADC internal channel sampling time constraint:
Kojto 158:b23ee177fd68 1754 * For ADC conversion of internal channels,
Kojto 158:b23ee177fd68 1755 * a sampling time minimum value is required.
Kojto 158:b23ee177fd68 1756 * Refer to device datasheet.
Kojto 158:b23ee177fd68 1757 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 1758 * ADC state:
Kojto 158:b23ee177fd68 1759 * All ADC instances of the ADC common group must be disabled.
Kojto 158:b23ee177fd68 1760 * This check can be done with function @ref LL_ADC_IsEnabled() for each
Kojto 158:b23ee177fd68 1761 * ADC instance or by using helper macro helper macro
Kojto 158:b23ee177fd68 1762 * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
Kojto 158:b23ee177fd68 1763 * @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalCh\n
Kojto 158:b23ee177fd68 1764 * CCR TSEN LL_ADC_SetCommonPathInternalCh\n
Kojto 158:b23ee177fd68 1765 * CCR VLCDEN LL_ADC_SetCommonPathInternalCh
Kojto 158:b23ee177fd68 1766 * @param ADCxy_COMMON ADC common instance
Kojto 158:b23ee177fd68 1767 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
Kojto 158:b23ee177fd68 1768 * @param PathInternal This parameter can be a combination of the following values:
Kojto 158:b23ee177fd68 1769 * @arg @ref LL_ADC_PATH_INTERNAL_NONE
Kojto 158:b23ee177fd68 1770 * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
Kojto 158:b23ee177fd68 1771 * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
Kojto 158:b23ee177fd68 1772 * @arg @ref LL_ADC_PATH_INTERNAL_VLCD (*)
Kojto 158:b23ee177fd68 1773 *
Kojto 158:b23ee177fd68 1774 * (*) value not defined in all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.
Kojto 158:b23ee177fd68 1775 * @retval None
Kojto 158:b23ee177fd68 1776 */
Kojto 158:b23ee177fd68 1777 __STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
Kojto 158:b23ee177fd68 1778 {
Kojto 158:b23ee177fd68 1779 #if defined (ADC_CCR_VLCDEN)
Kojto 158:b23ee177fd68 1780 MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN | ADC_CCR_VLCDEN, PathInternal);
Kojto 158:b23ee177fd68 1781 #else
Kojto 158:b23ee177fd68 1782 MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN, PathInternal);
Kojto 158:b23ee177fd68 1783 #endif
Kojto 158:b23ee177fd68 1784 }
Kojto 158:b23ee177fd68 1785
Kojto 158:b23ee177fd68 1786 /**
Kojto 158:b23ee177fd68 1787 * @brief Get parameter common to several ADC: measurement path to internal
Kojto 158:b23ee177fd68 1788 * channels (VrefInt, temperature sensor, ...).
Kojto 158:b23ee177fd68 1789 * @note One or several values can be selected.
Kojto 158:b23ee177fd68 1790 * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
Kojto 158:b23ee177fd68 1791 * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
Kojto 158:b23ee177fd68 1792 * @rmtoll CCR VREFEN LL_ADC_GetCommonPathInternalCh\n
Kojto 158:b23ee177fd68 1793 * CCR TSEN LL_ADC_GetCommonPathInternalCh\n
Kojto 158:b23ee177fd68 1794 * CCR VLCDEN LL_ADC_GetCommonPathInternalCh
Kojto 158:b23ee177fd68 1795 * @param ADCxy_COMMON ADC common instance
Kojto 158:b23ee177fd68 1796 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
Kojto 158:b23ee177fd68 1797 * @retval Returned value can be a combination of the following values:
Kojto 158:b23ee177fd68 1798 * @arg @ref LL_ADC_PATH_INTERNAL_NONE
Kojto 158:b23ee177fd68 1799 * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
Kojto 158:b23ee177fd68 1800 * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
Kojto 158:b23ee177fd68 1801 * @arg @ref LL_ADC_PATH_INTERNAL_VLCD (*)
Kojto 158:b23ee177fd68 1802 *
Kojto 158:b23ee177fd68 1803 * (*) value not defined in all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.
Kojto 158:b23ee177fd68 1804 */
Kojto 158:b23ee177fd68 1805 __STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
Kojto 158:b23ee177fd68 1806 {
Kojto 158:b23ee177fd68 1807 #if defined(ADC_CCR_VLCDEN)
Kojto 158:b23ee177fd68 1808 return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN | ADC_CCR_VLCDEN));
Kojto 158:b23ee177fd68 1809 #else
Kojto 158:b23ee177fd68 1810 return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN));
Kojto 158:b23ee177fd68 1811 #endif
Kojto 158:b23ee177fd68 1812 }
Kojto 158:b23ee177fd68 1813
Kojto 158:b23ee177fd68 1814 /**
Kojto 158:b23ee177fd68 1815 * @}
Kojto 158:b23ee177fd68 1816 */
Kojto 158:b23ee177fd68 1817
Kojto 158:b23ee177fd68 1818 /** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
Kojto 158:b23ee177fd68 1819 * @{
Kojto 158:b23ee177fd68 1820 */
Kojto 158:b23ee177fd68 1821
Kojto 158:b23ee177fd68 1822 /**
Kojto 158:b23ee177fd68 1823 * @brief Set ADC instance clock source and prescaler.
Kojto 158:b23ee177fd68 1824 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 1825 * ADC state:
Kojto 158:b23ee177fd68 1826 * ADC must be disabled.
Kojto 158:b23ee177fd68 1827 * @rmtoll CFGR2 CKMODE LL_ADC_SetClock
Kojto 158:b23ee177fd68 1828 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 1829 * @param ClockSource This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1830 * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
Kojto 158:b23ee177fd68 1831 * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
Kojto 158:b23ee177fd68 1832 * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1 (2)
Kojto 158:b23ee177fd68 1833 * @arg @ref LL_ADC_CLOCK_ASYNC (1)
Kojto 158:b23ee177fd68 1834 *
Kojto 158:b23ee177fd68 1835 * (1) Asynchronous clock prescaler can be configured using
Kojto 158:b23ee177fd68 1836 * function @ref LL_ADC_SetCommonClock().\n
Kojto 158:b23ee177fd68 1837 * (2) Caution: This parameter has some clock ratio constraints:
Kojto 158:b23ee177fd68 1838 * This configuration must be enabled only if PCLK has a 50%
Kojto 158:b23ee177fd68 1839 * duty clock cycle (APB prescaler configured inside the RCC
Kojto 158:b23ee177fd68 1840 * must be bypassed and the system clock must by 50% duty
Kojto 158:b23ee177fd68 1841 * cycle).
Kojto 158:b23ee177fd68 1842 * Refer to reference manual.
Kojto 158:b23ee177fd68 1843 * @retval None
Kojto 158:b23ee177fd68 1844 */
Kojto 158:b23ee177fd68 1845 __STATIC_INLINE void LL_ADC_SetClock(ADC_TypeDef *ADCx, uint32_t ClockSource)
Kojto 158:b23ee177fd68 1846 {
Kojto 158:b23ee177fd68 1847 MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_CKMODE, ClockSource);
Kojto 158:b23ee177fd68 1848 }
Kojto 158:b23ee177fd68 1849
Kojto 158:b23ee177fd68 1850 /**
Kojto 158:b23ee177fd68 1851 * @brief Get ADC instance clock source and prescaler.
Kojto 158:b23ee177fd68 1852 * @rmtoll CFGR2 CKMODE LL_ADC_GetClock
Kojto 158:b23ee177fd68 1853 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 1854 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1855 * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
Kojto 158:b23ee177fd68 1856 * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
Kojto 158:b23ee177fd68 1857 * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1 (2)
Kojto 158:b23ee177fd68 1858 * @arg @ref LL_ADC_CLOCK_ASYNC (1)
Kojto 158:b23ee177fd68 1859 *
Kojto 158:b23ee177fd68 1860 * (1) Asynchronous clock prescaler can be retrieved using
Kojto 158:b23ee177fd68 1861 * function @ref LL_ADC_GetCommonClock().\n
Kojto 158:b23ee177fd68 1862 * (2) Caution: This parameter has some clock ratio constraints:
Kojto 158:b23ee177fd68 1863 * This configuration must be enabled only if PCLK has a 50%
Kojto 158:b23ee177fd68 1864 * duty clock cycle (APB prescaler configured inside the RCC
Kojto 158:b23ee177fd68 1865 * must be bypassed and the system clock must by 50% duty
Kojto 158:b23ee177fd68 1866 * cycle).
Kojto 158:b23ee177fd68 1867 * Refer to reference manual.
Kojto 158:b23ee177fd68 1868 */
Kojto 158:b23ee177fd68 1869 __STATIC_INLINE uint32_t LL_ADC_GetClock(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 1870 {
Kojto 158:b23ee177fd68 1871 return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_CKMODE));
Kojto 158:b23ee177fd68 1872 }
Kojto 158:b23ee177fd68 1873
Kojto 158:b23ee177fd68 1874 /**
Kojto 158:b23ee177fd68 1875 * @brief Set ADC calibration factor in the mode single-ended
Kojto 158:b23ee177fd68 1876 * or differential (for devices with differential mode available).
Kojto 158:b23ee177fd68 1877 * @note This function is intended to set calibration parameters
Kojto 158:b23ee177fd68 1878 * without having to perform a new calibration using
Kojto 158:b23ee177fd68 1879 * @ref LL_ADC_StartCalibration().
Kojto 158:b23ee177fd68 1880 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 1881 * ADC state:
Kojto 158:b23ee177fd68 1882 * ADC must be enabled, without calibration on going, without conversion
Kojto 158:b23ee177fd68 1883 * on going on group regular.
Kojto 158:b23ee177fd68 1884 * @rmtoll CALFACT CALFACT LL_ADC_SetCalibrationFactor
Kojto 158:b23ee177fd68 1885 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 1886 * @param CalibrationFactor Value between Min_Data=0x00 and Max_Data=0x7F
Kojto 158:b23ee177fd68 1887 * @retval None
Kojto 158:b23ee177fd68 1888 */
Kojto 158:b23ee177fd68 1889 __STATIC_INLINE void LL_ADC_SetCalibrationFactor(ADC_TypeDef *ADCx, uint32_t CalibrationFactor)
Kojto 158:b23ee177fd68 1890 {
Kojto 158:b23ee177fd68 1891 MODIFY_REG(ADCx->CALFACT,
Kojto 158:b23ee177fd68 1892 ADC_CALFACT_CALFACT,
Kojto 158:b23ee177fd68 1893 CalibrationFactor);
Kojto 158:b23ee177fd68 1894 }
Kojto 158:b23ee177fd68 1895
Kojto 158:b23ee177fd68 1896 /**
Kojto 158:b23ee177fd68 1897 * @brief Get ADC calibration factor in the mode single-ended
Kojto 158:b23ee177fd68 1898 * or differential (for devices with differential mode available).
Kojto 158:b23ee177fd68 1899 * @note Calibration factors are set by hardware after performing
Kojto 158:b23ee177fd68 1900 * a calibration run using function @ref LL_ADC_StartCalibration().
Kojto 158:b23ee177fd68 1901 * @rmtoll CALFACT CALFACT LL_ADC_GetCalibrationFactor
Kojto 158:b23ee177fd68 1902 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 1903 * @retval Value between Min_Data=0x00 and Max_Data=0x7F
Kojto 158:b23ee177fd68 1904 */
Kojto 158:b23ee177fd68 1905 __STATIC_INLINE uint32_t LL_ADC_GetCalibrationFactor(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 1906 {
Kojto 158:b23ee177fd68 1907 return (uint32_t)(READ_BIT(ADCx->CALFACT, ADC_CALFACT_CALFACT));
Kojto 158:b23ee177fd68 1908 }
Kojto 158:b23ee177fd68 1909
Kojto 158:b23ee177fd68 1910 /**
Kojto 158:b23ee177fd68 1911 * @brief Set ADC resolution.
Kojto 158:b23ee177fd68 1912 * Refer to reference manual for alignments formats
Kojto 158:b23ee177fd68 1913 * dependencies to ADC resolutions.
Kojto 158:b23ee177fd68 1914 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 1915 * ADC state:
Kojto 158:b23ee177fd68 1916 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 1917 * on group regular.
Kojto 158:b23ee177fd68 1918 * @rmtoll CFGR1 RES LL_ADC_SetResolution
Kojto 158:b23ee177fd68 1919 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 1920 * @param Resolution This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1921 * @arg @ref LL_ADC_RESOLUTION_12B
Kojto 158:b23ee177fd68 1922 * @arg @ref LL_ADC_RESOLUTION_10B
Kojto 158:b23ee177fd68 1923 * @arg @ref LL_ADC_RESOLUTION_8B
Kojto 158:b23ee177fd68 1924 * @arg @ref LL_ADC_RESOLUTION_6B
Kojto 158:b23ee177fd68 1925 * @retval None
Kojto 158:b23ee177fd68 1926 */
Kojto 158:b23ee177fd68 1927 __STATIC_INLINE void LL_ADC_SetResolution(ADC_TypeDef *ADCx, uint32_t Resolution)
Kojto 158:b23ee177fd68 1928 {
Kojto 158:b23ee177fd68 1929 MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_RES, Resolution);
Kojto 158:b23ee177fd68 1930 }
Kojto 158:b23ee177fd68 1931
Kojto 158:b23ee177fd68 1932 /**
Kojto 158:b23ee177fd68 1933 * @brief Get ADC resolution.
Kojto 158:b23ee177fd68 1934 * Refer to reference manual for alignments formats
Kojto 158:b23ee177fd68 1935 * dependencies to ADC resolutions.
Kojto 158:b23ee177fd68 1936 * @rmtoll CFGR1 RES LL_ADC_GetResolution
Kojto 158:b23ee177fd68 1937 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 1938 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1939 * @arg @ref LL_ADC_RESOLUTION_12B
Kojto 158:b23ee177fd68 1940 * @arg @ref LL_ADC_RESOLUTION_10B
Kojto 158:b23ee177fd68 1941 * @arg @ref LL_ADC_RESOLUTION_8B
Kojto 158:b23ee177fd68 1942 * @arg @ref LL_ADC_RESOLUTION_6B
Kojto 158:b23ee177fd68 1943 */
Kojto 158:b23ee177fd68 1944 __STATIC_INLINE uint32_t LL_ADC_GetResolution(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 1945 {
Kojto 158:b23ee177fd68 1946 return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_RES));
Kojto 158:b23ee177fd68 1947 }
Kojto 158:b23ee177fd68 1948
Kojto 158:b23ee177fd68 1949 /**
Kojto 158:b23ee177fd68 1950 * @brief Set ADC conversion data alignment.
Kojto 158:b23ee177fd68 1951 * @note Refer to reference manual for alignments formats
Kojto 158:b23ee177fd68 1952 * dependencies to ADC resolutions.
Kojto 158:b23ee177fd68 1953 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 1954 * ADC state:
Kojto 158:b23ee177fd68 1955 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 1956 * on group regular.
Kojto 158:b23ee177fd68 1957 * @rmtoll CFGR1 ALIGN LL_ADC_SetDataAlignment
Kojto 158:b23ee177fd68 1958 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 1959 * @param DataAlignment This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1960 * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
Kojto 158:b23ee177fd68 1961 * @arg @ref LL_ADC_DATA_ALIGN_LEFT
Kojto 158:b23ee177fd68 1962 * @retval None
Kojto 158:b23ee177fd68 1963 */
Kojto 158:b23ee177fd68 1964 __STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
Kojto 158:b23ee177fd68 1965 {
Kojto 158:b23ee177fd68 1966 MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_ALIGN, DataAlignment);
Kojto 158:b23ee177fd68 1967 }
Kojto 158:b23ee177fd68 1968
Kojto 158:b23ee177fd68 1969 /**
Kojto 158:b23ee177fd68 1970 * @brief Get ADC conversion data alignment.
Kojto 158:b23ee177fd68 1971 * @note Refer to reference manual for alignments formats
Kojto 158:b23ee177fd68 1972 * dependencies to ADC resolutions.
Kojto 158:b23ee177fd68 1973 * @rmtoll CFGR1 ALIGN LL_ADC_GetDataAlignment
Kojto 158:b23ee177fd68 1974 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 1975 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1976 * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
Kojto 158:b23ee177fd68 1977 * @arg @ref LL_ADC_DATA_ALIGN_LEFT
Kojto 158:b23ee177fd68 1978 */
Kojto 158:b23ee177fd68 1979 __STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 1980 {
Kojto 158:b23ee177fd68 1981 return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_ALIGN));
Kojto 158:b23ee177fd68 1982 }
Kojto 158:b23ee177fd68 1983
Kojto 158:b23ee177fd68 1984 /**
Kojto 158:b23ee177fd68 1985 * @brief Set ADC low power mode.
Kojto 158:b23ee177fd68 1986 * @note Description of ADC low power modes:
Kojto 158:b23ee177fd68 1987 * - ADC low power mode "auto wait": Dynamic low power mode,
Kojto 158:b23ee177fd68 1988 * ADC conversions occurrences are limited to the minimum necessary
Kojto 158:b23ee177fd68 1989 * in order to reduce power consumption.
Kojto 158:b23ee177fd68 1990 * New ADC conversion starts only when the previous
Kojto 158:b23ee177fd68 1991 * unitary conversion data (for ADC group regular)
Kojto 158:b23ee177fd68 1992 * has been retrieved by user software.
Kojto 158:b23ee177fd68 1993 * In the meantime, ADC remains idle: does not performs any
Kojto 158:b23ee177fd68 1994 * other conversion.
Kojto 158:b23ee177fd68 1995 * This mode allows to automatically adapt the ADC conversions
Kojto 158:b23ee177fd68 1996 * triggers to the speed of the software that reads the data.
Kojto 158:b23ee177fd68 1997 * Moreover, this avoids risk of overrun for low frequency
Kojto 158:b23ee177fd68 1998 * applications.
Kojto 158:b23ee177fd68 1999 * How to use this low power mode:
Kojto 158:b23ee177fd68 2000 * - Do not use with interruption or DMA since these modes
Kojto 158:b23ee177fd68 2001 * have to clear immediately the EOC flag to free the
Kojto 158:b23ee177fd68 2002 * IRQ vector sequencer.
Kojto 158:b23ee177fd68 2003 * - Do use with polling: 1. Start conversion,
Kojto 158:b23ee177fd68 2004 * 2. Later on, when conversion data is needed: poll for end of
Kojto 158:b23ee177fd68 2005 * conversion to ensure that conversion is completed and
Kojto 158:b23ee177fd68 2006 * retrieve ADC conversion data. This will trig another
Kojto 158:b23ee177fd68 2007 * ADC conversion start.
Kojto 158:b23ee177fd68 2008 * - ADC low power mode "auto power-off" (feature available on
Kojto 158:b23ee177fd68 2009 * this device if parameter LL_ADC_LP_MODE_AUTOOFF is available):
Kojto 158:b23ee177fd68 2010 * the ADC automatically powers-off after a conversion and
Kojto 158:b23ee177fd68 2011 * automatically wakes up when a new conversion is triggered
Kojto 158:b23ee177fd68 2012 * (with startup time between trigger and start of sampling).
Kojto 158:b23ee177fd68 2013 * This feature can be combined with low power mode "auto wait".
Kojto 158:b23ee177fd68 2014 * @note With ADC low power mode "auto wait", the ADC conversion data read
Kojto 158:b23ee177fd68 2015 * is corresponding to previous ADC conversion start, independently
Kojto 158:b23ee177fd68 2016 * of delay during which ADC was idle.
Kojto 158:b23ee177fd68 2017 * Therefore, the ADC conversion data may be outdated: does not
Kojto 158:b23ee177fd68 2018 * correspond to the current voltage level on the selected
Kojto 158:b23ee177fd68 2019 * ADC channel.
Kojto 158:b23ee177fd68 2020 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2021 * ADC state:
Kojto 158:b23ee177fd68 2022 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2023 * on group regular.
Kojto 158:b23ee177fd68 2024 * @rmtoll CFGR1 WAIT LL_ADC_SetLowPowerMode\n
Kojto 158:b23ee177fd68 2025 * CFGR1 AUTOFF LL_ADC_SetLowPowerMode
Kojto 158:b23ee177fd68 2026 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2027 * @param LowPowerMode This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2028 * @arg @ref LL_ADC_LP_MODE_NONE
Kojto 158:b23ee177fd68 2029 * @arg @ref LL_ADC_LP_AUTOWAIT
Kojto 158:b23ee177fd68 2030 * @arg @ref LL_ADC_LP_AUTOPOWEROFF
Kojto 158:b23ee177fd68 2031 * @arg @ref LL_ADC_LP_AUTOWAIT_AUTOPOWEROFF
Kojto 158:b23ee177fd68 2032 * @retval None
Kojto 158:b23ee177fd68 2033 */
Kojto 158:b23ee177fd68 2034 __STATIC_INLINE void LL_ADC_SetLowPowerMode(ADC_TypeDef *ADCx, uint32_t LowPowerMode)
Kojto 158:b23ee177fd68 2035 {
Kojto 158:b23ee177fd68 2036 MODIFY_REG(ADCx->CFGR1, (ADC_CFGR1_WAIT | ADC_CFGR1_AUTOFF), LowPowerMode);
Kojto 158:b23ee177fd68 2037 }
Kojto 158:b23ee177fd68 2038
Kojto 158:b23ee177fd68 2039 /**
Kojto 158:b23ee177fd68 2040 * @brief Get ADC low power mode:
Kojto 158:b23ee177fd68 2041 * @note Description of ADC low power modes:
Kojto 158:b23ee177fd68 2042 * - ADC low power mode "auto wait": Dynamic low power mode,
Kojto 158:b23ee177fd68 2043 * ADC conversions occurrences are limited to the minimum necessary
Kojto 158:b23ee177fd68 2044 * in order to reduce power consumption.
Kojto 158:b23ee177fd68 2045 * New ADC conversion starts only when the previous
Kojto 158:b23ee177fd68 2046 * unitary conversion data (for ADC group regular)
Kojto 158:b23ee177fd68 2047 * has been retrieved by user software.
Kojto 158:b23ee177fd68 2048 * In the meantime, ADC remains idle: does not performs any
Kojto 158:b23ee177fd68 2049 * other conversion.
Kojto 158:b23ee177fd68 2050 * This mode allows to automatically adapt the ADC conversions
Kojto 158:b23ee177fd68 2051 * triggers to the speed of the software that reads the data.
Kojto 158:b23ee177fd68 2052 * Moreover, this avoids risk of overrun for low frequency
Kojto 158:b23ee177fd68 2053 * applications.
Kojto 158:b23ee177fd68 2054 * How to use this low power mode:
Kojto 158:b23ee177fd68 2055 * - Do not use with interruption or DMA since these modes
Kojto 158:b23ee177fd68 2056 * have to clear immediately the EOC flag to free the
Kojto 158:b23ee177fd68 2057 * IRQ vector sequencer.
Kojto 158:b23ee177fd68 2058 * - Do use with polling: 1. Start conversion,
Kojto 158:b23ee177fd68 2059 * 2. Later on, when conversion data is needed: poll for end of
Kojto 158:b23ee177fd68 2060 * conversion to ensure that conversion is completed and
Kojto 158:b23ee177fd68 2061 * retrieve ADC conversion data. This will trig another
Kojto 158:b23ee177fd68 2062 * ADC conversion start.
Kojto 158:b23ee177fd68 2063 * - ADC low power mode "auto power-off" (feature available on
Kojto 158:b23ee177fd68 2064 * this device if parameter LL_ADC_LP_MODE_AUTOOFF is available):
Kojto 158:b23ee177fd68 2065 * the ADC automatically powers-off after a conversion and
Kojto 158:b23ee177fd68 2066 * automatically wakes up when a new conversion is triggered
Kojto 158:b23ee177fd68 2067 * (with startup time between trigger and start of sampling).
Kojto 158:b23ee177fd68 2068 * This feature can be combined with low power mode "auto wait".
Kojto 158:b23ee177fd68 2069 * @note With ADC low power mode "auto wait", the ADC conversion data read
Kojto 158:b23ee177fd68 2070 * is corresponding to previous ADC conversion start, independently
Kojto 158:b23ee177fd68 2071 * of delay during which ADC was idle.
Kojto 158:b23ee177fd68 2072 * Therefore, the ADC conversion data may be outdated: does not
Kojto 158:b23ee177fd68 2073 * correspond to the current voltage level on the selected
Kojto 158:b23ee177fd68 2074 * ADC channel.
Kojto 158:b23ee177fd68 2075 * @rmtoll CFGR1 WAIT LL_ADC_GetLowPowerMode\n
Kojto 158:b23ee177fd68 2076 * CFGR1 AUTOFF LL_ADC_GetLowPowerMode
Kojto 158:b23ee177fd68 2077 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2078 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2079 * @arg @ref LL_ADC_LP_MODE_NONE
Kojto 158:b23ee177fd68 2080 * @arg @ref LL_ADC_LP_AUTOWAIT
Kojto 158:b23ee177fd68 2081 * @arg @ref LL_ADC_LP_AUTOPOWEROFF
Kojto 158:b23ee177fd68 2082 * @arg @ref LL_ADC_LP_AUTOWAIT_AUTOPOWEROFF
Kojto 158:b23ee177fd68 2083 */
Kojto 158:b23ee177fd68 2084 __STATIC_INLINE uint32_t LL_ADC_GetLowPowerMode(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 2085 {
Kojto 158:b23ee177fd68 2086 return (uint32_t)(READ_BIT(ADCx->CFGR1, (ADC_CFGR1_WAIT | ADC_CFGR1_AUTOFF)));
Kojto 158:b23ee177fd68 2087 }
Kojto 158:b23ee177fd68 2088
Kojto 158:b23ee177fd68 2089 /**
Kojto 158:b23ee177fd68 2090 * @brief Set sampling time common to a group of channels.
Kojto 158:b23ee177fd68 2091 * @note Unit: ADC clock cycles.
Kojto 158:b23ee177fd68 2092 * @note On this STM32 serie, sampling time scope is on ADC instance:
Kojto 158:b23ee177fd68 2093 * Sampling time common to all channels.
Kojto 158:b23ee177fd68 2094 * (on some other STM32 families, sampling time is channel wise)
Kojto 158:b23ee177fd68 2095 * @note In case of internal channel (VrefInt, TempSensor, ...) to be
Kojto 158:b23ee177fd68 2096 * converted:
Kojto 158:b23ee177fd68 2097 * sampling time constraints must be respected (sampling time can be
Kojto 158:b23ee177fd68 2098 * adjusted in function of ADC clock frequency and sampling time
Kojto 158:b23ee177fd68 2099 * setting).
Kojto 158:b23ee177fd68 2100 * Refer to device datasheet for timings values (parameters TS_vrefint,
Kojto 158:b23ee177fd68 2101 * TS_temp, ...).
Kojto 158:b23ee177fd68 2102 * @note Conversion time is the addition of sampling time and processing time.
Kojto 158:b23ee177fd68 2103 * On this STM32 serie, ADC processing time is:
Kojto 158:b23ee177fd68 2104 * - 12.5 ADC clock cycles at ADC resolution 12 bits
Kojto 158:b23ee177fd68 2105 * - 10.5 ADC clock cycles at ADC resolution 10 bits
Kojto 158:b23ee177fd68 2106 * - 8.5 ADC clock cycles at ADC resolution 8 bits
Kojto 158:b23ee177fd68 2107 * - 6.5 ADC clock cycles at ADC resolution 6 bits
Kojto 158:b23ee177fd68 2108 * @note In case of ADC conversion of internal channel (VrefInt,
Kojto 158:b23ee177fd68 2109 * temperature sensor, ...), a sampling time minimum value
Kojto 158:b23ee177fd68 2110 * is required.
Kojto 158:b23ee177fd68 2111 * Refer to device datasheet.
Kojto 158:b23ee177fd68 2112 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2113 * ADC state:
Kojto 158:b23ee177fd68 2114 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2115 * on group regular.
Kojto 158:b23ee177fd68 2116 * @rmtoll SMPR SMP LL_ADC_SetSamplingTimeCommonChannels
Kojto 158:b23ee177fd68 2117 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2118 * @param SamplingTime This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2119 * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
Anna Bridge 186:707f6e361f3e 2120 * @arg @ref LL_ADC_SAMPLINGTIME_3CYCLES_5
Kojto 158:b23ee177fd68 2121 * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
Anna Bridge 186:707f6e361f3e 2122 * @arg @ref LL_ADC_SAMPLINGTIME_12CYCLES_5
Anna Bridge 186:707f6e361f3e 2123 * @arg @ref LL_ADC_SAMPLINGTIME_19CYCLES_5
Anna Bridge 186:707f6e361f3e 2124 * @arg @ref LL_ADC_SAMPLINGTIME_39CYCLES_5
Anna Bridge 186:707f6e361f3e 2125 * @arg @ref LL_ADC_SAMPLINGTIME_79CYCLES_5
Anna Bridge 186:707f6e361f3e 2126 * @arg @ref LL_ADC_SAMPLINGTIME_160CYCLES_5
Kojto 158:b23ee177fd68 2127 * @retval None
Kojto 158:b23ee177fd68 2128 */
Kojto 158:b23ee177fd68 2129 __STATIC_INLINE void LL_ADC_SetSamplingTimeCommonChannels(ADC_TypeDef *ADCx, uint32_t SamplingTime)
Kojto 158:b23ee177fd68 2130 {
Kojto 158:b23ee177fd68 2131 MODIFY_REG(ADCx->SMPR, ADC_SMPR_SMP, SamplingTime);
Kojto 158:b23ee177fd68 2132 }
Kojto 158:b23ee177fd68 2133
Kojto 158:b23ee177fd68 2134 /**
Kojto 158:b23ee177fd68 2135 * @brief Get sampling time common to a group of channels.
Kojto 158:b23ee177fd68 2136 * @note Unit: ADC clock cycles.
Kojto 158:b23ee177fd68 2137 * @note On this STM32 serie, sampling time scope is on ADC instance:
Kojto 158:b23ee177fd68 2138 * Sampling time common to all channels.
Kojto 158:b23ee177fd68 2139 * (on some other STM32 families, sampling time is channel wise)
Kojto 158:b23ee177fd68 2140 * @note Conversion time is the addition of sampling time and processing time.
Kojto 158:b23ee177fd68 2141 * Refer to reference manual for ADC processing time of
Kojto 158:b23ee177fd68 2142 * this STM32 serie.
Kojto 158:b23ee177fd68 2143 * @rmtoll SMPR SMP LL_ADC_GetSamplingTimeCommonChannels
Kojto 158:b23ee177fd68 2144 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2145 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2146 * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5
Anna Bridge 186:707f6e361f3e 2147 * @arg @ref LL_ADC_SAMPLINGTIME_3CYCLES_5
Kojto 158:b23ee177fd68 2148 * @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
Anna Bridge 186:707f6e361f3e 2149 * @arg @ref LL_ADC_SAMPLINGTIME_12CYCLES_5
Anna Bridge 186:707f6e361f3e 2150 * @arg @ref LL_ADC_SAMPLINGTIME_19CYCLES_5
Anna Bridge 186:707f6e361f3e 2151 * @arg @ref LL_ADC_SAMPLINGTIME_39CYCLES_5
Anna Bridge 186:707f6e361f3e 2152 * @arg @ref LL_ADC_SAMPLINGTIME_79CYCLES_5
Anna Bridge 186:707f6e361f3e 2153 * @arg @ref LL_ADC_SAMPLINGTIME_160CYCLES_5
Kojto 158:b23ee177fd68 2154 */
Kojto 158:b23ee177fd68 2155 __STATIC_INLINE uint32_t LL_ADC_GetSamplingTimeCommonChannels(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 2156 {
Kojto 158:b23ee177fd68 2157 return (uint32_t)(READ_BIT(ADCx->SMPR, ADC_SMPR_SMP));
Kojto 158:b23ee177fd68 2158 }
Kojto 158:b23ee177fd68 2159
Kojto 158:b23ee177fd68 2160 /**
Kojto 158:b23ee177fd68 2161 * @}
Kojto 158:b23ee177fd68 2162 */
Kojto 158:b23ee177fd68 2163
Kojto 158:b23ee177fd68 2164 /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
Kojto 158:b23ee177fd68 2165 * @{
Kojto 158:b23ee177fd68 2166 */
Kojto 158:b23ee177fd68 2167
Kojto 158:b23ee177fd68 2168 /**
Kojto 158:b23ee177fd68 2169 * @brief Set ADC group regular conversion trigger source:
Kojto 158:b23ee177fd68 2170 * internal (SW start) or from external IP (timer event,
Kojto 158:b23ee177fd68 2171 * external interrupt line).
Kojto 158:b23ee177fd68 2172 * @note On this STM32 serie, setting trigger source to external trigger
Kojto 158:b23ee177fd68 2173 * also set trigger polarity to rising edge
Kojto 158:b23ee177fd68 2174 * (default setting for compatibility with some ADC on other
Kojto 158:b23ee177fd68 2175 * STM32 families having this setting set by HW default value).
Kojto 158:b23ee177fd68 2176 * In case of need to modify trigger edge, use
Kojto 158:b23ee177fd68 2177 * function @ref LL_ADC_REG_SetTriggerEdge().
Kojto 158:b23ee177fd68 2178 * @note Availability of parameters of trigger sources from timer
Kojto 158:b23ee177fd68 2179 * depends on timers availability on the selected device.
Kojto 158:b23ee177fd68 2180 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2181 * ADC state:
Kojto 158:b23ee177fd68 2182 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2183 * on group regular.
Kojto 158:b23ee177fd68 2184 * @rmtoll CFGR1 EXTSEL LL_ADC_REG_SetTriggerSource\n
Kojto 158:b23ee177fd68 2185 * CFGR1 EXTEN LL_ADC_REG_SetTriggerSource
Kojto 158:b23ee177fd68 2186 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2187 * @param TriggerSource This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2188 * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
Kojto 158:b23ee177fd68 2189 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO
Kojto 158:b23ee177fd68 2190 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM21_CH2
Kojto 158:b23ee177fd68 2191 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
Kojto 158:b23ee177fd68 2192 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH4
Kojto 158:b23ee177fd68 2193 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM22_TRGO
Kojto 158:b23ee177fd68 2194 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3 (*)
Kojto 158:b23ee177fd68 2195 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
Kojto 158:b23ee177fd68 2196 * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
Kojto 158:b23ee177fd68 2197 *
Kojto 158:b23ee177fd68 2198 * (*) value not defined in all devices
Kojto 158:b23ee177fd68 2199 * @retval None
Kojto 158:b23ee177fd68 2200 */
Kojto 158:b23ee177fd68 2201 __STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
Kojto 158:b23ee177fd68 2202 {
Kojto 158:b23ee177fd68 2203 MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_EXTEN | ADC_CFGR1_EXTSEL, TriggerSource);
Kojto 158:b23ee177fd68 2204 }
Kojto 158:b23ee177fd68 2205
Kojto 158:b23ee177fd68 2206 /**
Kojto 158:b23ee177fd68 2207 * @brief Get ADC group regular conversion trigger source:
Kojto 158:b23ee177fd68 2208 * internal (SW start) or from external IP (timer event,
Kojto 158:b23ee177fd68 2209 * external interrupt line).
Kojto 158:b23ee177fd68 2210 * @note To determine whether group regular trigger source is
Kojto 158:b23ee177fd68 2211 * internal (SW start) or external, without detail
Kojto 158:b23ee177fd68 2212 * of which peripheral is selected as external trigger,
Kojto 158:b23ee177fd68 2213 * (equivalent to
Kojto 158:b23ee177fd68 2214 * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
Kojto 158:b23ee177fd68 2215 * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
Kojto 158:b23ee177fd68 2216 * @note Availability of parameters of trigger sources from timer
Kojto 158:b23ee177fd68 2217 * depends on timers availability on the selected device.
Kojto 158:b23ee177fd68 2218 * @rmtoll CFGR1 EXTSEL LL_ADC_REG_GetTriggerSource\n
Kojto 158:b23ee177fd68 2219 * CFGR1 EXTEN LL_ADC_REG_GetTriggerSource
Kojto 158:b23ee177fd68 2220 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2221 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2222 * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
Kojto 158:b23ee177fd68 2223 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO
Kojto 158:b23ee177fd68 2224 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM21_CH2
Kojto 158:b23ee177fd68 2225 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
Kojto 158:b23ee177fd68 2226 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH4
Kojto 158:b23ee177fd68 2227 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM22_TRGO
Kojto 158:b23ee177fd68 2228 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3 (*)
Kojto 158:b23ee177fd68 2229 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
Kojto 158:b23ee177fd68 2230 * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
Kojto 158:b23ee177fd68 2231 *
Kojto 158:b23ee177fd68 2232 * (*) value not defined in all devices
Kojto 158:b23ee177fd68 2233 */
Kojto 158:b23ee177fd68 2234 __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 2235 {
Kojto 158:b23ee177fd68 2236 register uint32_t TriggerSource = READ_BIT(ADCx->CFGR1, ADC_CFGR1_EXTSEL | ADC_CFGR1_EXTEN);
Kojto 158:b23ee177fd68 2237
Kojto 158:b23ee177fd68 2238 /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
Kojto 158:b23ee177fd68 2239 /* corresponding to ADC_CFGR1_EXTEN {0; 1; 2; 3}. */
Kojto 158:b23ee177fd68 2240 register uint32_t ShiftExten = ((TriggerSource & ADC_CFGR1_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2U));
Kojto 158:b23ee177fd68 2241
Kojto 158:b23ee177fd68 2242 /* Set bitfield corresponding to ADC_CFGR1_EXTEN and ADC_CFGR1_EXTSEL */
Kojto 158:b23ee177fd68 2243 /* to match with triggers literals definition. */
Kojto 158:b23ee177fd68 2244 return ((TriggerSource
Kojto 158:b23ee177fd68 2245 & (ADC_REG_TRIG_SOURCE_MASK >> ShiftExten) & ADC_CFGR1_EXTSEL)
Kojto 158:b23ee177fd68 2246 | ((ADC_REG_TRIG_EDGE_MASK >> ShiftExten) & ADC_CFGR1_EXTEN)
Kojto 158:b23ee177fd68 2247 );
Kojto 158:b23ee177fd68 2248 }
Kojto 158:b23ee177fd68 2249
Kojto 158:b23ee177fd68 2250 /**
Kojto 158:b23ee177fd68 2251 * @brief Get ADC group regular conversion trigger source internal (SW start)
Kojto 158:b23ee177fd68 2252 or external.
Kojto 158:b23ee177fd68 2253 * @note In case of group regular trigger source set to external trigger,
Kojto 158:b23ee177fd68 2254 * to determine which peripheral is selected as external trigger,
Kojto 158:b23ee177fd68 2255 * use function @ref LL_ADC_REG_GetTriggerSource().
Kojto 158:b23ee177fd68 2256 * @rmtoll CFGR1 EXTEN LL_ADC_REG_IsTriggerSourceSWStart
Kojto 158:b23ee177fd68 2257 * @param ADCx ADC instance
Anna Bridge 186:707f6e361f3e 2258 * @retval Value "0" if trigger source external trigger
Anna Bridge 186:707f6e361f3e 2259 * Value "1" if trigger source SW start.
Kojto 158:b23ee177fd68 2260 */
Kojto 158:b23ee177fd68 2261 __STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 2262 {
Kojto 158:b23ee177fd68 2263 return (READ_BIT(ADCx->CFGR1, ADC_CFGR1_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR1_EXTEN));
Kojto 158:b23ee177fd68 2264 }
Kojto 158:b23ee177fd68 2265
Kojto 158:b23ee177fd68 2266 /**
Kojto 158:b23ee177fd68 2267 * @brief Set ADC group regular conversion trigger polarity.
Kojto 158:b23ee177fd68 2268 * @note Applicable only for trigger source set to external trigger.
Kojto 158:b23ee177fd68 2269 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2270 * ADC state:
Kojto 158:b23ee177fd68 2271 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2272 * on group regular.
Kojto 158:b23ee177fd68 2273 * @rmtoll CFGR1 EXTEN LL_ADC_REG_SetTriggerEdge
Kojto 158:b23ee177fd68 2274 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2275 * @param ExternalTriggerEdge This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2276 * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
Kojto 158:b23ee177fd68 2277 * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
Kojto 158:b23ee177fd68 2278 * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
Kojto 158:b23ee177fd68 2279 * @retval None
Kojto 158:b23ee177fd68 2280 */
Kojto 158:b23ee177fd68 2281 __STATIC_INLINE void LL_ADC_REG_SetTriggerEdge(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
Kojto 158:b23ee177fd68 2282 {
Kojto 158:b23ee177fd68 2283 MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_EXTEN, ExternalTriggerEdge);
Kojto 158:b23ee177fd68 2284 }
Kojto 158:b23ee177fd68 2285
Kojto 158:b23ee177fd68 2286 /**
Kojto 158:b23ee177fd68 2287 * @brief Get ADC group regular conversion trigger polarity.
Kojto 158:b23ee177fd68 2288 * @note Applicable only for trigger source set to external trigger.
Kojto 158:b23ee177fd68 2289 * @rmtoll CFGR1 EXTEN LL_ADC_REG_GetTriggerEdge
Kojto 158:b23ee177fd68 2290 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2291 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2292 * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
Kojto 158:b23ee177fd68 2293 * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
Kojto 158:b23ee177fd68 2294 * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
Kojto 158:b23ee177fd68 2295 */
Kojto 158:b23ee177fd68 2296 __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerEdge(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 2297 {
Kojto 158:b23ee177fd68 2298 return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_EXTEN));
Kojto 158:b23ee177fd68 2299 }
Kojto 158:b23ee177fd68 2300
Kojto 158:b23ee177fd68 2301
Kojto 158:b23ee177fd68 2302 /**
Kojto 158:b23ee177fd68 2303 * @brief Set ADC group regular sequencer scan direction.
Kojto 158:b23ee177fd68 2304 * @note On some other STM32 families, this setting is not available and
Kojto 158:b23ee177fd68 2305 * the default scan direction is forward.
Kojto 158:b23ee177fd68 2306 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2307 * ADC state:
Kojto 158:b23ee177fd68 2308 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2309 * on group regular.
Kojto 158:b23ee177fd68 2310 * @rmtoll CFGR1 SCANDIR LL_ADC_REG_SetSequencerScanDirection
Kojto 158:b23ee177fd68 2311 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2312 * @param ScanDirection This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2313 * @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_FORWARD
Kojto 158:b23ee177fd68 2314 * @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_BACKWARD
Kojto 158:b23ee177fd68 2315 * @retval None
Kojto 158:b23ee177fd68 2316 */
Kojto 158:b23ee177fd68 2317 __STATIC_INLINE void LL_ADC_REG_SetSequencerScanDirection(ADC_TypeDef *ADCx, uint32_t ScanDirection)
Kojto 158:b23ee177fd68 2318 {
Kojto 158:b23ee177fd68 2319 MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_SCANDIR, ScanDirection);
Kojto 158:b23ee177fd68 2320 }
Kojto 158:b23ee177fd68 2321
Kojto 158:b23ee177fd68 2322 /**
Kojto 158:b23ee177fd68 2323 * @brief Get ADC group regular sequencer scan direction.
Kojto 158:b23ee177fd68 2324 * @note On some other STM32 families, this setting is not available and
Kojto 158:b23ee177fd68 2325 * the default scan direction is forward.
Kojto 158:b23ee177fd68 2326 * @rmtoll CFGR1 SCANDIR LL_ADC_REG_GetSequencerScanDirection
Kojto 158:b23ee177fd68 2327 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2328 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2329 * @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_FORWARD
Kojto 158:b23ee177fd68 2330 * @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_BACKWARD
Kojto 158:b23ee177fd68 2331 */
Kojto 158:b23ee177fd68 2332 __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerScanDirection(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 2333 {
Kojto 158:b23ee177fd68 2334 return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_SCANDIR));
Kojto 158:b23ee177fd68 2335 }
Kojto 158:b23ee177fd68 2336
Kojto 158:b23ee177fd68 2337 /**
Kojto 158:b23ee177fd68 2338 * @brief Set ADC group regular sequencer discontinuous mode:
Kojto 158:b23ee177fd68 2339 * sequence subdivided and scan conversions interrupted every selected
Kojto 158:b23ee177fd68 2340 * number of ranks.
Kojto 158:b23ee177fd68 2341 * @note It is not possible to enable both ADC group regular
Kojto 158:b23ee177fd68 2342 * continuous mode and sequencer discontinuous mode.
Kojto 158:b23ee177fd68 2343 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2344 * ADC state:
Kojto 158:b23ee177fd68 2345 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2346 * on group regular.
Kojto 158:b23ee177fd68 2347 * @rmtoll CFGR1 DISCEN LL_ADC_REG_SetSequencerDiscont\n
Kojto 158:b23ee177fd68 2348 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2349 * @param SeqDiscont This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2350 * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
Kojto 158:b23ee177fd68 2351 * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
Kojto 158:b23ee177fd68 2352 * @retval None
Kojto 158:b23ee177fd68 2353 */
Kojto 158:b23ee177fd68 2354 __STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
Kojto 158:b23ee177fd68 2355 {
Kojto 158:b23ee177fd68 2356 MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_DISCEN, SeqDiscont);
Kojto 158:b23ee177fd68 2357 }
Kojto 158:b23ee177fd68 2358
Kojto 158:b23ee177fd68 2359 /**
Kojto 158:b23ee177fd68 2360 * @brief Get ADC group regular sequencer discontinuous mode:
Kojto 158:b23ee177fd68 2361 * sequence subdivided and scan conversions interrupted every selected
Kojto 158:b23ee177fd68 2362 * number of ranks.
Kojto 158:b23ee177fd68 2363 * @rmtoll CFGR1 DISCEN LL_ADC_REG_GetSequencerDiscont\n
Kojto 158:b23ee177fd68 2364 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2365 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2366 * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
Kojto 158:b23ee177fd68 2367 * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
Kojto 158:b23ee177fd68 2368 */
Kojto 158:b23ee177fd68 2369 __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 2370 {
Kojto 158:b23ee177fd68 2371 return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_DISCEN));
Kojto 158:b23ee177fd68 2372 }
Kojto 158:b23ee177fd68 2373
Kojto 158:b23ee177fd68 2374 /**
Kojto 158:b23ee177fd68 2375 * @brief Set ADC group regular sequence: channel on rank corresponding to
Kojto 158:b23ee177fd68 2376 * channel number.
Kojto 158:b23ee177fd68 2377 * @note This function performs:
Kojto 158:b23ee177fd68 2378 * - Channels ordering into each rank of scan sequence:
Kojto 158:b23ee177fd68 2379 * rank of each channel is fixed by channel HW number
Kojto 158:b23ee177fd68 2380 * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
Kojto 158:b23ee177fd68 2381 * - Set channels selected by overwriting the current sequencer
Kojto 158:b23ee177fd68 2382 * configuration.
Kojto 158:b23ee177fd68 2383 * @note On this STM32 serie, ADC group regular sequencer is
Kojto 158:b23ee177fd68 2384 * not fully configurable: sequencer length and each rank
Kojto 158:b23ee177fd68 2385 * affectation to a channel are fixed by channel HW number.
Kojto 158:b23ee177fd68 2386 * @note Depending on devices and packages, some channels may not be available.
Kojto 158:b23ee177fd68 2387 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 2388 * @note On this STM32 serie, to measure internal channels (VrefInt,
Kojto 158:b23ee177fd68 2389 * TempSensor, ...), measurement paths to internal channels must be
Kojto 158:b23ee177fd68 2390 * enabled separately.
Kojto 158:b23ee177fd68 2391 * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
Kojto 158:b23ee177fd68 2392 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2393 * ADC state:
Kojto 158:b23ee177fd68 2394 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2395 * on group regular.
Kojto 158:b23ee177fd68 2396 * @note One or several values can be selected.
Kojto 158:b23ee177fd68 2397 * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
Kojto 158:b23ee177fd68 2398 * @rmtoll CHSELR CHSEL0 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2399 * CHSELR CHSEL1 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2400 * CHSELR CHSEL2 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2401 * CHSELR CHSEL3 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2402 * CHSELR CHSEL4 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2403 * CHSELR CHSEL5 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2404 * CHSELR CHSEL6 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2405 * CHSELR CHSEL7 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2406 * CHSELR CHSEL8 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2407 * CHSELR CHSEL9 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2408 * CHSELR CHSEL10 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2409 * CHSELR CHSEL11 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2410 * CHSELR CHSEL12 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2411 * CHSELR CHSEL13 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2412 * CHSELR CHSEL14 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2413 * CHSELR CHSEL15 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2414 * CHSELR CHSEL16 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2415 * CHSELR CHSEL17 LL_ADC_REG_SetSequencerChannels\n
Kojto 158:b23ee177fd68 2416 * CHSELR CHSEL18 LL_ADC_REG_SetSequencerChannels
Kojto 158:b23ee177fd68 2417 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2418 * @param Channel This parameter can be a combination of the following values:
Kojto 158:b23ee177fd68 2419 * @arg @ref LL_ADC_CHANNEL_0
Kojto 158:b23ee177fd68 2420 * @arg @ref LL_ADC_CHANNEL_1
Kojto 158:b23ee177fd68 2421 * @arg @ref LL_ADC_CHANNEL_2
Kojto 158:b23ee177fd68 2422 * @arg @ref LL_ADC_CHANNEL_3
Kojto 158:b23ee177fd68 2423 * @arg @ref LL_ADC_CHANNEL_4
Kojto 158:b23ee177fd68 2424 * @arg @ref LL_ADC_CHANNEL_5
Kojto 158:b23ee177fd68 2425 * @arg @ref LL_ADC_CHANNEL_6
Kojto 158:b23ee177fd68 2426 * @arg @ref LL_ADC_CHANNEL_7
Kojto 158:b23ee177fd68 2427 * @arg @ref LL_ADC_CHANNEL_8
Kojto 158:b23ee177fd68 2428 * @arg @ref LL_ADC_CHANNEL_9
Kojto 158:b23ee177fd68 2429 * @arg @ref LL_ADC_CHANNEL_10
Kojto 158:b23ee177fd68 2430 * @arg @ref LL_ADC_CHANNEL_11
Kojto 158:b23ee177fd68 2431 * @arg @ref LL_ADC_CHANNEL_12
Kojto 158:b23ee177fd68 2432 * @arg @ref LL_ADC_CHANNEL_13
Kojto 158:b23ee177fd68 2433 * @arg @ref LL_ADC_CHANNEL_14
Kojto 158:b23ee177fd68 2434 * @arg @ref LL_ADC_CHANNEL_15
Kojto 158:b23ee177fd68 2435 * @arg @ref LL_ADC_CHANNEL_16 (1)
Kojto 158:b23ee177fd68 2436 * @arg @ref LL_ADC_CHANNEL_17
Kojto 158:b23ee177fd68 2437 * @arg @ref LL_ADC_CHANNEL_18
Kojto 158:b23ee177fd68 2438 * @arg @ref LL_ADC_CHANNEL_VREFINT
Kojto 158:b23ee177fd68 2439 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
Kojto 158:b23ee177fd68 2440 * @arg @ref LL_ADC_CHANNEL_VLCD (1)
Kojto 158:b23ee177fd68 2441 *
Kojto 158:b23ee177fd68 2442 * (1) On STM32L0, parameter not available on all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.
Kojto 158:b23ee177fd68 2443 * @retval None
Kojto 158:b23ee177fd68 2444 */
Kojto 158:b23ee177fd68 2445 __STATIC_INLINE void LL_ADC_REG_SetSequencerChannels(ADC_TypeDef *ADCx, uint32_t Channel)
Kojto 158:b23ee177fd68 2446 {
Kojto 158:b23ee177fd68 2447 /* Parameter "Channel" is used with masks because containing */
Kojto 158:b23ee177fd68 2448 /* other bits reserved for other purpose. */
Kojto 158:b23ee177fd68 2449 WRITE_REG(ADCx->CHSELR, (Channel & ADC_CHANNEL_ID_BITFIELD_MASK));
Kojto 158:b23ee177fd68 2450 }
Kojto 158:b23ee177fd68 2451
Kojto 158:b23ee177fd68 2452 /**
Kojto 158:b23ee177fd68 2453 * @brief Add channel to ADC group regular sequence: channel on rank corresponding to
Kojto 158:b23ee177fd68 2454 * channel number.
Kojto 158:b23ee177fd68 2455 * @note This function performs:
Kojto 158:b23ee177fd68 2456 * - Channels ordering into each rank of scan sequence:
Kojto 158:b23ee177fd68 2457 * rank of each channel is fixed by channel HW number
Kojto 158:b23ee177fd68 2458 * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
Kojto 158:b23ee177fd68 2459 * - Set channels selected by adding them to the current sequencer
Kojto 158:b23ee177fd68 2460 * configuration.
Kojto 158:b23ee177fd68 2461 * @note On this STM32 serie, ADC group regular sequencer is
Kojto 158:b23ee177fd68 2462 * not fully configurable: sequencer length and each rank
Kojto 158:b23ee177fd68 2463 * affectation to a channel are fixed by channel HW number.
Kojto 158:b23ee177fd68 2464 * @note Depending on devices and packages, some channels may not be available.
Kojto 158:b23ee177fd68 2465 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 2466 * @note On this STM32 serie, to measure internal channels (VrefInt,
Kojto 158:b23ee177fd68 2467 * TempSensor, ...), measurement paths to internal channels must be
Kojto 158:b23ee177fd68 2468 * enabled separately.
Kojto 158:b23ee177fd68 2469 * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
Kojto 158:b23ee177fd68 2470 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2471 * ADC state:
Kojto 158:b23ee177fd68 2472 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2473 * on group regular.
Kojto 158:b23ee177fd68 2474 * @note One or several values can be selected.
Kojto 158:b23ee177fd68 2475 * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
Kojto 158:b23ee177fd68 2476 * @rmtoll CHSELR CHSEL0 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2477 * CHSELR CHSEL1 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2478 * CHSELR CHSEL2 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2479 * CHSELR CHSEL3 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2480 * CHSELR CHSEL4 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2481 * CHSELR CHSEL5 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2482 * CHSELR CHSEL6 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2483 * CHSELR CHSEL7 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2484 * CHSELR CHSEL8 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2485 * CHSELR CHSEL9 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2486 * CHSELR CHSEL10 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2487 * CHSELR CHSEL11 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2488 * CHSELR CHSEL12 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2489 * CHSELR CHSEL13 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2490 * CHSELR CHSEL14 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2491 * CHSELR CHSEL15 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2492 * CHSELR CHSEL16 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2493 * CHSELR CHSEL17 LL_ADC_REG_SetSequencerChAdd\n
Kojto 158:b23ee177fd68 2494 * CHSELR CHSEL18 LL_ADC_REG_SetSequencerChAdd
Kojto 158:b23ee177fd68 2495 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2496 * @param Channel This parameter can be a combination of the following values:
Kojto 158:b23ee177fd68 2497 * @arg @ref LL_ADC_CHANNEL_0
Kojto 158:b23ee177fd68 2498 * @arg @ref LL_ADC_CHANNEL_1
Kojto 158:b23ee177fd68 2499 * @arg @ref LL_ADC_CHANNEL_2
Kojto 158:b23ee177fd68 2500 * @arg @ref LL_ADC_CHANNEL_3
Kojto 158:b23ee177fd68 2501 * @arg @ref LL_ADC_CHANNEL_4
Kojto 158:b23ee177fd68 2502 * @arg @ref LL_ADC_CHANNEL_5
Kojto 158:b23ee177fd68 2503 * @arg @ref LL_ADC_CHANNEL_6
Kojto 158:b23ee177fd68 2504 * @arg @ref LL_ADC_CHANNEL_7
Kojto 158:b23ee177fd68 2505 * @arg @ref LL_ADC_CHANNEL_8
Kojto 158:b23ee177fd68 2506 * @arg @ref LL_ADC_CHANNEL_9
Kojto 158:b23ee177fd68 2507 * @arg @ref LL_ADC_CHANNEL_10
Kojto 158:b23ee177fd68 2508 * @arg @ref LL_ADC_CHANNEL_11
Kojto 158:b23ee177fd68 2509 * @arg @ref LL_ADC_CHANNEL_12
Kojto 158:b23ee177fd68 2510 * @arg @ref LL_ADC_CHANNEL_13
Kojto 158:b23ee177fd68 2511 * @arg @ref LL_ADC_CHANNEL_14
Kojto 158:b23ee177fd68 2512 * @arg @ref LL_ADC_CHANNEL_15
Kojto 158:b23ee177fd68 2513 * @arg @ref LL_ADC_CHANNEL_16 (1)
Kojto 158:b23ee177fd68 2514 * @arg @ref LL_ADC_CHANNEL_17
Kojto 158:b23ee177fd68 2515 * @arg @ref LL_ADC_CHANNEL_18
Kojto 158:b23ee177fd68 2516 * @arg @ref LL_ADC_CHANNEL_VREFINT
Kojto 158:b23ee177fd68 2517 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
Kojto 158:b23ee177fd68 2518 * @arg @ref LL_ADC_CHANNEL_VLCD (1)
Kojto 158:b23ee177fd68 2519 *
Kojto 158:b23ee177fd68 2520 * (1) On STM32L0, parameter not available on all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.
Kojto 158:b23ee177fd68 2521 * @retval None
Kojto 158:b23ee177fd68 2522 */
Kojto 158:b23ee177fd68 2523 __STATIC_INLINE void LL_ADC_REG_SetSequencerChAdd(ADC_TypeDef *ADCx, uint32_t Channel)
Kojto 158:b23ee177fd68 2524 {
Kojto 158:b23ee177fd68 2525 /* Parameter "Channel" is used with masks because containing */
Kojto 158:b23ee177fd68 2526 /* other bits reserved for other purpose. */
Kojto 158:b23ee177fd68 2527 SET_BIT(ADCx->CHSELR, (Channel & ADC_CHANNEL_ID_BITFIELD_MASK));
Kojto 158:b23ee177fd68 2528 }
Kojto 158:b23ee177fd68 2529
Kojto 158:b23ee177fd68 2530 /**
Kojto 158:b23ee177fd68 2531 * @brief Remove channel to ADC group regular sequence: channel on rank corresponding to
Kojto 158:b23ee177fd68 2532 * channel number.
Kojto 158:b23ee177fd68 2533 * @note This function performs:
Kojto 158:b23ee177fd68 2534 * - Channels ordering into each rank of scan sequence:
Kojto 158:b23ee177fd68 2535 * rank of each channel is fixed by channel HW number
Kojto 158:b23ee177fd68 2536 * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
Kojto 158:b23ee177fd68 2537 * - Set channels selected by removing them to the current sequencer
Kojto 158:b23ee177fd68 2538 * configuration.
Kojto 158:b23ee177fd68 2539 * @note On this STM32 serie, ADC group regular sequencer is
Kojto 158:b23ee177fd68 2540 * not fully configurable: sequencer length and each rank
Kojto 158:b23ee177fd68 2541 * affectation to a channel are fixed by channel HW number.
Kojto 158:b23ee177fd68 2542 * @note Depending on devices and packages, some channels may not be available.
Kojto 158:b23ee177fd68 2543 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 2544 * @note On this STM32 serie, to measure internal channels (VrefInt,
Kojto 158:b23ee177fd68 2545 * TempSensor, ...), measurement paths to internal channels must be
Kojto 158:b23ee177fd68 2546 * enabled separately.
Kojto 158:b23ee177fd68 2547 * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
Kojto 158:b23ee177fd68 2548 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2549 * ADC state:
Kojto 158:b23ee177fd68 2550 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2551 * on group regular.
Kojto 158:b23ee177fd68 2552 * @note One or several values can be selected.
Kojto 158:b23ee177fd68 2553 * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
Kojto 158:b23ee177fd68 2554 * @rmtoll CHSELR CHSEL0 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2555 * CHSELR CHSEL1 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2556 * CHSELR CHSEL2 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2557 * CHSELR CHSEL3 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2558 * CHSELR CHSEL4 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2559 * CHSELR CHSEL5 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2560 * CHSELR CHSEL6 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2561 * CHSELR CHSEL7 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2562 * CHSELR CHSEL8 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2563 * CHSELR CHSEL9 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2564 * CHSELR CHSEL10 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2565 * CHSELR CHSEL11 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2566 * CHSELR CHSEL12 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2567 * CHSELR CHSEL13 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2568 * CHSELR CHSEL14 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2569 * CHSELR CHSEL15 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2570 * CHSELR CHSEL16 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2571 * CHSELR CHSEL17 LL_ADC_REG_SetSequencerChRem\n
Kojto 158:b23ee177fd68 2572 * CHSELR CHSEL18 LL_ADC_REG_SetSequencerChRem
Kojto 158:b23ee177fd68 2573 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2574 * @param Channel This parameter can be a combination of the following values:
Kojto 158:b23ee177fd68 2575 * @arg @ref LL_ADC_CHANNEL_0
Kojto 158:b23ee177fd68 2576 * @arg @ref LL_ADC_CHANNEL_1
Kojto 158:b23ee177fd68 2577 * @arg @ref LL_ADC_CHANNEL_2
Kojto 158:b23ee177fd68 2578 * @arg @ref LL_ADC_CHANNEL_3
Kojto 158:b23ee177fd68 2579 * @arg @ref LL_ADC_CHANNEL_4
Kojto 158:b23ee177fd68 2580 * @arg @ref LL_ADC_CHANNEL_5
Kojto 158:b23ee177fd68 2581 * @arg @ref LL_ADC_CHANNEL_6
Kojto 158:b23ee177fd68 2582 * @arg @ref LL_ADC_CHANNEL_7
Kojto 158:b23ee177fd68 2583 * @arg @ref LL_ADC_CHANNEL_8
Kojto 158:b23ee177fd68 2584 * @arg @ref LL_ADC_CHANNEL_9
Kojto 158:b23ee177fd68 2585 * @arg @ref LL_ADC_CHANNEL_10
Kojto 158:b23ee177fd68 2586 * @arg @ref LL_ADC_CHANNEL_11
Kojto 158:b23ee177fd68 2587 * @arg @ref LL_ADC_CHANNEL_12
Kojto 158:b23ee177fd68 2588 * @arg @ref LL_ADC_CHANNEL_13
Kojto 158:b23ee177fd68 2589 * @arg @ref LL_ADC_CHANNEL_14
Kojto 158:b23ee177fd68 2590 * @arg @ref LL_ADC_CHANNEL_15
Kojto 158:b23ee177fd68 2591 * @arg @ref LL_ADC_CHANNEL_16 (1)
Kojto 158:b23ee177fd68 2592 * @arg @ref LL_ADC_CHANNEL_17
Kojto 158:b23ee177fd68 2593 * @arg @ref LL_ADC_CHANNEL_18
Kojto 158:b23ee177fd68 2594 * @arg @ref LL_ADC_CHANNEL_VREFINT
Kojto 158:b23ee177fd68 2595 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
Kojto 158:b23ee177fd68 2596 * @arg @ref LL_ADC_CHANNEL_VLCD (1)
Kojto 158:b23ee177fd68 2597 *
Kojto 158:b23ee177fd68 2598 * (1) On STM32L0, parameter not available on all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.
Kojto 158:b23ee177fd68 2599 * @retval None
Kojto 158:b23ee177fd68 2600 */
Kojto 158:b23ee177fd68 2601 __STATIC_INLINE void LL_ADC_REG_SetSequencerChRem(ADC_TypeDef *ADCx, uint32_t Channel)
Kojto 158:b23ee177fd68 2602 {
Kojto 158:b23ee177fd68 2603 /* Parameter "Channel" is used with masks because containing */
Kojto 158:b23ee177fd68 2604 /* other bits reserved for other purpose. */
Kojto 158:b23ee177fd68 2605 CLEAR_BIT(ADCx->CHSELR, (Channel & ADC_CHANNEL_ID_BITFIELD_MASK));
Kojto 158:b23ee177fd68 2606 }
Kojto 158:b23ee177fd68 2607
Kojto 158:b23ee177fd68 2608 /**
Kojto 158:b23ee177fd68 2609 * @brief Get ADC group regular sequence: channel on rank corresponding to
Kojto 158:b23ee177fd68 2610 * channel number.
Kojto 158:b23ee177fd68 2611 * @note This function performs:
Kojto 158:b23ee177fd68 2612 * - Channels order reading into each rank of scan sequence:
Kojto 158:b23ee177fd68 2613 * rank of each channel is fixed by channel HW number
Kojto 158:b23ee177fd68 2614 * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
Kojto 158:b23ee177fd68 2615 * @note On this STM32 serie, ADC group regular sequencer is
Kojto 158:b23ee177fd68 2616 * not fully configurable: sequencer length and each rank
Kojto 158:b23ee177fd68 2617 * affectation to a channel are fixed by channel HW number.
Kojto 158:b23ee177fd68 2618 * @note Depending on devices and packages, some channels may not be available.
Kojto 158:b23ee177fd68 2619 * Refer to device datasheet for channels availability.
Kojto 158:b23ee177fd68 2620 * @note On this STM32 serie, to measure internal channels (VrefInt,
Kojto 158:b23ee177fd68 2621 * TempSensor, ...), measurement paths to internal channels must be
Kojto 158:b23ee177fd68 2622 * enabled separately.
Kojto 158:b23ee177fd68 2623 * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
Kojto 158:b23ee177fd68 2624 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2625 * ADC state:
Kojto 158:b23ee177fd68 2626 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2627 * on group regular.
Kojto 158:b23ee177fd68 2628 * @note One or several values can be retrieved.
Kojto 158:b23ee177fd68 2629 * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
Kojto 158:b23ee177fd68 2630 * @rmtoll CHSELR CHSEL0 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2631 * CHSELR CHSEL1 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2632 * CHSELR CHSEL2 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2633 * CHSELR CHSEL3 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2634 * CHSELR CHSEL4 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2635 * CHSELR CHSEL5 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2636 * CHSELR CHSEL6 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2637 * CHSELR CHSEL7 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2638 * CHSELR CHSEL8 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2639 * CHSELR CHSEL9 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2640 * CHSELR CHSEL10 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2641 * CHSELR CHSEL11 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2642 * CHSELR CHSEL12 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2643 * CHSELR CHSEL13 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2644 * CHSELR CHSEL14 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2645 * CHSELR CHSEL15 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2646 * CHSELR CHSEL16 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2647 * CHSELR CHSEL17 LL_ADC_REG_GetSequencerChannels\n
Kojto 158:b23ee177fd68 2648 * CHSELR CHSEL18 LL_ADC_REG_GetSequencerChannels
Kojto 158:b23ee177fd68 2649 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2650 * @retval Returned value can be a combination of the following values:
Kojto 158:b23ee177fd68 2651 * @arg @ref LL_ADC_CHANNEL_0
Kojto 158:b23ee177fd68 2652 * @arg @ref LL_ADC_CHANNEL_1
Kojto 158:b23ee177fd68 2653 * @arg @ref LL_ADC_CHANNEL_2
Kojto 158:b23ee177fd68 2654 * @arg @ref LL_ADC_CHANNEL_3
Kojto 158:b23ee177fd68 2655 * @arg @ref LL_ADC_CHANNEL_4
Kojto 158:b23ee177fd68 2656 * @arg @ref LL_ADC_CHANNEL_5
Kojto 158:b23ee177fd68 2657 * @arg @ref LL_ADC_CHANNEL_6
Kojto 158:b23ee177fd68 2658 * @arg @ref LL_ADC_CHANNEL_7
Kojto 158:b23ee177fd68 2659 * @arg @ref LL_ADC_CHANNEL_8
Kojto 158:b23ee177fd68 2660 * @arg @ref LL_ADC_CHANNEL_9
Kojto 158:b23ee177fd68 2661 * @arg @ref LL_ADC_CHANNEL_10
Kojto 158:b23ee177fd68 2662 * @arg @ref LL_ADC_CHANNEL_11
Kojto 158:b23ee177fd68 2663 * @arg @ref LL_ADC_CHANNEL_12
Kojto 158:b23ee177fd68 2664 * @arg @ref LL_ADC_CHANNEL_13
Kojto 158:b23ee177fd68 2665 * @arg @ref LL_ADC_CHANNEL_14
Kojto 158:b23ee177fd68 2666 * @arg @ref LL_ADC_CHANNEL_15
Kojto 158:b23ee177fd68 2667 * @arg @ref LL_ADC_CHANNEL_16 (1)
Kojto 158:b23ee177fd68 2668 * @arg @ref LL_ADC_CHANNEL_17
Kojto 158:b23ee177fd68 2669 * @arg @ref LL_ADC_CHANNEL_18
Kojto 158:b23ee177fd68 2670 * @arg @ref LL_ADC_CHANNEL_VREFINT
Kojto 158:b23ee177fd68 2671 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
Kojto 158:b23ee177fd68 2672 * @arg @ref LL_ADC_CHANNEL_VLCD (1)
Kojto 158:b23ee177fd68 2673 *
Kojto 158:b23ee177fd68 2674 * (1) On STM32L0, parameter not available on all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.
Kojto 158:b23ee177fd68 2675 */
Kojto 158:b23ee177fd68 2676 __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerChannels(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 2677 {
Kojto 158:b23ee177fd68 2678 register uint32_t ChannelsBitfield = READ_BIT(ADCx->CHSELR, ADC_CHSELR_CHSEL);
Kojto 158:b23ee177fd68 2679
Kojto 158:b23ee177fd68 2680 return ( (((ChannelsBitfield & ADC_CHSELR_CHSEL0) >> ADC_CHSELR_CHSEL0_BITOFFSET_POS) * LL_ADC_CHANNEL_0)
Kojto 158:b23ee177fd68 2681 | (((ChannelsBitfield & ADC_CHSELR_CHSEL1) >> ADC_CHSELR_CHSEL1_BITOFFSET_POS) * LL_ADC_CHANNEL_1)
Kojto 158:b23ee177fd68 2682 | (((ChannelsBitfield & ADC_CHSELR_CHSEL2) >> ADC_CHSELR_CHSEL2_BITOFFSET_POS) * LL_ADC_CHANNEL_2)
Kojto 158:b23ee177fd68 2683 | (((ChannelsBitfield & ADC_CHSELR_CHSEL3) >> ADC_CHSELR_CHSEL3_BITOFFSET_POS) * LL_ADC_CHANNEL_3)
Kojto 158:b23ee177fd68 2684 | (((ChannelsBitfield & ADC_CHSELR_CHSEL4) >> ADC_CHSELR_CHSEL4_BITOFFSET_POS) * LL_ADC_CHANNEL_4)
Kojto 158:b23ee177fd68 2685 | (((ChannelsBitfield & ADC_CHSELR_CHSEL5) >> ADC_CHSELR_CHSEL5_BITOFFSET_POS) * LL_ADC_CHANNEL_5)
Kojto 158:b23ee177fd68 2686 | (((ChannelsBitfield & ADC_CHSELR_CHSEL6) >> ADC_CHSELR_CHSEL6_BITOFFSET_POS) * LL_ADC_CHANNEL_6)
Kojto 158:b23ee177fd68 2687 | (((ChannelsBitfield & ADC_CHSELR_CHSEL7) >> ADC_CHSELR_CHSEL7_BITOFFSET_POS) * LL_ADC_CHANNEL_7)
Kojto 158:b23ee177fd68 2688 | (((ChannelsBitfield & ADC_CHSELR_CHSEL8) >> ADC_CHSELR_CHSEL8_BITOFFSET_POS) * LL_ADC_CHANNEL_8)
Kojto 158:b23ee177fd68 2689 | (((ChannelsBitfield & ADC_CHSELR_CHSEL9) >> ADC_CHSELR_CHSEL9_BITOFFSET_POS) * LL_ADC_CHANNEL_9)
Kojto 158:b23ee177fd68 2690 | (((ChannelsBitfield & ADC_CHSELR_CHSEL10) >> ADC_CHSELR_CHSEL10_BITOFFSET_POS) * LL_ADC_CHANNEL_10)
Kojto 158:b23ee177fd68 2691 | (((ChannelsBitfield & ADC_CHSELR_CHSEL11) >> ADC_CHSELR_CHSEL11_BITOFFSET_POS) * LL_ADC_CHANNEL_11)
Kojto 158:b23ee177fd68 2692 | (((ChannelsBitfield & ADC_CHSELR_CHSEL12) >> ADC_CHSELR_CHSEL12_BITOFFSET_POS) * LL_ADC_CHANNEL_12)
Kojto 158:b23ee177fd68 2693 | (((ChannelsBitfield & ADC_CHSELR_CHSEL13) >> ADC_CHSELR_CHSEL13_BITOFFSET_POS) * LL_ADC_CHANNEL_13)
Kojto 158:b23ee177fd68 2694 | (((ChannelsBitfield & ADC_CHSELR_CHSEL14) >> ADC_CHSELR_CHSEL14_BITOFFSET_POS) * LL_ADC_CHANNEL_14)
Kojto 158:b23ee177fd68 2695 | (((ChannelsBitfield & ADC_CHSELR_CHSEL15) >> ADC_CHSELR_CHSEL15_BITOFFSET_POS) * LL_ADC_CHANNEL_15)
Kojto 158:b23ee177fd68 2696 #if defined(ADC_CCR_VLCDEN)
Kojto 158:b23ee177fd68 2697 | (((ChannelsBitfield & ADC_CHSELR_CHSEL16) >> ADC_CHSELR_CHSEL16_BITOFFSET_POS) * LL_ADC_CHANNEL_16)
Kojto 158:b23ee177fd68 2698 #endif
Kojto 158:b23ee177fd68 2699 | (((ChannelsBitfield & ADC_CHSELR_CHSEL17) >> ADC_CHSELR_CHSEL17_BITOFFSET_POS) * LL_ADC_CHANNEL_17)
Kojto 158:b23ee177fd68 2700 | (((ChannelsBitfield & ADC_CHSELR_CHSEL18) >> ADC_CHSELR_CHSEL18_BITOFFSET_POS) * LL_ADC_CHANNEL_18)
Kojto 158:b23ee177fd68 2701 );
Kojto 158:b23ee177fd68 2702 }
Kojto 158:b23ee177fd68 2703 /**
Kojto 158:b23ee177fd68 2704 * @brief Set ADC continuous conversion mode on ADC group regular.
Kojto 158:b23ee177fd68 2705 * @note Description of ADC continuous conversion mode:
Kojto 158:b23ee177fd68 2706 * - single mode: one conversion per trigger
Kojto 158:b23ee177fd68 2707 * - continuous mode: after the first trigger, following
Kojto 158:b23ee177fd68 2708 * conversions launched successively automatically.
Kojto 158:b23ee177fd68 2709 * @note It is not possible to enable both ADC group regular
Kojto 158:b23ee177fd68 2710 * continuous mode and sequencer discontinuous mode.
Kojto 158:b23ee177fd68 2711 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2712 * ADC state:
Kojto 158:b23ee177fd68 2713 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2714 * on group regular.
Kojto 158:b23ee177fd68 2715 * @rmtoll CFGR1 CONT LL_ADC_REG_SetContinuousMode
Kojto 158:b23ee177fd68 2716 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2717 * @param Continuous This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2718 * @arg @ref LL_ADC_REG_CONV_SINGLE
Kojto 158:b23ee177fd68 2719 * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
Kojto 158:b23ee177fd68 2720 * @retval None
Kojto 158:b23ee177fd68 2721 */
Kojto 158:b23ee177fd68 2722 __STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
Kojto 158:b23ee177fd68 2723 {
Kojto 158:b23ee177fd68 2724 MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_CONT, Continuous);
Kojto 158:b23ee177fd68 2725 }
Kojto 158:b23ee177fd68 2726
Kojto 158:b23ee177fd68 2727 /**
Kojto 158:b23ee177fd68 2728 * @brief Get ADC continuous conversion mode on ADC group regular.
Kojto 158:b23ee177fd68 2729 * @note Description of ADC continuous conversion mode:
Kojto 158:b23ee177fd68 2730 * - single mode: one conversion per trigger
Kojto 158:b23ee177fd68 2731 * - continuous mode: after the first trigger, following
Kojto 158:b23ee177fd68 2732 * conversions launched successively automatically.
Kojto 158:b23ee177fd68 2733 * @rmtoll CFGR1 CONT LL_ADC_REG_GetContinuousMode
Kojto 158:b23ee177fd68 2734 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2735 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2736 * @arg @ref LL_ADC_REG_CONV_SINGLE
Kojto 158:b23ee177fd68 2737 * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
Kojto 158:b23ee177fd68 2738 */
Kojto 158:b23ee177fd68 2739 __STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 2740 {
Kojto 158:b23ee177fd68 2741 return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_CONT));
Kojto 158:b23ee177fd68 2742 }
Kojto 158:b23ee177fd68 2743
Kojto 158:b23ee177fd68 2744 /**
Kojto 158:b23ee177fd68 2745 * @brief Set ADC group regular conversion data transfer: no transfer or
Kojto 158:b23ee177fd68 2746 * transfer by DMA, and DMA requests mode.
Kojto 158:b23ee177fd68 2747 * @note If transfer by DMA selected, specifies the DMA requests
Kojto 158:b23ee177fd68 2748 * mode:
Kojto 158:b23ee177fd68 2749 * - Limited mode (One shot mode): DMA transfer requests are stopped
Kojto 158:b23ee177fd68 2750 * when number of DMA data transfers (number of
Kojto 158:b23ee177fd68 2751 * ADC conversions) is reached.
Kojto 158:b23ee177fd68 2752 * This ADC mode is intended to be used with DMA mode non-circular.
Kojto 158:b23ee177fd68 2753 * - Unlimited mode: DMA transfer requests are unlimited,
Kojto 158:b23ee177fd68 2754 * whatever number of DMA data transfers (number of
Kojto 158:b23ee177fd68 2755 * ADC conversions).
Kojto 158:b23ee177fd68 2756 * This ADC mode is intended to be used with DMA mode circular.
Kojto 158:b23ee177fd68 2757 * @note If ADC DMA requests mode is set to unlimited and DMA is set to
Kojto 158:b23ee177fd68 2758 * mode non-circular:
Kojto 158:b23ee177fd68 2759 * when DMA transfers size will be reached, DMA will stop transfers of
Kojto 158:b23ee177fd68 2760 * ADC conversions data ADC will raise an overrun error
Kojto 158:b23ee177fd68 2761 * (overrun flag and interruption if enabled).
Kojto 158:b23ee177fd68 2762 * @note To configure DMA source address (peripheral address),
Kojto 158:b23ee177fd68 2763 * use function @ref LL_ADC_DMA_GetRegAddr().
Kojto 158:b23ee177fd68 2764 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2765 * ADC state:
Kojto 158:b23ee177fd68 2766 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2767 * on group regular.
Kojto 158:b23ee177fd68 2768 * @rmtoll CFGR1 DMAEN LL_ADC_REG_SetDMATransfer\n
Kojto 158:b23ee177fd68 2769 * CFGR1 DMACFG LL_ADC_REG_SetDMATransfer
Kojto 158:b23ee177fd68 2770 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2771 * @param DMATransfer This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2772 * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
Kojto 158:b23ee177fd68 2773 * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
Kojto 158:b23ee177fd68 2774 * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
Kojto 158:b23ee177fd68 2775 * @retval None
Kojto 158:b23ee177fd68 2776 */
Kojto 158:b23ee177fd68 2777 __STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
Kojto 158:b23ee177fd68 2778 {
Kojto 158:b23ee177fd68 2779 MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_DMAEN | ADC_CFGR1_DMACFG, DMATransfer);
Kojto 158:b23ee177fd68 2780 }
Kojto 158:b23ee177fd68 2781
Kojto 158:b23ee177fd68 2782 /**
Kojto 158:b23ee177fd68 2783 * @brief Get ADC group regular conversion data transfer: no transfer or
Kojto 158:b23ee177fd68 2784 * transfer by DMA, and DMA requests mode.
Kojto 158:b23ee177fd68 2785 * @note If transfer by DMA selected, specifies the DMA requests
Kojto 158:b23ee177fd68 2786 * mode:
Kojto 158:b23ee177fd68 2787 * - Limited mode (One shot mode): DMA transfer requests are stopped
Kojto 158:b23ee177fd68 2788 * when number of DMA data transfers (number of
Kojto 158:b23ee177fd68 2789 * ADC conversions) is reached.
Kojto 158:b23ee177fd68 2790 * This ADC mode is intended to be used with DMA mode non-circular.
Kojto 158:b23ee177fd68 2791 * - Unlimited mode: DMA transfer requests are unlimited,
Kojto 158:b23ee177fd68 2792 * whatever number of DMA data transfers (number of
Kojto 158:b23ee177fd68 2793 * ADC conversions).
Kojto 158:b23ee177fd68 2794 * This ADC mode is intended to be used with DMA mode circular.
Kojto 158:b23ee177fd68 2795 * @note If ADC DMA requests mode is set to unlimited and DMA is set to
Kojto 158:b23ee177fd68 2796 * mode non-circular:
Kojto 158:b23ee177fd68 2797 * when DMA transfers size will be reached, DMA will stop transfers of
Kojto 158:b23ee177fd68 2798 * ADC conversions data ADC will raise an overrun error
Kojto 158:b23ee177fd68 2799 * (overrun flag and interruption if enabled).
Kojto 158:b23ee177fd68 2800 * @note To configure DMA source address (peripheral address),
Kojto 158:b23ee177fd68 2801 * use function @ref LL_ADC_DMA_GetRegAddr().
Kojto 158:b23ee177fd68 2802 * @rmtoll CFGR1 DMAEN LL_ADC_REG_GetDMATransfer\n
Kojto 158:b23ee177fd68 2803 * CFGR1 DMACFG LL_ADC_REG_GetDMATransfer
Kojto 158:b23ee177fd68 2804 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2805 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2806 * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
Kojto 158:b23ee177fd68 2807 * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
Kojto 158:b23ee177fd68 2808 * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
Kojto 158:b23ee177fd68 2809 */
Kojto 158:b23ee177fd68 2810 __STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 2811 {
Kojto 158:b23ee177fd68 2812 return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_DMAEN | ADC_CFGR1_DMACFG));
Kojto 158:b23ee177fd68 2813 }
Kojto 158:b23ee177fd68 2814
Kojto 158:b23ee177fd68 2815 /**
Kojto 158:b23ee177fd68 2816 * @brief Set ADC group regular behavior in case of overrun:
Kojto 158:b23ee177fd68 2817 * data preserved or overwritten.
Kojto 158:b23ee177fd68 2818 * @note Compatibility with devices without feature overrun:
Kojto 158:b23ee177fd68 2819 * other devices without this feature have a behavior
Kojto 158:b23ee177fd68 2820 * equivalent to data overwritten.
Kojto 158:b23ee177fd68 2821 * The default setting of overrun is data preserved.
Kojto 158:b23ee177fd68 2822 * Therefore, for compatibility with all devices, parameter
Kojto 158:b23ee177fd68 2823 * overrun should be set to data overwritten.
Kojto 158:b23ee177fd68 2824 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2825 * ADC state:
Kojto 158:b23ee177fd68 2826 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2827 * on group regular.
Kojto 158:b23ee177fd68 2828 * @rmtoll CFGR1 OVRMOD LL_ADC_REG_SetOverrun
Kojto 158:b23ee177fd68 2829 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2830 * @param Overrun This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2831 * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
Kojto 158:b23ee177fd68 2832 * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
Kojto 158:b23ee177fd68 2833 * @retval None
Kojto 158:b23ee177fd68 2834 */
Kojto 158:b23ee177fd68 2835 __STATIC_INLINE void LL_ADC_REG_SetOverrun(ADC_TypeDef *ADCx, uint32_t Overrun)
Kojto 158:b23ee177fd68 2836 {
Kojto 158:b23ee177fd68 2837 MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_OVRMOD, Overrun);
Kojto 158:b23ee177fd68 2838 }
Kojto 158:b23ee177fd68 2839
Kojto 158:b23ee177fd68 2840 /**
Kojto 158:b23ee177fd68 2841 * @brief Get ADC group regular behavior in case of overrun:
Kojto 158:b23ee177fd68 2842 * data preserved or overwritten.
Kojto 158:b23ee177fd68 2843 * @rmtoll CFGR1 OVRMOD LL_ADC_REG_GetOverrun
Kojto 158:b23ee177fd68 2844 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2845 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2846 * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
Kojto 158:b23ee177fd68 2847 * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
Kojto 158:b23ee177fd68 2848 */
Kojto 158:b23ee177fd68 2849 __STATIC_INLINE uint32_t LL_ADC_REG_GetOverrun(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 2850 {
Kojto 158:b23ee177fd68 2851 return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_OVRMOD));
Kojto 158:b23ee177fd68 2852 }
Kojto 158:b23ee177fd68 2853
Kojto 158:b23ee177fd68 2854 /**
Kojto 158:b23ee177fd68 2855 * @}
Kojto 158:b23ee177fd68 2856 */
Kojto 158:b23ee177fd68 2857
Kojto 158:b23ee177fd68 2858
Kojto 158:b23ee177fd68 2859 /** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
Kojto 158:b23ee177fd68 2860 * @{
Kojto 158:b23ee177fd68 2861 */
Kojto 158:b23ee177fd68 2862
Kojto 158:b23ee177fd68 2863 /**
Kojto 158:b23ee177fd68 2864 * @brief Set ADC analog watchdog monitored channels:
Kojto 158:b23ee177fd68 2865 * a single channel or all channels,
Kojto 158:b23ee177fd68 2866 * on ADC group regular.
Kojto 158:b23ee177fd68 2867 * @note Once monitored channels are selected, analog watchdog
Kojto 158:b23ee177fd68 2868 * is enabled.
Kojto 158:b23ee177fd68 2869 * @note In case of need to define a single channel to monitor
Kojto 158:b23ee177fd68 2870 * with analog watchdog from sequencer channel definition,
Kojto 158:b23ee177fd68 2871 * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
Kojto 158:b23ee177fd68 2872 * @note On this STM32 serie, there is only 1 kind of analog watchdog
Kojto 158:b23ee177fd68 2873 * instance:
Kojto 158:b23ee177fd68 2874 * - AWD standard (instance AWD1):
Kojto 158:b23ee177fd68 2875 * - channels monitored: can monitor 1 channel or all channels.
Kojto 158:b23ee177fd68 2876 * - groups monitored: ADC group regular.
Kojto 158:b23ee177fd68 2877 * - resolution: resolution is not limited (corresponds to
Kojto 158:b23ee177fd68 2878 * ADC resolution configured).
Kojto 158:b23ee177fd68 2879 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2880 * ADC state:
Kojto 158:b23ee177fd68 2881 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2882 * on group regular.
Kojto 158:b23ee177fd68 2883 * @rmtoll CFGR1 AWDCH LL_ADC_SetAnalogWDMonitChannels\n
Kojto 158:b23ee177fd68 2884 * CFGR1 AWDSGL LL_ADC_SetAnalogWDMonitChannels\n
Kojto 158:b23ee177fd68 2885 * CFGR1 AWDEN LL_ADC_SetAnalogWDMonitChannels
Kojto 158:b23ee177fd68 2886 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2887 * @param AWDChannelGroup This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2888 * @arg @ref LL_ADC_AWD_DISABLE
Kojto 158:b23ee177fd68 2889 * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
Kojto 158:b23ee177fd68 2890 * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
Kojto 158:b23ee177fd68 2891 * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
Kojto 158:b23ee177fd68 2892 * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
Kojto 158:b23ee177fd68 2893 * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
Kojto 158:b23ee177fd68 2894 * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
Kojto 158:b23ee177fd68 2895 * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
Kojto 158:b23ee177fd68 2896 * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
Kojto 158:b23ee177fd68 2897 * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
Kojto 158:b23ee177fd68 2898 * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
Kojto 158:b23ee177fd68 2899 * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
Kojto 158:b23ee177fd68 2900 * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
Kojto 158:b23ee177fd68 2901 * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
Kojto 158:b23ee177fd68 2902 * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
Kojto 158:b23ee177fd68 2903 * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
Kojto 158:b23ee177fd68 2904 * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
Kojto 158:b23ee177fd68 2905 * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
Kojto 158:b23ee177fd68 2906 * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (1)
Kojto 158:b23ee177fd68 2907 * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
Kojto 158:b23ee177fd68 2908 * @arg @ref LL_ADC_AWD_CHANNEL_18_REG
Kojto 158:b23ee177fd68 2909 * @arg @ref LL_ADC_AWD_CH_VREFINT_REG
Kojto 158:b23ee177fd68 2910 * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG
Kojto 158:b23ee177fd68 2911 * @arg @ref LL_ADC_AWD_CH_VLCD_REG (1)
Kojto 158:b23ee177fd68 2912 *
Kojto 158:b23ee177fd68 2913 * (1) On STM32L0, parameter not available on all devices: only on STM32L053xx, STM32L063xx, STM32L073xx, STM32L083xx.
Kojto 158:b23ee177fd68 2914 * @retval None
Kojto 158:b23ee177fd68 2915 */
Kojto 158:b23ee177fd68 2916 __STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDChannelGroup)
Kojto 158:b23ee177fd68 2917 {
Kojto 158:b23ee177fd68 2918 MODIFY_REG(ADCx->CFGR1,
Kojto 158:b23ee177fd68 2919 (ADC_CFGR1_AWDCH | ADC_CFGR1_AWDSGL | ADC_CFGR1_AWDEN),
Kojto 158:b23ee177fd68 2920 (AWDChannelGroup & ADC_AWD_CR_ALL_CHANNEL_MASK));
Kojto 158:b23ee177fd68 2921 }
Kojto 158:b23ee177fd68 2922
Kojto 158:b23ee177fd68 2923 /**
Kojto 158:b23ee177fd68 2924 * @brief Get ADC analog watchdog monitored channel.
Kojto 158:b23ee177fd68 2925 * @note Usage of the returned channel number:
Kojto 158:b23ee177fd68 2926 * - To reinject this channel into another function LL_ADC_xxx:
Kojto 158:b23ee177fd68 2927 * the returned channel number is only partly formatted on definition
Kojto 158:b23ee177fd68 2928 * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
Kojto 158:b23ee177fd68 2929 * with parts of literals LL_ADC_CHANNEL_x or using
Kojto 158:b23ee177fd68 2930 * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
Kojto 158:b23ee177fd68 2931 * Then the selected literal LL_ADC_CHANNEL_x can be used
Kojto 158:b23ee177fd68 2932 * as parameter for another function.
Kojto 158:b23ee177fd68 2933 * - To get the channel number in decimal format:
Kojto 158:b23ee177fd68 2934 * process the returned value with the helper macro
Kojto 158:b23ee177fd68 2935 * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
Kojto 158:b23ee177fd68 2936 * Applicable only when the analog watchdog is set to monitor
Kojto 158:b23ee177fd68 2937 * one channel.
Kojto 158:b23ee177fd68 2938 * @note On this STM32 serie, there is only 1 kind of analog watchdog
Kojto 158:b23ee177fd68 2939 * instance:
Kojto 158:b23ee177fd68 2940 * - AWD standard (instance AWD1):
Kojto 158:b23ee177fd68 2941 * - channels monitored: can monitor 1 channel or all channels.
Kojto 158:b23ee177fd68 2942 * - groups monitored: ADC group regular.
Kojto 158:b23ee177fd68 2943 * - resolution: resolution is not limited (corresponds to
Kojto 158:b23ee177fd68 2944 * ADC resolution configured).
Kojto 158:b23ee177fd68 2945 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 2946 * ADC state:
Kojto 158:b23ee177fd68 2947 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 2948 * on group regular.
Kojto 158:b23ee177fd68 2949 * @rmtoll CFGR1 AWDCH LL_ADC_GetAnalogWDMonitChannels\n
Kojto 158:b23ee177fd68 2950 * CFGR1 AWDSGL LL_ADC_GetAnalogWDMonitChannels\n
Kojto 158:b23ee177fd68 2951 * CFGR1 AWDEN LL_ADC_GetAnalogWDMonitChannels
Kojto 158:b23ee177fd68 2952 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 2953 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2954 * @arg @ref LL_ADC_AWD_DISABLE
Kojto 158:b23ee177fd68 2955 * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
Kojto 158:b23ee177fd68 2956 * @arg @ref LL_ADC_AWD_CHANNEL_0_REG
Kojto 158:b23ee177fd68 2957 * @arg @ref LL_ADC_AWD_CHANNEL_1_REG
Kojto 158:b23ee177fd68 2958 * @arg @ref LL_ADC_AWD_CHANNEL_2_REG
Kojto 158:b23ee177fd68 2959 * @arg @ref LL_ADC_AWD_CHANNEL_3_REG
Kojto 158:b23ee177fd68 2960 * @arg @ref LL_ADC_AWD_CHANNEL_4_REG
Kojto 158:b23ee177fd68 2961 * @arg @ref LL_ADC_AWD_CHANNEL_5_REG
Kojto 158:b23ee177fd68 2962 * @arg @ref LL_ADC_AWD_CHANNEL_6_REG
Kojto 158:b23ee177fd68 2963 * @arg @ref LL_ADC_AWD_CHANNEL_7_REG
Kojto 158:b23ee177fd68 2964 * @arg @ref LL_ADC_AWD_CHANNEL_8_REG
Kojto 158:b23ee177fd68 2965 * @arg @ref LL_ADC_AWD_CHANNEL_9_REG
Kojto 158:b23ee177fd68 2966 * @arg @ref LL_ADC_AWD_CHANNEL_10_REG
Kojto 158:b23ee177fd68 2967 * @arg @ref LL_ADC_AWD_CHANNEL_11_REG
Kojto 158:b23ee177fd68 2968 * @arg @ref LL_ADC_AWD_CHANNEL_12_REG
Kojto 158:b23ee177fd68 2969 * @arg @ref LL_ADC_AWD_CHANNEL_13_REG
Kojto 158:b23ee177fd68 2970 * @arg @ref LL_ADC_AWD_CHANNEL_14_REG
Kojto 158:b23ee177fd68 2971 * @arg @ref LL_ADC_AWD_CHANNEL_15_REG
Kojto 158:b23ee177fd68 2972 * @arg @ref LL_ADC_AWD_CHANNEL_16_REG
Kojto 158:b23ee177fd68 2973 * @arg @ref LL_ADC_AWD_CHANNEL_17_REG
Kojto 158:b23ee177fd68 2974 * @arg @ref LL_ADC_AWD_CHANNEL_18_REG
Kojto 158:b23ee177fd68 2975 */
Kojto 158:b23ee177fd68 2976 __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 2977 {
Kojto 158:b23ee177fd68 2978 register uint32_t AWDChannelGroup = READ_BIT(ADCx->CFGR1, (ADC_CFGR1_AWDCH | ADC_CFGR1_AWDSGL | ADC_CFGR1_AWDEN));
Kojto 158:b23ee177fd68 2979
Kojto 158:b23ee177fd68 2980 /* Note: Set variable according to channel definition including channel ID */
Kojto 158:b23ee177fd68 2981 /* with bitfield. */
Kojto 158:b23ee177fd68 2982 register uint32_t AWDChannelSingle = ((AWDChannelGroup & ADC_CFGR1_AWDSGL) >> ADC_CFGR1_AWDSGL_BITOFFSET_POS);
Kojto 158:b23ee177fd68 2983 register uint32_t AWDChannelBitField = (ADC_CHANNEL_0_BITFIELD << ((AWDChannelGroup & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS));
Kojto 158:b23ee177fd68 2984
Kojto 158:b23ee177fd68 2985 return (AWDChannelGroup | (AWDChannelBitField * AWDChannelSingle));
Kojto 158:b23ee177fd68 2986 }
Kojto 158:b23ee177fd68 2987
Kojto 158:b23ee177fd68 2988 /**
Kojto 158:b23ee177fd68 2989 * @brief Set ADC analog watchdog thresholds value of both thresholds
Kojto 158:b23ee177fd68 2990 * high and low.
Kojto 158:b23ee177fd68 2991 * @note If value of only one threshold high or low must be set,
Kojto 158:b23ee177fd68 2992 * use function @ref LL_ADC_SetAnalogWDThresholds().
Kojto 158:b23ee177fd68 2993 * @note In case of ADC resolution different of 12 bits,
Kojto 158:b23ee177fd68 2994 * analog watchdog thresholds data require a specific shift.
Kojto 158:b23ee177fd68 2995 * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
Kojto 158:b23ee177fd68 2996 * @note On this STM32 serie, there is only 1 kind of analog watchdog
Kojto 158:b23ee177fd68 2997 * instance:
Kojto 158:b23ee177fd68 2998 * - AWD standard (instance AWD1):
Kojto 158:b23ee177fd68 2999 * - channels monitored: can monitor 1 channel or all channels.
Kojto 158:b23ee177fd68 3000 * - groups monitored: ADC group regular.
Kojto 158:b23ee177fd68 3001 * - resolution: resolution is not limited (corresponds to
Kojto 158:b23ee177fd68 3002 * ADC resolution configured).
Kojto 158:b23ee177fd68 3003 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 3004 * ADC state:
Kojto 158:b23ee177fd68 3005 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 3006 * on group regular.
Kojto 158:b23ee177fd68 3007 * @rmtoll TR HT LL_ADC_ConfigAnalogWDThresholds\n
Kojto 158:b23ee177fd68 3008 * TR LT LL_ADC_ConfigAnalogWDThresholds
Kojto 158:b23ee177fd68 3009 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3010 * @param AWDThresholdHighValue Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 3011 * @param AWDThresholdLowValue Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 3012 * @retval None
Kojto 158:b23ee177fd68 3013 */
Kojto 158:b23ee177fd68 3014 __STATIC_INLINE void LL_ADC_ConfigAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdHighValue, uint32_t AWDThresholdLowValue)
Kojto 158:b23ee177fd68 3015 {
Kojto 158:b23ee177fd68 3016 MODIFY_REG(ADCx->TR,
Kojto 158:b23ee177fd68 3017 ADC_TR_HT | ADC_TR_LT,
Kojto 158:b23ee177fd68 3018 (AWDThresholdHighValue << ADC_TR_HT_BITOFFSET_POS) | AWDThresholdLowValue);
Kojto 158:b23ee177fd68 3019 }
Kojto 158:b23ee177fd68 3020
Kojto 158:b23ee177fd68 3021 /**
Kojto 158:b23ee177fd68 3022 * @brief Set ADC analog watchdog threshold value of threshold
Kojto 158:b23ee177fd68 3023 * high or low.
Kojto 158:b23ee177fd68 3024 * @note If values of both thresholds high or low must be set,
Kojto 158:b23ee177fd68 3025 * use function @ref LL_ADC_ConfigAnalogWDThresholds().
Kojto 158:b23ee177fd68 3026 * @note In case of ADC resolution different of 12 bits,
Kojto 158:b23ee177fd68 3027 * analog watchdog thresholds data require a specific shift.
Kojto 158:b23ee177fd68 3028 * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
Kojto 158:b23ee177fd68 3029 * @note On this STM32 serie, there is only 1 kind of analog watchdog
Kojto 158:b23ee177fd68 3030 * instance:
Kojto 158:b23ee177fd68 3031 * - AWD standard (instance AWD1):
Kojto 158:b23ee177fd68 3032 * - channels monitored: can monitor 1 channel or all channels.
Kojto 158:b23ee177fd68 3033 * - groups monitored: ADC group regular.
Kojto 158:b23ee177fd68 3034 * - resolution: resolution is not limited (corresponds to
Kojto 158:b23ee177fd68 3035 * ADC resolution configured).
Kojto 158:b23ee177fd68 3036 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 3037 * ADC state:
Kojto 158:b23ee177fd68 3038 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 3039 * on group regular.
Kojto 158:b23ee177fd68 3040 * @rmtoll TR HT LL_ADC_SetAnalogWDThresholds\n
Kojto 158:b23ee177fd68 3041 * TR LT LL_ADC_SetAnalogWDThresholds
Kojto 158:b23ee177fd68 3042 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3043 * @param AWDThresholdsHighLow This parameter can be one of the following values:
Kojto 158:b23ee177fd68 3044 * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
Kojto 158:b23ee177fd68 3045 * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
Kojto 158:b23ee177fd68 3046 * @param AWDThresholdValue: Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 3047 * @retval None
Kojto 158:b23ee177fd68 3048 */
Kojto 158:b23ee177fd68 3049 __STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue)
Kojto 158:b23ee177fd68 3050 {
Kojto 158:b23ee177fd68 3051 /* Parameter "AWDThresholdsHighLow" is used with mask "0x00000010" */
Kojto 158:b23ee177fd68 3052 /* to be equivalent to "POSITION_VAL(AWDThresholdsHighLow)": if threshold */
Kojto 158:b23ee177fd68 3053 /* high is selected, then data is shifted to LSB. Else(threshold low), */
Kojto 158:b23ee177fd68 3054 /* data is not shifted. */
Kojto 158:b23ee177fd68 3055 MODIFY_REG(ADCx->TR,
Kojto 158:b23ee177fd68 3056 AWDThresholdsHighLow,
Kojto 158:b23ee177fd68 3057 AWDThresholdValue << ((AWDThresholdsHighLow >> ADC_TR_HT_BITOFFSET_POS) & ((uint32_t)0x00000010U)));
Kojto 158:b23ee177fd68 3058 }
Kojto 158:b23ee177fd68 3059
Kojto 158:b23ee177fd68 3060 /**
Kojto 158:b23ee177fd68 3061 * @brief Get ADC analog watchdog threshold value of threshold high,
Kojto 158:b23ee177fd68 3062 * threshold low or raw data with ADC thresholds high and low
Kojto 158:b23ee177fd68 3063 * concatenated.
Kojto 158:b23ee177fd68 3064 * @note If raw data with ADC thresholds high and low is retrieved,
Kojto 158:b23ee177fd68 3065 * the data of each threshold high or low can be isolated
Kojto 158:b23ee177fd68 3066 * using helper macro:
Kojto 158:b23ee177fd68 3067 * @ref __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW().
Kojto 158:b23ee177fd68 3068 * @note In case of ADC resolution different of 12 bits,
Kojto 158:b23ee177fd68 3069 * analog watchdog thresholds data require a specific shift.
Kojto 158:b23ee177fd68 3070 * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
Kojto 158:b23ee177fd68 3071 * @rmtoll TR HT LL_ADC_GetAnalogWDThresholds\n
Kojto 158:b23ee177fd68 3072 * TR LT LL_ADC_GetAnalogWDThresholds
Kojto 158:b23ee177fd68 3073 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3074 * @param AWDThresholdsHighLow This parameter can be one of the following values:
Kojto 158:b23ee177fd68 3075 * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
Kojto 158:b23ee177fd68 3076 * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
Kojto 158:b23ee177fd68 3077 * @arg @ref LL_ADC_AWD_THRESHOLDS_HIGH_LOW
Kojto 158:b23ee177fd68 3078 * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 3079 */
Kojto 158:b23ee177fd68 3080 __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow)
Kojto 158:b23ee177fd68 3081 {
Kojto 158:b23ee177fd68 3082 /* Parameter "AWDThresholdsHighLow" is used with mask "0x00000010" */
Kojto 158:b23ee177fd68 3083 /* to be equivalent to "POSITION_VAL(AWDThresholdsHighLow)": if threshold */
Kojto 158:b23ee177fd68 3084 /* high is selected, then data is shifted to LSB. Else(threshold low or */
Kojto 158:b23ee177fd68 3085 /* both thresholds), data is not shifted. */
Kojto 158:b23ee177fd68 3086 return (uint32_t)(READ_BIT(ADCx->TR,
Kojto 158:b23ee177fd68 3087 (AWDThresholdsHighLow | ADC_TR_LT))
Kojto 158:b23ee177fd68 3088 >> ((~AWDThresholdsHighLow) & ((uint32_t)0x00000010U))
Kojto 158:b23ee177fd68 3089 );
Kojto 158:b23ee177fd68 3090 }
Kojto 158:b23ee177fd68 3091
Kojto 158:b23ee177fd68 3092 /**
Kojto 158:b23ee177fd68 3093 * @}
Kojto 158:b23ee177fd68 3094 */
Kojto 158:b23ee177fd68 3095
Kojto 158:b23ee177fd68 3096 /** @defgroup ADC_LL_EF_Configuration_ADC_oversampling Configuration of ADC transversal scope: oversampling
Kojto 158:b23ee177fd68 3097 * @{
Kojto 158:b23ee177fd68 3098 */
Kojto 158:b23ee177fd68 3099
Kojto 158:b23ee177fd68 3100 /**
Kojto 158:b23ee177fd68 3101 * @brief Set ADC oversampling scope.
Kojto 158:b23ee177fd68 3102 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 3103 * ADC state:
Kojto 158:b23ee177fd68 3104 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 3105 * on group regular.
Kojto 158:b23ee177fd68 3106 * @rmtoll CFGR2 OVSE LL_ADC_SetOverSamplingScope
Kojto 158:b23ee177fd68 3107 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3108 * @param OvsScope This parameter can be one of the following values:
Kojto 158:b23ee177fd68 3109 * @arg @ref LL_ADC_OVS_DISABLE
Kojto 158:b23ee177fd68 3110 * @arg @ref LL_ADC_OVS_GRP_REGULAR_CONTINUED
Kojto 158:b23ee177fd68 3111 * @retval None
Kojto 158:b23ee177fd68 3112 */
Kojto 158:b23ee177fd68 3113 __STATIC_INLINE void LL_ADC_SetOverSamplingScope(ADC_TypeDef *ADCx, uint32_t OvsScope)
Kojto 158:b23ee177fd68 3114 {
Kojto 158:b23ee177fd68 3115 MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_OVSE, OvsScope);
Kojto 158:b23ee177fd68 3116 }
Kojto 158:b23ee177fd68 3117
Kojto 158:b23ee177fd68 3118 /**
Kojto 158:b23ee177fd68 3119 * @brief Get ADC oversampling scope.
Kojto 158:b23ee177fd68 3120 * @rmtoll CFGR2 OVSE LL_ADC_GetOverSamplingScope
Kojto 158:b23ee177fd68 3121 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3122 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 3123 * @arg @ref LL_ADC_OVS_DISABLE
Kojto 158:b23ee177fd68 3124 * @arg @ref LL_ADC_OVS_GRP_REGULAR_CONTINUED
Kojto 158:b23ee177fd68 3125 */
Kojto 158:b23ee177fd68 3126 __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingScope(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3127 {
Kojto 158:b23ee177fd68 3128 return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_OVSE));
Kojto 158:b23ee177fd68 3129 }
Kojto 158:b23ee177fd68 3130
Kojto 158:b23ee177fd68 3131 /**
Kojto 158:b23ee177fd68 3132 * @brief Set ADC oversampling discontinuous mode (triggered mode)
Kojto 158:b23ee177fd68 3133 * on the selected ADC group.
Kojto 158:b23ee177fd68 3134 * @note Number of oversampled conversions are done either in:
Kojto 158:b23ee177fd68 3135 * - continuous mode (all conversions of oversampling ratio
Kojto 158:b23ee177fd68 3136 * are done from 1 trigger)
Kojto 158:b23ee177fd68 3137 * - discontinuous mode (each conversion of oversampling ratio
Kojto 158:b23ee177fd68 3138 * needs a trigger)
Kojto 158:b23ee177fd68 3139 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 3140 * ADC state:
Kojto 158:b23ee177fd68 3141 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 3142 * on group regular.
Kojto 158:b23ee177fd68 3143 * @rmtoll CFGR2 TOVS LL_ADC_SetOverSamplingDiscont
Kojto 158:b23ee177fd68 3144 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3145 * @param OverSamplingDiscont This parameter can be one of the following values:
Kojto 158:b23ee177fd68 3146 * @arg @ref LL_ADC_OVS_REG_CONT
Kojto 158:b23ee177fd68 3147 * @arg @ref LL_ADC_OVS_REG_DISCONT
Kojto 158:b23ee177fd68 3148 * @retval None
Kojto 158:b23ee177fd68 3149 */
Kojto 158:b23ee177fd68 3150 __STATIC_INLINE void LL_ADC_SetOverSamplingDiscont(ADC_TypeDef *ADCx, uint32_t OverSamplingDiscont)
Kojto 158:b23ee177fd68 3151 {
Kojto 158:b23ee177fd68 3152 MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_TOVS, OverSamplingDiscont);
Kojto 158:b23ee177fd68 3153 }
Kojto 158:b23ee177fd68 3154
Kojto 158:b23ee177fd68 3155 /**
Kojto 158:b23ee177fd68 3156 * @brief Get ADC oversampling discontinuous mode (triggered mode)
Kojto 158:b23ee177fd68 3157 * on the selected ADC group.
Kojto 158:b23ee177fd68 3158 * @note Number of oversampled conversions are done either in:
Kojto 158:b23ee177fd68 3159 * - continuous mode (all conversions of oversampling ratio
Kojto 158:b23ee177fd68 3160 * are done from 1 trigger)
Kojto 158:b23ee177fd68 3161 * - discontinuous mode (each conversion of oversampling ratio
Kojto 158:b23ee177fd68 3162 * needs a trigger)
Kojto 158:b23ee177fd68 3163 * @rmtoll CFGR2 TOVS LL_ADC_GetOverSamplingDiscont
Kojto 158:b23ee177fd68 3164 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3165 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 3166 * @arg @ref LL_ADC_OVS_REG_CONT
Kojto 158:b23ee177fd68 3167 * @arg @ref LL_ADC_OVS_REG_DISCONT
Kojto 158:b23ee177fd68 3168 */
Kojto 158:b23ee177fd68 3169 __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingDiscont(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3170 {
Kojto 158:b23ee177fd68 3171 return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_TOVS));
Kojto 158:b23ee177fd68 3172 }
Kojto 158:b23ee177fd68 3173
Kojto 158:b23ee177fd68 3174 /**
Kojto 158:b23ee177fd68 3175 * @brief Set ADC oversampling
Kojto 158:b23ee177fd68 3176 * @note This function set the 2 items of oversampling configuration:
Kojto 158:b23ee177fd68 3177 * - ratio
Kojto 158:b23ee177fd68 3178 * - shift
Kojto 158:b23ee177fd68 3179 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 3180 * ADC state:
Kojto 158:b23ee177fd68 3181 * ADC must be disabled or enabled without conversion on going
Kojto 158:b23ee177fd68 3182 * on group regular.
Kojto 158:b23ee177fd68 3183 * @rmtoll CFGR2 OVSS LL_ADC_ConfigOverSamplingRatioShift\n
Kojto 158:b23ee177fd68 3184 * CFGR2 OVSR LL_ADC_ConfigOverSamplingRatioShift
Kojto 158:b23ee177fd68 3185 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3186 * @param Ratio This parameter can be one of the following values:
Kojto 158:b23ee177fd68 3187 * @arg @ref LL_ADC_OVS_RATIO_2
Kojto 158:b23ee177fd68 3188 * @arg @ref LL_ADC_OVS_RATIO_4
Kojto 158:b23ee177fd68 3189 * @arg @ref LL_ADC_OVS_RATIO_8
Kojto 158:b23ee177fd68 3190 * @arg @ref LL_ADC_OVS_RATIO_16
Kojto 158:b23ee177fd68 3191 * @arg @ref LL_ADC_OVS_RATIO_32
Kojto 158:b23ee177fd68 3192 * @arg @ref LL_ADC_OVS_RATIO_64
Kojto 158:b23ee177fd68 3193 * @arg @ref LL_ADC_OVS_RATIO_128
Kojto 158:b23ee177fd68 3194 * @arg @ref LL_ADC_OVS_RATIO_256
Kojto 158:b23ee177fd68 3195 * @param Shift This parameter can be one of the following values:
Kojto 158:b23ee177fd68 3196 * @arg @ref LL_ADC_OVS_SHIFT_NONE
Kojto 158:b23ee177fd68 3197 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_1
Kojto 158:b23ee177fd68 3198 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_2
Kojto 158:b23ee177fd68 3199 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_3
Kojto 158:b23ee177fd68 3200 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_4
Kojto 158:b23ee177fd68 3201 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_5
Kojto 158:b23ee177fd68 3202 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_6
Kojto 158:b23ee177fd68 3203 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_7
Kojto 158:b23ee177fd68 3204 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_8
Kojto 158:b23ee177fd68 3205 * @retval None
Kojto 158:b23ee177fd68 3206 */
Kojto 158:b23ee177fd68 3207 __STATIC_INLINE void LL_ADC_ConfigOverSamplingRatioShift(ADC_TypeDef *ADCx, uint32_t Ratio, uint32_t Shift)
Kojto 158:b23ee177fd68 3208 {
Kojto 158:b23ee177fd68 3209 MODIFY_REG(ADCx->CFGR2, (ADC_CFGR2_OVSS | ADC_CFGR2_OVSR), (Shift | Ratio));
Kojto 158:b23ee177fd68 3210 }
Kojto 158:b23ee177fd68 3211
Kojto 158:b23ee177fd68 3212 /**
Kojto 158:b23ee177fd68 3213 * @brief Get ADC oversampling ratio
Kojto 158:b23ee177fd68 3214 * @rmtoll CFGR2 OVSR LL_ADC_GetOverSamplingRatio
Kojto 158:b23ee177fd68 3215 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3216 * @retval Ratio This parameter can be one of the following values:
Kojto 158:b23ee177fd68 3217 * @arg @ref LL_ADC_OVS_RATIO_2
Kojto 158:b23ee177fd68 3218 * @arg @ref LL_ADC_OVS_RATIO_4
Kojto 158:b23ee177fd68 3219 * @arg @ref LL_ADC_OVS_RATIO_8
Kojto 158:b23ee177fd68 3220 * @arg @ref LL_ADC_OVS_RATIO_16
Kojto 158:b23ee177fd68 3221 * @arg @ref LL_ADC_OVS_RATIO_32
Kojto 158:b23ee177fd68 3222 * @arg @ref LL_ADC_OVS_RATIO_64
Kojto 158:b23ee177fd68 3223 * @arg @ref LL_ADC_OVS_RATIO_128
Kojto 158:b23ee177fd68 3224 * @arg @ref LL_ADC_OVS_RATIO_256
Kojto 158:b23ee177fd68 3225 */
Kojto 158:b23ee177fd68 3226 __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingRatio(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3227 {
Kojto 158:b23ee177fd68 3228 return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_OVSR));
Kojto 158:b23ee177fd68 3229 }
Kojto 158:b23ee177fd68 3230
Kojto 158:b23ee177fd68 3231 /**
Kojto 158:b23ee177fd68 3232 * @brief Get ADC oversampling shift
Kojto 158:b23ee177fd68 3233 * @rmtoll CFGR2 OVSS LL_ADC_GetOverSamplingShift
Kojto 158:b23ee177fd68 3234 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3235 * @retval Shift This parameter can be one of the following values:
Kojto 158:b23ee177fd68 3236 * @arg @ref LL_ADC_OVS_SHIFT_NONE
Kojto 158:b23ee177fd68 3237 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_1
Kojto 158:b23ee177fd68 3238 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_2
Kojto 158:b23ee177fd68 3239 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_3
Kojto 158:b23ee177fd68 3240 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_4
Kojto 158:b23ee177fd68 3241 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_5
Kojto 158:b23ee177fd68 3242 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_6
Kojto 158:b23ee177fd68 3243 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_7
Kojto 158:b23ee177fd68 3244 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_8
Kojto 158:b23ee177fd68 3245 */
Kojto 158:b23ee177fd68 3246 __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingShift(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3247 {
Kojto 158:b23ee177fd68 3248 return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_OVSS));
Kojto 158:b23ee177fd68 3249 }
Kojto 158:b23ee177fd68 3250
Kojto 158:b23ee177fd68 3251 /**
Kojto 158:b23ee177fd68 3252 * @}
Kojto 158:b23ee177fd68 3253 */
Kojto 158:b23ee177fd68 3254
Kojto 158:b23ee177fd68 3255 /** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
Kojto 158:b23ee177fd68 3256 * @{
Kojto 158:b23ee177fd68 3257 */
Kojto 158:b23ee177fd68 3258
Kojto 158:b23ee177fd68 3259 /**
Kojto 158:b23ee177fd68 3260 * @brief Enable ADC instance internal voltage regulator.
Kojto 158:b23ee177fd68 3261 * @note On this STM32 serie, there are three possibilities to enable
Kojto 158:b23ee177fd68 3262 * the voltage regulator:
Kojto 158:b23ee177fd68 3263 * - by enabling it manually
Anna Bridge 186:707f6e361f3e 3264 * using function @ref LL_ADC_EnableInternalRegulator().
Kojto 158:b23ee177fd68 3265 * - by launching a calibration
Kojto 158:b23ee177fd68 3266 * using function @ref LL_ADC_StartCalibration().
Kojto 158:b23ee177fd68 3267 * - by enabling the ADC
Kojto 158:b23ee177fd68 3268 * using function @ref LL_ADC_Enable().
Kojto 158:b23ee177fd68 3269 * @note On this STM32 serie, after ADC internal voltage regulator enable,
Kojto 158:b23ee177fd68 3270 * a delay for ADC internal voltage regulator stabilization
Kojto 158:b23ee177fd68 3271 * is required before performing a ADC calibration or ADC enable.
Anna Bridge 186:707f6e361f3e 3272 * Refer to device datasheet, parameter "tUP_LDO".
Kojto 158:b23ee177fd68 3273 * Refer to literal @ref LL_ADC_DELAY_INTERNAL_REGUL_STAB_US.
Kojto 158:b23ee177fd68 3274 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 3275 * ADC state:
Kojto 158:b23ee177fd68 3276 * ADC must be ADC disabled.
Kojto 158:b23ee177fd68 3277 * @rmtoll CR ADVREGEN LL_ADC_EnableInternalRegulator
Kojto 158:b23ee177fd68 3278 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3279 * @retval None
Kojto 158:b23ee177fd68 3280 */
Kojto 158:b23ee177fd68 3281 __STATIC_INLINE void LL_ADC_EnableInternalRegulator(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3282 {
Kojto 158:b23ee177fd68 3283 /* Note: Write register with some additional bits forced to state reset */
Kojto 158:b23ee177fd68 3284 /* instead of modifying only the selected bit for this function, */
Kojto 158:b23ee177fd68 3285 /* to not interfere with bits with HW property "rs". */
Kojto 158:b23ee177fd68 3286 MODIFY_REG(ADCx->CR,
Kojto 158:b23ee177fd68 3287 ADC_CR_BITS_PROPERTY_RS,
Kojto 158:b23ee177fd68 3288 ADC_CR_ADVREGEN);
Kojto 158:b23ee177fd68 3289 }
Kojto 158:b23ee177fd68 3290
Kojto 158:b23ee177fd68 3291 /**
Kojto 158:b23ee177fd68 3292 * @brief Disable ADC internal voltage regulator.
Kojto 158:b23ee177fd68 3293 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 3294 * ADC state:
Kojto 158:b23ee177fd68 3295 * ADC must be ADC disabled.
Kojto 158:b23ee177fd68 3296 * @rmtoll CR ADVREGEN LL_ADC_DisableInternalRegulator
Kojto 158:b23ee177fd68 3297 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3298 * @retval None
Kojto 158:b23ee177fd68 3299 */
Kojto 158:b23ee177fd68 3300 __STATIC_INLINE void LL_ADC_DisableInternalRegulator(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3301 {
Kojto 158:b23ee177fd68 3302 CLEAR_BIT(ADCx->CR, (ADC_CR_ADVREGEN | ADC_CR_BITS_PROPERTY_RS));
Kojto 158:b23ee177fd68 3303 }
Kojto 158:b23ee177fd68 3304
Kojto 158:b23ee177fd68 3305 /**
Kojto 158:b23ee177fd68 3306 * @brief Get the selected ADC instance internal voltage regulator state.
Kojto 158:b23ee177fd68 3307 * @rmtoll CR ADVREGEN LL_ADC_IsInternalRegulatorEnabled
Kojto 158:b23ee177fd68 3308 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3309 * @retval 0: internal regulator is disabled, 1: internal regulator is enabled.
Kojto 158:b23ee177fd68 3310 */
Kojto 158:b23ee177fd68 3311 __STATIC_INLINE uint32_t LL_ADC_IsInternalRegulatorEnabled(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3312 {
Kojto 158:b23ee177fd68 3313 return (READ_BIT(ADCx->CR, ADC_CR_ADVREGEN) == (ADC_CR_ADVREGEN));
Kojto 158:b23ee177fd68 3314 }
Kojto 158:b23ee177fd68 3315
Kojto 158:b23ee177fd68 3316 /**
Kojto 158:b23ee177fd68 3317 * @brief Enable the selected ADC instance.
Kojto 158:b23ee177fd68 3318 * @note On this STM32 serie, after ADC enable, a delay for
Kojto 158:b23ee177fd68 3319 * ADC internal analog stabilization is required before performing a
Kojto 158:b23ee177fd68 3320 * ADC conversion start.
Kojto 158:b23ee177fd68 3321 * Refer to device datasheet, parameter tSTAB.
Kojto 158:b23ee177fd68 3322 * @note On this STM32 serie, flag LL_ADC_FLAG_ADRDY is raised when the ADC
Kojto 158:b23ee177fd68 3323 * is enabled and when conversion clock is active.
Kojto 158:b23ee177fd68 3324 * (not only core clock: this ADC has a dual clock domain)
Kojto 158:b23ee177fd68 3325 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 3326 * ADC state:
Kojto 158:b23ee177fd68 3327 * ADC must be ADC disabled and ADC internal voltage regulator enabled.
Kojto 158:b23ee177fd68 3328 * @rmtoll CR ADEN LL_ADC_Enable
Kojto 158:b23ee177fd68 3329 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3330 * @retval None
Kojto 158:b23ee177fd68 3331 */
Kojto 158:b23ee177fd68 3332 __STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3333 {
Kojto 158:b23ee177fd68 3334 /* Note: Write register with some additional bits forced to state reset */
Kojto 158:b23ee177fd68 3335 /* instead of modifying only the selected bit for this function, */
Kojto 158:b23ee177fd68 3336 /* to not interfere with bits with HW property "rs". */
Kojto 158:b23ee177fd68 3337 MODIFY_REG(ADCx->CR,
Kojto 158:b23ee177fd68 3338 ADC_CR_BITS_PROPERTY_RS,
Kojto 158:b23ee177fd68 3339 ADC_CR_ADEN);
Kojto 158:b23ee177fd68 3340 }
Kojto 158:b23ee177fd68 3341
Kojto 158:b23ee177fd68 3342 /**
Kojto 158:b23ee177fd68 3343 * @brief Disable the selected ADC instance.
Kojto 158:b23ee177fd68 3344 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 3345 * ADC state:
Kojto 158:b23ee177fd68 3346 * ADC must be not disabled. Must be enabled without conversion on going
Kojto 158:b23ee177fd68 3347 * on group regular.
Kojto 158:b23ee177fd68 3348 * @rmtoll CR ADDIS LL_ADC_Disable
Kojto 158:b23ee177fd68 3349 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3350 * @retval None
Kojto 158:b23ee177fd68 3351 */
Kojto 158:b23ee177fd68 3352 __STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3353 {
Kojto 158:b23ee177fd68 3354 /* Note: Write register with some additional bits forced to state reset */
Kojto 158:b23ee177fd68 3355 /* instead of modifying only the selected bit for this function, */
Kojto 158:b23ee177fd68 3356 /* to not interfere with bits with HW property "rs". */
Kojto 158:b23ee177fd68 3357 MODIFY_REG(ADCx->CR,
Kojto 158:b23ee177fd68 3358 ADC_CR_BITS_PROPERTY_RS,
Kojto 158:b23ee177fd68 3359 ADC_CR_ADDIS);
Kojto 158:b23ee177fd68 3360 }
Kojto 158:b23ee177fd68 3361
Kojto 158:b23ee177fd68 3362 /**
Kojto 158:b23ee177fd68 3363 * @brief Get the selected ADC instance enable state.
Kojto 158:b23ee177fd68 3364 * @note On this STM32 serie, flag LL_ADC_FLAG_ADRDY is raised when the ADC
Kojto 158:b23ee177fd68 3365 * is enabled and when conversion clock is active.
Kojto 158:b23ee177fd68 3366 * (not only core clock: this ADC has a dual clock domain)
Kojto 158:b23ee177fd68 3367 * @rmtoll CR ADEN LL_ADC_IsEnabled
Kojto 158:b23ee177fd68 3368 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3369 * @retval 0: ADC is disabled, 1: ADC is enabled.
Kojto 158:b23ee177fd68 3370 */
Kojto 158:b23ee177fd68 3371 __STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3372 {
Kojto 158:b23ee177fd68 3373 return (READ_BIT(ADCx->CR, ADC_CR_ADEN) == (ADC_CR_ADEN));
Kojto 158:b23ee177fd68 3374 }
Kojto 158:b23ee177fd68 3375
Kojto 158:b23ee177fd68 3376 /**
Kojto 158:b23ee177fd68 3377 * @brief Get the selected ADC instance disable state.
Kojto 158:b23ee177fd68 3378 * @rmtoll CR ADDIS LL_ADC_IsDisableOngoing
Kojto 158:b23ee177fd68 3379 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3380 * @retval 0: no ADC disable command on going.
Kojto 158:b23ee177fd68 3381 */
Kojto 158:b23ee177fd68 3382 __STATIC_INLINE uint32_t LL_ADC_IsDisableOngoing(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3383 {
Kojto 158:b23ee177fd68 3384 return (READ_BIT(ADCx->CR, ADC_CR_ADDIS) == (ADC_CR_ADDIS));
Kojto 158:b23ee177fd68 3385 }
Kojto 158:b23ee177fd68 3386
Kojto 158:b23ee177fd68 3387 /**
Kojto 158:b23ee177fd68 3388 * @brief Start ADC calibration in the mode single-ended
Kojto 158:b23ee177fd68 3389 * or differential (for devices with differential mode available).
Kojto 158:b23ee177fd68 3390 * @note On this STM32 serie, a minimum number of ADC clock cycles
Kojto 158:b23ee177fd68 3391 * are required between ADC end of calibration and ADC enable.
Kojto 158:b23ee177fd68 3392 * Refer to literal @ref LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES.
Kojto 158:b23ee177fd68 3393 * @note In case of usage of ADC with DMA transfer:
Kojto 158:b23ee177fd68 3394 * On this STM32 serie, ADC DMA transfer request should be disabled
Kojto 158:b23ee177fd68 3395 * during calibration:
Kojto 158:b23ee177fd68 3396 * Calibration factor is available in data register
Kojto 158:b23ee177fd68 3397 * and also transfered by DMA.
Kojto 158:b23ee177fd68 3398 * To not insert ADC calibration factor among ADC conversion data
Kojto 158:b23ee177fd68 3399 * in array variable, DMA transfer must be disabled during
Kojto 158:b23ee177fd68 3400 * calibration.
Kojto 158:b23ee177fd68 3401 * (DMA transfer setting backup and disable before calibration,
Kojto 158:b23ee177fd68 3402 * DMA transfer setting restore after calibration.
Kojto 158:b23ee177fd68 3403 * Refer to functions @ref LL_ADC_REG_GetDMATransfer(),
Kojto 158:b23ee177fd68 3404 * @ref LL_ADC_REG_SetDMATransfer() ).
Kojto 158:b23ee177fd68 3405 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 3406 * ADC state:
Kojto 158:b23ee177fd68 3407 * ADC must be ADC disabled.
Kojto 158:b23ee177fd68 3408 * @rmtoll CR ADCAL LL_ADC_StartCalibration
Kojto 158:b23ee177fd68 3409 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3410 * @retval None
Kojto 158:b23ee177fd68 3411 */
Kojto 158:b23ee177fd68 3412 __STATIC_INLINE void LL_ADC_StartCalibration(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3413 {
Kojto 158:b23ee177fd68 3414 /* Note: Write register with some additional bits forced to state reset */
Kojto 158:b23ee177fd68 3415 /* instead of modifying only the selected bit for this function, */
Kojto 158:b23ee177fd68 3416 /* to not interfere with bits with HW property "rs". */
Kojto 158:b23ee177fd68 3417 MODIFY_REG(ADCx->CR,
Kojto 158:b23ee177fd68 3418 ADC_CR_BITS_PROPERTY_RS,
Kojto 158:b23ee177fd68 3419 ADC_CR_ADCAL);
Kojto 158:b23ee177fd68 3420 }
Kojto 158:b23ee177fd68 3421
Kojto 158:b23ee177fd68 3422 /**
Kojto 158:b23ee177fd68 3423 * @brief Get ADC calibration state.
Kojto 158:b23ee177fd68 3424 * @rmtoll CR ADCAL LL_ADC_IsCalibrationOnGoing
Kojto 158:b23ee177fd68 3425 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3426 * @retval 0: calibration complete, 1: calibration in progress.
Kojto 158:b23ee177fd68 3427 */
Kojto 158:b23ee177fd68 3428 __STATIC_INLINE uint32_t LL_ADC_IsCalibrationOnGoing(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3429 {
Kojto 158:b23ee177fd68 3430 return (READ_BIT(ADCx->CR, ADC_CR_ADCAL) == (ADC_CR_ADCAL));
Kojto 158:b23ee177fd68 3431 }
Kojto 158:b23ee177fd68 3432
Kojto 158:b23ee177fd68 3433 /**
Kojto 158:b23ee177fd68 3434 * @}
Kojto 158:b23ee177fd68 3435 */
Kojto 158:b23ee177fd68 3436
Kojto 158:b23ee177fd68 3437 /** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
Kojto 158:b23ee177fd68 3438 * @{
Kojto 158:b23ee177fd68 3439 */
Kojto 158:b23ee177fd68 3440
Kojto 158:b23ee177fd68 3441 /**
Kojto 158:b23ee177fd68 3442 * @brief Start ADC group regular conversion.
Kojto 158:b23ee177fd68 3443 * @note On this STM32 serie, this function is relevant for both
Kojto 158:b23ee177fd68 3444 * internal trigger (SW start) and external trigger:
Kojto 158:b23ee177fd68 3445 * - If ADC trigger has been set to software start, ADC conversion
Kojto 158:b23ee177fd68 3446 * starts immediately.
Kojto 158:b23ee177fd68 3447 * - If ADC trigger has been set to external trigger, ADC conversion
Kojto 158:b23ee177fd68 3448 * will start at next trigger event (on the selected trigger edge)
Kojto 158:b23ee177fd68 3449 * following the ADC start conversion command.
Kojto 158:b23ee177fd68 3450 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 3451 * ADC state:
Kojto 158:b23ee177fd68 3452 * ADC must be enabled without conversion on going on group regular,
Anna Bridge 186:707f6e361f3e 3453 * without conversion stop command on going on group regular,
Anna Bridge 186:707f6e361f3e 3454 * without ADC disable command on going.
Kojto 158:b23ee177fd68 3455 * @rmtoll CR ADSTART LL_ADC_REG_StartConversion
Kojto 158:b23ee177fd68 3456 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3457 * @retval None
Kojto 158:b23ee177fd68 3458 */
Kojto 158:b23ee177fd68 3459 __STATIC_INLINE void LL_ADC_REG_StartConversion(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3460 {
Kojto 158:b23ee177fd68 3461 /* Note: Write register with some additional bits forced to state reset */
Kojto 158:b23ee177fd68 3462 /* instead of modifying only the selected bit for this function, */
Kojto 158:b23ee177fd68 3463 /* to not interfere with bits with HW property "rs". */
Kojto 158:b23ee177fd68 3464 MODIFY_REG(ADCx->CR,
Kojto 158:b23ee177fd68 3465 ADC_CR_BITS_PROPERTY_RS,
Kojto 158:b23ee177fd68 3466 ADC_CR_ADSTART);
Kojto 158:b23ee177fd68 3467 }
Kojto 158:b23ee177fd68 3468
Kojto 158:b23ee177fd68 3469 /**
Kojto 158:b23ee177fd68 3470 * @brief Stop ADC group regular conversion.
Kojto 158:b23ee177fd68 3471 * @note On this STM32 serie, setting of this feature is conditioned to
Kojto 158:b23ee177fd68 3472 * ADC state:
Kojto 158:b23ee177fd68 3473 * ADC must be enabled with conversion on going on group regular,
Kojto 158:b23ee177fd68 3474 * without ADC disable command on going.
Kojto 158:b23ee177fd68 3475 * @rmtoll CR ADSTP LL_ADC_REG_StopConversion
Kojto 158:b23ee177fd68 3476 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3477 * @retval None
Kojto 158:b23ee177fd68 3478 */
Kojto 158:b23ee177fd68 3479 __STATIC_INLINE void LL_ADC_REG_StopConversion(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3480 {
Kojto 158:b23ee177fd68 3481 /* Note: Write register with some additional bits forced to state reset */
Kojto 158:b23ee177fd68 3482 /* instead of modifying only the selected bit for this function, */
Kojto 158:b23ee177fd68 3483 /* to not interfere with bits with HW property "rs". */
Kojto 158:b23ee177fd68 3484 MODIFY_REG(ADCx->CR,
Kojto 158:b23ee177fd68 3485 ADC_CR_BITS_PROPERTY_RS,
Kojto 158:b23ee177fd68 3486 ADC_CR_ADSTP);
Kojto 158:b23ee177fd68 3487 }
Kojto 158:b23ee177fd68 3488
Kojto 158:b23ee177fd68 3489 /**
Kojto 158:b23ee177fd68 3490 * @brief Get ADC group regular conversion state.
Kojto 158:b23ee177fd68 3491 * @rmtoll CR ADSTART LL_ADC_REG_IsConversionOngoing
Kojto 158:b23ee177fd68 3492 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3493 * @retval 0: no conversion is on going on ADC group regular.
Kojto 158:b23ee177fd68 3494 */
Kojto 158:b23ee177fd68 3495 __STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3496 {
Kojto 158:b23ee177fd68 3497 return (READ_BIT(ADCx->CR, ADC_CR_ADSTART) == (ADC_CR_ADSTART));
Kojto 158:b23ee177fd68 3498 }
Kojto 158:b23ee177fd68 3499
Kojto 158:b23ee177fd68 3500 /**
Kojto 158:b23ee177fd68 3501 * @brief Get ADC group regular command of conversion stop state
Kojto 158:b23ee177fd68 3502 * @rmtoll CR ADSTP LL_ADC_REG_IsStopConversionOngoing
Kojto 158:b23ee177fd68 3503 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3504 * @retval 0: no command of conversion stop is on going on ADC group regular.
Kojto 158:b23ee177fd68 3505 */
Kojto 158:b23ee177fd68 3506 __STATIC_INLINE uint32_t LL_ADC_REG_IsStopConversionOngoing(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3507 {
Kojto 158:b23ee177fd68 3508 return (READ_BIT(ADCx->CR, ADC_CR_ADSTP) == (ADC_CR_ADSTP));
Kojto 158:b23ee177fd68 3509 }
Kojto 158:b23ee177fd68 3510
Kojto 158:b23ee177fd68 3511 /**
Kojto 158:b23ee177fd68 3512 * @brief Get ADC group regular conversion data, range fit for
Kojto 158:b23ee177fd68 3513 * all ADC configurations: all ADC resolutions and
Kojto 158:b23ee177fd68 3514 * all oversampling increased data width (for devices
Kojto 158:b23ee177fd68 3515 * with feature oversampling).
Kojto 158:b23ee177fd68 3516 * @rmtoll DR DATA LL_ADC_REG_ReadConversionData32
Kojto 158:b23ee177fd68 3517 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3518 * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
Kojto 158:b23ee177fd68 3519 */
Kojto 158:b23ee177fd68 3520 __STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3521 {
Kojto 158:b23ee177fd68 3522 return (uint32_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
Kojto 158:b23ee177fd68 3523 }
Kojto 158:b23ee177fd68 3524
Kojto 158:b23ee177fd68 3525 /**
Kojto 158:b23ee177fd68 3526 * @brief Get ADC group regular conversion data, range fit for
Kojto 158:b23ee177fd68 3527 * ADC resolution 12 bits.
Kojto 158:b23ee177fd68 3528 * @note For devices with feature oversampling: Oversampling
Kojto 158:b23ee177fd68 3529 * can increase data width, function for extended range
Kojto 158:b23ee177fd68 3530 * may be needed: @ref LL_ADC_REG_ReadConversionData32.
Kojto 158:b23ee177fd68 3531 * @rmtoll DR DATA LL_ADC_REG_ReadConversionData12
Kojto 158:b23ee177fd68 3532 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3533 * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 3534 */
Kojto 158:b23ee177fd68 3535 __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3536 {
Kojto 158:b23ee177fd68 3537 return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
Kojto 158:b23ee177fd68 3538 }
Kojto 158:b23ee177fd68 3539
Kojto 158:b23ee177fd68 3540 /**
Kojto 158:b23ee177fd68 3541 * @brief Get ADC group regular conversion data, range fit for
Kojto 158:b23ee177fd68 3542 * ADC resolution 10 bits.
Kojto 158:b23ee177fd68 3543 * @note For devices with feature oversampling: Oversampling
Kojto 158:b23ee177fd68 3544 * can increase data width, function for extended range
Kojto 158:b23ee177fd68 3545 * may be needed: @ref LL_ADC_REG_ReadConversionData32.
Kojto 158:b23ee177fd68 3546 * @rmtoll DR DATA LL_ADC_REG_ReadConversionData10
Kojto 158:b23ee177fd68 3547 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3548 * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
Kojto 158:b23ee177fd68 3549 */
Kojto 158:b23ee177fd68 3550 __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData10(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3551 {
Kojto 158:b23ee177fd68 3552 return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
Kojto 158:b23ee177fd68 3553 }
Kojto 158:b23ee177fd68 3554
Kojto 158:b23ee177fd68 3555 /**
Kojto 158:b23ee177fd68 3556 * @brief Get ADC group regular conversion data, range fit for
Kojto 158:b23ee177fd68 3557 * ADC resolution 8 bits.
Kojto 158:b23ee177fd68 3558 * @note For devices with feature oversampling: Oversampling
Kojto 158:b23ee177fd68 3559 * can increase data width, function for extended range
Kojto 158:b23ee177fd68 3560 * may be needed: @ref LL_ADC_REG_ReadConversionData32.
Kojto 158:b23ee177fd68 3561 * @rmtoll DR DATA LL_ADC_REG_ReadConversionData8
Kojto 158:b23ee177fd68 3562 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3563 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 3564 */
Kojto 158:b23ee177fd68 3565 __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData8(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3566 {
Kojto 158:b23ee177fd68 3567 return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
Kojto 158:b23ee177fd68 3568 }
Kojto 158:b23ee177fd68 3569
Kojto 158:b23ee177fd68 3570 /**
Kojto 158:b23ee177fd68 3571 * @brief Get ADC group regular conversion data, range fit for
Kojto 158:b23ee177fd68 3572 * ADC resolution 6 bits.
Kojto 158:b23ee177fd68 3573 * @note For devices with feature oversampling: Oversampling
Kojto 158:b23ee177fd68 3574 * can increase data width, function for extended range
Kojto 158:b23ee177fd68 3575 * may be needed: @ref LL_ADC_REG_ReadConversionData32.
Kojto 158:b23ee177fd68 3576 * @rmtoll DR DATA LL_ADC_REG_ReadConversionData6
Kojto 158:b23ee177fd68 3577 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3578 * @retval Value between Min_Data=0x00 and Max_Data=0x3F
Kojto 158:b23ee177fd68 3579 */
Kojto 158:b23ee177fd68 3580 __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData6(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3581 {
Kojto 158:b23ee177fd68 3582 return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
Kojto 158:b23ee177fd68 3583 }
Kojto 158:b23ee177fd68 3584
Kojto 158:b23ee177fd68 3585 /**
Kojto 158:b23ee177fd68 3586 * @}
Kojto 158:b23ee177fd68 3587 */
Kojto 158:b23ee177fd68 3588
Kojto 158:b23ee177fd68 3589 /** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
Kojto 158:b23ee177fd68 3590 * @{
Kojto 158:b23ee177fd68 3591 */
Kojto 158:b23ee177fd68 3592
Kojto 158:b23ee177fd68 3593 /**
Kojto 158:b23ee177fd68 3594 * @brief Get flag ADC ready.
Kojto 158:b23ee177fd68 3595 * @note On this STM32 serie, flag LL_ADC_FLAG_ADRDY is raised when the ADC
Kojto 158:b23ee177fd68 3596 * is enabled and when conversion clock is active.
Kojto 158:b23ee177fd68 3597 * (not only core clock: this ADC has a dual clock domain)
Kojto 158:b23ee177fd68 3598 * @rmtoll ISR ADRDY LL_ADC_IsActiveFlag_ADRDY
Kojto 158:b23ee177fd68 3599 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3600 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3601 */
Kojto 158:b23ee177fd68 3602 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_ADRDY(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3603 {
Kojto 158:b23ee177fd68 3604 return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_ADRDY) == (LL_ADC_FLAG_ADRDY));
Kojto 158:b23ee177fd68 3605 }
Kojto 158:b23ee177fd68 3606
Kojto 158:b23ee177fd68 3607 /**
Kojto 158:b23ee177fd68 3608 * @brief Get flag ADC group regular end of unitary conversion.
Kojto 158:b23ee177fd68 3609 * @rmtoll ISR EOC LL_ADC_IsActiveFlag_EOC
Kojto 158:b23ee177fd68 3610 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3611 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3612 */
Kojto 158:b23ee177fd68 3613 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOC(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3614 {
Kojto 158:b23ee177fd68 3615 return (READ_BIT(ADCx->ISR, ADC_ISR_EOC) == (ADC_ISR_EOC));
Kojto 158:b23ee177fd68 3616 }
Kojto 158:b23ee177fd68 3617
Kojto 158:b23ee177fd68 3618 /**
Kojto 158:b23ee177fd68 3619 * @brief Get flag ADC group regular end of sequence conversions.
Kojto 158:b23ee177fd68 3620 * @rmtoll ISR EOSEQ LL_ADC_IsActiveFlag_EOS
Kojto 158:b23ee177fd68 3621 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3622 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3623 */
Kojto 158:b23ee177fd68 3624 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOS(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3625 {
Kojto 158:b23ee177fd68 3626 return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOS) == (LL_ADC_FLAG_EOS));
Kojto 158:b23ee177fd68 3627 }
Kojto 158:b23ee177fd68 3628
Kojto 158:b23ee177fd68 3629 /**
Kojto 158:b23ee177fd68 3630 * @brief Get flag ADC group regular overrun.
Kojto 158:b23ee177fd68 3631 * @rmtoll ISR OVR LL_ADC_IsActiveFlag_OVR
Kojto 158:b23ee177fd68 3632 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3633 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3634 */
Kojto 158:b23ee177fd68 3635 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_OVR(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3636 {
Kojto 158:b23ee177fd68 3637 return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_OVR) == (LL_ADC_FLAG_OVR));
Kojto 158:b23ee177fd68 3638 }
Kojto 158:b23ee177fd68 3639
Kojto 158:b23ee177fd68 3640 /**
Kojto 158:b23ee177fd68 3641 * @brief Get flag ADC group regular end of sampling phase.
Kojto 158:b23ee177fd68 3642 * @rmtoll ISR EOSMP LL_ADC_IsActiveFlag_EOSMP
Kojto 158:b23ee177fd68 3643 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3644 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3645 */
Kojto 158:b23ee177fd68 3646 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOSMP(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3647 {
Kojto 158:b23ee177fd68 3648 return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOSMP) == (LL_ADC_FLAG_EOSMP));
Kojto 158:b23ee177fd68 3649 }
Kojto 158:b23ee177fd68 3650
Kojto 158:b23ee177fd68 3651 /**
Kojto 158:b23ee177fd68 3652 * @brief Get flag ADC analog watchdog 1 flag
Kojto 158:b23ee177fd68 3653 * @rmtoll ISR AWD LL_ADC_IsActiveFlag_AWD1
Kojto 158:b23ee177fd68 3654 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3655 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3656 */
Kojto 158:b23ee177fd68 3657 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3658 {
Kojto 158:b23ee177fd68 3659 return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1));
Kojto 158:b23ee177fd68 3660 }
Kojto 158:b23ee177fd68 3661
Kojto 158:b23ee177fd68 3662 /**
Kojto 158:b23ee177fd68 3663 * @brief Get flag ADC end of calibration.
Kojto 158:b23ee177fd68 3664 * @rmtoll ISR EOCAL LL_ADC_IsActiveFlag_EOCAL
Kojto 158:b23ee177fd68 3665 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3666 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3667 */
Kojto 158:b23ee177fd68 3668 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOCAL(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3669 {
Kojto 158:b23ee177fd68 3670 return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOCAL) == (LL_ADC_FLAG_EOCAL));
Kojto 158:b23ee177fd68 3671 }
Kojto 158:b23ee177fd68 3672
Kojto 158:b23ee177fd68 3673 /**
Kojto 158:b23ee177fd68 3674 * @brief Clear flag ADC ready.
Kojto 158:b23ee177fd68 3675 * @note On this STM32 serie, flag LL_ADC_FLAG_ADRDY is raised when the ADC
Kojto 158:b23ee177fd68 3676 * is enabled and when conversion clock is active.
Kojto 158:b23ee177fd68 3677 * (not only core clock: this ADC has a dual clock domain)
Kojto 158:b23ee177fd68 3678 * @rmtoll ISR ADRDY LL_ADC_ClearFlag_ADRDY
Kojto 158:b23ee177fd68 3679 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3680 * @retval None
Kojto 158:b23ee177fd68 3681 */
Kojto 158:b23ee177fd68 3682 __STATIC_INLINE void LL_ADC_ClearFlag_ADRDY(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3683 {
Kojto 158:b23ee177fd68 3684 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_ADRDY);
Kojto 158:b23ee177fd68 3685 }
Kojto 158:b23ee177fd68 3686
Kojto 158:b23ee177fd68 3687 /**
Kojto 158:b23ee177fd68 3688 * @brief Clear flag ADC group regular end of unitary conversion.
Kojto 158:b23ee177fd68 3689 * @rmtoll ISR EOC LL_ADC_ClearFlag_EOC
Kojto 158:b23ee177fd68 3690 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3691 * @retval None
Kojto 158:b23ee177fd68 3692 */
Kojto 158:b23ee177fd68 3693 __STATIC_INLINE void LL_ADC_ClearFlag_EOC(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3694 {
Kojto 158:b23ee177fd68 3695 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOC);
Kojto 158:b23ee177fd68 3696 }
Kojto 158:b23ee177fd68 3697
Kojto 158:b23ee177fd68 3698 /**
Kojto 158:b23ee177fd68 3699 * @brief Clear flag ADC group regular end of sequence conversions.
Kojto 158:b23ee177fd68 3700 * @rmtoll ISR EOSEQ LL_ADC_ClearFlag_EOS
Kojto 158:b23ee177fd68 3701 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3702 * @retval None
Kojto 158:b23ee177fd68 3703 */
Kojto 158:b23ee177fd68 3704 __STATIC_INLINE void LL_ADC_ClearFlag_EOS(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3705 {
Kojto 158:b23ee177fd68 3706 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOS);
Kojto 158:b23ee177fd68 3707 }
Kojto 158:b23ee177fd68 3708
Kojto 158:b23ee177fd68 3709 /**
Kojto 158:b23ee177fd68 3710 * @brief Clear flag ADC group regular overrun.
Kojto 158:b23ee177fd68 3711 * @rmtoll ISR OVR LL_ADC_ClearFlag_OVR
Kojto 158:b23ee177fd68 3712 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3713 * @retval None
Kojto 158:b23ee177fd68 3714 */
Kojto 158:b23ee177fd68 3715 __STATIC_INLINE void LL_ADC_ClearFlag_OVR(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3716 {
Kojto 158:b23ee177fd68 3717 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_OVR);
Kojto 158:b23ee177fd68 3718 }
Kojto 158:b23ee177fd68 3719
Kojto 158:b23ee177fd68 3720 /**
Kojto 158:b23ee177fd68 3721 * @brief Clear flag ADC group regular end of sampling phase.
Kojto 158:b23ee177fd68 3722 * @rmtoll ISR EOSMP LL_ADC_ClearFlag_EOSMP
Kojto 158:b23ee177fd68 3723 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3724 * @retval None
Kojto 158:b23ee177fd68 3725 */
Kojto 158:b23ee177fd68 3726 __STATIC_INLINE void LL_ADC_ClearFlag_EOSMP(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3727 {
Kojto 158:b23ee177fd68 3728 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOSMP);
Kojto 158:b23ee177fd68 3729 }
Kojto 158:b23ee177fd68 3730
Kojto 158:b23ee177fd68 3731 /**
Kojto 158:b23ee177fd68 3732 * @brief Clear flag ADC analog watchdog 1.
Kojto 158:b23ee177fd68 3733 * @rmtoll ISR AWD LL_ADC_ClearFlag_AWD1
Kojto 158:b23ee177fd68 3734 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3735 * @retval None
Kojto 158:b23ee177fd68 3736 */
Kojto 158:b23ee177fd68 3737 __STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3738 {
Kojto 158:b23ee177fd68 3739 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD1);
Kojto 158:b23ee177fd68 3740 }
Kojto 158:b23ee177fd68 3741
Kojto 158:b23ee177fd68 3742 /**
Kojto 158:b23ee177fd68 3743 * @brief Clear flag ADC end of calibration.
Kojto 158:b23ee177fd68 3744 * @rmtoll ISR EOCAL LL_ADC_ClearFlag_EOCAL
Kojto 158:b23ee177fd68 3745 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3746 * @retval None
Kojto 158:b23ee177fd68 3747 */
Kojto 158:b23ee177fd68 3748 __STATIC_INLINE void LL_ADC_ClearFlag_EOCAL(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3749 {
Kojto 158:b23ee177fd68 3750 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOCAL);
Kojto 158:b23ee177fd68 3751 }
Kojto 158:b23ee177fd68 3752
Kojto 158:b23ee177fd68 3753 /**
Kojto 158:b23ee177fd68 3754 * @}
Kojto 158:b23ee177fd68 3755 */
Kojto 158:b23ee177fd68 3756
Kojto 158:b23ee177fd68 3757 /** @defgroup ADC_LL_EF_IT_Management ADC IT management
Kojto 158:b23ee177fd68 3758 * @{
Kojto 158:b23ee177fd68 3759 */
Kojto 158:b23ee177fd68 3760
Kojto 158:b23ee177fd68 3761 /**
Kojto 158:b23ee177fd68 3762 * @brief Enable ADC ready.
Kojto 158:b23ee177fd68 3763 * @rmtoll IER ADRDYIE LL_ADC_EnableIT_ADRDY
Kojto 158:b23ee177fd68 3764 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3765 * @retval None
Kojto 158:b23ee177fd68 3766 */
Kojto 158:b23ee177fd68 3767 __STATIC_INLINE void LL_ADC_EnableIT_ADRDY(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3768 {
Kojto 158:b23ee177fd68 3769 SET_BIT(ADCx->IER, LL_ADC_IT_ADRDY);
Kojto 158:b23ee177fd68 3770 }
Kojto 158:b23ee177fd68 3771
Kojto 158:b23ee177fd68 3772 /**
Kojto 158:b23ee177fd68 3773 * @brief Enable interruption ADC group regular end of unitary conversion.
Kojto 158:b23ee177fd68 3774 * @rmtoll IER EOCIE LL_ADC_EnableIT_EOC
Kojto 158:b23ee177fd68 3775 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3776 * @retval None
Kojto 158:b23ee177fd68 3777 */
Kojto 158:b23ee177fd68 3778 __STATIC_INLINE void LL_ADC_EnableIT_EOC(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3779 {
Kojto 158:b23ee177fd68 3780 SET_BIT(ADCx->IER, LL_ADC_IT_EOC);
Kojto 158:b23ee177fd68 3781 }
Kojto 158:b23ee177fd68 3782
Kojto 158:b23ee177fd68 3783 /**
Kojto 158:b23ee177fd68 3784 * @brief Enable interruption ADC group regular end of sequence conversions.
Kojto 158:b23ee177fd68 3785 * @rmtoll IER EOSEQIE LL_ADC_EnableIT_EOS
Kojto 158:b23ee177fd68 3786 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3787 * @retval None
Kojto 158:b23ee177fd68 3788 */
Kojto 158:b23ee177fd68 3789 __STATIC_INLINE void LL_ADC_EnableIT_EOS(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3790 {
Kojto 158:b23ee177fd68 3791 SET_BIT(ADCx->IER, LL_ADC_IT_EOS);
Kojto 158:b23ee177fd68 3792 }
Kojto 158:b23ee177fd68 3793
Kojto 158:b23ee177fd68 3794 /**
Kojto 158:b23ee177fd68 3795 * @brief Enable ADC group regular interruption overrun.
Kojto 158:b23ee177fd68 3796 * @rmtoll IER OVRIE LL_ADC_EnableIT_OVR
Kojto 158:b23ee177fd68 3797 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3798 * @retval None
Kojto 158:b23ee177fd68 3799 */
Kojto 158:b23ee177fd68 3800 __STATIC_INLINE void LL_ADC_EnableIT_OVR(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3801 {
Kojto 158:b23ee177fd68 3802 SET_BIT(ADCx->IER, LL_ADC_IT_OVR);
Kojto 158:b23ee177fd68 3803 }
Kojto 158:b23ee177fd68 3804
Kojto 158:b23ee177fd68 3805 /**
Kojto 158:b23ee177fd68 3806 * @brief Enable interruption ADC group regular end of sampling.
Kojto 158:b23ee177fd68 3807 * @rmtoll IER EOSMPIE LL_ADC_EnableIT_EOSMP
Kojto 158:b23ee177fd68 3808 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3809 * @retval None
Kojto 158:b23ee177fd68 3810 */
Kojto 158:b23ee177fd68 3811 __STATIC_INLINE void LL_ADC_EnableIT_EOSMP(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3812 {
Kojto 158:b23ee177fd68 3813 SET_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
Kojto 158:b23ee177fd68 3814 }
Kojto 158:b23ee177fd68 3815
Kojto 158:b23ee177fd68 3816 /**
Kojto 158:b23ee177fd68 3817 * @brief Enable interruption ADC analog watchdog 1.
Kojto 158:b23ee177fd68 3818 * @rmtoll IER AWDIE LL_ADC_EnableIT_AWD1
Kojto 158:b23ee177fd68 3819 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3820 * @retval None
Kojto 158:b23ee177fd68 3821 */
Kojto 158:b23ee177fd68 3822 __STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3823 {
Kojto 158:b23ee177fd68 3824 SET_BIT(ADCx->IER, LL_ADC_IT_AWD1);
Kojto 158:b23ee177fd68 3825 }
Kojto 158:b23ee177fd68 3826
Kojto 158:b23ee177fd68 3827 /**
Kojto 158:b23ee177fd68 3828 * @brief Enable interruption ADC end of calibration.
Kojto 158:b23ee177fd68 3829 * @rmtoll IER EOCALIE LL_ADC_EnableIT_EOCAL
Kojto 158:b23ee177fd68 3830 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3831 * @retval None
Kojto 158:b23ee177fd68 3832 */
Kojto 158:b23ee177fd68 3833 __STATIC_INLINE void LL_ADC_EnableIT_EOCAL(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3834 {
Kojto 158:b23ee177fd68 3835 SET_BIT(ADCx->IER, LL_ADC_IT_EOCAL);
Kojto 158:b23ee177fd68 3836 }
Kojto 158:b23ee177fd68 3837
Kojto 158:b23ee177fd68 3838 /**
Kojto 158:b23ee177fd68 3839 * @brief Disable interruption ADC ready.
Kojto 158:b23ee177fd68 3840 * @rmtoll IER ADRDYIE LL_ADC_DisableIT_ADRDY
Kojto 158:b23ee177fd68 3841 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3842 * @retval None
Kojto 158:b23ee177fd68 3843 */
Kojto 158:b23ee177fd68 3844 __STATIC_INLINE void LL_ADC_DisableIT_ADRDY(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3845 {
Kojto 158:b23ee177fd68 3846 CLEAR_BIT(ADCx->IER, LL_ADC_IT_ADRDY);
Kojto 158:b23ee177fd68 3847 }
Kojto 158:b23ee177fd68 3848
Kojto 158:b23ee177fd68 3849 /**
Kojto 158:b23ee177fd68 3850 * @brief Disable interruption ADC group regular end of unitary conversion.
Kojto 158:b23ee177fd68 3851 * @rmtoll IER EOCIE LL_ADC_DisableIT_EOC
Kojto 158:b23ee177fd68 3852 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3853 * @retval None
Kojto 158:b23ee177fd68 3854 */
Kojto 158:b23ee177fd68 3855 __STATIC_INLINE void LL_ADC_DisableIT_EOC(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3856 {
Kojto 158:b23ee177fd68 3857 CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOC);
Kojto 158:b23ee177fd68 3858 }
Kojto 158:b23ee177fd68 3859
Kojto 158:b23ee177fd68 3860 /**
Kojto 158:b23ee177fd68 3861 * @brief Disable interruption ADC group regular end of sequence conversions.
Kojto 158:b23ee177fd68 3862 * @rmtoll IER EOSEQIE LL_ADC_DisableIT_EOS
Kojto 158:b23ee177fd68 3863 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3864 * @retval None
Kojto 158:b23ee177fd68 3865 */
Kojto 158:b23ee177fd68 3866 __STATIC_INLINE void LL_ADC_DisableIT_EOS(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3867 {
Kojto 158:b23ee177fd68 3868 CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOS);
Kojto 158:b23ee177fd68 3869 }
Kojto 158:b23ee177fd68 3870
Kojto 158:b23ee177fd68 3871 /**
Kojto 158:b23ee177fd68 3872 * @brief Disable interruption ADC group regular overrun.
Kojto 158:b23ee177fd68 3873 * @rmtoll IER OVRIE LL_ADC_DisableIT_OVR
Kojto 158:b23ee177fd68 3874 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3875 * @retval None
Kojto 158:b23ee177fd68 3876 */
Kojto 158:b23ee177fd68 3877 __STATIC_INLINE void LL_ADC_DisableIT_OVR(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3878 {
Kojto 158:b23ee177fd68 3879 CLEAR_BIT(ADCx->IER, LL_ADC_IT_OVR);
Kojto 158:b23ee177fd68 3880 }
Kojto 158:b23ee177fd68 3881
Kojto 158:b23ee177fd68 3882 /**
Kojto 158:b23ee177fd68 3883 * @brief Disable interruption ADC group regular end of sampling.
Kojto 158:b23ee177fd68 3884 * @rmtoll IER EOSMPIE LL_ADC_DisableIT_EOSMP
Kojto 158:b23ee177fd68 3885 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3886 * @retval None
Kojto 158:b23ee177fd68 3887 */
Kojto 158:b23ee177fd68 3888 __STATIC_INLINE void LL_ADC_DisableIT_EOSMP(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3889 {
Kojto 158:b23ee177fd68 3890 CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
Kojto 158:b23ee177fd68 3891 }
Kojto 158:b23ee177fd68 3892
Kojto 158:b23ee177fd68 3893 /**
Kojto 158:b23ee177fd68 3894 * @brief Disable interruption ADC analog watchdog 1.
Kojto 158:b23ee177fd68 3895 * @rmtoll IER AWDIE LL_ADC_DisableIT_AWD1
Kojto 158:b23ee177fd68 3896 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3897 * @retval None
Kojto 158:b23ee177fd68 3898 */
Kojto 158:b23ee177fd68 3899 __STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3900 {
Kojto 158:b23ee177fd68 3901 CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD1);
Kojto 158:b23ee177fd68 3902 }
Kojto 158:b23ee177fd68 3903
Kojto 158:b23ee177fd68 3904 /**
Kojto 158:b23ee177fd68 3905 * @brief Disable interruption ADC end of calibration.
Kojto 158:b23ee177fd68 3906 * @rmtoll IER EOCALIE LL_ADC_DisableIT_EOCAL
Kojto 158:b23ee177fd68 3907 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3908 * @retval None
Kojto 158:b23ee177fd68 3909 */
Kojto 158:b23ee177fd68 3910 __STATIC_INLINE void LL_ADC_DisableIT_EOCAL(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3911 {
Kojto 158:b23ee177fd68 3912 CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOCAL);
Kojto 158:b23ee177fd68 3913 }
Kojto 158:b23ee177fd68 3914
Kojto 158:b23ee177fd68 3915 /**
Kojto 158:b23ee177fd68 3916 * @brief Get state of interruption ADC ready
Kojto 158:b23ee177fd68 3917 * (0: interrupt disabled, 1: interrupt enabled).
Kojto 158:b23ee177fd68 3918 * @rmtoll IER ADRDYIE LL_ADC_IsEnabledIT_ADRDY
Kojto 158:b23ee177fd68 3919 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3920 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3921 */
Kojto 158:b23ee177fd68 3922 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_ADRDY(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3923 {
Kojto 158:b23ee177fd68 3924 return (READ_BIT(ADCx->IER, LL_ADC_IT_ADRDY) == (LL_ADC_IT_ADRDY));
Kojto 158:b23ee177fd68 3925 }
Kojto 158:b23ee177fd68 3926
Kojto 158:b23ee177fd68 3927 /**
Kojto 158:b23ee177fd68 3928 * @brief Get state of interruption ADC group regular end of unitary conversion
Kojto 158:b23ee177fd68 3929 * (0: interrupt disabled, 1: interrupt enabled).
Kojto 158:b23ee177fd68 3930 * @rmtoll IER EOCIE LL_ADC_IsEnabledIT_EOC
Kojto 158:b23ee177fd68 3931 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3932 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3933 */
Kojto 158:b23ee177fd68 3934 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOC(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3935 {
Kojto 158:b23ee177fd68 3936 return (READ_BIT(ADCx->IER, LL_ADC_IT_EOC) == (LL_ADC_IT_EOC));
Kojto 158:b23ee177fd68 3937 }
Kojto 158:b23ee177fd68 3938
Kojto 158:b23ee177fd68 3939 /**
Kojto 158:b23ee177fd68 3940 * @brief Get state of interruption ADC group regular end of sequence conversions
Kojto 158:b23ee177fd68 3941 * (0: interrupt disabled, 1: interrupt enabled).
Kojto 158:b23ee177fd68 3942 * @rmtoll IER EOSEQIE LL_ADC_IsEnabledIT_EOS
Kojto 158:b23ee177fd68 3943 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3944 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3945 */
Kojto 158:b23ee177fd68 3946 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOS(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3947 {
Kojto 158:b23ee177fd68 3948 return (READ_BIT(ADCx->IER, LL_ADC_IT_EOS) == (LL_ADC_IT_EOS));
Kojto 158:b23ee177fd68 3949 }
Kojto 158:b23ee177fd68 3950
Kojto 158:b23ee177fd68 3951 /**
Kojto 158:b23ee177fd68 3952 * @brief Get state of interruption ADC group regular overrun
Kojto 158:b23ee177fd68 3953 * (0: interrupt disabled, 1: interrupt enabled).
Kojto 158:b23ee177fd68 3954 * @rmtoll IER OVRIE LL_ADC_IsEnabledIT_OVR
Kojto 158:b23ee177fd68 3955 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3956 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3957 */
Kojto 158:b23ee177fd68 3958 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_OVR(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3959 {
Kojto 158:b23ee177fd68 3960 return (READ_BIT(ADCx->IER, LL_ADC_IT_OVR) == (LL_ADC_IT_OVR));
Kojto 158:b23ee177fd68 3961 }
Kojto 158:b23ee177fd68 3962
Kojto 158:b23ee177fd68 3963 /**
Kojto 158:b23ee177fd68 3964 * @brief Get state of interruption ADC group regular end of sampling
Kojto 158:b23ee177fd68 3965 * (0: interrupt disabled, 1: interrupt enabled).
Kojto 158:b23ee177fd68 3966 * @rmtoll IER EOSMPIE LL_ADC_IsEnabledIT_EOSMP
Kojto 158:b23ee177fd68 3967 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3968 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3969 */
Kojto 158:b23ee177fd68 3970 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOSMP(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3971 {
Kojto 158:b23ee177fd68 3972 return (READ_BIT(ADCx->IER, LL_ADC_IT_EOSMP) == (LL_ADC_IT_EOSMP));
Kojto 158:b23ee177fd68 3973 }
Kojto 158:b23ee177fd68 3974
Kojto 158:b23ee177fd68 3975 /**
Kojto 158:b23ee177fd68 3976 * @brief Get state of interruption ADC analog watchdog 1
Kojto 158:b23ee177fd68 3977 * (0: interrupt disabled, 1: interrupt enabled).
Kojto 158:b23ee177fd68 3978 * @rmtoll IER AWDIE LL_ADC_IsEnabledIT_AWD1
Kojto 158:b23ee177fd68 3979 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3980 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3981 */
Kojto 158:b23ee177fd68 3982 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3983 {
Kojto 158:b23ee177fd68 3984 return (READ_BIT(ADCx->IER, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1));
Kojto 158:b23ee177fd68 3985 }
Kojto 158:b23ee177fd68 3986
Kojto 158:b23ee177fd68 3987 /**
Kojto 158:b23ee177fd68 3988 * @brief Get state of interruption ADC end of calibration
Kojto 158:b23ee177fd68 3989 * (0: interrupt disabled, 1: interrupt enabled).
Kojto 158:b23ee177fd68 3990 * @rmtoll IER EOCALIE LL_ADC_IsEnabledIT_EOCAL
Kojto 158:b23ee177fd68 3991 * @param ADCx ADC instance
Kojto 158:b23ee177fd68 3992 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3993 */
Kojto 158:b23ee177fd68 3994 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOCAL(ADC_TypeDef *ADCx)
Kojto 158:b23ee177fd68 3995 {
Kojto 158:b23ee177fd68 3996 return (READ_BIT(ADCx->IER, LL_ADC_IT_EOCAL) == (LL_ADC_IT_EOCAL));
Kojto 158:b23ee177fd68 3997 }
Kojto 158:b23ee177fd68 3998
Kojto 158:b23ee177fd68 3999 /**
Kojto 158:b23ee177fd68 4000 * @}
Kojto 158:b23ee177fd68 4001 */
Kojto 158:b23ee177fd68 4002
Kojto 158:b23ee177fd68 4003 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 4004 /** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
Kojto 158:b23ee177fd68 4005 * @{
Kojto 158:b23ee177fd68 4006 */
Kojto 158:b23ee177fd68 4007
Kojto 158:b23ee177fd68 4008 /* Initialization of some features of ADC common parameters and multimode */
Kojto 158:b23ee177fd68 4009 ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
Kojto 158:b23ee177fd68 4010 ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
Kojto 158:b23ee177fd68 4011 void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
Kojto 158:b23ee177fd68 4012
Kojto 158:b23ee177fd68 4013 /* De-initialization of ADC instance */
Kojto 158:b23ee177fd68 4014 ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
Kojto 158:b23ee177fd68 4015
Kojto 158:b23ee177fd68 4016 /* Initialization of some features of ADC instance */
Kojto 158:b23ee177fd68 4017 ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
Kojto 158:b23ee177fd68 4018 void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
Kojto 158:b23ee177fd68 4019
Kojto 158:b23ee177fd68 4020 /* Initialization of some features of ADC instance and ADC group regular */
Kojto 158:b23ee177fd68 4021 ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
Kojto 158:b23ee177fd68 4022 void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
Kojto 158:b23ee177fd68 4023
Kojto 158:b23ee177fd68 4024 /**
Kojto 158:b23ee177fd68 4025 * @}
Kojto 158:b23ee177fd68 4026 */
Kojto 158:b23ee177fd68 4027 #endif /* USE_FULL_LL_DRIVER */
Kojto 158:b23ee177fd68 4028
Kojto 158:b23ee177fd68 4029 /**
Kojto 158:b23ee177fd68 4030 * @}
Kojto 158:b23ee177fd68 4031 */
Kojto 158:b23ee177fd68 4032
Kojto 158:b23ee177fd68 4033 /**
Kojto 158:b23ee177fd68 4034 * @}
Kojto 158:b23ee177fd68 4035 */
Kojto 158:b23ee177fd68 4036
Kojto 158:b23ee177fd68 4037 #endif /* ADC1 */
Kojto 158:b23ee177fd68 4038
Kojto 158:b23ee177fd68 4039 /**
Kojto 158:b23ee177fd68 4040 * @}
Kojto 158:b23ee177fd68 4041 */
Kojto 158:b23ee177fd68 4042
Kojto 158:b23ee177fd68 4043 #ifdef __cplusplus
Kojto 158:b23ee177fd68 4044 }
Kojto 158:b23ee177fd68 4045 #endif
Kojto 158:b23ee177fd68 4046
Kojto 158:b23ee177fd68 4047 #endif /* __STM32L0xx_LL_ADC_H */
Kojto 158:b23ee177fd68 4048
Kojto 158:b23ee177fd68 4049 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/