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

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

?? sam7_emac.c

?? IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR IAR
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
	FreeRTOS.org V5.1.1 - Copyright (C) 2003-2008 Richard Barry.

	This file is part of the FreeRTOS.org distribution.

	FreeRTOS.org is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	FreeRTOS.org is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with FreeRTOS.org; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

	A special exception to the GPL can be applied should you wish to distribute
	a combined work that includes FreeRTOS.org, without being obliged to provide
	the source code for any proprietary components.  See the licensing section
	of http://www.FreeRTOS.org for full details of how and when the exception
	can be applied.

    ***************************************************************************
    ***************************************************************************
    *                                                                         *
    * SAVE TIME AND MONEY!  We can port FreeRTOS.org to your own hardware,    *
    * and even write all or part of your application on your behalf.          *
    * See http://www.OpenRTOS.com for details of the services we provide to   *
    * expedite your project.                                                  *
    *                                                                         *
    ***************************************************************************
    ***************************************************************************

	Please ensure to read the configuration and relevant port sections of the
	online documentation.

	http://www.FreeRTOS.org - Documentation, latest information, license and 
	contact details.

	http://www.SafeRTOS.com - A version that is certified for use in safety 
	critical systems.

	http://www.OpenRTOS.com - Commercial support, development, porting, 
	licensing and training services.
*/

/*
 * Basic interrupt driven driver for the EMAC peripheral.  This driver is not
 * reentrant as with uIP the buffers are only ever accessed from a single task.
 *
 * The simple buffer management used within uIP allows the EMAC driver to also
 * be simplistic.  The driver contained within the lwIP demo is more
 * comprehensive.
 */


/*
Changes from V3.2.2

	+ Corrected the byte order when writing the MAC address to the MAC.
	+ Support added for MII interfaces.  Previously only RMII was supported.

Changes from V3.2.3

	+ The MII interface is now the default.
	+ Modified the initialisation sequence slightly to allow auto init more
	  time to complete.

Changes from V3.2.4

	+ Also read the EMAC_RSR register in the EMAC ISR as a work around the 
	  the EMAC bug that can reset the RX bit in EMAC_ISR register before the
	  bit has been read.

Changes from V4.0.4

	+ Corrected the Rx frame length mask when obtaining the length from the
	  rx descriptor.

*/

/* Standard includes. */
#include <string.h>

/* Scheduler includes. */
#include "FreeRTOS.h"
#include "semphr.h"
#include "task.h"

/* uIP includes. */
#include "uip.h"

/* Hardware specific includes. */
#include "Emac.h"
#include "mii.h"


/* USE_RMII_INTERFACE must be defined as 1 to use an RMII interface, or 0
to use an MII interface. */
#define USE_RMII_INTERFACE 0

/* The buffer addresses written into the descriptors must be aligned so the
last few bits are zero.  These bits have special meaning for the EMAC
peripheral and cannot be used as part of the address. */
#define emacADDRESS_MASK			( ( unsigned portLONG ) 0xFFFFFFFC )

/* Bit used within the address stored in the descriptor to mark the last
descriptor in the array. */
#define emacRX_WRAP_BIT				( ( unsigned portLONG ) 0x02 )

/* Bit used within the Tx descriptor status to indicate whether the
descriptor is under the control of the EMAC or the software. */
#define emacTX_BUF_USED				( ( unsigned portLONG ) 0x80000000 )

/* A short delay is used to wait for a buffer to become available, should
one not be immediately available when trying to transmit a frame. */
#define emacBUFFER_WAIT_DELAY		( 2 )
#define emacMAX_WAIT_CYCLES			( configTICK_RATE_HZ / 40 )

/* Misc defines. */
#define emacINTERRUPT_LEVEL			( 5 )
#define emacNO_DELAY				( 0 )
#define emacTOTAL_FRAME_HEADER_SIZE	( 54 )
#define emacPHY_INIT_DELAY			( 5000 / portTICK_RATE_MS )
#define emacRESET_KEY				( ( unsigned portLONG ) 0xA5000000 )
#define emacRESET_LENGTH			( ( unsigned portLONG ) ( 0x01 << 8 ) )

