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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? 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 頁
字號:
		{
			ulNextRxBuffer = 0;
		}
	}

	/* Is there a packet ready? */

	while( ( xRxDescriptors[ ulNextRxBuffer ].addr & AT91C_OWNERSHIP_BIT ) && !ulSectionLength )
	{
		pcSource = ( portCHAR * )( xRxDescriptors[ ulNextRxBuffer ].addr & emacADDRESS_MASK );
		ulSectionLength = xRxDescriptors[ ulNextRxBuffer ].U_Status.status & emacRX_LENGTH_FRAME;

		if( ulSectionLength == 0 )
		{
			/* The frame is longer than the buffer pointed to by this
			descriptor so copy the entire buffer to uIP - then move onto
			the next descriptor to get the rest of the frame. */
			if( ( ulLengthSoFar + ETH_RX_BUFFER_SIZE ) <= UIP_BUFSIZE )
			{
				memcpy( &( uip_buf[ ulLengthSoFar ] ), pcSource, ETH_RX_BUFFER_SIZE );
				ulLengthSoFar += ETH_RX_BUFFER_SIZE;
			}			
		}
		else
		{
			/* This is the last section of the frame.  Copy the section to
			uIP. */
			if( ulSectionLength < UIP_BUFSIZE )
			{
				/* The section length holds the length of the entire frame.
				ulLengthSoFar holds the length of the frame sections already
				copied to uIP, so the length of the final section is
				ulSectionLength - ulLengthSoFar; */
				if( ulSectionLength > ulLengthSoFar )
				{
					memcpy( &( uip_buf[ ulLengthSoFar ] ), pcSource, ( ulSectionLength - ulLengthSoFar ) );
				}
			}			

			/* Is this the last buffer for the frame?  If not why? */
			ulEOF = xRxDescriptors[ ulNextRxBuffer ].U_Status.status & AT91C_EOF;
		}

		/* Mark the buffer as free again. */
		xRxDescriptors[ ulNextRxBuffer ].addr &= ~( AT91C_OWNERSHIP_BIT );

		/* Increment to the next buffer, wrapping if necessary. */
		ulNextRxBuffer++;
		if( ulNextRxBuffer >= NB_RX_BUFFERS )
		{
			ulNextRxBuffer = 0;
		}
	}

	/* If we obtained data but for some reason did not find the end of the
	frame then discard the data as it must contain an error. */
	if( !ulEOF )
	{
		ulSectionLength = 0;
	}

	return ulSectionLength;
}
/*-----------------------------------------------------------*/

static void prvSetupDescriptors(void)
{
unsigned portBASE_TYPE xIndex;
unsigned portLONG ulAddress;

	/* Initialise xRxDescriptors descriptor. */
	for( xIndex = 0; xIndex < NB_RX_BUFFERS; ++xIndex )
	{
		/* Calculate the address of the nth buffer within the array. */
		ulAddress = ( unsigned portLONG )( pcRxBuffer + ( xIndex * ETH_RX_BUFFER_SIZE ) );

		/* Write the buffer address into the descriptor.  The DMA will place
		the data at this address when this descriptor is being used.  Mask off
		the bottom bits of the address as these have special meaning. */
		xRxDescriptors[ xIndex ].addr = ulAddress & emacADDRESS_MASK;
	}	

	/* The last buffer has the wrap bit set so the EMAC knows to wrap back
	to the first buffer. */
	xRxDescriptors[ NB_RX_BUFFERS - 1 ].addr |= emacRX_WRAP_BIT;

	/* Initialise xTxDescriptors. */
	for( xIndex = 0; xIndex < NB_TX_BUFFERS; ++xIndex )
	{
		/* Calculate the address of the nth buffer within the array. */
		ulAddress = ( unsigned portLONG )( pcTxBuffer + ( xIndex * ETH_TX_BUFFER_SIZE ) );

		/* Write the buffer address into the descriptor.  The DMA will read
		data from here when the descriptor is being used. */
		xTxDescriptors[ xIndex ].addr = ulAddress & emacADDRESS_MASK;
		xTxDescriptors[ xIndex ].U_Status.status = AT91C_TRANSMIT_OK;
	}	

	/* The last buffer has the wrap bit set so the EMAC knows to wrap back
	to the first buffer. */
	xTxDescriptors[ NB_TX_BUFFERS - 1 ].U_Status.status = AT91C_TRANSMIT_WRAP | AT91C_TRANSMIT_OK;

	/* Tell the EMAC where to find the descriptors. */
	AT91C_BASE_EMAC->EMAC_RBQP = ( unsigned portLONG ) xRxDescriptors;
	AT91C_BASE_EMAC->EMAC_TBQP = ( unsigned portLONG ) xTxDescriptors;
	
	/* Clear all the bits in the receive status register. */
	AT91C_BASE_EMAC->EMAC_RSR = ( AT91C_EMAC_OVR | AT91C_EMAC_REC | AT91C_EMAC_BNA );

	/* Enable the copy of data into the buffers, ignore broadcasts,
	and don't copy FCS. */
	AT91C_BASE_EMAC->EMAC_NCFGR |= ( AT91C_EMAC_CAF | AT91C_EMAC_NBC | AT91C_EMAC_DRFCS);

	/* Enable Rx and Tx, plus the stats register. */
	AT91C_BASE_EMAC->EMAC_NCR |= ( AT91C_EMAC_TE | AT91C_EMAC_RE | AT91C_EMAC_WESTAT );
}	
/*-----------------------------------------------------------*/

