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

📄 system.c

📁 这里有很多我自己做的凌阳单片机源程序
💻 C
字号:
//底层驱动函数
#include<spce061a_chf.h>
#include"zhonghe.h"
#include"bit.h"
//////////////////////////////////////////////////
//函数:void check_busy(void)
//描述:检测"忙"信号的函数,并等待到"闲"
//参数:无
//返回:无	
///////////////////////////////////////////////////
void check_busy()
{
	unsigned int c;
	
	PB_Dir->byte.byteh=0x00;
	PB->byte.byteh=0xff;//悬浮式输入	
		
	do
	{
		*P_Watchdog_Clear=0x01;	
		P1_5=0;//rs=0
		P1_6=1;//rw=1
		P1_7=1;//E=1	
		c=PB->byte.byteh;//只读出高8位			
		P1_7=0;//E=0;
		asm("nop");		
		c&=0x80;	
	}while(c==0x80);	
}
//////////////////////////////////////////////////
//函数:void write_command(unsigned int command)
//描述:写一个字节的命令到LCD中的控制寄存器当中
//参数:command--要写入的命令
//返回:无	
///////////////////////////////////////////////////
void write_command(unsigned int command)
{	
	check_busy();
	PB_Dir->byte.byteh=0xff;
	PB->byte.byteh=command;//操作高8位	
	P1_5=0;//rs=0
	P1_6=0;//rw=0
	P1_7=1;//E=1
	asm("nop");		
	P1_7=0;//E=0;//下降沿触发
	asm("nop");		
}
//////////////////////////////////////////////////
//函数:void write_data(unsigned int data2)
//描述:写一个字节的数据到LCD中的控制寄存器当中
//参数:data2--要写入的数据
//返回:无	
///////////////////////////////////////////////////
void write_data(unsigned int data2)
{
	check_busy();
	PB_Dir->byte.byteh=0xff;
	PB->byte.byteh=data2;//操作高8位	
	P1_5=1;//rs=1	
	P1_6=0;//rw=0
	P1_7=1;//E=1
	asm("nop");	
	P1_7=0;//E=0;//下降沿触发
	asm("nop");		
}
///////////////////////////////////////////
//函数:unsigned int AD(void)
//描述:进行AD采集
//参数:无
//返回:返回电压数字量
/////////////////////////////////////////////
unsigned int AD(void)
{
	unsigned int ui_Data;
	while(!(Get_ADC_MUX_Ctrl()&0x8000));
	ui_Data=Get_ADC_LineIn_Data();
	return(ui_Data&0xffc0);
}

⌨️ 快捷键说明

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