2
2
******************************************************************************
3
3
* @file stm32f3xx_hal_adc_ex.c
4
4
* @author MCD Application Team
5
- * @version V1.2.1
6
- * @date 29-April-2015
5
+ * @version V1.3.0
6
+ * @date 01-July-2016
7
7
* @brief This file provides firmware functions to manage the following
8
8
* functionalities of the Analog to Digital Convertor (ADC)
9
9
* peripheral:
@@ -6941,8 +6941,11 @@ HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef* hadc, ADC_
6941
6941
/* Check the parameters */
6942
6942
assert_param (IS_ADC_MULTIMODE_MASTER_INSTANCE (hadc -> Instance ));
6943
6943
assert_param (IS_ADC_MODE (multimode -> Mode ));
6944
- assert_param (IS_ADC_DMA_ACCESS_MODE (multimode -> DMAAccessMode ));
6945
- assert_param (IS_ADC_SAMPLING_DELAY (multimode -> TwoSamplingDelay ));
6944
+ if (multimode -> Mode != ADC_MODE_INDEPENDENT )
6945
+ {
6946
+ assert_param (IS_ADC_DMA_ACCESS_MODE (multimode -> DMAAccessMode ));
6947
+ assert_param (IS_ADC_SAMPLING_DELAY (multimode -> TwoSamplingDelay ));
6948
+ }
6946
6949
6947
6950
/* Process locked */
6948
6951
__HAL_LOCK (hadc );
@@ -6964,31 +6967,22 @@ HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef* hadc, ADC_
6964
6967
/* control registers) */
6965
6968
tmpADC_Common = ADC_COMMON_REGISTER (hadc );
6966
6969
6967
- /* Configuration of ADC common group ADC1&ADC2, ADC3&ADC4 if available */
6968
- /* (ADC2, ADC3, ADC4 availability depends on STM32 product) */
6969
- /* - DMA access mode */
6970
- MODIFY_REG (tmpADC_Common -> CCR ,
6971
- ADC_CCR_MDMA |
6972
- ADC_CCR_DMACFG ,
6973
- multimode -> DMAAccessMode |
6974
- ADC_CCR_MULTI_DMACONTREQ (hadc -> Init .DMAContinuousRequests ) );
6975
-
6976
- /* Parameters that can be updated only when ADC is disabled: */
6977
- /* - Multimode mode selection */
6978
- /* - Multimode delay */
6979
- /* Note: If ADC is not in the appropriate state to modify these */
6980
- /* parameters, their setting is bypassed without error reporting */
6981
- /* (as it can be the expected behaviour in case of intended action */
6982
- /* to update parameter above (which fulfills the ADC state */
6983
- /* condition: no conversion on going on group regular) */
6984
- /* on the fly). */
6985
- if ((ADC_IS_ENABLE (hadc ) == RESET ) &&
6986
- (ADC_IS_ENABLE (& tmphadcSharingSameCommonRegister ) == RESET ) )
6970
+ /* If multimode is selected, configure all multimode paramaters. */
6971
+ /* Otherwise, reset multimode parameters (can be used in case of */
6972
+ /* transition from multimode to independent mode). */
6973
+ if (multimode -> Mode != ADC_MODE_INDEPENDENT )
6987
6974
{
6988
6975
/* Configuration of ADC common group ADC1&ADC2, ADC3&ADC4 if available */
6989
6976
/* (ADC2, ADC3, ADC4 availability depends on STM32 product) */
6990
- /* - set the selected multimode */
6991
6977
/* - DMA access mode */
6978
+ MODIFY_REG (tmpADC_Common -> CCR ,
6979
+ ADC_CCR_MDMA |
6980
+ ADC_CCR_DMACFG ,
6981
+ multimode -> DMAAccessMode |
6982
+ ADC_CCR_MULTI_DMACONTREQ (hadc -> Init .DMAContinuousRequests ) );
6983
+
6984
+ /* Parameters that can be updated only when ADC is disabled: */
6985
+ /* - Multimode mode selection */
6992
6986
/* - Set delay between two sampling phases */
6993
6987
/* Note: Delay range depends on selected resolution: */
6994
6988
/* from 1 to 12 clock cycles for 12 bits */
@@ -6997,11 +6991,34 @@ HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef* hadc, ADC_
6997
6991
/* from 1 to 6 clock cycles for 6 bits */
6998
6992
/* If a higher delay is selected, it will be clamped to maximum delay */
6999
6993
/* range */
7000
- MODIFY_REG (tmpADC_Common -> CCR ,
7001
- ADC_CCR_MULTI |
7002
- ADC_CCR_DELAY ,
7003
- multimode -> Mode |
7004
- multimode -> TwoSamplingDelay );
6994
+ /* Note: If ADC is not in the appropriate state to modify these */
6995
+ /* parameters, their setting is bypassed without error reporting */
6996
+ /* (as it can be the expected behaviour in case of intended action */
6997
+ /* to update parameter above (which fulfills the ADC state */
6998
+ /* condition: no conversion on going on group regular) */
6999
+ /* on the fly). */
7000
+ if ((ADC_IS_ENABLE (hadc ) == RESET ) &&
7001
+ (ADC_IS_ENABLE (& tmphadcSharingSameCommonRegister ) == RESET ) )
7002
+ {
7003
+ MODIFY_REG (tmpADC_Common -> CCR ,
7004
+ ADC_CCR_MULTI |
7005
+ ADC_CCR_DELAY ,
7006
+ multimode -> Mode |
7007
+ multimode -> TwoSamplingDelay );
7008
+ }
7009
+ }
7010
+ else /* ADC_MODE_INDEPENDENT */
7011
+ {
7012
+ CLEAR_BIT (tmpADC_Common -> CCR , ADC_CCR_MDMA | ADC_CCR_DMACFG );
7013
+
7014
+ /* Parameters that can be updated only when ADC is disabled: */
7015
+ /* - Multimode mode selection */
7016
+ /* - Multimode delay */
7017
+ if ((ADC_IS_ENABLE (hadc ) == RESET ) &&
7018
+ (ADC_IS_ENABLE (& tmphadcSharingSameCommonRegister ) == RESET ) )
7019
+ {
7020
+ CLEAR_BIT (tmpADC_Common -> CCR , ADC_CCR_MULTI | ADC_CCR_DELAY );
7021
+ }
7005
7022
}
7006
7023
}
7007
7024
/* If one of the ADC sharing the same common group is enabled, no update */
0 commit comments