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

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

?? tcp.c

?? 最新版FreeRTOS, 包擴多種開發平臺的移植
?? C
?? 第 1 頁 / 共 2 頁
字號:
	i2cMessage( ucDataProtocol, sizeof( ucDataProtocol),tcpDEVICE_ADDRESS, tpcSOCKET_OPT_REG, i2cWRITE, NULL, portMAX_DELAY );
	i2cMessage( ucDataPort,		sizeof( ucDataPort),	tcpDEVICE_ADDRESS, tcpSOURCE_PORT_REG, i2cWRITE, NULL, portMAX_DELAY );
	i2cMessage( ucDataSockInit, sizeof( ucDataSockInit),tcpDEVICE_ADDRESS, tcpCOMMAND_REG, i2cWRITE, xMessageComplete, portMAX_DELAY );

	/* Wait for the Init command to be sent. */
	if( !xSemaphoreTake( xMessageComplete, tcpLONG_DELAY ) )
	{
		/* For some reason the message was not transmitted within our block
		period. */
		return ( portLONG ) pdFAIL;
	}

	/* Allow the socket to initialise. */
	vTaskDelay( tcpINIT_DELAY );

	/* Read back the status to ensure the socket initialised ok. */
	prvReadRegister( &ucStatus, tcpINTERRUPT_STATUS_REG, tcpSTATUS_READ_LEN );
	
	/* We should find that the socket init was successful. */
	if( ucStatus != tcpISR_SOCKET_INIT )
	{
		return ( portLONG ) pdFAIL;
	}


	/* Setup the Tx pointer registers to indicate that the Tx buffer is empty. */
	i2cMessage( ucDataTxReadPointer, sizeof( ucDataTxReadPointer ), tcpDEVICE_ADDRESS, tcpTX_READ_POINTER_REG, i2cWRITE, NULL, portMAX_DELAY );
	vTaskDelay( tcpSHORT_DELAY );
	i2cMessage( ucDataTxWritePointer, sizeof( ucDataTxWritePointer ), tcpDEVICE_ADDRESS, tcpTX_WRITE_POINTER_REG, i2cWRITE, NULL, portMAX_DELAY );
	vTaskDelay( tcpSHORT_DELAY );
	i2cMessage( ucDataTxAckPointer,	  sizeof( ucDataTxAckPointer ),	  tcpDEVICE_ADDRESS, tcpTX_ACK_POINTER_REG, i2cWRITE, NULL, portMAX_DELAY );
	vTaskDelay( tcpSHORT_DELAY );

	return ( portLONG ) pdPASS;
}
/*-----------------------------------------------------------*/

void vTCPListen( void )
{
unsigned portCHAR ucISR;

	/* Start a passive listen on the socket. */

	/* Enable interrupts in the WizNet device after ensuring none are 
	currently pending. */
	while( SCB_EXTINT & tcpCLEAR_EINT0 )
	{
		/* The WIZnet device is still asserting and interrupt so tell it to 
		clear. */
		i2cMessage( ucDataClearInterrupt, sizeof( ucDataClearInterrupt ), tcpDEVICE_ADDRESS, tcpINTERRUPT_REG, i2cWRITE, xMessageComplete, portMAX_DELAY );
		xSemaphoreTake( xMessageComplete, tcpLONG_DELAY );

		vTaskDelay( 1 );
		SCB_EXTINT = tcpCLEAR_EINT0;
	}

	while( xQueueReceive( xTCPISRQueue, &ucISR, tcpNO_DELAY ) )
	{
		/* Just clearing the queue used by the ISR routine to tell this task
		that the WIZnet device needs attention. */
	}

	/* Now all the pending interrupts have been cleared we can enable the 
	processor interrupts. */
	VICIntEnable |= tcpEINT0_VIC_CHANNEL_BIT;

	/* Then start listening for incoming connections. */
	i2cMessage( ucDataListen, sizeof( ucDataListen ), tcpDEVICE_ADDRESS, tcpCOMMAND_REG, i2cWRITE, NULL, portMAX_DELAY );
}
/*-----------------------------------------------------------*/

