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

📄 main.c

📁 C8051F330部分模块程序,已经调试成功
💻 C
字号:
//File name:main.c
//Autor:Liuyul
//Date:2006-08-09
//Description:Making the operiton of whole system,share moble and work;
//Call:  
//			/d/YH2/Keyboard.c   
//			/d/YH2/Wind.c       
//			/d/YH2/Display.c   
//			/d/YH2/Head.h   
//			/d/YH2/Func.f       
//			/d/YH2/Gobale.inc    
//			/d/YH2/Interrupt.c
//			/d/YH2/Struct.str
// History: Date     Autor         Vision
//       2006-08-07  Liuyulong        2.1
#include <330_head.h>
#include "330_func.h"
#include "330_Gobale.h"
#include "330_struct.h"
#include "330_display.c"
#include "330_keyboard.c"
#include "330_wind.c"
#include "330_Interrupt.c"
#define test 0
#define loop 30
extern unsigned xdata first;
extern unsigned xdata lastsetuptemp;
extern unsigned xdata lastsetupwind;
extern unsigned xdata lastsetupflap;
extern unsigned xdata lastsetupmode;
extern unsigned xdata lastsetupaddr;
extern xdata unsigned char screenkeep;           //屏保寄存器
extern bit powersize ;  
struct keyboard out ;   
struct screen setdata ; 
unsigned char loopnum ;
main(){
unsigned char main_keynum ;
//unsigned char res_root ;
disableWDT() ;		   //关闭看门狗 
enableWDT () ;
refreshWDT() ;
SYSCLK_Init () ;		//the clock of system set up;
refreshWDT() ;
PORT_Init () ;
rstsrc = 0 ;
ref0cn = 0x0b ;
top = 0 ; 
battom = 0 ;
refreshWDT() ;
write(0,0,0) ;
refreshWDT() ;
del1s () ;
//set up Interrupt;
eie1 = 0x18 ;		//Enable interrupt ADC0;
eip1 = 0x08 ;
ie = 0x10 ;			 
if(first != 0xaa){                        //The system first opration initial; 
	first = 0x55 ;
	out.temp = temp_int_num ;             //Initial temperation is 22;
	out.wind = wind_int_speed ;           //Initial wind is 10;
	out.automode = 1 ;				 //Initial auto mode ;
	out.addressl = mobleaddr & 0x0f ;	 //Initial low Byte system address 
	out.addressh = mobleaddr >> 4 ;		 //Initial high Byte system address;
	out.addressh &= 0x0f ;
	}
else {									 //After Lost power and start,system will initial ;
	out.addressl = lastsetupaddr & 0x0f;//reset the low byte system address;     
	out.addressh = lastsetupaddr >> 4 ;	 
	out.addressh &= 0x0f ;				 //reset the high byte system address;
	out.temp = lastsetuptemp ;			 //reset the temperature num;
	out.wind = lastsetupwind ;			 //reset the PWM of wind ;
	out.automode = lastsetupmode ;		 //reset the auto mode;
	}
	refreshWDT() ;
powersize = 1 ;          //System bize is true,the system will stop;
while(powersize == 1)   			   
			{
			ea = false;        		       //Stop AC electrial machinery ;
			led = 1 ;      		       //Close LCD light ;
			closelcd();       			   //Close LCD ; 
			refreshWDT() ;
			main_keynum = keyscan ();
			while (main_keynum == 4)			   //If the key "POWER" is not press,wait for press ;
			    { 
				main_keynum = keyscan ();
				refreshWDT() ;
				powersize = 0 ;			 //Power size is false means system is working ;
			//	res_root = rstsrc ;
			//    res_root &= 0x08 ;
			//  if(res_root == 0x08){
			//	main_keynum = 4 ;
			//	rstsrc &= 0xf7 ;
			//	}
				}
				}
ea = 1;	//Open the totle gate of Interrupt;
led = 0 ;
screenkeep = 0 ;
PCA_Init () ;
refreshWDT() ;
out.menu = 1 ;
tempcheck ();
refreshWDT() ;
tempcheck ();
refreshWDT() ;
display ();
refreshWDT() ;
/*
for (loopnum = 0;loopnum  < loop ;loopnum ++){
for (;screenkeep < 30;){
	keyboard ();
	PCA_Init () ;
	led = 0;
	}
	led = 1;
	out.menu = 0;
	display ();
	keyboard ();
	tempcheck ();						
	numone(setdata.tempnum%10);         //Temperature of house at LED one ;
	numten(setdata.tempnum/10);  		//Temperature of house at LED ten ;
	del1s();
	}
	*/
while(1){
tempcheck ();						//Check the temperature of house ;
refreshWDT() ;
coolauto();  
refreshWDT() ;
for (loopnum = 0;loopnum  < loop ;loopnum ++){
for (;screenkeep < 49;){
	keyboard ();
	refreshWDT() ;
	led = 0;
	del1s () ;
	refreshWDT() ;
	}
	refreshWDT() ;						
//	battom_size =~battom_size ;
	led = 1;
	out.menu = 0;
	keyboard ();
	refreshWDT() ;
	lastsetuptemp = out.temp;			//Save the set num of temperature; 
	lastsetupwind = out.wind;			//Save the set num of wind ;
	lastsetupmode = out.automode;		//Save the set num of mode ;
	del1s () ;
	}
}
}

⌨️ 快捷键说明

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