ad.h

来自「atmega128的多路ADC转换程序,可移植性强,可读性强」· C头文件 代码 · 共 60 行

H
60
字号
/***********************  宏定义  ************************/
#ifndef TIME_1MS
		#define	TIME_1MS			0x94	        /* T0中断载入值外部11.0592M */
#endif			

/* ATmega128的5个模拟量采集通道 */
#define	ADC0				0
#define	ADC1				1
#define	ADC2				2
#define ADC3                            3
#define	ADC4				4

/***********************  常量定义  ************************/
#define SAMPLE_TIMES	12					/* 每路模拟量采样次数 */

/* 模拟量通道定义 */
#define	DT_				 2	/* 排气温度 */
#define C2_                              1       /* 室外热交换温度C2 */
#define C1_                              0       /* 室外热交换温度C1 */
#define CT1_                             3       /* CT电流 */
#define CT2_                             4       /* 涡旋热保护温度 */

#define	START_CHANNEL		C1_		       //定义起始模拟通道
#define END_CHANNEL		CT2_    	       //定义最终模拟通道
//#define TOTAL_CHANNEL	(END_CHANNEL-START_CHANNEL+1)  //定义模拟通道总数

#define	DisableInterrupt()	asm( "cli" )	/* 禁止中断 */
#define	EnableInterrupt()	asm( "sei" )	/* 打开中断 */



/*********************  函数原型定义  **********************/
void	DisableWatchDog( void );
void	EnableWatchDog( void );
void	InitT0( void );
void	InitADC( void );		/* 初始化A/D转换 */
void	T0_Interrupt( void );
void	ADC_Interrupt( void );
void	DisableT0Interrupt( void );
void	EnableT0Interrupt( void );
void	StartADConvert( void );
void	ChangeADChannel( void );	/* 切换模拟量通道 */
void	SampleInSys( void );		/* 采样模块主函数 */
void	InitSample( void );		/* 初始化模拟数据采样结构 */
void	InitRealData( void );		/* 初始化实时数据 */
static void	CalAnalogData( void );	/* 计算模拟量对应的实际值 */


#define A1      0.000015388       /* PTC-51H */
#define B1      0.00503993        /* PTC-51H */
#define F1      1.0535278         /* PTC-51H */
#define H1      11.375            /* PTC-51H */

#define A2      0.00001505        /* PBC-41E */
#define B2      0.00504565        /* PBC-41E */
#define F2      0.9550179         /* PBC-41E */
#define H2      42.4375           /* PBC-41E */


#define	DEFAULT_TEMP	        12.0				/* 缺省温度 */

⌨️ 快捷键说明

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