/* The Atmel header file only defines the TX frame length mask. */
#define emacRX_LENGTH_FRAME			( 0xfff )

/*-----------------------------------------------------------*/

/*
 * Prototype for the EMAC interrupt asm wrapper.
 */
extern void vEMACISREntry( void );

/*
 * Prototype for the EMAC interrupt function - called by the asm wrapper.
 */
__arm void vEMACISR( void );

/*
 * Initialise both the Tx and Rx descriptors used by the EMAC.
 */
static void prvSetupDescriptors(void);

/*
 * Write our MAC address into the EMAC.  The MAC address is set as one of the
 * uip options.
 */
static void prvSetupMACAddress( void );

/*
 * Configure the EMAC and AIC for EMAC interrupts.
 */
static void prvSetupEMACInterrupt( void );

/*
 * Some initialisation functions taken from the Atmel EMAC sample code.
 */
static void vReadPHY( unsigned portCHAR ucPHYAddress, unsigned portCHAR ucAddress, unsigned portLONG *pulValue );
#if USE_RMII_INTERFACE != 1
	static void vWritePHY( unsigned portCHAR ucPHYAddress, unsigned portCHAR ucAddress, unsigned portLONG ulValue);
#endif
static portBASE_TYPE xGetLinkSpeed( void );
static portBASE_TYPE prvProbePHY( void );

/*-----------------------------------------------------------*/

/* Buffer written to by the EMAC DMA.  Must be aligned as described by the
comment above the emacADDRESS_MASK definition. */
#pragma data_alignment=8
static volatile portCHAR pcRxBuffer[ NB_RX_BUFFERS * ETH_RX_BUFFER_SIZE ];

/* Buffer read by the EMAC DMA.  Must be aligned as described by he comment
above the emacADDRESS_MASK definition. */
#pragma data_alignment=8
static portCHAR pcTxBuffer[ NB_TX_BUFFERS * ETH_TX_BUFFER_SIZE ];

/* Descriptors used to communicate between the program and the EMAC peripheral.
These descriptors hold the locations and state of the Rx and Tx buffers. */
static volatile AT91S_TxTdDescriptor xTxDescriptors[ NB_TX_BUFFERS ];
static volatile AT91S_RxTdDescriptor xRxDescriptors[ NB_RX_BUFFERS ];

/* The IP and Ethernet addresses are read from the uIP setup. */
const portCHAR cMACAddress[ 6 ] = { UIP_ETHADDR0, UIP_ETHADDR1, UIP_ETHADDR2, UIP_ETHADDR3, UIP_ETHADDR4, UIP_ETHADDR5 };
const unsigned char ucIPAddress[ 4 ]  = { UIP_IPADDR0, UIP_IPADDR1, UIP_IPADDR2, UIP_IPADDR3 };

/* The semaphore used by the EMAC ISR to wake the EMAC task. */
static xSemaphoreHandle xSemaphore = NULL;

/*-----------------------------------------------------------*/

