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

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

?? func_connect.c

?? 2.4G無線音箱的接收程序,采用ATMEGA8單片機和STS公司的無線模塊完成
?? C
字號:
/******************************************************************************
*
* Purpose:      Func_Connect.c
*
* Creator:      Paul v/d Linden
*
* Version:		$Revision: 13 $
*
* File Name:	$Workfile: Func_Connect.c $
*
* Author:		Paul v/d Linden
*
* Check in:		$Author: Chong.cheeleong $
*
* The information is provided 揳s is?without any express or implied warranty  
* of any kind, * including warranties of merchantability, non infringement of   
* intellectual property, or fitness for any particular purpose. In no event shall
* Wireless Sound Solutions and/or its affiliate companies, or its suppliers be 
* liable for any damages whatsoever arising out of the use of or inability to  
* use the information or the materials. Wireless Sound Solutions, its affiliate
* companies, and its suppliers further do not warrant the accuracy or          
* completeness of information, text, graphics, or other items contained within 
* materials. Wireless Sound Solutions, Inc., may make changes to materials, or 
* the products described within, at any time, without notice.                  
* ?007 Wireless Sound Solutions. All rights reserved. Wireless Sound Solutions
* STS and STS-wireless are trademarks of Wireless Sound Solutions.        
******************************************************************************/
/*
** Include files
** -------------
*/
#include <stdio.h>
#include <ina90.h>
#include "defines.h"


/*
** Message definitions 
*/
/*
 * Unique Key Message
 * Byte 1  : 90
 * Byte 2  : Unique Key LSB
 * Byte 3  : Unique Key MSB
 * Byte 16 : Checksum.
 */
#define MSG_TYPE_UNIQUE_KEY	90 /* 0x5B */

/*
 * Key Acknowledge Message
 * Byte 1  : 91
 * Byte 16 : Checksum.
 */
#define MSG_TYPE_KEY_ACK 91 /* 0x5C */

#define TIME_CONNECT_TIMEOUT 60

unsigned char Connect_Timer   = 0xFF;
unsigned int  Connection_Code = 0xFFFF;
unsigned char prev_CONNECT_SW;



/******************************************************************************
*
* Function Name :   Prog_ConnectCode
*
* Purpose       :   Programs Connect code into DARR79 and EEPROM
*
* Arguments     :   Connection_Code
*
* Return value  :   none
*
******************************************************************************/
void Prog_ConnectCode(unsigned int Connection_Code)
{
	unsigned char tmp1,tmp2;

	tmp1 = Connection_Code & 0x0FF;
	tmp2 = (Connection_Code >> 8) & 0xFF;
	
	I2C_Write_Byte(COCO_ADDR, tmp1);
	I2C_Write_Byte(COCO_ADDR + 1, tmp2);
	_CLI();
	_EEPUT(0x10, tmp1);
	_EEPUT(0x11, tmp2);
	_SEI();
}


/******************************************************************************
*
* Function Name :   Get_ConnectCode
*
* Purpose       :   Get connect code.
*
* Arguments     :   none
*
* Return value  :   Connection_Code
*
******************************************************************************/
int Get_ConnectCode(void)
{
	int Con_Code;
	unsigned char tmp;

	_CLI();
	_EEGET(tmp, 0x10);
	Con_Code = tmp;
	_EEGET(tmp, 0x11);
	Con_Code += tmp << 8;
	_SEI();
	
	return (Con_Code);
}


/******************************************************************************
*
* Function Name :   Handle_Connect_Init
*
* Purpose       :   Initialize the Connect Procedure.
*
* Arguments     :   none
*
* Return value  :   none
*
******************************************************************************/
void Handle_Connect_Init(void)
{
	/* Setup Switch Data */
	prev_CONNECT_SW    = CONNECT_SW; /* prevent initial difference */
	
	/* Prepare Connect Code */
	if  (ERASE_CON_CODE_SW == 0)
	{
		/* Reset connection code (no encryption used when connection code is 0xFFFF */
		Prog_ConnectCode(0xFFFF); 
		putstring("Connection_Code = FFFF (RESET)\r");
	}

	/* read connect code from Eeprom */
	Connection_Code = Get_ConnectCode();
	/* write COCO register in DARR79 */
	I2C_Write_Byte(COCO_ADDR, Connection_Code & 0x0FF);
	I2C_Write_Byte(COCO_ADDR + 1, (Connection_Code >> 8) & 0xFF);
	
	#ifdef DEBUG
		putstring("Connection_Code = ");
		puthex((Connection_Code >> 8) & 0xFF);
		putstring(" ");
		puthex( Connection_Code       & 0xFF);
		putstring("\r");
	#endif

	/*
	 * programmed do not use Connect after first time program or reset
	 * using the Volume buttons 
	 */
	/* always startup with CU connect code active */
	if  (Use_ModuleMode == CU) 
	{
		#ifdef DEBUG
			putstring("Connect_Bit SET\r");
		#endif
		Connect_Bit = BIT_CONNECT; /* 0x80 */
	}
	else 
	{
		Connect_Bit = 0x00;
	}
		
	/* Enable Unit & update connect status */
	Write_GEC_ADDR(BIT_ENABLE + Connect_Bit);
}

/******************************************************************************
*
* Function Name :   Handle_Hot_Disconnect
*
* Purpose       :   Handle Hot Disconnect Procedure.
*
* Arguments     :   none
*
* Return value  :   none
*
******************************************************************************/
#ifdef PCB_PNP80_UNIVERSAL_TRX
void Handle_Hot_Disconnect_MainLoop(void)		
{
	/* Reset connection code (no encryption used when connection code is 0xFFFF */
	Prog_ConnectCode(0xFFFF); 

    /* read connect code from Eeprom */
    Connection_Code = Get_ConnectCode();
    /* write COCO register in DARR80 */
    I2C_Write_Byte(COCO_ADDR, Connection_Code & 0x0FF);
    I2C_Write_Byte(COCO_ADDR + 1, (Connection_Code >> 8) & 0xFF);
	
	Connect_Bit = BIT_CONNECT; /* 0x80 */
   
    /* Enable Unit & update connect status */
    Write_GEC_ADDR(BIT_ENABLE + Connect_Bit);
            
}
#endif /*PCB_PNP80_UNIVERSAL_TRX*/
/******************************************************************************
*
* Function Name :   Handle_Connect_MainLoop
*
* Purpose       :   Process the Connection Procedure.
*
* Arguments     :   none
*
* Return value  :   none
*
******************************************************************************/
void Handle_Connect_MainLoop(void)
{
#ifndef PCB_PNP80_UNIVERSAL_TRX
	if (Sync_Led_Status == LED_OFF)
	{
		/* prevent starting Connect Procedure twice */
		/* release the button first before starting again */
		if ((prev_CONNECT_SW != CONNECT_SW))
		{
			prev_CONNECT_SW = CONNECT_SW;
			/* start connect procedure only once */
			if (CONNECT_SW == 0x00)	/* only when key is pressed down */
			{
				DATA_LED_ON;
				if (Use_ModuleMode == CU)
				{
					/*###### CU ######*/
					Connect_Bit = 0;
					/* Turn off Connect only on CU */
					Write_GEC_ADDR( BIT_ENABLE); 
				}
				/* start Connect timeout timer */
				Connect_Timer = 0x00;
				/* change state */
				Sync_Led_Status = LED_CONNECTING;
				DATA_LED_OFF
			}
		}
	}
#else
    if (Sync_Led_Status == LED_SYNC_STATUS)
	{       
		/* prevent starting Connect Procedure twice */
		/* release the button first before starting again */
        if ( prev_CONNECT_SW != CONNECT_SW )
        {                 
           /* Update CONNECT_SW */
           prev_CONNECT_SW = CONNECT_SW;

           if ( !CONNECT_SW )  
           {
                /* 3 seconds delay */
                Wait_For_mSec(100);             
                
                unsigned char i ;
                for(i=50;i>0;i--)          
                {
                	if ( !CONNECT_SW )
                	{
                			Wait_For_mSec(100); 
                	}	
                	else
                	{
                			Connect_Bit = 0x00;
                            /* Turn off Connect only on CU */
                            Write_GEC_ADDR(BIT_ENABLE);
                            /* start Connect timeout timer */
                            Connect_Timer = 0x00;
                            /* change state */
                            Sync_Led_Status = LED_CONNECTING;
                            break ;
                	}	
                }
                if(i==0)
                {	
                		Handle_Hot_Disconnect_MainLoop();
                            /* Set to default link status */
                        Sync_Led_Status = LED_SYNC_STATUS; 
                }	
                /* After 3 seconds check button pressed again */
//                if ( !CONNECT_SW ) 
//                {
//                    Connection_Code = Get_ConnectCode();
//                    /* Check if not connected */
//                    if ( Connection_Code == 0xFFFF )
//                    {   
//                        
//                        Connect_Bit = 0x00;
//                        /* Turn off Connect only on CU */
//                        Write_GEC_ADDR(BIT_ENABLE);
//                      
//                        /* start Connect timeout timer */
//                        Connect_Timer = 0x00;
//                        /* change state */
//                        Sync_Led_Status = LED_CONNECTING;
//                                      
//                    }
//                    /* Already connected */
//                    else
//                    {
//
//                      /* 5 seconds delay */
//                         Wait_For_mSec(5000);                       
//                         if(!CONNECT_SW)
//                         {
//                            /* Reset Connect Code to default */
//                            Handle_Hot_Disconnect_MainLoop();
//                            /* Set to default link status */
////                        Sync_Led_Status = LED_SYNC_STATUS;    
//                         }
//                    }             
//                }
            }
		}
	}
#endif /*PCB_PNP80_UNIVERSAL_TRX*/
	else
	if (Sync_Led_Status == LED_CONNECTING)
	{
		/********************************************/
		/*** 1 Second Timed on CU Process Connect ***/
		/********************************************/
		/* Sec_Event flag is set by MCU timer */
		if (Sec_Event == 1)
		{
			Sec_Event = 0; /*Cleared in end of mailloop*/
			Connect_Timer++;

			if (Use_ModuleMode == CU)	
			{
				DATA_LED_ON;
				TX_Data_send_array[0] = MSG_TYPE_UNIQUE_KEY;
				/*
				** Generate Unique Connection Code
				** (Key press generates a random function in time)
				** Only generate one time at power-up (should be stored in EEPROM)
				*/
				if (Connection_Code == 0xFFFF)
				{
					Connection_Code = RND_Value;
					if (Connection_Code == 0) Connection_Code = 1; /* Connect code 0 is not allowed */
				}
				/* Send Connection_Code */
				TX_Data_send_array[1] = Connection_Code & 0xFF;
				TX_Data_send_array[2] = (Connection_Code >> 8) & 0xFF;
				
				#ifdef DEBUG
					putstring("CU send con_code ");
					puthex(TX_Data_send_array[0]);
					putchar(' ');
					puthex(TX_Data_send_array[1]);
					putchar(' ');
					puthex(TX_Data_send_array[2]);
					putchar('\r');
				#endif

				if (Use_Speaker_Enable_Bits & 0x01) Send_Message(STR_A, 1);
				if (Use_Speaker_Enable_Bits & 0x02) Send_Message(STR_B, 1);
				if (Use_Speaker_Enable_Bits & 0x04) Send_Message(STR_C, 1);
				if (Use_Speaker_Enable_Bits & 0x08) Send_Message(STR_D, 1);
				
				DATA_LED_OFF;
			}
		
			/********************************/
			/*** Check Connection Timeout ***/
			/********************************/
			if (Connect_Timer > TIME_CONNECT_TIMEOUT)
			{
				DATA_LED_ON;
								
				#ifdef NOT_THIS_TIME
				/* Connect_Bit is set only on a CU */
				/*
				** Use this code only in multiple MU applications
				** Do not leave the LED_CONNECTING state on receiving 
				** the first Key Ack msg.
				** Process them and switch to LED_OFF when all MUs
				** had send there Key Ack msg.
				** Only in that case this code section is needed
				** When no response is coming from any MU the
				** Connect_Bit stays 0, audio insecure.
				*/
				if (Use_ModuleMode == CU)	
				{
					/* Do not use connection when a time-out occurred and */
					/* no other units have been connected yet */
					if (Get_ConnectCode() != 0xFFFF)
					{
						#ifdef DEBUG
							putstring("Timeout, Connect_Bit = 0x80\r");
						#endif
						Connect_Bit = BIT_CONNECT; /* 0x80 */
						Write_GEC_ADDR( BIT_ENABLE + Connect_Bit);
					}
				}
				#endif 
#ifndef PCB_PNP80_UNIVERSAL_TRX
				/* Update the RF leds */
				Update_LED(Read_RFC());
				/* leave this the Connection Procedure Unsuccessful */
				Sync_Led_Status = LED_OFF;
#else
                Sync_Led_Status = LED_SYNC_STATUS;
#endif
				DATA_LED_OFF;
			}
		}
	}
}


