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

📄 main.c

📁 这里有很多我自己做的凌阳单片机源程序
💻 C
字号:
//		LCD  D0~D7接IOA0~IOA7
//		LCD_CS    接高电平/接IOB2
//		LCD_AO    接IOB5
//		LCD_RW 	  接IOB6
//		LCD_EP    接IOB7
#include "LCD_Dis.h"
#include"host_TX.h"
#include "SPLC501_LCD.h"
#include "test.h"
#include "LCD_PortConfig.h"
#include "LCD_Config.h"
#include"LCD_Driver_User.h"
#define error 0xf001//接收到错误的信号时候发出的命令
#define sure_single 0xf0f0//到达目的地的命令
unsigned int *data_addr11=0xf200;
///////////////////////////////////////////
//函数:int main(void)
//描述:先接收从机发送的信息,在等待键盘输入,接着控制电机上拉,到达位置后通知从机进车库,从机到位后,发送	
///////	完毕命令,主机接收到后控制电机回到原位	
//参数:无
//返回:无
/////////////////////////////////////////////
int main(void)
{
	unsigned int key_flag=0;//键盘按下标志
	unsigned int key_wait=0;//控制键盘按下的命令
	unsigned int state_flag=5;	//五种状态的标志
	unsigned int key_value_data=0;//保存键值
	unsigned int temp_data=0;//用于接收数据	
	*(volatile unsigned int *)0x7013 = 0x0013;	
	LCD_InIt();
	SetPaintMode(0,0xffff);	
	FontSet(0,0);	
	FontSet(1,0xffff);	
	LCD501_Bitmap(16,1,(unsigned int *)encoding_00);
	LCD501_Bitmap(32,1,(unsigned int *)encoding_01);
	LCD501_Bitmap(48,1,(unsigned int *)encoding_02);
	LCD501_Bitmap(64,1,(unsigned int *)encoding_03);
	LCD501_Bitmap(80,1,(unsigned int *)encoding_04);
	LCD501_Bitmap(96,1,(unsigned int *)encoding_05);
	
	LCD501_Bitmap(0,20,(unsigned int *)encoding_06);
	LCD501_Bitmap(16,20,(unsigned int *)encoding_07);
	LCD501_Bitmap(32,20,(unsigned int *)encoding_08);
	LCD501_Bitmap(48,20,(unsigned int *)encoding_09);
	
	LCD501_Bitmap(64,20,(unsigned int *)encoding_0a);
	LCD501_Bitmap(80,20,(unsigned int *)encoding_0b);
	LCD501_Bitmap(96,20,(unsigned int *)encoding_0c);
	
	LCD501_Bitmap(0,40,(unsigned int *)encoding_0d);
	LCD501_Bitmap(16,40,(unsigned int *)encoding_0e);
	LCD501_Bitmap(32,40,(unsigned int *)encoding_0f);
	LCD501_Bitmap(48,40,(unsigned int *)encoding_10);
	LCD501_Bitmap(64,40,(unsigned int *)encoding_11);
	LCD501_Bitmap(80,40,(unsigned int *)encoding_12);
	//LCD501_Bitmap(96,40,(unsigned int *)encoding_13);
	
	while(1)
	{
		state_flag=read_flash(data_addr11);
		*(unsigned int *)0x7012 = 1;		
		while(state_flag%5==0)//主机处在接收状态
		{
			temp_data=Rx_hanshu();
			temp_data=0x0f0f;//??????????测试用
			if(temp_data==0x0f0f)
			{
				state_flag++;
				key_wait=1;
				break;
			}
			else
			{
				Tx_hanshu(error);
			}
		}
		page_erase(data_addr11);//擦除相应的页
		write_flash(state_flag,data_addr11);
		//在这里提示按键输入	
		LCD_InIt();
		SetPaintMode(0,0xffff);	
		FontSet(0,0);	
		FontSet(1,0xffff);	
		LCD501_Bitmap(0,1,(unsigned int *)encoding_13);//??????????????????/还要该显示序号
		LCD501_Bitmap(16,1,(unsigned int *)encoding_14);
		LCD501_Bitmap(32,1,(unsigned int *)encoding_15);
		//LCD501_Bitmap(48,1,(unsigned int *)encoding_03);
		while(key_wait==1)
		{
			while(key_scan_delay())
			{
				key_flag=key_scan_delay();
			}
			key_value_data=get_keyvalue();
			switch(key_value_data)
			{
				case input:input_hanshu();key_wait=0;break;
				case look:looking_hanshu();key_wait=0;break;
				default:break;
			}
		}
		key_wait=1;			
		while(state_flag%5==1)
		{
			//在这里控制电机
			state_flag++;
		}
		page_erase(data_addr11);//擦除相应的页
		write_flash(state_flag,data_addr11);
		while(state_flag%5==2)
		{
			Tx_hanshu(sure_single);
			temp_data=Rx_hanshu();
			while(temp_data==0x0f01)
			{
				temp_data=Rx_hanshu();
			}
			state_flag++;
		}
		page_erase(data_addr11);//擦除相应的页
		write_flash(state_flag,data_addr11);
		while(state_flag%5==3)
		{
			temp_data=Rx_hanshu();
			while(temp_data!=0x0f02)
			{
				Tx_hanshu(error);
				temp_data=Rx_hanshu();
			}
			state_flag++;
		}
		page_erase(data_addr11);//擦除相应的页
		write_flash(state_flag,data_addr11);
		while(state_flag%5==4)
		{
			//控制电机回原位
			state_flag++;
		}
		page_erase(data_addr11);//擦除相应的页
		write_flash(state_flag,data_addr11);	
		state_flag=5;		
	}
	return 0;
}

⌨️ 快捷键说明

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