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

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

?? func_connect.c.bak

?? 2.4G無線音箱的接收程序,采用ATMEGA8單片機和STS公司的無線模塊完成
?? BAK
字號:
/******************************************************************************
*
* 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);             
                
                /* 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一区二区三区免费野_久草精品视频
亚洲成人资源在线| 成人综合婷婷国产精品久久免费| 国产又粗又猛又爽又黄91精品| 99久久精品一区二区| 日韩色视频在线观看| 性久久久久久久久| 丰满岳乱妇一区二区三区| 91.麻豆视频| 亚洲综合色婷婷| 不卡区在线中文字幕| 精品av久久707| 蜜桃一区二区三区四区| 欧美三级在线看| 怡红院av一区二区三区| 成人毛片视频在线观看| 久久一留热品黄| 韩国av一区二区三区四区| 91麻豆精品国产91| 性感美女久久精品| 欧美视频一二三区| 依依成人综合视频| 色婷婷综合激情| 一区二区三区高清不卡| 一本到不卡精品视频在线观看| 欧美国产精品久久| 丁香啪啪综合成人亚洲小说| 久久精品视频在线看| 国产精品综合久久| 国产亚洲一区二区三区| 国产精品99精品久久免费| 久久久久九九视频| 国产传媒一区在线| 欧美极品另类videosde| 成人动漫精品一区二区| 成人欧美一区二区三区黑人麻豆| caoporn国产一区二区| 亚洲欧美色一区| 色天使色偷偷av一区二区| 一区二区在线电影| 欧美日韩精品免费观看视频| 婷婷成人激情在线网| 欧美一区二区三区小说| 国产在线视频不卡二| 久久精品在线观看| 成人国产精品视频| 樱花草国产18久久久久| 3d动漫精品啪啪一区二区竹菊| 日韩精品欧美精品| 久久夜色精品一区| 99国产一区二区三精品乱码| 亚洲最新视频在线播放| 欧美一区二区三区色| 蜜臀久久久99精品久久久久久| 久久亚洲精华国产精华液| www.亚洲色图.com| 天天色图综合网| 久久人人超碰精品| 91免费观看在线| 日韩精品91亚洲二区在线观看| 精品电影一区二区| 一本大道av一区二区在线播放| 一区二区三区波多野结衣在线观看 | 青青草精品视频| 久久久噜噜噜久久人人看 | 97精品电影院| 热久久国产精品| 国产精品久久久久一区二区三区共| 在线视频你懂得一区二区三区| 国产无人区一区二区三区| 一本久道中文字幕精品亚洲嫩| 日韩av中文字幕一区二区三区 | 97精品国产露脸对白| 奇米综合一区二区三区精品视频 | 91在线播放网址| 麻豆国产精品777777在线| 国产日韩欧美精品一区| 日韩影院精彩在线| 欧美国产日产图区| 欧美蜜桃一区二区三区| 99综合影院在线| 美女视频第一区二区三区免费观看网站| 国产精品污污网站在线观看| 日韩一卡二卡三卡四卡| 色播五月激情综合网| 国产一区二区三区免费看| 午夜精品视频在线观看| 亚洲色图第一区| 国产色综合久久| 日韩欧美不卡在线观看视频| 欧美中文字幕一区二区三区亚洲| 国内精品免费在线观看| 青椒成人免费视频| 婷婷久久综合九色国产成人| 亚洲精品中文在线| 中文字幕在线一区免费| 久久久.com| 26uuu久久天堂性欧美| 7777精品伊人久久久大香线蕉的 | 久久蜜桃av一区精品变态类天堂 | 欧美视频一区二| 成人h动漫精品| 久久99精品久久只有精品| 偷拍与自拍一区| 亚洲午夜电影在线| 亚洲综合免费观看高清完整版在线 | 奇米影视7777精品一区二区| 艳妇臀荡乳欲伦亚洲一区| 亚洲免费观看在线观看| 国产精品你懂的在线| 中日韩av电影| 国产精品久久久久影院老司 | 色88888久久久久久影院按摩| 欧洲另类一二三四区| 91丝袜高跟美女视频| 99精品国产99久久久久久白柏| 成人黄色大片在线观看| 91亚洲精华国产精华精华液| 99久久免费精品高清特色大片| 不卡的av在线播放| 91麻豆国产福利在线观看| 色噜噜狠狠成人中文综合 | 午夜精品免费在线| 日韩精品国产欧美| 免费的成人av| 国产一区二区三区高清播放| 从欧美一区二区三区| 91免费看`日韩一区二区| 在线观看亚洲一区| 51精品秘密在线观看| 久久综合999| 1区2区3区精品视频| 亚洲国产精品精华液网站 | 亚洲电影你懂得| 日韩激情视频在线观看| 狠狠v欧美v日韩v亚洲ⅴ| 国产高清在线精品| 91丨porny丨最新| 欧美精品一级二级三级| 久久蜜臀中文字幕| 一个色在线综合| 美女尤物国产一区| 国产乱妇无码大片在线观看| 成人黄色大片在线观看| 欧美日韩在线免费视频| 久久蜜桃av一区二区天堂 | 国产精品免费久久久久| 久久99国产精品免费| 成人ar影院免费观看视频| 欧美视频一区二区三区在线观看| 日韩欧美一区二区三区在线| 国产精品你懂的在线| 婷婷久久综合九色综合绿巨人 | 亚洲黄色av一区| 久久国产精品色婷婷| 91色乱码一区二区三区| 91精品国产91久久久久久最新毛片 | 免费xxxx性欧美18vr| 成人av片在线观看| 日韩一区二区三区精品视频| 中文字幕一区二区三区不卡在线| 日韩国产欧美一区二区三区| 风间由美性色一区二区三区| 日韩一区二区三区观看| 亚洲免费观看高清在线观看| 激情国产一区二区 | 日本成人在线网站| 成人免费毛片高清视频| 欧美一级欧美一级在线播放| 亚洲天堂精品视频| 国产精品996| 精品久久久久久综合日本欧美 | 国产精品香蕉一区二区三区| 欧美三级三级三级| 国产精品久久久久久亚洲伦| 久久国产精品露脸对白| 欧美福利电影网| 伊人婷婷欧美激情| 国产白丝精品91爽爽久久| 日韩精品一区二区三区中文精品| 亚洲一区免费观看| 成人美女在线视频| 久久精品亚洲一区二区三区浴池 | 麻豆极品一区二区三区| 欧美伦理电影网| 一区二区三区中文免费| 97精品国产露脸对白| 国产精品久久久99| 成人精品国产一区二区4080| 国产欧美精品区一区二区三区| 久久se精品一区二区| 日韩免费一区二区| 另类小说视频一区二区| 91精品国产91久久久久久一区二区| 亚洲第一av色| 欧美精品久久天天躁| 日韩高清中文字幕一区| 7799精品视频| 久久国产日韩欧美精品| 精品国精品国产| 91福利社在线观看|