static void prvSetupMACAddress( void )
{
	/* Must be written SA1L then SA1H. */
	AT91C_BASE_EMAC->EMAC_SA1L =	( ( unsigned portLONG ) cMACAddress[ 3 ] << 24 ) |
									( ( unsigned portLONG ) cMACAddress[ 2 ] << 16 ) |
									( ( unsigned portLONG ) cMACAddress[ 1 ] << 8  ) |
									cMACAddress[ 0 ];

	AT91C_BASE_EMAC->EMAC_SA1H =	( ( unsigned portLONG ) cMACAddress[ 5 ] << 8 ) |
									cMACAddress[ 4 ];
}
/*-----------------------------------------------------------*/

static void prvSetupEMACInterrupt( void )
{
	/* Create the semaphore used to trigger the EMAC task. */
	vSemaphoreCreateBinary( xSemaphore );
	if( xSemaphore )
	{
		/* We start by 'taking' the semaphore so the ISR can 'give' it when the
		first interrupt occurs. */
		xSemaphoreTake( xSemaphore, emacNO_DELAY );
		portENTER_CRITICAL();
		{
			/* We want to interrupt on Rx events. */
			AT91C_BASE_EMAC->EMAC_IER = AT91C_EMAC_RCOMP;

			/* Enable the interrupts in the AIC. */
			AT91F_AIC_ConfigureIt( AT91C_BASE_AIC, AT91C_ID_EMAC, emacINTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, ( void (*)( void ) ) vEMACISREntry );
			AT91F_AIC_EnableIt( AT91C_BASE_AIC, AT91C_ID_EMAC );
		}
		portEXIT_CRITICAL();
	}
}
/*-----------------------------------------------------------*/

__arm void vEMACISR( void )
{
volatile unsigned portLONG ulIntStatus, ulRxStatus;
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;

	ulIntStatus = AT91C_BASE_EMAC->EMAC_ISR;
	ulRxStatus = AT91C_BASE_EMAC->EMAC_RSR;

	if( ( ulIntStatus & AT91C_EMAC_RCOMP ) || ( ulRxStatus & AT91C_EMAC_REC ) )
	{
		/* A frame has been received, signal the uIP task so it can process
		the Rx descriptors. */
		xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );
		AT91C_BASE_EMAC->EMAC_RSR = AT91C_EMAC_REC;
	}

	/* If a task was woken by either a character being received or a character
	being transmitted then we may need to switch to another task. */
	portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );

	/* Clear the interrupt. */
	AT91C_BASE_AIC->AIC_EOICR = 0;
}
/*-----------------------------------------------------------*/



/*
 * The following functions are initialisation functions taken from the Atmel
 * EMAC sample code.
 */

