mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
110:165afa46840b
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

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