xSemaphoreHandle xEMACInit( void )
{
	/* Code supplied by Atmel (modified) --------------------*/

	/* disable pull up on RXDV => PHY normal mode (not in test mode),
	PHY has internal pull down. */
	AT91C_BASE_PIOB->PIO_PPUDR = 1 << 15;

	#if USE_RMII_INTERFACE != 1
	  	/* PHY has internal pull down : set MII mode. */
	  	AT91C_BASE_PIOB->PIO_PPUDR= 1 << 16;
	#endif

	/* clear PB18 <=> PHY powerdown. */
	AT91F_PIO_CfgOutput( AT91C_BASE_PIOB, 1 << 18 ) ;
	AT91F_PIO_ClearOutput( AT91C_BASE_PIOB,  1 << 18) ;

	/* After PHY power up, hardware reset. */
	AT91C_BASE_RSTC->RSTC_RMR = emacRESET_KEY | emacRESET_LENGTH| AT91C_RSTC_URSTEN;
	AT91C_BASE_RSTC->RSTC_RCR = emacRESET_KEY | AT91C_RSTC_EXTRST;
	
	/* Wait for hardware reset end. */
	while( !( AT91C_BASE_RSTC->RSTC_RSR & AT91C_RSTC_NRSTL ) )
	{
		__asm( "NOP" );
	}
	__asm( "NOP" );
  	
	/* EMAC IO init for EMAC-PHY com. Remove EF100 config. */
	AT91F_EMAC_CfgPIO();

	/* Enable com between EMAC PHY.

	Enable management port. */
	AT91C_BASE_EMAC->EMAC_NCR |= AT91C_EMAC_MPE;	

	/* MDC = MCK/32. */
	AT91C_BASE_EMAC->EMAC_NCFGR |= ( 2 ) << 10;	

	/* Wait for PHY auto init end (rather crude delay!). */
	vTaskDelay( emacPHY_INIT_DELAY );

	/* PHY configuration. */
	#if USE_RMII_INTERFACE != 1
	{
		unsigned portLONG ulControl;

		/* PHY has internal pull down : disable MII isolate. */
		vReadPHY( AT91C_PHY_ADDR, MII_BMCR, &ulControl );
		vReadPHY( AT91C_PHY_ADDR, MII_BMCR, &ulControl );
		ulControl &= ~BMCR_ISOLATE;
		vWritePHY( AT91C_PHY_ADDR, MII_BMCR, ulControl );
	}
	#endif

	/* Disable management port again. */
	AT91C_BASE_EMAC->EMAC_NCR &= ~AT91C_EMAC_MPE;

	#if USE_RMII_INTERFACE != 1
		/* Enable EMAC in MII mode, enable clock ERXCK and ETXCK. */
		AT91C_BASE_EMAC->EMAC_USRIO = AT91C_EMAC_CLKEN ;
	#else
		/* Enable EMAC in RMII mode, enable RMII clock (50MHz from oscillator
		on ERFCK). */
		AT91C_BASE_EMAC->EMAC_USRIO = AT91C_EMAC_RMII | AT91C_EMAC_CLKEN ;
	#endif

	/* End of code supplied by Atmel ------------------------*/

	/* Setup the buffers and descriptors. */
	prvSetupDescriptors();
	
	/* Load our MAC address into the EMAC. */
	prvSetupMACAddress();

	/* Try to connect. */
	if( prvProbePHY() )
	{
		/* Enable the interrupt! */
		prvSetupEMACInterrupt();
	}

	return xSemaphore;
}
/*-----------------------------------------------------------*/

portLONG lEMACSend( void )
{
static unsigned portBASE_TYPE uxTxBufferIndex = 0;
portBASE_TYPE xWaitCycles = 0;
portLONG lReturn = pdPASS;
portCHAR *pcBuffer;

	/* Is a buffer available? */
	while( !( xTxDescriptors[ uxTxBufferIndex ].U_Status.status & AT91C_TRANSMIT_OK ) )
	{
		/* There is no room to write the Tx data to the Tx buffer.  Wait a
		short while, then try again. */
		xWaitCycles++;
		if( xWaitCycles > emacMAX_WAIT_CYCLES )
		{
			/* Give up. */
			lReturn = pdFAIL;
			break;
		}
		else
		{
			vTaskDelay( emacBUFFER_WAIT_DELAY );
		}
	}

	/* lReturn will only be pdPASS if a buffer is available. */
	if( lReturn == pdPASS )
	{
		/* Copy the headers into the Tx buffer.  These will be in the uIP buffer. */
		pcBuffer = ( portCHAR * ) xTxDescriptors[ uxTxBufferIndex ].addr;
		memcpy( ( void * ) pcBuffer, ( void * ) uip_buf, emacTOTAL_FRAME_HEADER_SIZE );
		if( uip_len > emacTOTAL_FRAME_HEADER_SIZE )
		{
			memcpy( ( void * ) &( pcBuffer[ emacTOTAL_FRAME_HEADER_SIZE ] ), ( void * ) uip_appdata, ( uip_len - emacTOTAL_FRAME_HEADER_SIZE ) );
		}

		/* Send. */	
		portENTER_CRITICAL();
		{
			if( uxTxBufferIndex >= ( NB_TX_BUFFERS - 1 ) )
			{
				/* Fill out the necessary in the descriptor to get the data sent. */
				xTxDescriptors[ uxTxBufferIndex ].U_Status.status = 	( uip_len & ( unsigned portLONG ) AT91C_LENGTH_FRAME )
																		| AT91C_LAST_BUFFER
																		| AT91C_TRANSMIT_WRAP;
				uxTxBufferIndex = 0;
			}
			else
			{
				/* Fill out the necessary in the descriptor to get the data sent. */
				xTxDescriptors[ uxTxBufferIndex ].U_Status.status = 	( uip_len & ( unsigned portLONG ) AT91C_LENGTH_FRAME )
																		| AT91C_LAST_BUFFER;
				uxTxBufferIndex++;
			}
	
			AT91C_BASE_EMAC->EMAC_NCR |= AT91C_EMAC_TSTART;
		}
		portEXIT_CRITICAL();
	}

	return lReturn;
}
/*-----------------------------------------------------------*/