static portBASE_TYPE prvProbePHY( void )
{
unsigned portLONG ulPHYId1, ulPHYId2, ulStatus;
portBASE_TYPE xReturn = pdPASS;
	
	/* Code supplied by Atmel (reformatted) -----------------*/

	/* Enable management port */
	AT91C_BASE_EMAC->EMAC_NCR |= AT91C_EMAC_MPE;	
	AT91C_BASE_EMAC->EMAC_NCFGR |= ( 2 ) << 10;

	/* Read the PHY ID. */
	vReadPHY( AT91C_PHY_ADDR, MII_PHYSID1, &ulPHYId1 );
	vReadPHY( AT91C_PHY_ADDR, MII_PHYSID2, &ulPHYId2 );

	/* AMD AM79C875:
			PHY_ID1 = 0x0022
			PHY_ID2 = 0x5541
			Bits 3:0 Revision Number Four bit manufacturer抯 revision number.
				0001 stands for Rev. A, etc.
	*/
	if( ( ( ulPHYId1 << 16 ) | ( ulPHYId2 & 0xfff0 ) ) != MII_DM9161_ID )
	{
		/* Did not expect this ID. */
		xReturn = pdFAIL;
	}
	else
	{
		ulStatus = xGetLinkSpeed();

		if( ulStatus != pdPASS )
		{
			xReturn = pdFAIL;
		}
	}

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

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

	return xReturn;
}
/*-----------------------------------------------------------*/

