📄 stm32f10x_adc.lst
字号:
640 tmpreg2 = (u32)ADC_Channel << (5 * (Rank - 13));
641 /* Set the SQx bits for the selected rank */
642 tmpreg1 |= tmpreg2;
643 /* Store the new register value */
644 ADCx->SQR1 = tmpreg1;
645 }
646 }
647
648 /*******************************************************************************
649 * Function Name : ADC_ExternalTrigConvCmd
650 * Description : Enables or disables the ADCx conversion through external trigger.
651 * Input : - ADCx: where x can be 1 or 2 to select the ADC peripheral.
652 * - NewState: new state of the selected ADC external trigger
653 * start of conversion.
654 * This parameter can be: ENABLE or DISABLE.
655 * Output : None
656 * Return : None
657 *******************************************************************************/
658 void ADC_ExternalTrigConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
659 {
660 /* Check the parameters */
661 assert_param(IS_FUNCTIONAL_STATE(NewState));
662
663 if (NewState != DISABLE)
664 {
665 /* Enable the selected ADC conversion on external event */
666 ADCx->CR2 |= CR2_EXTTRIG_Set;
667 }
668 else
669 {
670 /* Disable the selected ADC conversion on external event */
671 ADCx->CR2 &= CR2_EXTTRIG_Reset;
672 }
673 }
674
675 /*******************************************************************************
676 * Function Name : ADC_GetConversionValue
677 * Description : Returns the last ADCx conversion result data for regular channel.
678 * Input : - ADCx: where x can be 1 or 2 to select the ADC peripheral.
679 * Output : None
680 * Return : The Data conversion value.
681 *******************************************************************************/
682 u16 ADC_GetConversionValue(ADC_TypeDef* ADCx)
683 {
684 /* Return the selected ADC conversion value */
685 return (u16) ADCx->DR;
686 }
687
688 /*******************************************************************************
689 * Function Name : ADC_GetDualModeConversionValue
690 * Description : Returns the last ADCs conversion result data in dual mode.
691 * Output : None
692 * Return : The Data conversion value.
693 *******************************************************************************/
694 u32 ADC_GetDualModeConversionValue(void)
695 {
696 /* Return the dual mode conversion value */
697 return ADC1->DR;
698 }
699
700 /*******************************************************************************
701 * Function Name : ADC_AutoInjectedConvCmd
702 * Description : Enables or disables the selected ADC automatic injected group
703 * conversion after regular one.
704 * Input : - ADCx: where x can be 1 or 2 to select the ADC peripheral.
705 * - NewState: new state of the selected ADC auto injected
706 * conversion
707 * This parameter can be: ENABLE or DISABLE.
708 * Output : None
709 * Return : None
710 *******************************************************************************/
711 void ADC_AutoInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
712 {
713 /* Check the parameters */
714 assert_param(IS_FUNCTIONAL_STATE(NewState));
715
716 if (NewState != DISABLE)
717 {
718 /* Enable the selected ADC automatic injected group conversion */
719 ADCx->CR1 |= CR1_JAUTO_Set;
720 }
721 else
722 {
723 /* Disable the selected ADC automatic injected group conversion */
724 ADCx->CR1 &= CR1_JAUTO_Reset;
725 }
726 }
727
728 /*******************************************************************************
729 * Function Name : ADC_InjectedDiscModeCmd
730 * Description : Enables or disables the discontinuous mode for injected group
731 * channel for the specified ADC
732 * Input : - ADCx: where x can be 1 or 2 to select the ADC peripheral.
733 * - NewState: new state of the selected ADC discontinuous mode
734 * on injected group channel.
735 * This parameter can be: ENABLE or DISABLE.
736 * Output : None
737 * Return : None
738 *******************************************************************************/
739 void ADC_InjectedDiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
740 {
741 /* Check the parameters */
742 assert_param(IS_FUNCTIONAL_STATE(NewState));
743
744 if (NewState != DISABLE)
745 {
746 /* Enable the selected ADC injected discontinuous mode */
747 ADCx->CR1 |= CR1_JDISCEN_Set;
748 }
749 else
750 {
751 /* Disable the selected ADC injected discontinuous mode */
752 ADCx->CR1 &= CR1_JDISCEN_Reset;
753 }
754 }
755
756 /*******************************************************************************
757 * Function Name : ADC_ExternalTrigInjectedConvConfig
758 * Description : Configures the ADCx external trigger for injected channels conversion.
759 * Input : - ADCx: where x can be 1 or 2 to select the ADC peripheral.
760 * - ADC_ExternalTrigInjecConv: specifies the ADC trigger to
761 * start injected conversion.
762 * This parameter can be one of the following values:
763 * - ADC_ExternalTrigInjecConv_T1_TRGO: Timer1 TRGO event
764 * selected
765 * - ADC_ExternalTrigInjecConv_T1_CC4: Timer1 capture
766 * compare4 selected
767 * - ADC_ExternalTrigInjecConv_T2_TRGO: Timer2 TRGO event
768 * selected
769 * - ADC_External TrigInjecConv_T2_CC1: Timer2 capture
770 * compare1 selected
771 * - ADC_ExternalTrigInjecConv_T3_CC4: Timer3 capture
772 * compare4 selected
773 * - ADC_ExternalTrigInjecConv_T4_TRGO: Timer4 TRGO event
774 * selected
775 * - ADC_ExternalTrigInjecConv_Ext_Interrupt15: External
776 * interrupt 15 event selected
777 * - ADC_ExternalTrigInjecConv_None: Injected conversion
778 * started by software and not by external trigger
779 * Output : None
780 * Return : None
781 *******************************************************************************/
782 void ADC_ExternalTrigInjectedConvConfig(ADC_TypeDef* ADCx, u32 ADC_ExternalTrigInjecConv)
783 {
784 u32 tmpreg = 0;
785
786 /* Check the parameters */
787 assert_param(IS_ADC_EXT_INJEC_TRIG(ADC_ExternalTrigInjecConv));
788
789 /* Get the old register value */
790 tmpreg = ADCx->CR2;
791 /* Clear the old external event selection for injected group */
792 tmpreg &= CR2_JEXTSEL_Reset;
793 /* Set the external event selection for injected group */
794 tmpreg |= ADC_ExternalTrigInjecConv;
795 /* Store the new register value */
796 ADCx->CR2 = tmpreg;
797 }
798
799 /*******************************************************************************
800 * Function Name : ADC_ExternalTrigInjectedConvCmd
801 * Description : Enables or disables the ADCx injected channels conversion
802 * through external trigger
803 * Input : - ADCx: where x can be 1 or 2 to select the ADC peripheral.
804 * - NewState: new state of the selected ADC external trigger
805 * start of injected conversion.
806 * This parameter can be: ENABLE or DISABLE.
807 * Output : None
808 * Return : None
809 *******************************************************************************/
810 void ADC_ExternalTrigInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
811 {
812 /* Check the parameters */
813 assert_param(IS_FUNCTIONAL_STATE(NewState));
814
815 if (NewState != DISABLE)
816 {
817 /* Enable the selected ADC external event selection for injected group */
818 ADCx->CR2 |= CR2_JEXTTRIG_Set;
819 }
820 else
821 {
822 /* Disable the selected ADC external event selection for injected group */
823 ADCx->CR2 &= CR2_JEXTTRIG_Reset;
824 }
825 }
826
827 /*******************************************************************************
828 * Function Name : ADC_SoftwareStartInjectedConvCmd
829 * Description : Enables or disables the selected ADC start of the injected
830 * channels conversion.
831 * Input : - ADCx: where x can be 1 or 2 to select the ADC peripheral.
832 * - NewState: new state of the selected ADC software start
833 * injected conversion.
834 * This parameter can be: ENABLE or DISABLE.
835 * Output : None
836 * Return : None
837 *******************************************************************************/
838 void ADC_SoftwareStartInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
839 {
840 /* Check the parameters */
841 assert_param(IS_FUNCTIONAL_STATE(NewState));
842
843 if (NewState != DISABLE)
844 {
845 /* Enable the selected ADC external event selection for injected group */
846 /* Starts the selected ADC injected conversion */
847 ADCx->CR2 |= CR2_JEXTTRIG_JSWSTRT_Set;
848 }
849 else
850 {
851 /* Stops the selected ADC injected conversion */
852 /* Disable the selected ADC external event selection for injected group */
853 ADCx->CR2 &= CR2_JEXTTRIG_JSWSTRT_Reset;
854 }
855 }
856
857 /*******************************************************************************
858 * Function Name : ADC_GetSoftwareStartInjectedConvCmdStatus
859 * Description : Gets the selected ADC Software start injected conversion Status.
860 * Input : - ADCx: where x can be 1 or 2 to select the ADC peripheral.
861 * Output : None
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -