亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? trans628.c

?? 使用PIC16F628和U2280構建的門禁控制機,有原理圖
?? C
?? 第 1 頁 / 共 2 頁
字號:
	 if (j == MAX_CODES)
	  	return 0;
	  else
	   return (j+1);		// returns the code that matches
								// if 0 - no match
								// if 1 - master code
								// if 2-25 - normal codes

}




_OSLabel(_TASK_Comparator1)		// define labels
_OSLabel(_TASK_Comparator1a)		// define labels
_OSLabel(_TASK_Comparator1b)		// define labels
_OSLabel(_TASK_Comparator2)		// define labels
_OSLabel(_TASK_Comparator2a)		// define labels
_OSLabel(_TASK_Comparator2b)		// define labels
_OSLabel(_TASK_Comparator2c)		// define labels
_OSLabel(_TASK_Comparator3)		// define labels
_OSLabel(_TASK_Comparator4)		// define labels
_OSLabel(_TASK_Comparator5)		// define labels
/***********************************************************************************************/
void TASK_Comparator(void)      // compares if the value fits data in EEPROM and takes decisions
/***********************************************************************************************/
{
	static byte match_CODE,i,j;
	static byte addr_target;			// used for speed up the address location
	static word counter_RESET_ALL;	 // this timer will erase whole EEPROM, except master
  	static byte prescal_1s;				// will produce 1s delay to make short beeps on buzzer


	flag_NO_MASTER_CARD = find_PLACE()? 0: 1;		// if the place is >0 master exists

	while (TRUE)						// main loop of the task
	 {
	 	OS_WaitBinSem(BINSEM_Found, OSNO_TIMEOUT, _TASK_Comparator1);
		
		match_CODE = compare_CODE();		// get the match code

//------ code is scanned - now time for actions
	 	 
	 	if (match_CODE)				// were match of code
	 	 {
	 	 	if (match_CODE > 1)		// it's a card, but not master
	 	 	 {
	 	 	 	if (counter_PROGRAM_MODE)	
				 {	 	 	 													// if still in program mode - delete cards
		 	 	 	counter_PROGRAM_MODE = AUTO_OFF_PROGRAM_MODE;	// prolongs time with additional delay
					
//============== remove cards in EEPROM memory      ======================
					addr_target = (match_CODE-1)*5;			// where is the target address
					
		 	 	 	for (i = 0; i<5; i++)
		 	 	 	 {
		 	 		 	while (WR)					// wait until EEPROM write finish
		 	 		 	 {
		 	 		 	 	OS_Yield(_TASK_Comparator1a);
		 	 		 	 }
	 	 		 	 
		 	 		 	 write_EEPROM(i+addr_target,0xFF);	//clears the location for that card
		 	 	 	 	
					 }

					counter_BUZZER = BEEP_100ms;	// when removing short beep
					OS_Delay(time_350ms,_TASK_Comparator1b);
					counter_BUZZER = BEEP_100ms;	// when removing short beep
					
					
					while (flag_PRESENSE)	// wait until card removed from receiver
					 {
			 	 	 	counter_PROGRAM_MODE = AUTO_OFF_PROGRAM_MODE;
	 	 		 	 	OS_Yield(_TASK_Comparator2);
					 }

					OSTryBinSem(BINSEM_Found); 	// clears events, if accumulated 
		

				 }
				 else
				 {
//***********************************************************************
//***********************************************************************
//***********************************************************************
//************* THIS IS THE NORMAL OPERATION - UNLOCK THE DOOR **********				 	
//***********************************************************************
//***********************************************************************
//***********************************************************************
					if (!counter_ACTIVE_OUT)		// only once
				 	 	counter_BUZZER = BEEP_1s;	// very long beep

					counter_AUTO_CLOSE = TIME_AUTO_CLOSE;	// to avoid locking, until card exists
					counter_ACTIVE_OUT = 50;	// 5s after card removed will keep door opened
					flag_OPEN = 1;			// opens the door (in other task is OUTPUT control)					 	

				 }	// was not program mode and card fits
	 	 	 }
	 	 	 else
	 	 	 {
// ======= it's master card - switch ON the program MODE (or if switched on - prolong it)
	
	 	 	 	counter_BUZZER = BEEP_500ms;		// makes sound middle length

				counter_RESET_ALL = TIME_RESET_ALL;		// this timer will erase whole EEPROM, except master
 	 	 	  	prescal_1s = 10;		// will produce 1s delay to make short beeps on buzzer

				while (flag_PRESENSE)			// WAITS UNTIL card is in the coild field
				 {
		 	 	 	counter_PROGRAM_MODE = AUTO_OFF_PROGRAM_MODE;
		 	 	 	OS_Delay(time_100ms, _TASK_Comparator2a);
		 	 	 	
		 	 	 	if (prescal_1s)
		 	 	 	  prescal_1s--;
		 	 	 	 else
		 	 	 	  {
		 	 	 	  	prescal_1s = 10;		// will produce 1s delay to make short beeps on buzzer

						if (counter_RESET_ALL < TIME_RESET_SOUNDS)
						  counter_BUZZER = BEEP_500ms;	// 10s before the end the sound is changed
						 else
		 	 	 	  		counter_BUZZER = BEEP_100ms;
		 	 	 	  }
		 	 	 	
					if (counter_RESET_ALL)
					 {
					 	if (counter_RESET_ALL == 1)	// to erase only once the content
					 	 {
					 	 	counter_BUZZER = BEEP_5s;	// very long beep
					 	 	
					 	 	for (i=5; i<128; i++)
					 	 	 {
					 	 	 	while (WR)
					 	 	 	 {
					 	 	 	 	OS_Yield(_TASK_Comparator2b);	// wait until EEPROM write is complete
					 	 	 	 }
					 	 	 	
								write_EEPROM(i,0xFF);	// erases the all memory locations except master						 	 	 	
					 	 	 }
					 	 }	// counter is equal to 1 - only in this case will do erasing 

				 	  counter_RESET_ALL--;	// decrement timer

					 }
					 else
					 {
					 	while (flag_PRESENSE)		// block counting
					 	 {
					 	 	 counter_PROGRAM_MODE = AUTO_OFF_PROGRAM_MODE;	// to avoid making sounds
						 	 OS_Yield(_TASK_Comparator2c);

					 	 }

 	 		 	 	 	 counter_PROGRAM_MODE = 5;			// force fast ending the mode after 0.5 s

					 }
		 	 	 	
				 }	// loop until card exist on the sensor
				// card is removed - have to clear the BINSEM, if exists
				 
				OSTryBinSem(BINSEM_Found); 	// clears events, if accumulated 
			
	 	 	 }
	 	 }
	 	 else		// nothing matches the code, but if this si the first power up - record master
	 	 {
	 	 	if (flag_NO_MASTER_CARD)		// seems that this is the first card, so
	 	 	 {		
	 	 	 										// it should be tooken like master card
				flag_NO_MASTER_CARD = 0; 	// now there is a master card
													// and should be recorded into EEPROM	
	 	 		for (i=0; i<5; i++)
	 	 		 {
	 	 		 	while (WR)					// wait until EEPROM write finish
	 	 		 	 {
	 	 		 	 	OS_Yield(_TASK_Comparator3);
	 	 		 	 }
	 	 		 	 
	 	 		 	 write_EEPROM(i,CODE_ARRAY[i]);	// writes the master code like first location
	 	 		 }
	 	 	 	
	 	 	 }	// there was master card
	 	 	 else
	 	 	 {
	 	 	 	if (counter_PROGRAM_MODE)			// in program mode - record CODE
				 {
				 	
					j = find_PLACE();				// get the first free location

					addr_target = j*5;			// where is the target address
					
					if (j < 25)						// still free locations
					 {
		 		 	 	for (i = 0; i<5; i++)
		 		 	 	 {
		 	 			 	while (WR)					// wait until EEPROM write finish
		 	 			 	 {
		 		 		 	 	OS_Yield(_TASK_Comparator4);
			 	 		 	 }
	 	 		 	 
			 	 		 	 write_EEPROM(i+addr_target,CODE_ARRAY[i]);	//saves the location for that card
						 }
						 
						counter_BUZZER = BEEP_1s;	// long beep

						while (flag_PRESENSE)		// wait until card removed from receiver
						 {
				 	 	 	counter_PROGRAM_MODE = AUTO_OFF_PROGRAM_MODE;
	 		 		 	 	OS_Yield(_TASK_Comparator5);
						 }

						OSTryBinSem(BINSEM_Found); 	// clears events, if accumulated 

					 } // were free locations, records data in EEPROM
				 	
				 }	  // was program mode - card added
	 	 	 	
	 	 	 }	// it was not the master card
	 	 	
	 	 }		// the code didn't match the tables

	 }			// main loop

}



