|
楼主 |
发表于 2018-9-6 00:16:32
|
显示全部楼层
把头文件结构体也整理出来,方便以后查看。
- /* Includes ------------------------------------------------------------------*/
- #include "stm32h7xx_hal_def.h"
- /** @addtogroup STM32H7xx_HAL_Driver
- * @{
- */
- /** @addtogroup ADCEx
- * @{
- */
- /* Exported types ------------------------------------------------------------*/
- /** @defgroup ADCEx_Exported_Types ADC Extended Exported Types
- * @{
- */
- /**
- * @brief ADC group injected contexts queue configuration
- */
- typedef struct
- {
- uint32_t ContextQueue; /*!< Injected channel configuration context: build-up over each
- HAL_ADCEx_InjectedConfigChannel() call to finally initialize
- JSQR register at HAL_ADCEx_InjectedConfigChannel() last call */
- uint32_t ChannelCount; /*!< Number of channels in the injected sequence */
- }ADC_InjectionConfigTypeDef;
- /**
- * @brief ADC handle Structure definition
- */
- typedef struct
- {
- ADC_TypeDef *Instance; /*!< Register base address */
- ADC_InitTypeDef Init; /*!< ADC initialization parameters and regular conversions setting */
- DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
- HAL_LockTypeDef Lock; /*!< ADC locking object */
- __IO uint32_t State; /*!< ADC communication state (bit-map of ADC states) */
- __IO uint32_t ErrorCode; /*!< ADC Error code */
- ADC_InjectionConfigTypeDef InjectionConfig ; /*!< ADC injected channel configuration build-up structure */
- }ADC_HandleTypeDef;
- /**
- * @brief ADC Injected Conversion Oversampling structure definition
- */
- typedef struct
- {
- uint32_t Ratio; /*!< Configures the oversampling ratio.
- This parameter can be a value between 0 to 1023 */
- uint32_t RightBitShift; /*!< Configures the division coefficient for the Oversampler.
- This parameter can be a value of @ref ADCEx_Right_Bit_Shift */
- }ADC_InjOversamplingTypeDef;
- /**
- * @brief Structure definition of ADC channel for regular group
- * @note The setting of these parameters by function HAL_ADC_ConfigChannel() is conditioned to ADC state.
- * ADC state can be either:
- * - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'SingleDiff')
- * - For all except parameters 'SamplingTime', 'Offset', 'OffsetNumber': ADC enabled without conversion on going on regular group.
- * - For parameters 'SamplingTime', 'Offset', 'OffsetNumber': ADC enabled without conversion on going on regular and injected groups.
- * If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
- * without error reporting (as it can be the expected behavior in case of intended action to update another parameter
- * (which fulfills the ADC state condition) on the fly).
- */
- typedef struct
- {
- uint32_t Channel; /*!< Specify the channel to configure into ADC regular group.
- This parameter can be a value of @ref ADC_channels
- Note: Depending on devices and ADC instances, some channels may not be available on device package pins. Refer to device DataSheet for channels availability. */
- uint32_t Rank; /*!< Specify the rank in the regular group sequencer.
- This parameter can be a value of @ref ADC_regular_rank
- Note: 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 adjusted) */
- uint32_t SamplingTime; /*!< Sampling time value to be set for the selected channel.
- Unit: ADC clock cycles
- Conversion time is the addition of sampling time and processing time
- This parameter can be a value of @ref ADC_sampling_times
- Caution: This parameter applies to a channel that can be used into regular and/or injected group.
- It overwrites the last setting.
- Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
- sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
- Refer to device DataSheet for timings values. */
- uint32_t SingleDiff; /*!< Select single-ended or differential input.
- In differential mode: Differential measurement is carried out between the selected channel 'i' (positive input) and channel 'i+1' (negative input).
- Only channel 'i' has to be configured, channel 'i+1' is configured automatically.
- This parameter must be a value of @ref ADCEx_SingleDifferential
- Caution: This parameter applies to a channel that can be used in a regular and/or injected group.
- It overwrites the last setting.
- Note: Refer to Reference Manual to ensure the selected channel is available in differential mode.
- Note: When configuring a channel 'i' in differential mode, the channel 'i+1' is not usable separately.
- Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
- If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behavior in case
- of another parameter update on the fly) */
- uint32_t OffsetNumber; /*!< Select the offset number
- This parameter can be a value of @ref ADCEx_OffsetNumber
- Caution: Only one offset is allowed per channel. This parameter overwrites the last setting. */
- uint32_t Offset; /*!< Define the offset to be subtracted from the raw converted data.
- Offset value must be a positive number.
- Depending of ADC resolution selected (16, 14, 12, 10 or 8 bits), this parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF,
- 0x3FFF, 0xFFF, 0x3FF or 0xFF respectively.
- Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled
- without continuous mode or external trigger that could launch a conversion). */
- FunctionalState OffsetRightShift; /*!< Define the Right-shift data after Offset correction.
- This parameter is applied only for 16-bit or 8-bit resolution.
- This parameter can be set to ENABLE or DISABLE.*/
- FunctionalState OffsetSignedSaturation; /*!< Specify whether the Signed saturation feature is used or not.
- This parameter is applied only for 16-bit or 8-bit resolution.
- This parameter can be set to ENABLE or DISABLE. */
- }ADC_ChannelConfTypeDef;
- /**
- * @brief Structure definition of ADC group injected and ADC channel affected to ADC group injected
- * @note Parameters of this structure are shared within 2 scopes:
- * - Scope channel: InjectedChannel, InjectedRank, InjectedSamplingTime , InjectedSingleDiff, InjectedOffsetNumber, InjectedOffset
- * - Scope ADC group injected (affects all channels of injected group): InjectedNbrOfConversion, InjectedDiscontinuousConvMode,
- * AutoInjectedConv, QueueInjectedContext, ExternalTrigInjecConv, ExternalTrigInjecConvEdge, InjecOversamplingMode, InjecOversampling.
- * @note The setting of these parameters by function HAL_ADCEx_InjectedConfigChannel() is conditioned to ADC state.
- * ADC state can be either:
- * - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'InjectedSingleDiff')
- * - For parameters 'InjectedDiscontinuousConvMode', 'QueueInjectedContext', 'InjecOversampling': ADC enabled without conversion on going on injected group.
- * - For parameters 'InjectedSamplingTime', 'InjectedOffset', 'InjectedOffsetNumber', 'AutoInjectedConv': ADC enabled without conversion on going on regular and injected groups.
- * - For parameters 'InjectedChannel', 'InjectedRank', 'InjectedNbrOfConversion', 'ExternalTrigInjecConv', 'ExternalTrigInjecConvEdge': ADC enabled and while conversion on going
- * on ADC groups regular and injected.
- * If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
- * without error reporting (as it can be the expected behavior in case of intended action to update another parameter (which fulfills the ADC state condition) on the fly).
- */
- typedef struct
- {
- uint32_t InjectedChannel; /*!< Specifies the channel to configure into ADC group injected.
- This parameter can be a value of @ref ADC_channels
- Note: Depending on devices and ADC instances, some channels may not be available on device package pins. Refer to device datasheet for channels availability. */
- uint32_t InjectedRank; /*!< Specifies the rank in the ADC group injected sequencer.
- This parameter must be a value of @ref ADCEx_injected_rank.
- Note: 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 adjusted) */
- uint32_t InjectedSamplingTime; /*!< Sampling time value to be set for the selected channel.
- Unit: ADC clock cycles.
- Conversion time is the addition of sampling time and processing time
- This parameter can be a value of @ref ADC_sampling_times.
- Caution: This parameter applies to a channel that can be used in a regular and/or injected group.
- It overwrites the last setting.
- Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
- sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
- Refer to device datasheet for timings values. */
- uint32_t InjectedSingleDiff; /*!< Selection of single-ended or differential input.
- In differential mode: Differential measurement is between the selected channel 'i' (positive input) and channel 'i+1' (negative input).
- Only channel 'i' has to be configured, channel 'i+1' is configured automatically.
- This parameter must be a value of @ref ADCEx_SingleDifferential.
- Caution: This parameter applies to a channel that can be used in a regular and/or injected group.
- It overwrites the last setting.
- Note: Refer to Reference Manual to ensure the selected channel is available in differential mode.
- Note: When configuring a channel 'i' in differential mode, the channel 'i+1' is not usable separately.
- Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
- If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behavior in case
- of another parameter update on the fly) */
- uint32_t InjectedOffsetNumber; /*!< Selects the offset number.
- This parameter can be a value of @ref ADCEx_OffsetNumber.
- Caution: Only one offset is allowed per channel. This parameter overwrites the last setting. */
- uint32_t InjectedOffset; /*!< Defines the offset to be subtracted from the raw converted data.
- Offset value must be a positive number.
- Depending of ADC resolution selected (16, 14, 12, 10 or 8bits), this parameter must be a number
- between Min_Data = 0x0000 and Max_Data = 0xFFFF, 0x3FFF, 0xFFF, 0x3FF or 0xFF respectively.
- Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled
- without continuous mode or external trigger that could launch a conversion). */
- uint32_t InjectedOffsetRightShift; /*!< Defines the Right-shift data after Offset correction.
- This parameter is applied only for 16-bit or 8-bit resolution.
- This parameter must be a value of @ref ADCEx_Right_Bit_Shift.*/
- FunctionalState InjectedOffsetSignedSaturation; /*!< Specifies whether the Signed saturation feature is used or not.
- This parameter is applied only for 16-bit or 8-bit resolution.
- This parameter can be set to ENABLE or DISABLE. */
- uint32_t InjectedLeftBitShift; /*!< Configures the left shifting applied to the final result with or without oversampling.
- This parameter can be a value of @ref ADCEx_Left_Bit_Shift */
- uint32_t InjectedNbrOfConversion; /*!< Specifies the number of ranks that will be converted within the ADC group injected sequencer.
- To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
- This parameter must be a number between Min_Data = 1 and Max_Data = 4.
- Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
- configure a channel on injected group can impact the configuration of other channels previously set. */
- FunctionalState InjectedDiscontinuousConvMode; /*!< Specifies whether the conversions sequence of ADC group injected is performed in Complete-sequence/Discontinuous-sequence
- (main sequence subdivided in successive parts).
- Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
- Discontinuous mode can be enabled only if continuous mode is disabled.
- This parameter can be set to ENABLE or DISABLE.
- Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
- Note: For injected group, discontinuous mode converts the sequence channel by channel (discontinuous length fixed to 1 rank).
- Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
- configure a channel on injected group can impact the configuration of other channels previously set. */
- FunctionalState AutoInjectedConv; /*!< Enables or disables the selected ADC group injected automatic conversion after regular one
- This parameter can be set to ENABLE or DISABLE.
- Note: To use Automatic injected conversion, discontinuous mode must be disabled ('DiscontinuousConvMode' and 'InjectedDiscontinuousConvMode' set to DISABLE)
- Note: To use Automatic injected conversion, injected group external triggers must be disabled ('ExternalTrigInjecConv' set to ADC_INJECTED_SOFTWARE_START)
- 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.
- To maintain JAUTO always enabled, DMA must be configured in circular mode.
- Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
- configure a channel on injected group can impact the configuration of other channels previously set. */
- FunctionalState QueueInjectedContext; /*!< Specifies whether the context queue feature is enabled.
- This parameter can be set to ENABLE or DISABLE.
- If context queue is enabled, injected sequencer&channels configurations are queued on up to 2 contexts. If a
- new injected context is set when queue is full, error is triggered by interruption and through function
- 'HAL_ADCEx_InjectedQueueOverflowCallback'.
- Caution: This feature request that the sequence is fully configured before injected conversion start.
- Therefore, configure channels with as many calls to HAL_ADCEx_InjectedConfigChannel() as the 'InjectedNbrOfConversion' parameter.
- Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
- configure a channel on injected group can impact the configuration of other channels previously set.
- Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion). */
- uint32_t ExternalTrigInjecConv; /*!< Selects the external event used to trigger the conversion start of injected group.
- If set to ADC_INJECTED_SOFTWARE_START, external triggers are disabled and software trigger is used instead.
- This parameter can be a value of @ref ADCEx_Injected_External_Trigger_Source.
- Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
- configure a channel on injected group can impact the configuration of other channels previously set. */
- uint32_t ExternalTrigInjecConvEdge; /*!< Selects the external trigger edge of injected group.
- This parameter can be a value of @ref ADC_injected_external_trigger_edge.
- If trigger source is set to ADC_INJECTED_SOFTWARE_START, this parameter is discarded.
- Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
- configure a channel on injected group can impact the configuration of other channels previously set. */
- FunctionalState InjecOversamplingMode; /*!< Specifies whether the oversampling feature is enabled or disabled.
- This parameter can be set to ENABLE or DISABLE.
- Note: This parameter can be modified only if there is no conversion is ongoing (both ADSTART and JADSTART cleared) */
- ADC_InjOversamplingTypeDef InjecOversampling; /*!< Specifies the Oversampling parameters.
- Caution: this setting overwrites the previous oversampling configuration if oversampling already enabled.
- Note: This parameter can be modified only if there is no conversion is ongoing (both ADSTART and JADSTART cleared). */
- }ADC_InjectionConfTypeDef;
- /**
- * @brief Structure definition of ADC MultiMode
- * @note The setting of these parameters by function HAL_ADCEx_MultiModeConfigChannel() is conditioned by ADCs state (both Master and Slave ADCs).
- * Both Master and Slave ADCs must be disabled.
- */
- typedef struct
- {
- uint32_t Mode; /*!< Configures the ADC to operate in independent or MultiMode.
- This parameter can be a value of @ref ADCEx_Common_mode */
- uint32_t DualModeData; /*!< Configures the Dual ADC Mode Data Format:
- This parameter can be a value of @ref ADCEx_Dual_Mode_Data_Format */
- uint32_t TwoSamplingDelay; /*!< Configures the Delay between 2 sampling phases.
- This parameter can be a value of @ref ADCEx_delay_between_2_sampling_phases
- Delay range depends on selected resolution:
- from 1 to 9 clock cycles for 16 bits,
- from 1 to 9 clock cycles for 14 bits
- from 1 to 8 clock cycles for 12 bits
- from 1 to 6 clock cycles for 10 bits
- from 1 to 6 clock cycles for 8 bits */
- }ADC_MultiModeTypeDef;
复制代码
|
|