unsigned portLONG ulEMACPoll( void )
{
static unsigned portBASE_TYPE ulNextRxBuffer = 0;
unsigned portLONG ulSectionLength = 0, ulLengthSoFar = 0, ulEOF = pdFALSE;
portCHAR *pcSource;

	/* Skip any fragments. */
	while( ( xRxDescriptors[ ulNextRxBuffer ].addr & AT91C_OWNERSHIP_BIT ) && !( xRxDescriptors[ ulNextRxBuffer ].U_Status.status & AT91C_SOF ) )
	{
		/* Mark the buffer as free again. */
		xRxDescriptors[ ulNextRxBuffer ].addr &= ~( AT91C_OWNERSHIP_BIT );		
		ulNextRxBuffer++;
		if( ulNextRxBuffer >= NB_RX_BUFFERS )

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
视频一区国产视频| 国产99久久久精品| 成人av电影在线| 欧洲一区二区三区在线| 国产欧美一区二区精品忘忧草| 亚洲精品久久嫩草网站秘色| 狠狠色丁香婷综合久久| 在线观看国产91| 国产精品素人一区二区| 韩国v欧美v日本v亚洲v| 欧美人妇做爰xxxⅹ性高电影| 国产女人18水真多18精品一级做| 日韩精品乱码免费| 欧美在线制服丝袜| 亚洲精品自拍动漫在线| 成人av综合在线| 久久精品一区蜜桃臀影院| 日韩影院免费视频| 欧美日韩一区久久| 亚洲精品成a人| 色婷婷激情综合| 亚洲丝袜另类动漫二区| 成人黄色在线视频| 欧美激情一区二区在线| 国产91在线看| 欧美高清在线视频| 粉嫩在线一区二区三区视频| 久久综合色综合88| 国产在线精品不卡| 精品处破学生在线二十三| 精品午夜一区二区三区在线观看| 日韩一区二区在线观看视频| 蜜桃视频在线一区| 精品国产伦理网| 国产呦精品一区二区三区网站| 日韩一级片在线播放| 免费在线观看日韩欧美| 欧美一级精品在线| 麻豆国产精品777777在线| 精品剧情在线观看| 粉嫩aⅴ一区二区三区四区五区| 国产日韩欧美精品在线| 成人99免费视频| 亚洲精品视频免费看| 欧美日韩中文一区| 日本女人一区二区三区| 久久亚洲一区二区三区明星换脸| 国产成人精品一区二| 亚洲欧美日韩国产中文在线| 色94色欧美sute亚洲线路一ni| 亚洲1区2区3区4区| 精品成人私密视频| 91在线视频免费观看| 亚洲成av人片一区二区| 日韩精品在线一区| 成人av在线电影| 亚洲第一搞黄网站| 久久久国产午夜精品| 91啪九色porn原创视频在线观看| 天涯成人国产亚洲精品一区av| 精品福利av导航| 一本大道久久a久久综合| 天天影视网天天综合色在线播放 | 洋洋av久久久久久久一区| 欧美日韩另类国产亚洲欧美一级| 紧缚捆绑精品一区二区| 自拍偷拍亚洲激情| 欧美军同video69gay| 国产成人综合网| 丝袜国产日韩另类美女| 国产午夜亚洲精品不卡| 欧美视频自拍偷拍| 国产成人午夜精品影院观看视频 | 国内精品久久久久影院薰衣草| 亚洲女性喷水在线观看一区| 国产精品女同一区二区三区| 欧洲激情一区二区| 成人毛片视频在线观看| 婷婷激情综合网| 亚洲激情男女视频| 久久久www免费人成精品| 在线视频中文字幕一区二区| 韩国精品主播一区二区在线观看| 一区二区三区小说| 国产免费久久精品| 日韩一区二区三区在线观看| 色综合激情久久| 国产91在线|亚洲| 久久国产成人午夜av影院| 亚洲狠狠爱一区二区三区| 国产精品国产精品国产专区不蜜| 日韩精品一区二区在线观看| 欧美曰成人黄网| 成人丝袜18视频在线观看| 麻豆成人久久精品二区三区小说| 午夜不卡av在线| 亚洲超碰精品一区二区| 亚洲另类中文字| 亚洲视频免费观看| 国产精品―色哟哟| 日本一区二区成人| 久久综合九色综合97婷婷女人| 日韩一区二区三区观看| 91精品福利在线一区二区三区 | 欧美va亚洲va| 日韩欧美精品在线视频| 欧美一区二区三区在线| 欧美区一区二区三区| 在线观看一区不卡| 在线视频你懂得一区| 一本色道久久综合狠狠躁的推荐 | 国产乱码精品1区2区3区| 日韩av一区二区在线影视| 视频一区视频二区中文| 日韩电影在线免费观看| 日本特黄久久久高潮| 久久电影网站中文字幕| 国产一区二区看久久| 国产在线麻豆精品观看| 国产一区二区在线影院| 国产河南妇女毛片精品久久久| 国产一区二区三区免费观看| 国产福利视频一区二区三区| 国产成人精品三级| av电影一区二区| 在线精品视频一区二区| 欧美性猛交xxxxxx富婆| 欧美精品自拍偷拍动漫精品| 91精品国产aⅴ一区二区| 日韩欧美在线观看一区二区三区| 日韩精品一区在线观看| 国产亚洲va综合人人澡精品| 国产精品污污网站在线观看| 亚洲人成影院在线观看| 亚洲妇熟xx妇色黄| 美女网站视频久久| 国产成人精品www牛牛影视| www.66久久| 欧美日韩欧美一区二区| 337p日本欧洲亚洲大胆色噜噜| 国产精品视频九色porn| 亚洲精品中文字幕乱码三区 | 亚洲图片欧美视频| 久久99热99| 成人18精品视频| 91 com成人网| 国产欧美一二三区| 亚洲国产精品人人做人人爽| 久久99久久精品欧美| 成人免费视频caoporn| 91成人免费在线视频| 精品久久一区二区| 一区二区三区91| 国产乱码精品一品二品| 欧美日韩国产首页在线观看| 国产午夜精品久久久久久免费视 | 国产精品综合在线视频| 91精品91久久久中77777| 欧美一区二区福利在线| 亚洲欧美日韩电影| 国产在线精品视频| 欧美日本在线观看| 国产精品免费视频观看| 天天做天天摸天天爽国产一区 | 亚洲欧美一区二区三区久本道91| 久久99精品视频| 在线观看91视频| 国产视频911| 蜜臂av日日欢夜夜爽一区| 色综合一区二区三区| 亚洲天堂av老司机| 黄一区二区三区| 91精品欧美久久久久久动漫 | 久久国产人妖系列| 69堂成人精品免费视频| 亚洲欧美在线视频| 蓝色福利精品导航| 欧美日韩国产影片| 亚洲综合免费观看高清完整版在线| 国产成人综合自拍| 精品少妇一区二区三区在线视频| 亚洲大片免费看| 在线观看一区日韩| 一区av在线播放| 色偷偷久久一区二区三区| 国产精品欧美一区喷水| 风间由美一区二区三区在线观看 | 欧美美女一区二区| 亚洲国产日韩精品| 色八戒一区二区三区| 中文字幕日韩一区| av高清不卡在线| 亚洲欧美另类久久久精品| 不卡视频一二三四| 国产精品水嫩水嫩| 99久久免费精品高清特色大片| 国产精品久久久一区麻豆最新章节| 成人深夜在线观看| 国产精品另类一区| www.欧美.com|