_OSLabel(_TASK_Executer1)		// define labels
_OSLabel(_TASK_Executer2)		// define labels
/***********************************************************************************************/
void TASK_Executer(void)      // controls LED/BUZZER/OUTPUTS
/***********************************************************************************************/
{


	static bit flag_OPEN_old;
	
	while (TRUE)						// main loop of the task
	 {

		if (flag_PRESENSE)
		 flag_PRESENSE--;

		if (counter_BUZZER)
		 {	
// to make smooth action of buzzer - synchronization with variable
		 	
		 	count_BUZZER = counter_BUZZER;
		 	counter_BUZZER = 0;
		 }
	
	
		if (count_BUZZER)			// control of BUZZER trought counter_BUZZER
		  {

			BUZZER = 0;						// makes clear sound
		  	count_BUZZER--;

		  }					// sound OUT
		 else
	  		BUZZER = 1;						// set buzzer in 1 to prevent high currents
		  
		  
//--------- when change in status of flag_OPEN - issue motor control (OPEN/CLOSE door)
		if (flag_OPEN != flag_OPEN_old)						// general flag for OPEN/CLOSE system door
		 {
			if (flag_OPEN)			// door opened
			  {
				counter_ACTIVE_OPEN = TIME_OPEN_ON;			// how long to turns motor OPEN	
				counter_AUTO_CLOSE = TIME_AUTO_CLOSE;		// and immediately start process of count down to close it
			  }
			 else
			   counter_ACTIVE_CLOSE = TIME_CLOSE_ON;		// how long to turns motor CLOSE
		 	
		 }	// was change in the status of flag_OPEN

		flag_OPEN_old = flag_OPEN;




//------- AUTO close the door after some time
		if (flag_OPEN)
		 	{
		 		if (!DOOR)					// only when door is close can start counting
		 		 {
			 		if (counter_AUTO_CLOSE)
			 		  	counter_AUTO_CLOSE--;
			 		 else
		 			  flag_OPEN = 0;			//	after time expired - door closes automatically

		 		 }	// door was closed, elsewise nothing counts until somebody close the door
				else
			 	 counter_AUTO_CLOSE = TIME_AUTO_CLOSE;		// if open - wates some time before auto close
				
		 	}	// flag_OPEN DOOR


//------- OUTPUT 0 control
	  	if (counter_ACTIVE_OUT)
	  	 {
	  	 	counter_ACTIVE_OUT--;
	  	 	OUT0 = 1;
	  	 }
	  	 else
	  	  OUT0 = 0;


//------- OUTPUT 1 control
		if (counter_ACTIVE_OPEN)		// time for open the door motors
		 {
		 	counter_ACTIVE_OPEN--;
			OUT1 = 1;
		 }
		 else
		 	OUT1 = 0;
		 	
//------- OUTPUT 2 control
		if (counter_ACTIVE_CLOSE)		// time for close the door motors
		 {
		 	 if (DOOR)									// if accidentally somebody opens the door
		 	  {
		 	  	 OUT2 = 0;								// stops the execution of opening
		 	  	 counter_ACTIVE_CLOSE = 0;			// immediately stops the process of closing
		 	  	 flag_OPEN = 1;						// start opening the door again (system is closed
		 	  	 											// and will issue again autolock algorythm
		 	  }
		 	  else
		 	  {
			 	 counter_ACTIVE_CLOSE--;
			 	 OUT2 = 1;
		 	  }
		 }
		 else
		 	OUT2 =0;
		 	
//------- Auto OFF program mode counter support
		if (counter_PROGRAM_MODE)
		  {
		 	counter_PROGRAM_MODE--;

			if (counter_PROGRAM_MODE == 1)
			  	counter_BUZZER = BEEP_100ms;
		  }


		OS_Delay(time_100ms, _TASK_Executer1);		// time to wake up

	 }
}