portLONG lProcessConnection( void )
{
unsigned portCHAR ucISR, ucState, ucLastState = 2, ucShadow;
extern volatile portLONG lTransactionCompleted;
portLONG lSameStateCount = 0, lDataSent = pdFALSE;
unsigned portLONG ulWritePointer, ulAckPointer;

	/* No I2C errors can yet have occurred. */
	portENTER_CRITICAL();
		lTransactionCompleted = pdTRUE;
	portEXIT_CRITICAL();

	/* Keep looping - processing interrupts, until we have completed a 
	transaction.   This uses the WIZnet in it's simplest form.  The socket
	accepts a connection - we process the connection - then close the socket.
	We then go back to reinitialise everything and start again. */
	while( lTransactionCompleted == pdTRUE )
	{
		/* Wait for a message on the queue from the WIZnet ISR.  When the 
		WIZnet device asserts an interrupt the ISR simply posts a message
		onto this queue to wake this task. */
		if( xQueueReceive( xTCPISRQueue, &ucISR, tcpCONNECTION_WAIT_DELAY ) )
		{
			/* The ISR posted a message on this queue to tell us that the
			WIZnet device asserted an interrupt.  The ISR cannot process
			an I2C message so cannot tell us what caused the interrupt so
			we have to query the device here.  This task is the highest
			priority in the system so will run immediately following the ISR. */
			prvReadRegister( &ucISR, tcpINTERRUPT_STATUS_REG, tcpSTATUS_READ_LEN );

			/* Once we have read what caused the ISR we can clear the interrupt
			in the WIZnet. */
			i2cMessage( ucDataClearInterrupt, sizeof( ucDataClearInterrupt ), tcpDEVICE_ADDRESS, tcpINTERRUPT_REG, i2cWRITE, NULL, portMAX_DELAY );

			/* Now we can clear the processor interrupt and re-enable ready for
			the next. */
			SCB_EXTINT = tcpCLEAR_EINT0;
			VICIntEnable |= tcpEINT0_VIC_CHANNEL_BIT;
	
			/* Process the interrupt ... */

			if( ucISR & tcpISR_ESTABLISHED )
			{
				/* A connection has been established - respond by sending
				a receive command. */
				i2cMessage( ucDataReceiveCmd, sizeof( ucDataReceiveCmd ), tcpDEVICE_ADDRESS, tcpCOMMAND_REG, i2cWRITE, NULL, portMAX_DELAY );
			}
		
			if( ucISR & tcpISR_RX_COMPLETE )
			{
				/* We message has been received.  This will be an HTTP get 
				command.  We only have one page to send so just send it without
				regard to what the actual requested page was. */
				prvSendSamplePage();
			}
		
		 	if( ucISR & tcpISR_TX_COMPLETE )
			{
				/* We have a TX complete interrupt - which oddly does not 
				indicate that the message being sent is complete so we cannot
				yet close the socket.  Instead we read the position of the Tx
				pointer within the WIZnet device so we know how much data it
				has to send.  Later we will read the ack pointer and compare 
				this to the Tx pointer to ascertain whether the transmission 
				has completed. */

				/* First read the shadow register. */
				prvReadRegister( &ucShadow, tcpTX_WRITE_SHADOW_REG, tcpSHADOW_READ_LEN );
			
				/* Now a short delay is required. */
				vTaskDelay( tcpSHORT_DELAY );

				/* Then we can read the real register. */
				prvReadRegister( ( unsigned portCHAR * ) &ulWritePointer, tcpTX_WRITE_POINTER_REG, sizeof( ulWritePointer ) );

				/* We cannot do anything more here but need to remember that 
				this interrupt has occurred. */
				lDataSent = pdTRUE;
			}
		
			if( ucISR & tcpISR_CLOSED )
			{
				/* The socket has been closed so we can leave this function. */
				lTransactionCompleted = pdFALSE;
			}
		}
		else
		{
			/* We have not received an interrupt from the WIZnet device for a 
			while.  Read the socket status and check that everything is as
			expected. */
			prvReadRegister( &ucState, tcpSOCKET_STATE_REG, tcpSTATUS_READ_LEN );
			
			if( ( ucState == tcpSTATUS_ESTABLISHED ) && ( lDataSent > 0 ) ) 
			{
				/* The socket is established and we have already received a Tx
				end interrupt.  We must therefore be waiting for the Tx buffer
				inside the WIZnet device to be empty before we can close the
				socket. 

				Read the Ack pointer register to see if it has caught up with
				the Tx pointer register.  First we have to read the shadow 
				register. */
				prvReadRegister( &ucShadow, tcpTX_ACK_SHADOW_REG, tcpSHADOW_READ_LEN );
				vTaskDelay( tcpSHORT_DELAY );
				prvReadRegister( ( unsigned portCHAR * ) &ulAckPointer, tcpTX_ACK_POINTER_REG, sizeof( ulWritePointer ) );

				if( ulAckPointer == ulWritePointer )
				{
					/* The Ack and write pointer are now equal and we can 
					safely close the socket. */
					i2cMessage( ucDataDisconnect, sizeof( ucDataDisconnect ), tcpDEVICE_ADDRESS, tcpCOMMAND_REG, i2cWRITE, NULL, portMAX_DELAY );
				}
				else
				{
					/* Keep a count of how many times we encounter the Tx
					buffer still containing data. */
					lDataSent++;
					if( lDataSent > tcpMAX_ATTEMPTS_TO_CHECK_BUFFER )
					{
						/* Assume we cannot complete sending the data and 
						therefore cannot safely close the socket.  Start over. */
						vTCPHardReset();
						lTransactionCompleted = pdFALSE;
					}
				}
			}
			else if( ucState != tcpSTATUS_LISTEN )
			{
				/* If we have not yet received a Tx end interrupt we would only 
				ever expect to find the socket still listening for any 
				sustained period. */
				if( ucState == ucLastState )
				{
					lSameStateCount++;
					if( lSameStateCount > tcpMAX_NON_LISTEN_STAUS_READS )
					{						
						/* We are persistently in an unexpected state.  Assume
						we cannot safely close the socket and start over. */
						vTCPHardReset();
						lTransactionCompleted = pdFALSE;
					}
				}
			}
			else
			{
				/* We are in the listen state so are happy that everything
				is as expected. */
				lSameStateCount = 0;
			}

			/* Remember what state we are in this time around so we can check
			for a persistence on an unexpected state. */
			ucLastState = ucState;
		}
	}

	/* We are going to reinitialise the WIZnet device so do not want our 
	interrupts from the WIZnet to be processed. */
	VICIntEnClear |= tcpEINT0_VIC_CHANNEL_BIT;
	return lTransactionCompleted;
}
/*-----------------------------------------------------------*/

