Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 5 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /** |
1 | /** |
2 | ****************************************************************************** |
2 | ****************************************************************************** |
3 | * @file stm32f1xx_hal_adc_ex.c |
3 | * @file stm32f1xx_hal_adc_ex.c |
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @version V1.0.1 |
5 | * @version V1.0.4 |
6 | * @date 31-July-2015 |
6 | * @date 29-April-2016 |
7 | * @brief This file provides firmware functions to manage the following |
7 | * @brief This file provides firmware functions to manage the following |
8 | * functionalities of the Analog to Digital Convertor (ADC) |
8 | * functionalities of the Analog to Digital Convertor (ADC) |
9 | * peripheral: |
9 | * peripheral: |
10 | * + Operation functions |
10 | * + Operation functions |
11 | * ++ Start, stop, get result of conversions of injected |
11 | * ++ Start, stop, get result of conversions of injected |
Line 24... | Line 24... | ||
24 | [..] |
24 | [..] |
25 | @endverbatim |
25 | @endverbatim |
26 | ****************************************************************************** |
26 | ****************************************************************************** |
27 | * @attention |
27 | * @attention |
28 | * |
28 | * |
29 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
29 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
30 | * |
30 | * |
31 | * Redistribution and use in source and binary forms, with or without modification, |
31 | * Redistribution and use in source and binary forms, with or without modification, |
32 | * are permitted provided that the following conditions are met: |
32 | * are permitted provided that the following conditions are met: |
33 | * 1. Redistributions of source code must retain the above copyright notice, |
33 | * 1. Redistributions of source code must retain the above copyright notice, |
34 | * this list of conditions and the following disclaimer. |
34 | * this list of conditions and the following disclaimer. |
Line 713... | Line 713... | ||
713 | /* Process unlocked */ |
713 | /* Process unlocked */ |
714 | __HAL_UNLOCK(hadc); |
714 | __HAL_UNLOCK(hadc); |
715 | 715 | ||
716 | return HAL_ERROR; |
716 | return HAL_ERROR; |
717 | } |
717 | } |
718 | 718 | ||
719 | /* Enable the ADC peripherals: master and slave (in case if not already */ |
719 | /* Enable the ADC peripherals: master and slave (in case if not already */ |
720 | /* enabled previously) */ |
720 | /* enabled previously) */ |
721 | tmp_hal_status = ADC_Enable(hadc); |
721 | tmp_hal_status = ADC_Enable(hadc); |
722 | if (tmp_hal_status == HAL_OK) |
722 | if (tmp_hal_status == HAL_OK) |
723 | { |
723 | { |
Line 896... | Line 896... | ||
896 | } |
896 | } |
897 | #endif /* STM32F101xG || defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */ |
897 | #endif /* STM32F101xG || defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */ |
898 | 898 | ||
899 | /** |
899 | /** |
900 | * @brief Get ADC injected group conversion result. |
900 | * @brief Get ADC injected group conversion result. |
- | 901 | * @note Reading register JDRx automatically clears ADC flag JEOC |
|
- | 902 | * (ADC group injected end of unitary conversion). |
|
- | 903 | * @note This function does not clear ADC flag JEOS |
|
- | 904 | * (ADC group injected end of sequence conversion) |
|
- | 905 | * Occurrence of flag JEOS rising: |
|
- | 906 | * - If sequencer is composed of 1 rank, flag JEOS is equivalent |
|
- | 907 | * to flag JEOC. |
|
- | 908 | * - If sequencer is composed of several ranks, during the scan |
|
- | 909 | * sequence flag JEOC only is raised, at the end of the scan sequence |
|
- | 910 | * both flags JEOC and EOS are raised. |
|
- | 911 | * Flag JEOS must not be cleared by this function because |
|
- | 912 | * it would not be compliant with low power features |
|
- | 913 | * (feature low power auto-wait, not available on all STM32 families). |
|
- | 914 | * To clear this flag, either use function: |
|
- | 915 | * in programming model IT: @ref HAL_ADC_IRQHandler(), in programming |
|
- | 916 | * model polling: @ref HAL_ADCEx_InjectedPollForConversion() |
|
- | 917 | * or @ref __HAL_ADC_CLEAR_FLAG(&hadc, ADC_FLAG_JEOS). |
|
901 | * @param hadc: ADC handle |
918 | * @param hadc: ADC handle |
902 | * @param InjectedRank: the converted ADC injected rank. |
919 | * @param InjectedRank: the converted ADC injected rank. |
903 | * This parameter can be one of the following values: |
920 | * This parameter can be one of the following values: |
904 | * @arg ADC_INJECTED_RANK_1: Injected Channel1 selected |
921 | * @arg ADC_INJECTED_RANK_1: Injected Channel1 selected |
905 | * @arg ADC_INJECTED_RANK_2: Injected Channel2 selected |
922 | * @arg ADC_INJECTED_RANK_2: Injected Channel2 selected |
906 | * @arg ADC_INJECTED_RANK_3: Injected Channel3 selected |
923 | * @arg ADC_INJECTED_RANK_3: Injected Channel3 selected |
907 | * @arg ADC_INJECTED_RANK_4: Injected Channel4 selected |
924 | * @arg ADC_INJECTED_RANK_4: Injected Channel4 selected |
908 | * @retval None |
925 | * @retval ADC group injected conversion data |
909 | */ |
926 | */ |
910 | uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank) |
927 | uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank) |
911 | { |
928 | { |
912 | uint32_t tmp_jdr = 0; |
929 | uint32_t tmp_jdr = 0; |
913 | 930 | ||
914 | /* Check the parameters */ |
931 | /* Check the parameters */ |
915 | assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance)); |
932 | assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance)); |
916 | assert_param(IS_ADC_INJECTED_RANK(InjectedRank)); |
933 | assert_param(IS_ADC_INJECTED_RANK(InjectedRank)); |
917 | - | ||
918 | /* Clear injected group conversion flag to have similar behaviour as */ |
- | |
919 | /* regular group: reading data register also clears end of conversion flag. */ |
- | |
920 | __HAL_ADC_CLEAR_FLAG(hadc, ADC_FLAG_JEOC); |
- | |
921 | 934 | ||
922 | /* Get ADC converted value */ |
935 | /* Get ADC converted value */ |
923 | switch(InjectedRank) |
936 | switch(InjectedRank) |
924 | { |
937 | { |
925 | case ADC_INJECTED_RANK_4: |
938 | case ADC_INJECTED_RANK_4: |
Line 980... | Line 993... | ||
980 | * @param hadc: ADC handle |
993 | * @param hadc: ADC handle |
981 | * @retval None |
994 | * @retval None |
982 | */ |
995 | */ |
983 | __weak void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc) |
996 | __weak void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc) |
984 | { |
997 | { |
- | 998 | /* Prevent unused argument(s) compilation warning */ |
|
- | 999 | UNUSED(hadc); |
|
985 | /* NOTE : This function Should not be modified, when the callback is needed, |
1000 | /* NOTE : This function Should not be modified, when the callback is needed, |
986 | the HAL_ADCEx_InjectedConvCpltCallback could be implemented in the user file |
1001 | the HAL_ADCEx_InjectedConvCpltCallback could be implemented in the user file |
987 | */ |
1002 | */ |
988 | } |
1003 | } |
989 | 1004 |