static void vReadPHY( unsigned portCHAR ucPHYAddress, unsigned portCHAR ucAddress, unsigned portLONG *pulValue )
{
	/* Code supplied by Atmel (reformatted) ----------------------*/

	AT91C_BASE_EMAC->EMAC_MAN = 	(AT91C_EMAC_SOF & (0x01<<30))
									| (2 << 16) | (2 << 28)
									| ((ucPHYAddress & 0x1f) << 23)
									| (ucAddress << 18);

	/* Wait until IDLE bit in Network Status register is cleared. */
	while( !( AT91C_BASE_EMAC->EMAC_NSR & AT91C_EMAC_IDLE ) )
	{
		__asm( "NOP" );
	}

	*pulValue = ( AT91C_BASE_EMAC->EMAC_MAN & 0x0000ffff );	

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

#if USE_RMII_INTERFACE != 1
static void vWritePHY( unsigned portCHAR ucPHYAddress, unsigned portCHAR ucAddress, unsigned portLONG ulValue )
{
	/* Code supplied by Atmel (reformatted) ----------------------*/

	AT91C_BASE_EMAC->EMAC_MAN = (( AT91C_EMAC_SOF & (0x01<<30))
								| (2 << 16) | (1 << 28)
								| ((ucPHYAddress & 0x1f) << 23)
								| (ucAddress << 18))
								| (ulValue & 0xffff);

	/* Wait until IDLE bit in Network Status register is cleared */
	while( !( AT91C_BASE_EMAC->EMAC_NSR & AT91C_EMAC_IDLE ) )
	{
		__asm( "NOP" );
	};

	/* End of code supplied by Atmel ------------------------*/
}
#endif
/*-----------------------------------------------------------*/

static portBASE_TYPE xGetLinkSpeed( void )
{
	unsigned portLONG ulBMSR, ulBMCR, ulLPA, ulMACCfg, ulSpeed, ulDuplex;

	/* Code supplied by Atmel (reformatted) -----------------*/

	/* Link status is latched, so read twice to get current value */
	vReadPHY(AT91C_PHY_ADDR, MII_BMSR, &ulBMSR);
	vReadPHY(AT91C_PHY_ADDR, MII_BMSR, &ulBMSR);

	if( !( ulBMSR & BMSR_LSTATUS ) )
	{	
		/* No Link. */
		return pdFAIL;
	}

	vReadPHY(AT91C_PHY_ADDR, MII_BMCR, &ulBMCR);
	if (ulBMCR & BMCR_ANENABLE)
	{				
		/* AutoNegotiation is enabled. */
		if (!(ulBMSR & BMSR_ANEGCOMPLETE))
		{
			/* Auto-negotiation in progress. */
			return pdFAIL;				
		}		

		vReadPHY(AT91C_PHY_ADDR, MII_LPA, &ulLPA);
		if( ( ulLPA & LPA_100FULL ) || ( ulLPA & LPA_100HALF ) )
		{
			ulSpeed = SPEED_100;
		}
		else
		{
			ulSpeed = SPEED_10;
		}

		if( ( ulLPA & LPA_100FULL ) || ( ulLPA & LPA_10FULL ) )
		{
			ulDuplex = DUPLEX_FULL;
		}
		else
		{
			ulDuplex = DUPLEX_HALF;
		}
	}
	else
	{
		ulSpeed = ( ulBMCR & BMCR_SPEED100 ) ? SPEED_100 : SPEED_10;
		ulDuplex = ( ulBMCR & BMCR_FULLDPLX ) ? DUPLEX_FULL : DUPLEX_HALF;
	}

	/* Update the MAC */
	ulMACCfg = AT91C_BASE_EMAC->EMAC_NCFGR & ~( AT91C_EMAC_SPD | AT91C_EMAC_FD );
	if( ulSpeed == SPEED_100 )
	{
		if( ulDuplex == DUPLEX_FULL )
		{
			/* 100 Full Duplex */
			AT91C_BASE_EMAC->EMAC_NCFGR = ulMACCfg | AT91C_EMAC_SPD | AT91C_EMAC_FD;
		}
		else
		{					
			/* 100 Half Duplex */
			AT91C_BASE_EMAC->EMAC_NCFGR = ulMACCfg | AT91C_EMAC_SPD;
		}
	}
	else
	{
		if (ulDuplex == DUPLEX_FULL)
		{
			/* 10 Full Duplex */
			AT91C_BASE_EMAC->EMAC_NCFGR = ulMACCfg | AT91C_EMAC_FD;
		}
		else
		{
			/* 10 Half Duplex */
			AT91C_BASE_EMAC->EMAC_NCFGR = ulMACCfg;
		}
	}

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

	return pdPASS;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产无遮挡一区二区三区毛片日本| 美女一区二区在线观看| 国产精品一区二区免费不卡 | 一色屋精品亚洲香蕉网站| 成人综合日日夜夜| 欧美国产综合一区二区| 国产999精品久久久久久绿帽| 久久精品一区二区三区不卡| 国产盗摄一区二区| 亚洲同性gay激情无套| 欧美视频在线一区| 亚洲综合成人在线视频| 91精品国产综合久久小美女| 麻豆精品国产传媒mv男同| 国产三级一区二区三区| 国产成人自拍网| 亚洲人123区| 精品久久久久久久久久久久久久久久久| 日本三级亚洲精品| 国产亚洲va综合人人澡精品| 91免费精品国自产拍在线不卡| 亚洲国产精品一区二区久久| 精品捆绑美女sm三区| av欧美精品.com| 欧美亚洲一区二区在线| 国产精品亚洲成人| 亚洲午夜视频在线观看| 中文字幕二三区不卡| 欧美一级黄色片| 日本黄色一区二区| 久久激情综合网| 亚洲欧洲精品一区二区三区| 亚洲精品一区二区三区精华液| 一本高清dvd不卡在线观看| 国产资源精品在线观看| 亚洲国产视频a| 亚洲美女区一区| 欧美国产激情一区二区三区蜜月| 6080yy午夜一二三区久久| 国产成人av一区| 国产一区二区日韩精品| 蜜臀久久久久久久| 亚洲va欧美va天堂v国产综合| 中文字幕一区二区视频| 国产日韩欧美精品电影三级在线 | 成人开心网精品视频| 成人免费毛片嘿嘿连载视频| 成人综合婷婷国产精品久久蜜臀 | 日韩一级免费一区| 6080国产精品一区二区| 日韩午夜三级在线| 欧美变态凌虐bdsm| 国产偷国产偷亚洲高清人白洁 | 91精品国产色综合久久ai换脸| 在线精品视频一区二区三四| 欧美专区亚洲专区| 在线播放欧美女士性生活| 欧美一级夜夜爽| 久久综合九色欧美综合狠狠| 中文字幕+乱码+中文字幕一区| 亚洲成人综合视频| 午夜视频一区二区| 黄色日韩三级电影| 99久久精品国产网站| 欧美美女网站色| 欧美电视剧免费全集观看| 1000部国产精品成人观看| 日韩精品三区四区| 国产成人自拍高清视频在线免费播放| 成人国产电影网| 制服丝袜亚洲精品中文字幕| 国产亚洲欧洲一区高清在线观看| 一区二区三区资源| 国产综合久久久久久鬼色| 色屁屁一区二区| 久久亚区不卡日本| 亚洲高清不卡在线| 成人sese在线| 精品处破学生在线二十三| 亚洲最快最全在线视频| 国精产品一区一区三区mba桃花| 欧美丰满嫩嫩电影| 一区二区三区精品视频| 国产成人免费高清| 欧美日本在线视频| 国产精品二三区| 丁香另类激情小说| 久久久国产一区二区三区四区小说| 亚洲国产精品麻豆| 成人18视频在线播放| 国产精品国产三级国产aⅴ无密码| 精品一区二区三区免费观看 | 69堂亚洲精品首页| 一区二区日韩电影| 欧美日韩精品福利| 婷婷夜色潮精品综合在线| 在线看不卡av| 成人禁用看黄a在线| 日本在线播放一区二区三区| 91精品啪在线观看国产60岁| 日韩福利电影在线| 精品国产乱码久久久久久久| 美女高潮久久久| 精品成人一区二区三区四区| 国产精品一二三在| 久久久天堂av| 一本色道a无线码一区v| 亚洲成人综合在线| 久久蜜桃一区二区| av一区二区三区四区| 亚洲午夜日本在线观看| 成人综合婷婷国产精品久久| 亚洲国产一区视频| 久久精品一区二区| 在线国产亚洲欧美| 黄色资源网久久资源365| 亚洲欧洲一区二区在线播放| 欧美日韩不卡一区| 成人精品小蝌蚪| 五月婷婷久久综合| 国产精品美女久久久久久| 3751色影院一区二区三区| 国产精品18久久久久久久久 | 久久嫩草精品久久久久| 99久久er热在这里只有精品66| 日本不卡123| 亚洲免费观看高清完整版在线观看| 欧美一级欧美一级在线播放| 99久久免费精品| 国产美女一区二区| 蜜臀av一区二区在线免费观看| 一区二区三区精品视频在线| 国产三级三级三级精品8ⅰ区| 日韩欧美综合一区| 欧美妇女性影城| 色婷婷综合五月| 成人av资源下载| 国产一区二区三区四| 看片网站欧美日韩| 亚洲成人高清在线| 亚洲国产综合视频在线观看| 一二三区精品福利视频| 亚洲精品你懂的| 一区二区三区欧美激情| 国内精品嫩模私拍在线| 久久精品理论片| 国产麻豆午夜三级精品| 韩日av一区二区| 国产福利一区在线| 99精品热视频| 欧美图片一区二区三区| 欧美色倩网站大全免费| 日韩欧美一二区| 久久午夜老司机| 亚洲人成网站在线| 午夜欧美视频在线观看| 精品一区二区日韩| 国产成人高清视频| 欧美最新大片在线看| 欧美猛男gaygay网站| 日韩欧美一区二区视频| 国产精品少妇自拍| 一区二区三区在线免费| 日韩精品国产欧美| 豆国产96在线|亚洲| 在线成人高清不卡| 国产欧美精品一区二区色综合朱莉 | 亚洲电影欧美电影有声小说| 久久se精品一区精品二区| 99久久久国产精品免费蜜臀| 91精品国产综合久久蜜臀| 亚洲素人一区二区| 日本女优在线视频一区二区| 日本高清不卡aⅴ免费网站| 69精品人人人人| 亚洲欧美另类小说| 国产在线麻豆精品观看| 欧美性生活久久| 国产精品国产三级国产aⅴ入口 | 93久久精品日日躁夜夜躁欧美| 欧美一级搡bbbb搡bbbb| 一区在线播放视频| 国产成人精品影院| 国产欧美精品区一区二区三区| 三级影片在线观看欧美日韩一区二区| 国产成人精品aa毛片| 精品久久人人做人人爰| 麻豆一区二区99久久久久| 欧美日韩另类一区| 亚洲一区成人在线| 欧美日韩国产大片| 亚洲一区在线观看免费观看电影高清| 成人短视频下载| 中文字幕一区二区三区不卡| 成+人+亚洲+综合天堂| 中文字幕在线观看一区| 成人av在线一区二区三区| 自拍偷在线精品自拍偷无码专区| 国产99久久精品| 亚洲精品日日夜夜|