⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adc12.c

📁 Mouse for USB demo, based on STR710
💻 C
字号:
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name          : adc12.c
* Author             : MCD Application Team
* Date First Issued  : 31/07/2003
* Description        : Code sources of ADC12 functions
********************************************************************************
* History:
*  30/07/03 : Created
*  24/07/04 : #include "rccu.h" deleted
*******************************************************************************/
#include "adc12.h"

/*******************************************************************************
* Function Name      : ADC12_Init
* Description        : Initialize the ADC
* Input              : None.
* Return             : None.
*******************************************************************************/
void ADC12_Init(void)
{
  //Initiate ADC12 registers to their reset values
  ADC12->CSR  = 0x00;
  ADC12->CPR = 0x01;
}

/*******************************************************************************
* Function Name      : ADC12_PrescalerConfig
* Description        : Configure the prescaler
* Input              : None.
* Return             : None.
*******************************************************************************/
void ADC12_PrescalerConfig(u32 Adc12_clk)
{
  //Update the Prescaler Register
  ADC12->CPR = (vu16) (RCCU_FrequencyValue(RCCU_PCLK)/(Adc12_clk*512*4));
}

/*******************************************************************************
* Function Name      : ADC12_ITConfig
* Description        : enable or disable the interrupt
* Input              : status=ENABLE=>enable interrupt
*                      status=DISABLE=>disable interrupt
* Return             : None
*******************************************************************************/
void ADC12_ITConfig(FunctionalState NewState)
{
  if (NewState == ENABLE)
  {
    // Test the conversion mode
    if (ADC12->CSR & 0x0040)
    {
      // Set interrupt bit equivalent to the channel selected
      switch (ADC12->CSR & 0x30)
      {
        case 0x00 : ADC12->CSR |= ADC12_IT0_Mask;  break;
        case 0x10 : ADC12->CSR |= ADC12_IT1_Mask;  break;
        case 0x20 : ADC12->CSR |= ADC12_IT2_Mask;  break;
        case 0x30 : ADC12->CSR |= ADC12_IT3_Mask;  break;
      }
    }
    else
      // Set all interrupt bits in case of round robin mode
      ADC12->CSR |= ADC12_IT_Mask;
  }
  else
    // Clear all interrupt bits
    ADC12->CSR &= ~ADC12_IT_Mask;
}
/*********************(c) 2003  STMicroelectronics********************* END OF FILE **/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -