ad_convert.c
来自「uccos2的的源码文件」· C语言 代码 · 共 47 行
C
47 行
/****************************************Copyright (c)**************************************************
********************************************************************************************************/
#define IN_ADCONVERT
#include "S3C2410.h"
#include "ad_convert.h"
/********************************************
* *funcition:send the converted value to queue
********************************************/
unsigned int read_value(void)
{
unsigned int ad;
ad = (unsigned int)rADCDAT0 & 0x3ff;
return ad;
}
/*******************************************
* *
*******************************************/
void AD_init(void)
{
rCLKCON |= 1<<15; //enable the ADC clock
}
/**********************************************
* *
**********************************************/
void start_adc(unsigned int chanel)
{
int i;
static int prevCh=-1;
unsigned int preScaler;
preScaler = 50000000/ADC_FREQ -1;
rADCCON = (1<<14) | (preScaler<<6) | (chanel<<3); //setup channel
rADCCON|=0x1; //start AD convert
//while(rADCCON & 0x1); //check if Enable_start is low
while(rADCCON & 0x1); //Check if Enable_start is low
while(!(0x8000&rADCCON)); //Check ECFLG
}
//---------------------------------------end------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?