static void prvWriteString( const portCHAR * const pucTxBuffer, portLONG lTxLen, unsigned portLONG *pulTxAddress )
{
unsigned portLONG ulSendAddress;

	/* Send a string to the Tx buffer internal to the WIZnet device. */

	/* Calculate the address to which we are going to write in the buffer. */
	ulSendAddress = ( *pulTxAddress & tcpSINGLE_SOCKET_ADDR_MASK ) + tcpSINGLE_SOCKET_ADDR_OFFSET;

	/* Send the buffer to the calculated address.  Use the semaphore so we
	can wait until the entire message has been transferred. */
	i2cMessage( ( unsigned portCHAR * ) pucTxBuffer, lTxLen, tcpDEVICE_ADDRESS, ( unsigned portSHORT ) ulSendAddress, i2cWRITE, xMessageComplete, portMAX_DELAY );

	/* Wait until the semaphore indicates that the message has been transferred. */
	if( !xSemaphoreTake( xMessageComplete, tcpLONG_DELAY ) )
	{
		return;
	}

	/* Return the new address of the end of the buffer (within the WIZnet 
	device). */
	*pulTxAddress += ( unsigned portLONG ) lTxLen;
}
/*-----------------------------------------------------------*/

static void prvFlushBuffer( unsigned portLONG ulTxAddress )
{
unsigned portCHAR ucTxBuffer[ tcpMAX_REGISTER_LEN ];

	/* We have written some data to the Tx buffer internal to the WIZnet
	device.  Now we update the Tx pointer inside the WIZnet then send a
	Send command - which causes	the data up to the new Tx pointer to be 
	transmitted. */

	/* Make sure endieness is correct for transmission. */
	ulTxAddress = htonl( ulTxAddress );

	/* Place the new Tx pointer in the string to be transmitted. */
	ucTxBuffer[ 0 ] = ( unsigned portCHAR ) ( ulTxAddress & 0xff );
	ulTxAddress >>= 8;
	ucTxBuffer[ 1 ] = ( unsigned portCHAR ) ( ulTxAddress & 0xff );
	ulTxAddress >>= 8;
	ucTxBuffer[ 2 ] = ( unsigned portCHAR ) ( ulTxAddress & 0xff );
	ulTxAddress >>= 8;
	ucTxBuffer[ 3 ] = ( unsigned portCHAR ) ( ulTxAddress & 0xff );
	ulTxAddress >>= 8;

	/* And send it to the WIZnet device. */
	i2cMessage( ucTxBuffer, sizeof( ulTxAddress ), tcpDEVICE_ADDRESS, tcpTX_WRITE_POINTER_REG, i2cWRITE, xMessageComplete, portMAX_DELAY );

	if( !xSemaphoreTake( xMessageComplete, tcpLONG_DELAY ) )
	{
		return;
	}

	vTaskDelay( tcpSHORT_DELAY );

	/* Transmit! */
	i2cMessage( ucDataSend, sizeof( ucDataSend ), tcpDEVICE_ADDRESS, tcpCOMMAND_REG, i2cWRITE, xMessageComplete, portMAX_DELAY );

	if( !xSemaphoreTake( xMessageComplete, tcpLONG_DELAY ) )
	{
		return;
	}
}
/*-----------------------------------------------------------*/