/***********************************************************************************************/
#include <reader.c>					// hardware capture of codes
/***********************************************************************************************/




/***********************************************************************************************/
void main(void)
/***********************************************************************************************/
{
// ----------- TMR0 control  -----------------------------

	OPTION = 0b00000101;	//Pull UPS,prescaller 1:64 every 10 ms synchronize (with compensation - 99)


	TMR0 = adjust_10ms;			// initial timer dalay of 10ms
	T0IF = 0;						// reset timer to bring intial TMR0 delay
	
	INTCON = 0b01000000;			// GIE disable   T0IE disable


//=========== PWM control for buzzer ===============
	
	T1CON =  0b00000000;
	


// ----------- USART control  -----------------------------
   
//	SPBRG = 25 ;					// SET SPEED TO 9600 bps /4 MHz clock generator
//	TXSTA = 0b10100100;			// set data for USART enable transmitter, but no interrupts/no receive
//	RCSTA = 0b10000000;			// SPEN=1 data for USART setting,ADEN = 0,CREN = 0!!!!


	PIE1 = 0b00000000;			// no interrupts from periferal


// ------ tristate control ---------------------------------------

	CMCON = 0x07;				// enable ports for digital
	TRISA = 0b00000000;		// PORTA TRIS control  

	TRISB = 0b00010111;		// PORTB TRIS control


// ---------- definitions of the registers -----------------------

	PORTA = 0b00001000;		// no sound and LIGHT
	
	PORTB = 0b00000000;		

//=========== initialization of flags
	counter_BUZZER = 10;		// 1s initial beep
	flag_OPEN = 0;
 	flag_DETECTED = 0;


//----------- OSInit should stay before any other SALVO commands !!!!
   OSInit();						// initialize RTOS kernel
//----------- OSInit should stay before any other SALVO commands !!!!

// creates semaphores with their values
	
	 OSCreateBinSem(BINSEM_Found,	0);			// create message for displaying
	 
// creates the tasks that will be used in the program
    
    OSCreateTask( TASK_Acceptor,		OSTCBP(1),		5);
    OSCreateTask( TASK_Comparator,	OSTCBP(2),		5);
    OSCreateTask( TASK_Executer,		OSTCBP(3),		5);	
  

    OSEi(); 		// enable global interrupts


	//--------------- MAIN LOOP -------------------------------

	for (;;)						// non stopping loop of the main program
    {

	if (T0IF)					// no Interrupt timer routine
		{
			TMR0 += adjust_10ms;	// adjusts the value of timer	
			T0IF = 0;				// clear the flag
			OSTimer();
		}


		OSSched();					// run the RTOS kernel

    }
		

 

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本一区二区在线不卡| 国产情人综合久久777777| 国产精品99久久久久久久vr| 欧美日韩视频一区二区| 亚洲一二三区视频在线观看| 色视频欧美一区二区三区| 亚洲女性喷水在线观看一区| 91亚洲资源网| 亚洲成人久久影院| 亚洲精品在线免费观看视频| 国产成人aaa| 亚洲第一狼人社区| 亚洲成人免费看| 美女被吸乳得到大胸91| 国产精品国产三级国产三级人妇| 日本二三区不卡| 国产在线不卡一区| 亚洲国产精品久久人人爱蜜臀| 亚洲老妇xxxxxx| 久久精品视频免费| 欧美精品丝袜中出| 国产成人在线看| 久久福利资源站| 亚洲国产欧美在线| 蜜桃av噜噜一区| 国产综合久久久久久鬼色| 日韩精品电影一区亚洲| 一区二区三区视频在线观看 | 国产欧美一区二区精品仙草咪| 精品成人一区二区| 亚洲欧美怡红院| 亚洲欧洲日韩av| 午夜久久久久久电影| 亚洲制服丝袜av| 亚洲制服欧美中文字幕中文字幕| 日韩成人一级大片| 日韩avvvv在线播放| 成人性生交大片免费看视频在线| 久久精品久久综合| 91尤物视频在线观看| 欧美一区二区三区播放老司机| 91成人免费网站| 久久九九久精品国产免费直播| 中文字幕一区在线| 国产一区二区精品在线观看| 欧美色视频在线观看| 久久精品亚洲乱码伦伦中文| 天堂蜜桃91精品| 91视频91自| 国产日韩欧美一区二区三区乱码| 亚洲国产毛片aaaaa无费看| 成人美女在线视频| 欧美一卡二卡在线| 亚洲国产裸拍裸体视频在线观看乱了| 国产成人午夜精品影院观看视频 | 日韩欧美一级特黄在线播放| 日韩欧美高清在线| 亚洲永久精品大片| 91色乱码一区二区三区| 国产日本欧美一区二区| 麻豆精品一区二区综合av| 欧美三级资源在线| 夜夜精品视频一区二区| 91在线精品一区二区三区| 色妞www精品视频| 国产精品视频yy9299一区| 中文字幕一区二区三中文字幕| 久久99精品国产.久久久久久| 国产精品1区2区| 精品国产污污免费网站入口| 人禽交欧美网站| 成人污污视频在线观看| 久久久久久久久久久久久女国产乱 | 亚洲欧美乱综合| av中文字幕亚洲| 91精品一区二区三区久久久久久 | 国产精品久久久久久久久久免费看 | 精品久久久久久久久久久久包黑料| 久久久久久97三级| 国产精品99久| 国产欧美精品日韩区二区麻豆天美| 国产一区免费电影| 国产亚洲一二三区| 成人精品视频一区二区三区尤物| 久久久久久久久久看片| av一区二区三区黑人| 亚洲日穴在线视频| 国产精品1区二区.| 亚洲色图欧美激情| 欧美三级电影网| 青青青爽久久午夜综合久久午夜| 欧美一区二区三区白人| 国产精品一二三区在线| 亚洲人成网站影音先锋播放| 欧美中文字幕一区二区三区亚洲| 国产丝袜欧美中文另类| 成人在线综合网| 一区二区三区日韩欧美| 3751色影院一区二区三区| 国产一区二区三区最好精华液| 国产精品天干天干在观线 | 天天亚洲美女在线视频| 欧美一级片免费看| 福利电影一区二区三区| 亚洲最大成人综合| 欧美艳星brazzers| 亚洲精品午夜久久久| 91精品国产美女浴室洗澡无遮挡| 精品一区二区综合| 亚洲欧美日韩成人高清在线一区| 91精品国产综合久久久久久 | 亚洲国产精品久久久男人的天堂| 欧美成人欧美edvon| www.在线成人| 久久电影国产免费久久电影| 国产精品成人免费| 精品电影一区二区三区| 一本久久综合亚洲鲁鲁五月天| 午夜精品123| 国产精品水嫩水嫩| 欧美一级夜夜爽| 一本到不卡免费一区二区| 国产一区二区视频在线| 五月天欧美精品| 亚洲日本护士毛茸茸| 久久综合中文字幕| 大胆欧美人体老妇| 亚洲国产成人av网| 久久综合久久综合久久| 欧美日韩精品一区二区在线播放| 日韩在线一区二区| 亚洲日本欧美天堂| 中文字幕一区二区三区乱码在线| 欧美精品一区二区三区蜜桃视频 | 欧美肥妇bbw| 在线这里只有精品| 9久草视频在线视频精品| 久草在线在线精品观看| 亚洲国产成人高清精品| 亚洲免费高清视频在线| 国产精品色在线| 久久精品欧美一区二区三区不卡| 日韩欧美在线综合网| 风间由美中文字幕在线看视频国产欧美 | 激情久久久久久久久久久久久久久久| 亚洲图片你懂的| 亚洲欧美在线观看| 国产精品人妖ts系列视频| 久久久久久久久久久电影| 欧美精品一区二区三| 日韩一区二区三区免费看| 欧美一区二区视频网站| 91精品欧美一区二区三区综合在| 正在播放亚洲一区| 日韩精品一区二区三区老鸭窝| 欧美猛男gaygay网站| 911精品国产一区二区在线| 欧美一区二区免费观在线| 欧美一区二视频| 欧美mv日韩mv国产| 欧美韩国日本不卡| 欧美一区二区久久久| 日韩限制级电影在线观看| 久久综合网色—综合色88| 国产精品网站导航| 亚洲日本乱码在线观看| 亚洲成人自拍偷拍| 蜜桃av噜噜一区二区三区小说| 免费观看成人鲁鲁鲁鲁鲁视频| 日韩成人午夜精品| 九九**精品视频免费播放| 国产成人丝袜美腿| 色哟哟国产精品免费观看| 欧美色图片你懂的| 久久久久9999亚洲精品| 综合欧美一区二区三区| 亚洲亚洲人成综合网络| 久久精品99国产精品日本| 成人免费视频网站在线观看| 色婷婷综合久久久中文字幕| 欧美一区二区久久久| 国产精品久线在线观看| 日日嗨av一区二区三区四区| 久久99精品久久只有精品| 成人精品gif动图一区| 国产乱子轮精品视频| 99精品欧美一区二区三区综合在线| 在线一区二区三区做爰视频网站| 日韩免费福利电影在线观看| 最新热久久免费视频| 日韩电影免费在线观看网站| 成人一区二区三区在线观看| 欧美日韩中文字幕一区| 久久久久久久久蜜桃| 三级久久三级久久| 99re成人精品视频| 久久网这里都是精品| 亚洲亚洲人成综合网络| 成人综合婷婷国产精品久久免费| 欧美日韩一级黄|