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

📄 ad7705.h

📁 AD7705驱动程序
💻 H
字号:
/////////////////////////////////////////////////////////////////////////////
////Copyright (c) 2008,重庆大唐测控系统有限公司
////All rights reserved. 
////
////文件名称:AD7705.h
////摘    要:
////         1、使用2.4576M晶体
////         2、先复位芯片  adc_rest() 
////         3、再初始化芯片  adc1_init() 
////         4、读取一个通道的AD值 adc1_read_value()
/////////////////////////////////////////////////////////////////////////////
////当前版本:1.1.2
////作    者:yangxd
////完成日期:2008-11-23
/////////////////////////////////////////////////////////////////////////////

#include "p89v51.h"

#ifndef __AD7705_H__
#define __AD7705_H__

//引脚定义
sbit ADC_DI = P1^2;
sbit ADC_DO = P1^3;
sbit ADC_CLK = P1^0; 
sbit ADC_RESET = P1^7;

sbit ADC1_CS = P2^6;
sbit ADC2_CS = P2^7;
sbit ADC1_DRDY = P2^4;
sbit ADC2_DRDY = P2^5;	

//Operation modes
#define ADC_NORMAL 			0x00
#define ADC_SELF       		0x40
#define ADC_ZERO_SCALE 		0x80
#define ADC_FULL_SCALE 		0xc0

//Gain settings
#define ADC_GAIN_1 			0x00
#define ADC_GAIN_2 			0x08
#define ADC_GAIN_4 			0x10
#define ADC_GAIN_8 			0x18
#define ADC_GAIN_16 		0x20
#define ADC_GAIN_32 		0x28
#define ADC_GAIN_64 		0x30
#define ADC_GAIN_128 		0x38

//Polar operations
#define ADC_BIPOLAR 		0x00
#define ADC_UNIPOLAR 		0x04

//update rates
#define ADC_50 				0x04
#define ADC_60 				0x05
#define ADC_250 			0x06
#define ADC_500 			0x07

extern void adc_rest();
extern void adc1_init(unsigned char calmode, unsigned char gainsetting, unsigned char operation, unsigned char rate);
extern unsigned int adc1_read_value(unsigned char ch);
extern void adc2_init(unsigned char calmode, unsigned char gainsetting, unsigned char operation, unsigned char rate);
extern unsigned int adc2_read_value(unsigned char ch);

#endif

⌨️ 快捷键说明

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