static void prvSendSamplePage( void )
{
extern portLONG lErrorInTask;
unsigned portLONG ulTxAddress;
unsigned portCHAR ucShadow;
portLONG lIndex;
static unsigned portLONG ulRefreshCount = 0x00;
static portCHAR cPageBuffer[ tcpBUFFER_LEN ];


	/* This function just generates a sample page of HTML which gets
	sent each time a client attaches to the socket.  The page is created
	from two fixed strings (cSamplePageFirstPart and cSamplePageSecondPart)
	with a bit of dynamically generated data in the middle. */

	/* We need to know the address to which the html string should be sent
	in the WIZnet Tx buffer.  First read the shadow register. */
	prvReadRegister( &ucShadow, tcpTX_WRITE_SHADOW_REG, tcpSHADOW_READ_LEN );

	/* Now a short delay is required. */
	vTaskDelay( tcpSHORT_DELAY );

	/* Now we can read the real pointer value. */
	prvReadRegister( ( unsigned portCHAR * ) &ulTxAddress, tcpTX_WRITE_POINTER_REG, sizeof( ulTxAddress ) );

	/* Make sure endieness is correct. */
	ulTxAddress = htonl( ulTxAddress );

	/* Send the start of the page. */
	prvWriteString( cSamplePageFirstPart, strlen( cSamplePageFirstPart ), &ulTxAddress );

	/* Generate a bit of dynamic data and place it in the buffer ready to be
	transmitted. */
	strcpy( cPageBuffer, "<BR>Number of ticks since boot = 0x" );
	lIndex = strlen( cPageBuffer );
	ultoa( xTaskGetTickCount(), &( cPageBuffer[ lIndex ] ), 0 );
	strcat( cPageBuffer, "<br>Number of tasks executing = ");
	lIndex = strlen( cPageBuffer );
	ultoa( ( unsigned portLONG ) uxTaskGetNumberOfTasks(), &( cPageBuffer[ lIndex ] ), 0 );
	strcat( cPageBuffer, "<br>IO port 0 state (used by flash tasks) = 0x" );
	lIndex = strlen( cPageBuffer );
	ultoa( ( unsigned portLONG ) GPIO0_IOPIN, &( cPageBuffer[ lIndex ] ), 0 );
	strcat( cPageBuffer, "<br>Refresh = 0x" );
	lIndex = strlen( cPageBuffer );
	ultoa( ( unsigned portLONG ) ulRefreshCount, &( cPageBuffer[ lIndex ] ), 0 );
	
	if( lErrorInTask )
	{
		strcat( cPageBuffer, "<p>An error has occurred in at least one task." );
	}
	else
	{
		strcat( cPageBuffer, "<p>All tasks executing without error." );		
	}

	ulRefreshCount++;

	/* Send the dynamically generated string. */
	prvWriteString( cPageBuffer, strlen( cPageBuffer ), &ulTxAddress );

	/* Finish the page. */
	prvWriteString( cSamplePageSecondPart, strlen( cSamplePageSecondPart ), &ulTxAddress );

	/* Tell the WIZnet to send the data we have just written to its Tx buffer. */
	prvFlushBuffer( ulTxAddress );
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品影音先锋| 一区二区高清视频在线观看| 国产精品色在线| 综合分类小说区另类春色亚洲小说欧美| 中文字幕亚洲综合久久菠萝蜜| 自拍偷自拍亚洲精品播放| 亚洲精品中文在线影院| 青草av.久久免费一区| 成人免费毛片片v| 欧美日韩综合在线免费观看| 精品久久久久久久久久久久包黑料 | 欧美制服丝袜第一页| 精品国产亚洲一区二区三区在线观看 | 欧美激情一区在线| 日产国产欧美视频一区精品| 成人app软件下载大全免费| 7777精品伊人久久久大香线蕉超级流畅 | 日韩精品亚洲专区| 色综合天天综合网国产成人综合天| 5566中文字幕一区二区电影 | 国产精品久久久久桃色tv| 亚洲国产日韩综合久久精品| 国产不卡高清在线观看视频| 日韩一区二区三免费高清| 一区二区三区国产豹纹内裤在线 | 一本久久精品一区二区| 久久综合色之久久综合| 日韩中文字幕一区二区三区| 91国产视频在线观看| 亚洲少妇中出一区| 成人午夜在线免费| 欧美国产97人人爽人人喊| 韩国一区二区三区| 欧美一区永久视频免费观看| 亚洲一区二区美女| 色嗨嗨av一区二区三区| 国产精品成人免费| 成人精品电影在线观看| 国产精品拍天天在线| 91色porny蝌蚪| 综合欧美一区二区三区| 91网址在线看| 一区二区三区四区亚洲| 欧美三级中文字| 五月婷婷久久综合| 欧美一区二区二区| 国产在线国偷精品产拍免费yy| 精品国产乱码久久久久久影片| 狠狠色伊人亚洲综合成人| 国产欧美精品在线观看| 成人永久看片免费视频天堂| 日韩久久一区二区| 在线播放国产精品二区一二区四区| 日产欧产美韩系列久久99| 久久这里只有精品首页| 不卡的av网站| 丝袜美腿成人在线| 久久青草欧美一区二区三区| 成人一道本在线| 亚洲一区二区成人在线观看| 精品精品欲导航| 91影视在线播放| 精品综合久久久久久8888| 亚洲视频免费在线| 欧美电影免费观看高清完整版在| 成人性生交大片免费看视频在线| 一个色妞综合视频在线观看| 久久久久青草大香线综合精品| 欧美三级乱人伦电影| 成人黄色国产精品网站大全在线免费观看 | 国产精品国产三级国产有无不卡 | 图片区日韩欧美亚洲| 国产偷v国产偷v亚洲高清| 欧美人牲a欧美精品| caoporm超碰国产精品| 男人的天堂久久精品| 亚洲国产精品一区二区www | 国产精品123| 蜜臀精品一区二区三区在线观看 | 国产日韩欧美一区二区三区综合| 欧美另类变人与禽xxxxx| 91美女片黄在线| 国产成a人亚洲精品| 蜜桃视频在线观看一区| 日韩二区在线观看| 性欧美大战久久久久久久久| 最新国产精品久久精品| 国产女同互慰高潮91漫画| 精品国产不卡一区二区三区| 欧美一区二区在线免费观看| 91久久线看在观草草青青| 成人午夜激情片| 不卡一区二区三区四区| 99精品国产一区二区三区不卡 | 欧美精品久久天天躁| 欧美日韩一区二区三区高清| 国产精品不卡一区二区三区| 亚洲视频一区二区在线| 亚洲欧美日韩久久| 一区二区三区欧美日| 亚洲午夜私人影院| 日本特黄久久久高潮| 蜜桃av噜噜一区| 国产一区不卡在线| 成人性生交大片| 在线精品观看国产| 91精品免费在线观看| 精品福利一区二区三区免费视频| 精品少妇一区二区三区日产乱码 | 国产色产综合色产在线视频| 日韩一区欧美小说| 午夜欧美大尺度福利影院在线看| 免费观看91视频大全| 成人伦理片在线| 欧美男男青年gay1069videost | 日韩欧美二区三区| 久久久美女毛片| 一区二区三区欧美日| 日本中文一区二区三区| 国产成人亚洲综合a∨猫咪| 91免费看`日韩一区二区| 欧美一区二区三区精品| 国产欧美精品一区| 天天综合网天天综合色| 国产成人激情av| 在线播放中文一区| 国产欧美一二三区| 亚洲成av人综合在线观看| 国产成人av影院| 日韩三级高清在线| 一区二区三区日韩精品视频| 激情综合一区二区三区| 一本色道久久综合狠狠躁的推荐| 久久久精品黄色| 奇米色一区二区三区四区| 91色porny在线视频| 久久一日本道色综合| 日韩高清中文字幕一区| 处破女av一区二区| 欧美视频在线一区| 亚洲激情中文1区| 99这里只有精品| 久久亚洲精华国产精华液| 天天射综合影视| 欧美日韩在线一区二区| 一区二区三区日本| 色综合一个色综合| 国产精品天干天干在观线| 国产福利一区二区三区| 精品欧美乱码久久久久久1区2区| 亚洲欧美日韩国产综合在线| 成人综合婷婷国产精品久久免费| 久久久久久亚洲综合| 美女视频网站黄色亚洲| 91精品国产色综合久久| 日韩国产高清在线| 欧美成人bangbros| 极品少妇xxxx偷拍精品少妇| 精品日产卡一卡二卡麻豆| 国产剧情一区二区三区| 国产精品乱子久久久久| 丁香六月综合激情| 亚洲精品欧美激情| 91精品国产综合久久久久久| 日韩激情视频网站| 26uuu另类欧美亚洲曰本| 国产中文一区二区三区| 亚洲欧美在线视频| 色综合中文字幕国产| 三级不卡在线观看| 久久久久久久av麻豆果冻| 成人白浆超碰人人人人| 亚洲免费在线观看| 欧美日韩三级一区| www.激情成人| 天涯成人国产亚洲精品一区av| 精品精品国产高清a毛片牛牛| 成人黄色av电影| 日产精品久久久久久久性色| 久久色.com| 国产不卡视频一区二区三区| 亚洲欧洲精品成人久久奇米网| 在线亚洲精品福利网址导航| 久久99精品国产麻豆不卡| 久久久久久影视| 日韩视频在线你懂得| 色偷偷久久一区二区三区| 麻豆91精品视频| 秋霞影院一区二区| 亚洲精品免费播放| 久久夜色精品国产噜噜av| 欧美肥大bbwbbw高潮| 99久久99久久久精品齐齐| 毛片一区二区三区| 亚洲精选免费视频| 国产精品视频一二三| 欧美一级午夜免费电影| 91.com在线观看| 欧美最猛性xxxxx直播| 成人av影视在线观看|