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

📄 main.c

📁 单片机的下位端
💻 C
字号:
#include "sys.h"

/*the received command:
0:error;
1:query;
2:gather;
3:transfer;         */
UCHAR command;
bit receiveFlag;
data UCHAR *p;
code UCHAR handshake[6] = {0xaa,0xaa,0xaa,0xaa,0xaa,0xaa};
data UCHAR UIData[6] = {0,0,0,0,0,0};             //the first 3 is I;the last 3 is U;

UCHAR voltageShow = 0x00;


void main(void)
{
     Sys_Init();
	 UserInit();
	 receiveFlag = 0;         //havn't received the command
	 SOUND = 0;
	 LED = 0;
	 while(1)
	 {
	 	while(!receiveFlag)
		{
			VOLTAGEFLAG1 = 1;
			VOLTAGEFLAG2 = 1;
			
			voltageShow = 0x00;
			voltageShow = 0x00;  //延时一个指令周期
			//voltageShow = (VOLTAGEFLAG1<<5) | (VOLTAGEFLAG2<<4);
			if(VOLTAGEFLAG1)	//监测电机电池电压
			{
				SOUND = 1;
				//LED = 0;
				voltageShow |= 0x10;
			}
			if(VOLTAGEFLAG2)	//检测基站电池电压
			{
				SOUND = 1;
				LED = 1;
				voltageShow |= 0x20;
			}
			if(voltageShow == 0x00)
			{
				SOUND = 0;	
				LED = 0;
			}
		}
		receiveFlag = 0;
		switch(command)       //if error,do nothing;
		{
	    	case 1:Send(0);    break;
			case 2:GatherUI(); break;
			case 3:Send(1);    break;
			default: break;
		}
	 }
}

⌨️ 快捷键说明

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