Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lypinator 0:bb348c97df44 1 /**
lypinator 0:bb348c97df44 2 ******************************************************************************
lypinator 0:bb348c97df44 3 * @file stm32f4xx_hal_adc_ex.h
lypinator 0:bb348c97df44 4 * @author MCD Application Team
lypinator 0:bb348c97df44 5 * @brief Header file of ADC HAL module.
lypinator 0:bb348c97df44 6 ******************************************************************************
lypinator 0:bb348c97df44 7 * @attention
lypinator 0:bb348c97df44 8 *
lypinator 0:bb348c97df44 9 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
lypinator 0:bb348c97df44 10 *
lypinator 0:bb348c97df44 11 * Redistribution and use in source and binary forms, with or without modification,
lypinator 0:bb348c97df44 12 * are permitted provided that the following conditions are met:
lypinator 0:bb348c97df44 13 * 1. Redistributions of source code must retain the above copyright notice,
lypinator 0:bb348c97df44 14 * this list of conditions and the following disclaimer.
lypinator 0:bb348c97df44 15 * 2. Redistributions in binary form must reproduce the above copyright notice,
lypinator 0:bb348c97df44 16 * this list of conditions and the following disclaimer in the documentation
lypinator 0:bb348c97df44 17 * and/or other materials provided with the distribution.
lypinator 0:bb348c97df44 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
lypinator 0:bb348c97df44 19 * may be used to endorse or promote products derived from this software
lypinator 0:bb348c97df44 20 * without specific prior written permission.
lypinator 0:bb348c97df44 21 *
lypinator 0:bb348c97df44 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
lypinator 0:bb348c97df44 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
lypinator 0:bb348c97df44 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
lypinator 0:bb348c97df44 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
lypinator 0:bb348c97df44 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
lypinator 0:bb348c97df44 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
lypinator 0:bb348c97df44 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
lypinator 0:bb348c97df44 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
lypinator 0:bb348c97df44 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
lypinator 0:bb348c97df44 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
lypinator 0:bb348c97df44 32 *
lypinator 0:bb348c97df44 33 ******************************************************************************
lypinator 0:bb348c97df44 34 */
lypinator 0:bb348c97df44 35
lypinator 0:bb348c97df44 36 /* Define to prevent recursive inclusion -------------------------------------*/
lypinator 0:bb348c97df44 37 #ifndef __STM32F4xx_ADC_EX_H
lypinator 0:bb348c97df44 38 #define __STM32F4xx_ADC_EX_H
lypinator 0:bb348c97df44 39
lypinator 0:bb348c97df44 40 #ifdef __cplusplus
lypinator 0:bb348c97df44 41 extern "C" {
lypinator 0:bb348c97df44 42 #endif
lypinator 0:bb348c97df44 43
lypinator 0:bb348c97df44 44 /* Includes ------------------------------------------------------------------*/
lypinator 0:bb348c97df44 45 #include "stm32f4xx_hal_def.h"
lypinator 0:bb348c97df44 46
lypinator 0:bb348c97df44 47 /** @addtogroup STM32F4xx_HAL_Driver
lypinator 0:bb348c97df44 48 * @{
lypinator 0:bb348c97df44 49 */
lypinator 0:bb348c97df44 50
lypinator 0:bb348c97df44 51 /** @addtogroup ADCEx
lypinator 0:bb348c97df44 52 * @{
lypinator 0:bb348c97df44 53 */
lypinator 0:bb348c97df44 54
lypinator 0:bb348c97df44 55 /* Exported types ------------------------------------------------------------*/
lypinator 0:bb348c97df44 56 /** @defgroup ADCEx_Exported_Types ADC Exported Types
lypinator 0:bb348c97df44 57 * @{
lypinator 0:bb348c97df44 58 */
lypinator 0:bb348c97df44 59
lypinator 0:bb348c97df44 60 /**
lypinator 0:bb348c97df44 61 * @brief ADC Configuration injected Channel structure definition
lypinator 0:bb348c97df44 62 * @note Parameters of this structure are shared within 2 scopes:
lypinator 0:bb348c97df44 63 * - Scope channel: InjectedChannel, InjectedRank, InjectedSamplingTime, InjectedOffset
lypinator 0:bb348c97df44 64 * - Scope injected group (affects all channels of injected group): InjectedNbrOfConversion, InjectedDiscontinuousConvMode,
lypinator 0:bb348c97df44 65 * AutoInjectedConv, ExternalTrigInjecConvEdge, ExternalTrigInjecConv.
lypinator 0:bb348c97df44 66 * @note The setting of these parameters with function HAL_ADCEx_InjectedConfigChannel() is conditioned to ADC state.
lypinator 0:bb348c97df44 67 * ADC state can be either:
lypinator 0:bb348c97df44 68 * - For all parameters: ADC disabled
lypinator 0:bb348c97df44 69 * - For all except parameters 'InjectedDiscontinuousConvMode' and 'AutoInjectedConv': ADC enabled without conversion on going on injected group.
lypinator 0:bb348c97df44 70 * - For parameters 'ExternalTrigInjecConv' and 'ExternalTrigInjecConvEdge': ADC enabled, even with conversion on going on injected group.
lypinator 0:bb348c97df44 71 */
lypinator 0:bb348c97df44 72 typedef struct
lypinator 0:bb348c97df44 73 {
lypinator 0:bb348c97df44 74 uint32_t InjectedChannel; /*!< Selection of ADC channel to configure
lypinator 0:bb348c97df44 75 This parameter can be a value of @ref ADC_channels
lypinator 0:bb348c97df44 76 Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability. */
lypinator 0:bb348c97df44 77 uint32_t InjectedRank; /*!< Rank in the injected group sequencer
lypinator 0:bb348c97df44 78 This parameter must be a value of @ref ADCEx_injected_rank
lypinator 0:bb348c97df44 79 Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel setting (or parameter number of conversions can be adjusted) */
lypinator 0:bb348c97df44 80 uint32_t InjectedSamplingTime; /*!< Sampling time value to be set for the selected channel.
lypinator 0:bb348c97df44 81 Unit: ADC clock cycles
lypinator 0:bb348c97df44 82 Conversion time is the addition of sampling time and processing time (12 ADC clock cycles at ADC resolution 12 bits, 11 cycles at 10 bits, 9 cycles at 8 bits, 7 cycles at 6 bits).
lypinator 0:bb348c97df44 83 This parameter can be a value of @ref ADC_sampling_times
lypinator 0:bb348c97df44 84 Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
lypinator 0:bb348c97df44 85 If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
lypinator 0:bb348c97df44 86 Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
lypinator 0:bb348c97df44 87 sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
lypinator 0:bb348c97df44 88 Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 4us min). */
lypinator 0:bb348c97df44 89 uint32_t InjectedOffset; /*!< Defines the offset to be subtracted from the raw converted data (for channels set on injected group only).
lypinator 0:bb348c97df44 90 Offset value must be a positive number.
lypinator 0:bb348c97df44 91 Depending of ADC resolution selected (12, 10, 8 or 6 bits),
lypinator 0:bb348c97df44 92 this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively. */
lypinator 0:bb348c97df44 93 uint32_t InjectedNbrOfConversion; /*!< Specifies the number of ranks that will be converted within the injected group sequencer.
lypinator 0:bb348c97df44 94 To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
lypinator 0:bb348c97df44 95 This parameter must be a number between Min_Data = 1 and Max_Data = 4.
lypinator 0:bb348c97df44 96 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
lypinator 0:bb348c97df44 97 configure a channel on injected group can impact the configuration of other channels previously set. */
lypinator 0:bb348c97df44 98 uint32_t InjectedDiscontinuousConvMode; /*!< Specifies whether the conversions sequence of injected group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
lypinator 0:bb348c97df44 99 Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
lypinator 0:bb348c97df44 100 Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
lypinator 0:bb348c97df44 101 This parameter can be set to ENABLE or DISABLE.
lypinator 0:bb348c97df44 102 Note: For injected group, number of discontinuous ranks increment is fixed to one-by-one.
lypinator 0:bb348c97df44 103 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
lypinator 0:bb348c97df44 104 configure a channel on injected group can impact the configuration of other channels previously set. */
lypinator 0:bb348c97df44 105 uint32_t AutoInjectedConv; /*!< Enables or disables the selected ADC automatic injected group conversion after regular one
lypinator 0:bb348c97df44 106 This parameter can be set to ENABLE or DISABLE.
lypinator 0:bb348c97df44 107 Note: To use Automatic injected conversion, discontinuous mode must be disabled ('DiscontinuousConvMode' and 'InjectedDiscontinuousConvMode' set to DISABLE)
lypinator 0:bb348c97df44 108 Note: To use Automatic injected conversion, injected group external triggers must be disabled ('ExternalTrigInjecConv' set to ADC_SOFTWARE_START)
lypinator 0:bb348c97df44 109 Note: In case of DMA used with regular group: if DMA configured in normal mode (single shot) JAUTO will be stopped upon DMA transfer complete.
lypinator 0:bb348c97df44 110 To maintain JAUTO always enabled, DMA must be configured in circular mode.
lypinator 0:bb348c97df44 111 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
lypinator 0:bb348c97df44 112 configure a channel on injected group can impact the configuration of other channels previously set. */
lypinator 0:bb348c97df44 113 uint32_t ExternalTrigInjecConv; /*!< Selects the external event used to trigger the conversion start of injected group.
lypinator 0:bb348c97df44 114 If set to ADC_INJECTED_SOFTWARE_START, external triggers are disabled.
lypinator 0:bb348c97df44 115 If set to external trigger source, triggering is on event rising edge.
lypinator 0:bb348c97df44 116 This parameter can be a value of @ref ADCEx_External_trigger_Source_Injected
lypinator 0:bb348c97df44 117 Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
lypinator 0:bb348c97df44 118 If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behaviour in case of another parameter update on the fly)
lypinator 0:bb348c97df44 119 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
lypinator 0:bb348c97df44 120 configure a channel on injected group can impact the configuration of other channels previously set. */
lypinator 0:bb348c97df44 121 uint32_t ExternalTrigInjecConvEdge; /*!< Selects the external trigger edge of injected group.
lypinator 0:bb348c97df44 122 This parameter can be a value of @ref ADCEx_External_trigger_edge_Injected.
lypinator 0:bb348c97df44 123 If trigger is set to ADC_INJECTED_SOFTWARE_START, this parameter is discarded.
lypinator 0:bb348c97df44 124 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
lypinator 0:bb348c97df44 125 configure a channel on injected group can impact the configuration of other channels previously set. */
lypinator 0:bb348c97df44 126 }ADC_InjectionConfTypeDef;
lypinator 0:bb348c97df44 127
lypinator 0:bb348c97df44 128 /**
lypinator 0:bb348c97df44 129 * @brief ADC Configuration multi-mode structure definition
lypinator 0:bb348c97df44 130 */
lypinator 0:bb348c97df44 131 typedef struct
lypinator 0:bb348c97df44 132 {
lypinator 0:bb348c97df44 133 uint32_t Mode; /*!< Configures the ADC to operate in independent or multi mode.
lypinator 0:bb348c97df44 134 This parameter can be a value of @ref ADCEx_Common_mode */
lypinator 0:bb348c97df44 135 uint32_t DMAAccessMode; /*!< Configures the Direct memory access mode for multi ADC mode.
lypinator 0:bb348c97df44 136 This parameter can be a value of @ref ADCEx_Direct_memory_access_mode_for_multi_mode */
lypinator 0:bb348c97df44 137 uint32_t TwoSamplingDelay; /*!< Configures the Delay between 2 sampling phases.
lypinator 0:bb348c97df44 138 This parameter can be a value of @ref ADC_delay_between_2_sampling_phases */
lypinator 0:bb348c97df44 139 }ADC_MultiModeTypeDef;
lypinator 0:bb348c97df44 140
lypinator 0:bb348c97df44 141 /**
lypinator 0:bb348c97df44 142 * @}
lypinator 0:bb348c97df44 143 */
lypinator 0:bb348c97df44 144
lypinator 0:bb348c97df44 145 /* Exported constants --------------------------------------------------------*/
lypinator 0:bb348c97df44 146 /** @defgroup ADCEx_Exported_Constants ADC Exported Constants
lypinator 0:bb348c97df44 147 * @{
lypinator 0:bb348c97df44 148 */
lypinator 0:bb348c97df44 149
lypinator 0:bb348c97df44 150 /** @defgroup ADCEx_Common_mode ADC Common Mode
lypinator 0:bb348c97df44 151 * @{
lypinator 0:bb348c97df44 152 */
lypinator 0:bb348c97df44 153 #define ADC_MODE_INDEPENDENT 0x00000000U
lypinator 0:bb348c97df44 154 #define ADC_DUALMODE_REGSIMULT_INJECSIMULT ((uint32_t)ADC_CCR_MULTI_0)
lypinator 0:bb348c97df44 155 #define ADC_DUALMODE_REGSIMULT_ALTERTRIG ((uint32_t)ADC_CCR_MULTI_1)
lypinator 0:bb348c97df44 156 #define ADC_DUALMODE_INJECSIMULT ((uint32_t)(ADC_CCR_MULTI_2 | ADC_CCR_MULTI_0))
lypinator 0:bb348c97df44 157 #define ADC_DUALMODE_REGSIMULT ((uint32_t)(ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1))
lypinator 0:bb348c97df44 158 #define ADC_DUALMODE_INTERL ((uint32_t)(ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1 | ADC_CCR_MULTI_0))
lypinator 0:bb348c97df44 159 #define ADC_DUALMODE_ALTERTRIG ((uint32_t)(ADC_CCR_MULTI_3 | ADC_CCR_MULTI_0))
lypinator 0:bb348c97df44 160 #define ADC_TRIPLEMODE_REGSIMULT_INJECSIMULT ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_0))
lypinator 0:bb348c97df44 161 #define ADC_TRIPLEMODE_REGSIMULT_AlterTrig ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_1))
lypinator 0:bb348c97df44 162 #define ADC_TRIPLEMODE_INJECSIMULT ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_0))
lypinator 0:bb348c97df44 163 #define ADC_TRIPLEMODE_REGSIMULT ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1))
lypinator 0:bb348c97df44 164 #define ADC_TRIPLEMODE_INTERL ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1 | ADC_CCR_MULTI_0))
lypinator 0:bb348c97df44 165 #define ADC_TRIPLEMODE_ALTERTRIG ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_3 | ADC_CCR_MULTI_0))
lypinator 0:bb348c97df44 166 /**
lypinator 0:bb348c97df44 167 * @}
lypinator 0:bb348c97df44 168 */
lypinator 0:bb348c97df44 169
lypinator 0:bb348c97df44 170 /** @defgroup ADCEx_Direct_memory_access_mode_for_multi_mode ADC Direct Memory Access Mode For Multi Mode
lypinator 0:bb348c97df44 171 * @{
lypinator 0:bb348c97df44 172 */
lypinator 0:bb348c97df44 173 #define ADC_DMAACCESSMODE_DISABLED 0x00000000U /*!< DMA mode disabled */
lypinator 0:bb348c97df44 174 #define ADC_DMAACCESSMODE_1 ((uint32_t)ADC_CCR_DMA_0) /*!< DMA mode 1 enabled (2 / 3 half-words one by one - 1 then 2 then 3)*/
lypinator 0:bb348c97df44 175 #define ADC_DMAACCESSMODE_2 ((uint32_t)ADC_CCR_DMA_1) /*!< DMA mode 2 enabled (2 / 3 half-words by pairs - 2&1 then 1&3 then 3&2)*/
lypinator 0:bb348c97df44 176 #define ADC_DMAACCESSMODE_3 ((uint32_t)ADC_CCR_DMA) /*!< DMA mode 3 enabled (2 / 3 bytes by pairs - 2&1 then 1&3 then 3&2) */
lypinator 0:bb348c97df44 177 /**
lypinator 0:bb348c97df44 178 * @}
lypinator 0:bb348c97df44 179 */
lypinator 0:bb348c97df44 180
lypinator 0:bb348c97df44 181 /** @defgroup ADCEx_External_trigger_edge_Injected ADC External Trigger Edge Injected
lypinator 0:bb348c97df44 182 * @{
lypinator 0:bb348c97df44 183 */
lypinator 0:bb348c97df44 184 #define ADC_EXTERNALTRIGINJECCONVEDGE_NONE 0x00000000U
lypinator 0:bb348c97df44 185 #define ADC_EXTERNALTRIGINJECCONVEDGE_RISING ((uint32_t)ADC_CR2_JEXTEN_0)
lypinator 0:bb348c97df44 186 #define ADC_EXTERNALTRIGINJECCONVEDGE_FALLING ((uint32_t)ADC_CR2_JEXTEN_1)
lypinator 0:bb348c97df44 187 #define ADC_EXTERNALTRIGINJECCONVEDGE_RISINGFALLING ((uint32_t)ADC_CR2_JEXTEN)
lypinator 0:bb348c97df44 188 /**
lypinator 0:bb348c97df44 189 * @}
lypinator 0:bb348c97df44 190 */
lypinator 0:bb348c97df44 191
lypinator 0:bb348c97df44 192 /** @defgroup ADCEx_External_trigger_Source_Injected ADC External Trigger Source Injected
lypinator 0:bb348c97df44 193 * @{
lypinator 0:bb348c97df44 194 */
lypinator 0:bb348c97df44 195 #define ADC_EXTERNALTRIGINJECCONV_T1_CC4 0x00000000U
lypinator 0:bb348c97df44 196 #define ADC_EXTERNALTRIGINJECCONV_T1_TRGO ((uint32_t)ADC_CR2_JEXTSEL_0)
lypinator 0:bb348c97df44 197 #define ADC_EXTERNALTRIGINJECCONV_T2_CC1 ((uint32_t)ADC_CR2_JEXTSEL_1)
lypinator 0:bb348c97df44 198 #define ADC_EXTERNALTRIGINJECCONV_T2_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
lypinator 0:bb348c97df44 199 #define ADC_EXTERNALTRIGINJECCONV_T3_CC2 ((uint32_t)ADC_CR2_JEXTSEL_2)
lypinator 0:bb348c97df44 200 #define ADC_EXTERNALTRIGINJECCONV_T3_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0))
lypinator 0:bb348c97df44 201 #define ADC_EXTERNALTRIGINJECCONV_T4_CC1 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1))
lypinator 0:bb348c97df44 202 #define ADC_EXTERNALTRIGINJECCONV_T4_CC2 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
lypinator 0:bb348c97df44 203 #define ADC_EXTERNALTRIGINJECCONV_T4_CC3 ((uint32_t)ADC_CR2_JEXTSEL_3)
lypinator 0:bb348c97df44 204 #define ADC_EXTERNALTRIGINJECCONV_T4_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_0))
lypinator 0:bb348c97df44 205 #define ADC_EXTERNALTRIGINJECCONV_T5_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1))
lypinator 0:bb348c97df44 206 #define ADC_EXTERNALTRIGINJECCONV_T5_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
lypinator 0:bb348c97df44 207 #define ADC_EXTERNALTRIGINJECCONV_T8_CC2 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2))
lypinator 0:bb348c97df44 208 #define ADC_EXTERNALTRIGINJECCONV_T8_CC3 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0))
lypinator 0:bb348c97df44 209 #define ADC_EXTERNALTRIGINJECCONV_T8_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1))
lypinator 0:bb348c97df44 210 #define ADC_EXTERNALTRIGINJECCONV_EXT_IT15 ((uint32_t)ADC_CR2_JEXTSEL)
lypinator 0:bb348c97df44 211 #define ADC_INJECTED_SOFTWARE_START ((uint32_t)ADC_CR2_JEXTSEL + 1U)
lypinator 0:bb348c97df44 212 /**
lypinator 0:bb348c97df44 213 * @}
lypinator 0:bb348c97df44 214 */
lypinator 0:bb348c97df44 215
lypinator 0:bb348c97df44 216 /** @defgroup ADCEx_injected_rank ADC Injected Rank
lypinator 0:bb348c97df44 217 * @{
lypinator 0:bb348c97df44 218 */
lypinator 0:bb348c97df44 219 #define ADC_INJECTED_RANK_1 0x00000001U
lypinator 0:bb348c97df44 220 #define ADC_INJECTED_RANK_2 0x00000002U
lypinator 0:bb348c97df44 221 #define ADC_INJECTED_RANK_3 0x00000003U
lypinator 0:bb348c97df44 222 #define ADC_INJECTED_RANK_4 0x00000004U
lypinator 0:bb348c97df44 223 /**
lypinator 0:bb348c97df44 224 * @}
lypinator 0:bb348c97df44 225 */
lypinator 0:bb348c97df44 226
lypinator 0:bb348c97df44 227 /** @defgroup ADCEx_channels ADC Specific Channels
lypinator 0:bb348c97df44 228 * @{
lypinator 0:bb348c97df44 229 */
lypinator 0:bb348c97df44 230 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
lypinator 0:bb348c97df44 231 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) || \
lypinator 0:bb348c97df44 232 defined(STM32F410Rx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || \
lypinator 0:bb348c97df44 233 defined(STM32F412Cx)
lypinator 0:bb348c97df44 234 #define ADC_CHANNEL_TEMPSENSOR ((uint32_t)ADC_CHANNEL_16)
lypinator 0:bb348c97df44 235 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F412Zx ||
lypinator 0:bb348c97df44 236 STM32F412Vx || STM32F412Rx || STM32F412Cx */
lypinator 0:bb348c97df44 237
lypinator 0:bb348c97df44 238 #if defined(STM32F413xx) || defined(STM32F423xx)
lypinator 0:bb348c97df44 239 #define ADC_CHANNEL_TEMPSENSOR ((uint32_t)ADC_CHANNEL_18)
lypinator 0:bb348c97df44 240 #endif /* STM32F413xx || STM32F423xx */
lypinator 0:bb348c97df44 241
lypinator 0:bb348c97df44 242 #if defined(STM32F411xE) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
lypinator 0:bb348c97df44 243 defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
lypinator 0:bb348c97df44 244 #define ADC_CHANNEL_DIFFERENCIATION_TEMPSENSOR_VBAT 0x10000000U /* Dummy bit for driver internal usage, not used in ADC channel setting registers CR1 or SQRx */
lypinator 0:bb348c97df44 245 #define ADC_CHANNEL_TEMPSENSOR ((uint32_t)ADC_CHANNEL_18 | ADC_CHANNEL_DIFFERENCIATION_TEMPSENSOR_VBAT)
lypinator 0:bb348c97df44 246 #endif /* STM32F411xE || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
lypinator 0:bb348c97df44 247 /**
lypinator 0:bb348c97df44 248 * @}
lypinator 0:bb348c97df44 249 */
lypinator 0:bb348c97df44 250
lypinator 0:bb348c97df44 251
lypinator 0:bb348c97df44 252 /**
lypinator 0:bb348c97df44 253 * @}
lypinator 0:bb348c97df44 254 */
lypinator 0:bb348c97df44 255
lypinator 0:bb348c97df44 256 /* Exported macro ------------------------------------------------------------*/
lypinator 0:bb348c97df44 257 /** @defgroup ADC_Exported_Macros ADC Exported Macros
lypinator 0:bb348c97df44 258 * @{
lypinator 0:bb348c97df44 259 */
lypinator 0:bb348c97df44 260 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx)
lypinator 0:bb348c97df44 261 /**
lypinator 0:bb348c97df44 262 * @brief Disable internal path of ADC channel Vbat
lypinator 0:bb348c97df44 263 * @note Use case of this macro:
lypinator 0:bb348c97df44 264 * On devices STM32F42x and STM32F43x, ADC internal channels
lypinator 0:bb348c97df44 265 * Vbat and VrefInt share the same internal path, only
lypinator 0:bb348c97df44 266 * one of them can be enabled.This macro is to be used when ADC
lypinator 0:bb348c97df44 267 * channels Vbat and VrefInt are selected, and must be called
lypinator 0:bb348c97df44 268 * before starting conversion of ADC channel VrefInt in order
lypinator 0:bb348c97df44 269 * to disable ADC channel Vbat.
lypinator 0:bb348c97df44 270 * @retval None
lypinator 0:bb348c97df44 271 */
lypinator 0:bb348c97df44 272 #define __HAL_ADC_PATH_INTERNAL_VBAT_DISABLE() (ADC->CCR &= ~(ADC_CCR_VBATE))
lypinator 0:bb348c97df44 273 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
lypinator 0:bb348c97df44 274 /**
lypinator 0:bb348c97df44 275 * @}
lypinator 0:bb348c97df44 276 */
lypinator 0:bb348c97df44 277
lypinator 0:bb348c97df44 278 /* Exported functions --------------------------------------------------------*/
lypinator 0:bb348c97df44 279 /** @addtogroup ADCEx_Exported_Functions
lypinator 0:bb348c97df44 280 * @{
lypinator 0:bb348c97df44 281 */
lypinator 0:bb348c97df44 282
lypinator 0:bb348c97df44 283 /** @addtogroup ADCEx_Exported_Functions_Group1
lypinator 0:bb348c97df44 284 * @{
lypinator 0:bb348c97df44 285 */
lypinator 0:bb348c97df44 286
lypinator 0:bb348c97df44 287 /* I/O operation functions ******************************************************/
lypinator 0:bb348c97df44 288 HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef* hadc);
lypinator 0:bb348c97df44 289 HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef* hadc);
lypinator 0:bb348c97df44 290 HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
lypinator 0:bb348c97df44 291 HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef* hadc);
lypinator 0:bb348c97df44 292 HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc);
lypinator 0:bb348c97df44 293 uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank);
lypinator 0:bb348c97df44 294 HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
lypinator 0:bb348c97df44 295 HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef* hadc);
lypinator 0:bb348c97df44 296 uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef* hadc);
lypinator 0:bb348c97df44 297 void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc);
lypinator 0:bb348c97df44 298
lypinator 0:bb348c97df44 299 /* Peripheral Control functions *************************************************/
lypinator 0:bb348c97df44 300 HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc,ADC_InjectionConfTypeDef* sConfigInjected);
lypinator 0:bb348c97df44 301 HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef* hadc, ADC_MultiModeTypeDef* multimode);
lypinator 0:bb348c97df44 302
lypinator 0:bb348c97df44 303 /**
lypinator 0:bb348c97df44 304 * @}
lypinator 0:bb348c97df44 305 */
lypinator 0:bb348c97df44 306
lypinator 0:bb348c97df44 307 /**
lypinator 0:bb348c97df44 308 * @}
lypinator 0:bb348c97df44 309 */
lypinator 0:bb348c97df44 310 /* Private types -------------------------------------------------------------*/
lypinator 0:bb348c97df44 311 /* Private variables ---------------------------------------------------------*/
lypinator 0:bb348c97df44 312 /* Private constants ---------------------------------------------------------*/
lypinator 0:bb348c97df44 313 /** @defgroup ADCEx_Private_Constants ADC Private Constants
lypinator 0:bb348c97df44 314 * @{
lypinator 0:bb348c97df44 315 */
lypinator 0:bb348c97df44 316
lypinator 0:bb348c97df44 317 /**
lypinator 0:bb348c97df44 318 * @}
lypinator 0:bb348c97df44 319 */
lypinator 0:bb348c97df44 320
lypinator 0:bb348c97df44 321 /* Private macros ------------------------------------------------------------*/
lypinator 0:bb348c97df44 322 /** @defgroup ADCEx_Private_Macros ADC Private Macros
lypinator 0:bb348c97df44 323 * @{
lypinator 0:bb348c97df44 324 */
lypinator 0:bb348c97df44 325 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
lypinator 0:bb348c97df44 326 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) || \
lypinator 0:bb348c97df44 327 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
lypinator 0:bb348c97df44 328 defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
lypinator 0:bb348c97df44 329 #define IS_ADC_CHANNEL(CHANNEL) ((CHANNEL) <= ADC_CHANNEL_18)
lypinator 0:bb348c97df44 330 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE ||
lypinator 0:bb348c97df44 331 STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
lypinator 0:bb348c97df44 332
lypinator 0:bb348c97df44 333 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
lypinator 0:bb348c97df44 334 defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
lypinator 0:bb348c97df44 335 #define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) <= ADC_CHANNEL_18) || \
lypinator 0:bb348c97df44 336 ((CHANNEL) == ADC_CHANNEL_TEMPSENSOR))
lypinator 0:bb348c97df44 337 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
lypinator 0:bb348c97df44 338
lypinator 0:bb348c97df44 339 #define IS_ADC_MODE(MODE) (((MODE) == ADC_MODE_INDEPENDENT) || \
lypinator 0:bb348c97df44 340 ((MODE) == ADC_DUALMODE_REGSIMULT_INJECSIMULT) || \
lypinator 0:bb348c97df44 341 ((MODE) == ADC_DUALMODE_REGSIMULT_ALTERTRIG) || \
lypinator 0:bb348c97df44 342 ((MODE) == ADC_DUALMODE_INJECSIMULT) || \
lypinator 0:bb348c97df44 343 ((MODE) == ADC_DUALMODE_REGSIMULT) || \
lypinator 0:bb348c97df44 344 ((MODE) == ADC_DUALMODE_INTERL) || \
lypinator 0:bb348c97df44 345 ((MODE) == ADC_DUALMODE_ALTERTRIG) || \
lypinator 0:bb348c97df44 346 ((MODE) == ADC_TRIPLEMODE_REGSIMULT_INJECSIMULT) || \
lypinator 0:bb348c97df44 347 ((MODE) == ADC_TRIPLEMODE_REGSIMULT_AlterTrig) || \
lypinator 0:bb348c97df44 348 ((MODE) == ADC_TRIPLEMODE_INJECSIMULT) || \
lypinator 0:bb348c97df44 349 ((MODE) == ADC_TRIPLEMODE_REGSIMULT) || \
lypinator 0:bb348c97df44 350 ((MODE) == ADC_TRIPLEMODE_INTERL) || \
lypinator 0:bb348c97df44 351 ((MODE) == ADC_TRIPLEMODE_ALTERTRIG))
lypinator 0:bb348c97df44 352 #define IS_ADC_DMA_ACCESS_MODE(MODE) (((MODE) == ADC_DMAACCESSMODE_DISABLED) || \
lypinator 0:bb348c97df44 353 ((MODE) == ADC_DMAACCESSMODE_1) || \
lypinator 0:bb348c97df44 354 ((MODE) == ADC_DMAACCESSMODE_2) || \
lypinator 0:bb348c97df44 355 ((MODE) == ADC_DMAACCESSMODE_3))
lypinator 0:bb348c97df44 356 #define IS_ADC_EXT_INJEC_TRIG_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_NONE) || \
lypinator 0:bb348c97df44 357 ((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_RISING) || \
lypinator 0:bb348c97df44 358 ((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_FALLING) || \
lypinator 0:bb348c97df44 359 ((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_RISINGFALLING))
lypinator 0:bb348c97df44 360 #define IS_ADC_EXT_INJEC_TRIG(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
lypinator 0:bb348c97df44 361 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
lypinator 0:bb348c97df44 362 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
lypinator 0:bb348c97df44 363 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
lypinator 0:bb348c97df44 364 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC2) || \
lypinator 0:bb348c97df44 365 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
lypinator 0:bb348c97df44 366 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC1) || \
lypinator 0:bb348c97df44 367 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC2) || \
lypinator 0:bb348c97df44 368 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC3) || \
lypinator 0:bb348c97df44 369 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
lypinator 0:bb348c97df44 370 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_CC4) || \
lypinator 0:bb348c97df44 371 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_TRGO) || \
lypinator 0:bb348c97df44 372 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC2) || \
lypinator 0:bb348c97df44 373 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC3) || \
lypinator 0:bb348c97df44 374 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4) || \
lypinator 0:bb348c97df44 375 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15)|| \
lypinator 0:bb348c97df44 376 ((INJTRIG) == ADC_INJECTED_SOFTWARE_START))
lypinator 0:bb348c97df44 377 #define IS_ADC_INJECTED_LENGTH(LENGTH) (((LENGTH) >= 1U) && ((LENGTH) <= 4U))
lypinator 0:bb348c97df44 378 #define IS_ADC_INJECTED_RANK(RANK) (((RANK) >= 1U) && ((RANK) <= 4U))
lypinator 0:bb348c97df44 379
lypinator 0:bb348c97df44 380 /**
lypinator 0:bb348c97df44 381 * @brief Set the selected injected Channel rank.
lypinator 0:bb348c97df44 382 * @param _CHANNELNB_ Channel number.
lypinator 0:bb348c97df44 383 * @param _RANKNB_ Rank number.
lypinator 0:bb348c97df44 384 * @param _JSQR_JL_ Sequence length.
lypinator 0:bb348c97df44 385 * @retval None
lypinator 0:bb348c97df44 386 */
lypinator 0:bb348c97df44 387 #define ADC_JSQR(_CHANNELNB_, _RANKNB_, _JSQR_JL_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5U * (uint8_t)(((_RANKNB_) + 3U) - (_JSQR_JL_))))
lypinator 0:bb348c97df44 388
lypinator 0:bb348c97df44 389 /**
lypinator 0:bb348c97df44 390 * @brief Defines if the selected ADC is within ADC common register ADC123 or ADC1
lypinator 0:bb348c97df44 391 * if available (ADC2, ADC3 availability depends on STM32 product)
lypinator 0:bb348c97df44 392 * @param __HANDLE__ ADC handle
lypinator 0:bb348c97df44 393 * @retval Common control register ADC123 or ADC1
lypinator 0:bb348c97df44 394 */
lypinator 0:bb348c97df44 395 #if defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F415xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F429xx) || defined(STM32F437xx) || defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
lypinator 0:bb348c97df44 396 #define ADC_COMMON_REGISTER(__HANDLE__) ADC123_COMMON
lypinator 0:bb348c97df44 397 #else
lypinator 0:bb348c97df44 398 #define ADC_COMMON_REGISTER(__HANDLE__) ADC1_COMMON
lypinator 0:bb348c97df44 399 #endif /* STM32F405xx || STM32F407xx || STM32F415xx || STM32F417xx || STM32F427xx || STM32F429xx || STM32F437xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
lypinator 0:bb348c97df44 400 /**
lypinator 0:bb348c97df44 401 * @}
lypinator 0:bb348c97df44 402 */
lypinator 0:bb348c97df44 403
lypinator 0:bb348c97df44 404 /* Private functions ---------------------------------------------------------*/
lypinator 0:bb348c97df44 405 /** @defgroup ADCEx_Private_Functions ADC Private Functions
lypinator 0:bb348c97df44 406 * @{
lypinator 0:bb348c97df44 407 */
lypinator 0:bb348c97df44 408
lypinator 0:bb348c97df44 409 /**
lypinator 0:bb348c97df44 410 * @}
lypinator 0:bb348c97df44 411 */
lypinator 0:bb348c97df44 412
lypinator 0:bb348c97df44 413 /**
lypinator 0:bb348c97df44 414 * @}
lypinator 0:bb348c97df44 415 */
lypinator 0:bb348c97df44 416
lypinator 0:bb348c97df44 417 /**
lypinator 0:bb348c97df44 418 * @}
lypinator 0:bb348c97df44 419 */
lypinator 0:bb348c97df44 420
lypinator 0:bb348c97df44 421 #ifdef __cplusplus
lypinator 0:bb348c97df44 422 }
lypinator 0:bb348c97df44 423 #endif
lypinator 0:bb348c97df44 424
lypinator 0:bb348c97df44 425 #endif /*__STM32F4xx_ADC_EX_H */
lypinator 0:bb348c97df44 426
lypinator 0:bb348c97df44 427
lypinator 0:bb348c97df44 428 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/