/******************************************************************************
*
* Function Name :   Handle_Connect_RXMsg
*
* Purpose       :   Handle the RX Messages for the Connection Procedure.
*
* Arguments     :   none
*
* Return value  :   none
*
******************************************************************************/
void Handle_Connect_RXMsg(void)
{
	if (Sync_Led_Status == LED_CONNECTING)
	{
		if (Use_ModuleMode == MU)
		{
			/*###### MU ######*/
			if (RX_Data_recv_array[0] == MSG_TYPE_UNIQUE_KEY)
			{
				Prog_ConnectCode(RX_Data_recv_array[1] + (RX_Data_recv_array[2] << 8));

				#ifdef DEBUG
					putstring("MU send MSG_TYPE_KEY_ACK\r");
				#endif

				TX_Data_send_array[0] = MSG_TYPE_KEY_ACK;
				if (Data_Free_Up)
					Send_Message(STR_FREE, 1); /* use free slots in nack applic */
				else
					Send_Message(RX_Stream_Nr, 1); /* reply on received stream number */
#ifndef PCB_PNP80_UNIVERSAL_TRX

				Update_LED(Read_RFC());
				Sync_Led_Status = LED_OFF;
#else
                Sync_Led_Status = LED_SYNC_STATUS;
#endif
			}
		}
		else
		{
			/*###### CU ######*/
			if (RX_Data_recv_array[0] == MSG_TYPE_KEY_ACK)
			{
				/* MU has Acknowledged Connect key there for the encription can be turned on */
				#ifdef DEBUG
					putstring("CU MSG_TYPE_KEY_ACK\n");
				#endif

				Prog_ConnectCode(Connection_Code);

				#ifdef DEBUG
					putstring("CU SET CONNECT_BIT\n");
				#endif

				Connect_Bit = BIT_CONNECT; /* 0x80 */
				Write_GEC_ADDR( BIT_ENABLE + Connect_Bit);
				
#ifndef PCB_PNP80_UNIVERSAL_TRX
				Update_LED(Read_RFC());
				Sync_Led_Status = LED_OFF;
#else
                Sync_Led_Status = LED_SYNC_STATUS;
#endif
			}
		}
	}
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美一区在线| 欧美国产精品一区二区三区| 国产大陆亚洲精品国产| 亚洲一区二三区| 国产嫩草影院久久久久| 欧美一区二区三区男人的天堂| 成人不卡免费av| 美女免费视频一区二区| 亚洲午夜在线视频| 国产精品免费视频网站| 久久久亚洲精品一区二区三区 | 亚洲欧洲无码一区二区三区| 制服丝袜中文字幕一区| 一本大道久久a久久精二百| 国产在线精品免费av| 日韩中文字幕1| 夜夜嗨av一区二区三区中文字幕| 欧美极品aⅴ影院| wwwwww.欧美系列| 日韩精品专区在线影院重磅| 精品视频资源站| 在线一区二区三区四区五区| 99久久精品免费看国产免费软件| 国产麻豆视频一区二区| 韩国av一区二区三区在线观看| 五月婷婷色综合| 午夜精品一区二区三区免费视频| 一级做a爱片久久| 亚洲在线视频网站| 亚洲国产wwwccc36天堂| 夜夜夜精品看看| 亚洲一区二区精品久久av| 伊人色综合久久天天| 亚洲精品视频免费观看| 一区二区三区中文字幕在线观看| 亚洲日本va午夜在线影院| 中文字幕一区二区视频| 中文字幕日韩欧美一区二区三区| 最新日韩av在线| 亚洲精选视频在线| 亚洲精品一二三| 洋洋成人永久网站入口| 亚洲一区二区三区三| 亚洲一二三四区| 亚洲国产精品综合小说图片区| 亚洲宅男天堂在线观看无病毒| 一区二区三区四区在线| 亚洲福中文字幕伊人影院| 午夜亚洲国产au精品一区二区| 香蕉久久夜色精品国产使用方法 | 国产福利电影一区二区三区| 国产成人在线观看| aaa欧美大片| 欧美在线小视频| 宅男噜噜噜66一区二区66| 欧美xxxxxxxx| 欧美国产一区在线| 18成人在线视频| 午夜视频一区在线观看| 蓝色福利精品导航| 国产黄色精品视频| 在线免费观看视频一区| 91精品国产黑色紧身裤美女| 久久嫩草精品久久久精品一| 亚洲欧洲成人自拍| 日韩影院免费视频| 国产精品一级片在线观看| 99精品视频一区二区三区| 欧美日韩aaaaa| 久久精品欧美日韩精品| 亚洲最大成人综合| 久久国产综合精品| 91农村精品一区二区在线| 91精品国产麻豆国产自产在线 | 亚洲美女淫视频| 奇米精品一区二区三区在线观看一| 国产麻豆精品一区二区| 99久久久久久99| 日韩欧美另类在线| 亚洲欧洲国产日本综合| 日韩av中文字幕一区二区| www.亚洲国产| 欧美一级日韩免费不卡| 国产精品久久久久一区二区三区| 性做久久久久久免费观看欧美| 激情都市一区二区| 91官网在线观看| 久久精品在线免费观看| 亚洲主播在线播放| 高清不卡在线观看| 日韩一区二区三区精品视频| 亚洲欧美一区二区三区极速播放| 美女免费视频一区二区| 色88888久久久久久影院按摩| 欧美成人综合网站| 亚洲午夜视频在线观看| 成人sese在线| 久久天堂av综合合色蜜桃网| 亚洲aaa精品| 99riav一区二区三区| wwwwww.欧美系列| 丝袜脚交一区二区| 一本色道综合亚洲| 国产精品私房写真福利视频| 青青国产91久久久久久| 色狠狠色噜噜噜综合网| 国产偷国产偷精品高清尤物 | 中文字幕av在线一区二区三区| 青青青爽久久午夜综合久久午夜| 日本道精品一区二区三区| 中文字幕欧美激情一区| 久久精品国产一区二区| 在线精品亚洲一区二区不卡| 国产精品国产三级国产三级人妇| 久久99精品久久久久久久久久久久| 欧美日韩精品二区第二页| 亚洲精品成人在线| 91天堂素人约啪| 国产精品精品国产色婷婷| 国产精品伊人色| 久久精品夜色噜噜亚洲a∨| 美国精品在线观看| 91精选在线观看| 日本成人在线不卡视频| 欧美性淫爽ww久久久久无| 一区二区在线观看免费视频播放| 成人黄色777网| 国产精品你懂的在线欣赏| 懂色av中文字幕一区二区三区| 精品欧美一区二区在线观看| 麻豆久久久久久久| 日韩欧美视频在线| 寂寞少妇一区二区三区| 欧美精品一区二区三区蜜桃| 久久疯狂做爰流白浆xx| 欧美va在线播放| 精品一区二区影视| 26uuu精品一区二区| 激情都市一区二区| 国产性做久久久久久| 国产91在线|亚洲| 国产精品国产自产拍在线| eeuss影院一区二区三区| 亚洲丝袜制服诱惑| 91黄色免费版| 日韩高清不卡在线| 欧美成人精品1314www| 国产精品99久久不卡二区| 中文字幕一区二区三区乱码在线| 99国内精品久久| 亚洲超碰精品一区二区| 日韩欧美激情四射| 国产精品一区二区久久精品爱涩 | 一区二区在线免费观看| 欧美日韩aaa| 九九精品视频在线看| 中文字幕欧美区| 欧美亚洲一区三区| 理论电影国产精品| 国产精品久久久一本精品| 色噜噜狠狠色综合中国| 免费成人在线视频观看| 国产片一区二区三区| 色婷婷久久综合| 男人的天堂亚洲一区| 国产精品人妖ts系列视频| 在线视频国内自拍亚洲视频| 蜜臀av性久久久久蜜臀av麻豆| 久久综合色一综合色88| 97se狠狠狠综合亚洲狠狠| 日韩激情视频在线观看| 久久久精品国产免大香伊 | 日韩欧美中文字幕制服| 国产精品影音先锋| 亚洲国产精品久久不卡毛片| 精品粉嫩aⅴ一区二区三区四区| www.亚洲精品| 美女任你摸久久| 亚洲黄色尤物视频| 精品国产乱码久久久久久久| 一本久久精品一区二区| 久久99最新地址| 夜色激情一区二区| 国产人成一区二区三区影院| 欧美性受极品xxxx喷水| 成人在线视频一区二区| 香港成人在线视频| 欧美激情在线看| 91精品国产欧美一区二区成人| k8久久久一区二区三区| 美腿丝袜亚洲三区| 国产精品福利一区二区三区| 日韩欧美不卡一区| 欧洲色大大久久| 国产 欧美在线| 激情偷乱视频一区二区三区| 午夜精品久久久久久久 | 2023国产精品视频| 91精品国产综合久久福利| 91美女视频网站|