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

📄 ad.c

📁 s3c44b0的lcd-driver 可以运行
💻 C
字号:
/*
 *************************************************************************
 * Copyright (c) 2003, The Lab of Embedded System and Net Security,WHUT..
 * All rights reserved. 
 *
 * Filename:    ad.c
 * Discription: This file test ad converter.
 * 
 * version:            1.0
 * Author:             Qiu Yanfei <qyfhm@tom.com>
 * Accomplished Date:  2004/7/10 16:31:00
 *************************************************************************
*/
#include "..\cpu\44breg.h"

#include "ad.h"

void ad_init(void)
{
    rADCPSR = 20;           //sample rate 32 
    rADCCON = AD_SLEEP;     //enter sleep mode
}

U16 ad_convert(U8 line)
{    
    rADCCON = AD_ENABLE | (line<<2);       //Start A/D conversion
    
    while(rADCCON&AD_ENABLE);       //To avoid The first FLAG error case.
    
    while(!(rADCCON & AD_FLAG));    //Wait until conversion completed.
    
    return (U16)rADCDAT;
}

⌨️ 快捷键说明

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