浏览代码

dm9161网卡已能使用

樊春春 2 年之前
父节点
当前提交
e1c583a3f3

+ 130 - 0
User/Bsp/adc/adc.c

@@ -0,0 +1,130 @@
+/*
+*********************************************************************************************************
+*
+*	模块名称 : ADC驱动模块
+*	文件名称 : adc.c
+*	版    本 : V1.0
+*	说    明 : ADC3的DMA工作方式
+*	修改记录 :
+*
+*********************************************************************************************************
+*/
+
+#include "adc.h"
+/* define ---------------------------------------------------------------------*/
+#define ADC3_DR_ADDRESS ((uint32_t)0x4001224C)
+
+/* 变量 ----------------------------------------------------------------------*/
+__IO uint16_t ADC3ConvertedValue[2];
+__IO uint32_t ADC3ConvertedVoltage = 0;
+
+void dma_config()
+{
+    DMA_InitTypeDef DMA_InitStructure;
+    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); // DMA2时钟使能
+
+    DMA_DeInit(DMA2_Stream0);
+    /* DMA2 Stream0 channel2 配置 **************************************/
+    DMA_InitStructure.DMA_Channel            = DMA_Channel_2;
+    DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC3_DR_ADDRESS;
+    DMA_InitStructure.DMA_Memory0BaseAddr    = (uint32_t)ADC3ConvertedValue;
+    DMA_InitStructure.DMA_DIR                = DMA_DIR_PeripheralToMemory;
+    DMA_InitStructure.DMA_BufferSize         = 2;
+    DMA_InitStructure.DMA_PeripheralInc      = DMA_PeripheralInc_Disable;
+    DMA_InitStructure.DMA_MemoryInc          = DMA_MemoryInc_Enable;
+    DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
+    DMA_InitStructure.DMA_MemoryDataSize     = DMA_MemoryDataSize_HalfWord;
+    DMA_InitStructure.DMA_Mode               = DMA_Mode_Circular;
+    DMA_InitStructure.DMA_Priority           = DMA_Priority_High;
+    DMA_InitStructure.DMA_FIFOMode           = DMA_FIFOMode_Disable;
+    DMA_InitStructure.DMA_FIFOThreshold      = DMA_FIFOThreshold_HalfFull;
+    DMA_InitStructure.DMA_MemoryBurst        = DMA_MemoryBurst_Single;
+    DMA_InitStructure.DMA_PeripheralBurst    = DMA_PeripheralBurst_Single;
+    DMA_Init(DMA2_Stream0, &DMA_InitStructure);
+    DMA_Cmd(DMA2_Stream0, ENABLE);
+}
+/*
+*********************************************************************************************************
+*	函 数 名: adc3_init
+*	功能说明: ADC初始化
+*	形    参: 无
+*	返 回 值: 无
+*********************************************************************************************************
+*/
+void adc3_init(void)
+{
+    ADC_InitTypeDef       ADC_InitStructure;
+    ADC_CommonInitTypeDef ADC_CommonInitStructure;
+    DMA_InitTypeDef       DMA_InitStructure;
+    GPIO_InitTypeDef      GPIO_InitStructure;
+
+    /* 使能 ADC3, DMA2 和 GPIO 时钟 ****************************************/
+    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2 | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_DMA1, ENABLE);
+    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC3, ENABLE);
+
+    /* DMA2 Stream0 channel2 配置 **************************************/
+    DMA_InitStructure.DMA_Channel            = DMA_Channel_2;
+    DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC3_DR_ADDRESS;
+    DMA_InitStructure.DMA_Memory0BaseAddr    = (uint32_t)ADC3ConvertedValue;
+    DMA_InitStructure.DMA_DIR                = DMA_DIR_PeripheralToMemory;
+    DMA_InitStructure.DMA_BufferSize         = 2;
+    DMA_InitStructure.DMA_PeripheralInc      = DMA_PeripheralInc_Disable;
+    DMA_InitStructure.DMA_MemoryInc          = DMA_MemoryInc_Enable;
+    DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
+    DMA_InitStructure.DMA_MemoryDataSize     = DMA_MemoryDataSize_HalfWord;
+    DMA_InitStructure.DMA_Mode               = DMA_Mode_Circular;
+    DMA_InitStructure.DMA_Priority           = DMA_Priority_High;
+    DMA_InitStructure.DMA_FIFOMode           = DMA_FIFOMode_Disable;
+    DMA_InitStructure.DMA_FIFOThreshold      = DMA_FIFOThreshold_HalfFull;
+    DMA_InitStructure.DMA_MemoryBurst        = DMA_MemoryBurst_Single;
+    DMA_InitStructure.DMA_PeripheralBurst    = DMA_PeripheralBurst_Single;
+    DMA_Init(DMA2_Stream0, &DMA_InitStructure);
+    DMA_Cmd(DMA2_Stream0, ENABLE);
+
+    /* 配置ADC3通道7引脚为模拟输入模式******************************/
+    GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_9;
+    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
+    GPIO_Init(GPIOF, &GPIO_InitStructure);
+
+    /****************************************************************************
+      PCLK2 = HCLK / 2
+      下面选择的是2分频
+      ADCCLK = PCLK2 /2 = HCLK / 4 = 168 / 4 = 42M
+      ADC采样频率: Sampling Time + Conversion Time = 3 + 12 cycles = 15cyc
+                    Conversion Time = 42MHz / 15cyc = 2.8Mbps.
+    *****************************************************************************/
+    /* ADC公共部分初始化**********************************************************/
+    ADC_CommonInitStructure.ADC_Mode             = ADC_Mode_Independent;
+    ADC_CommonInitStructure.ADC_Prescaler        = ADC_Prescaler_Div2;
+    ADC_CommonInitStructure.ADC_DMAAccessMode    = ADC_DMAAccessMode_Disabled;
+    ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
+    ADC_CommonInit(&ADC_CommonInitStructure);
+
+    /* ADC3 初始化 ****************************************************************/
+    ADC_InitStructure.ADC_Resolution           = ADC_Resolution_12b;
+    ADC_InitStructure.ADC_ScanConvMode         = DISABLE;
+    ADC_InitStructure.ADC_ContinuousConvMode   = ENABLE;
+    ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
+    ADC_InitStructure.ADC_ExternalTrigConv     = ADC_ExternalTrigConv_T1_CC1;
+    ADC_InitStructure.ADC_DataAlign            = ADC_DataAlign_Right;
+    ADC_InitStructure.ADC_NbrOfConversion      = 1;
+    ADC_Init(ADC3, &ADC_InitStructure);
+
+    /* ADC3 规则 channel7 配置 *************************************/
+    ADC_RegularChannelConfig(ADC3, ADC_Channel_7, 1, ADC_SampleTime_3Cycles);
+
+    /* 使能DMA请求(单ADC模式) */
+    ADC_DMARequestAfterLastTransferCmd(ADC3, ENABLE);
+
+    /* 使能 ADC3 DMA */
+    ADC_DMACmd(ADC3, ENABLE);
+
+    /* 使能 ADC3 */
+    ADC_Cmd(ADC3, ENABLE);
+
+    /* 软件启动ADC转换 */
+    ADC_SoftwareStartConv(ADC3);
+}
+
+/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/

+ 8 - 0
User/Bsp/adc/adc.h

@@ -0,0 +1,8 @@
+#ifndef __ADC_H
+#define __ADC_H
+
+#include "includes.h"
+
+void adc3_init(void);
+
+#endif

+ 190 - 170
User/Bsp/dm9k/dm9k.c

@@ -1,17 +1,17 @@
 /*
 *********************************************************************************************************
 *
-*	Ä£¿éÃû³Æ : DM9KAEP µ×²ãÇý¶¯Ä£¿é(For STM32F4XX£¬ uip)
-*	ÎļþÃû³Æ : dm9k_uip.c
-*	°æ    ±¾ : V1.1
-*	˵    Ã÷ : ÕâÊÇÓ²¼þµ×²ãÇý¶¯³ÌÐòµÄÖ÷Îļþ¡£Ã¿¸öcÎļþ¿ÉÒÔ #include "bsp.h" À´°üº¬ËùÓеÄÍâÉèÇý¶¯Ä£¿é¡£
-*			   bsp = Borad surport packet °å¼¶Ö§³Ö°ü
-*	Ð޸ļǼ :
-*		°æ±¾ºÅ  ÈÕÆÚ        ×÷Õß     ˵Ã÷
-*		V1.0    2013-03-01  armfly   Õýʽ·¢²¼
-*		V1.1    2013-06-20  armfly   ¹æ·¶×¢ÊÍ£¬Ìí¼Ó±ØҪ˵Ã÷
+*	模��称 : DM9KAEP 底层驱动模�(For STM32F4XX, uip)
+*	文件�称 : dm9k_uip.c
+*	版    本 : V1.1
+*	说    明 : 这是硬件底层驱动程�的主文件。�个c文件�以 #include "bsp.h" �包�所有的外设驱动模�。
+*			   bsp = Borad surport packet �级支�包
+*	修改记录 :
+*		版本�  日期        作者     说明
+*		V1.0    2013-03-01  armfly   正��布
+*		V1.1    2013-06-20  armfly   规范注释,添加必�说明
 *
-*	Copyright (C), 2013-2014, °²¸»À³µç×Ó www.armfly.com
+*	Copyright (C), 2013-2014, 安富莱电� www.armfly.com
 *
 *********************************************************************************************************
 */
@@ -19,7 +19,7 @@
 #include "dm9k.h"
 
 uint8_t SendPackOk = 0;
-uint8_t is_fsmc_ok = 0; /* ÓÃÓÚָʾFSMCÊÇ·ñ³õʼ»¯ */
+uint8_t is_fsmc_ok = 0; /* 用于指示FSMC是��始化 */
 
 void dm9k_debug_test(void);
 
@@ -28,10 +28,10 @@ static void dm9k_initnic(void);
 
 /*
 *********************************************************************************************************
-*	º¯ Êý Ãû: dm9k_init
-*	¹¦ÄÜ˵Ã÷: uIP ½Ó¿Úº¯Êý,³õʼ»¯Íø¿¨.  uIP ½Ó¿Úº¯Êý.
-*	ÐÎ    ²Î: ÎÞ
-*	·µ »Ø Öµ: ÎÞ
+*	函 数 �: dm9k_init
+*	功能说明: uIP 接�函数,�始化网�.  uIP 接�函数.
+*	形    �: 无
+*	返 回 值: 无
 *********************************************************************************************************
 */
 void dm9k_init(void)
@@ -40,15 +40,15 @@ void dm9k_init(void)
 
     is_fsmc_ok = 1;
 
-    dm9k_initnic(); /* ÅäÖÃDM9K */
+    dm9k_initnic(); /* �置DM9K */
 }
 
 /*
 *********************************************************************************************************
-*	º¯ Êý Ãû: dm9k_fsmc
-*	¹¦ÄÜ˵Ã÷: ÅäÖÃFSMC²¢¿Ú·ÃÎÊʱÐò
-*	ÐÎ    ²Î: ÎÞ
-*	·µ »Ø Öµ: ÎÞ
+*	函 数 �: dm9k_fsmc
+*	功能说明: �置FSMC并�访问时�
+*	形    �: 无
+*	返 回 值: 无
 *********************************************************************************************************
 */
 static void dm9k_fsmc(void)
@@ -59,9 +59,9 @@ static void dm9k_fsmc(void)
     /*-- FSMC Configuration ------------------------------------------------------*/
     /*----------------------- SRAM Bank 3 ----------------------------------------*/
     /*-- FSMC Configuration ------------------------------------------------------*/
-    p.FSMC_AddressSetupTime      = 6; /* ÉèÖÃΪ2»á³ö´í; 3Õý³£ */
+    p.FSMC_AddressSetupTime      = 6; /* 设置为2会出错; 3正常 */
     p.FSMC_AddressHoldTime       = 2;
-    p.FSMC_DataSetupTime         = 4; /* ÉèÖÃΪ1³ö´í£¬2Õý³£ */
+    p.FSMC_DataSetupTime         = 4; /* 设置为1出错,2正常 */
     p.FSMC_BusTurnAroundDuration = 1;
     p.FSMC_CLKDivision           = 0;
     p.FSMC_DataLatency           = 0;
@@ -91,10 +91,10 @@ static void dm9k_fsmc(void)
 
 /*
 *********************************************************************************************************
-*	º¯ Êý Ãû: dm9k_ReadReg
-*	¹¦ÄÜ˵Ã÷: ¶Á³öDM9KÖ¸¶¨¼Ä´æÆ÷µÄÖµ
-*	ÐÎ    ²Î: reg ¼Ä´æÆ÷µØÖ·
-*	·µ »Ø Öµ: ¼Ä´æÆ÷Öµ
+*	函 数 �: dm9k_ReadReg
+*	功能说明: 读出DM9K指定寄存器的值
+*	形    �: reg 寄存器地�
+*	返 回 值: 寄存器值
 *********************************************************************************************************
 */
 uint8_t dm9k_ReadReg(uint8_t reg)
@@ -105,11 +105,11 @@ uint8_t dm9k_ReadReg(uint8_t reg)
 
 /*
 *********************************************************************************************************
-*	º¯ Êý Ãû: dm9k_WriteReg
-*	¹¦ÄÜ˵Ã÷: ¶Á³öDM9KÖ¸¶¨¼Ä´æÆ÷µÄÖµ
-*	ÐÎ    ²Î: reg £º¼Ä´æÆ÷µØÖ·
-*			 writedata : дÈëµÄÊý¾Ý
-*	·µ »Ø Öµ: ÎÞ
+*	函 数 �: dm9k_WriteReg
+*	功能说明: 读出DM9K指定寄存器的值
+*	形    �: reg :寄存器地�
+*			 writedata : 写入的数�
+*	返 回 值: 无
 *********************************************************************************************************
 */
 void dm9k_WriteReg(uint8_t reg, uint8_t writedata)
@@ -120,17 +120,17 @@ void dm9k_WriteReg(uint8_t reg, uint8_t writedata)
 
 /*
 *********************************************************************************************************
-*	º¯ Êý Ãû: dm9k_hash_table
-*	¹¦ÄÜ˵Ã÷: ÉèÖà DM9KA MAC ¡¢ ¹ã²¥ ¡¢ ¶à²¥ ¼Ä´æÆ÷
-*	ÐÎ    ²Î: ÎÞ
-*	·µ »Ø Öµ: ÎÞ
+*	函 数 �: dm9k_hash_table
+*	功能说明: 设置 DM9KA MAC � 广播 � 多播 寄存器
+*	形    �: 无
+*	返 回 值: 无
 *********************************************************************************************************
 */
 void dm9k_hash_table()
 {
     uint8_t i;
 
-    /* ÉèÖà Íø¿¨ MAC λÖã¬À´×Ôì¶ MyHardware */
+    /* 设置 网� MAC �置,�自於 MyHardware */
     dm9k_WriteReg(DM9K_REG_PAR, DM9K_MAC_ADDR0);
     dm9k_WriteReg(DM9K_REG_PAR + 1, DM9K_MAC_ADDR1);
     dm9k_WriteReg(DM9K_REG_PAR + 2, DM9K_MAC_ADDR2);
@@ -138,131 +138,151 @@ void dm9k_hash_table()
     dm9k_WriteReg(DM9K_REG_PAR + 4, DM9K_MAC_ADDR4);
     dm9k_WriteReg(DM9K_REG_PAR + 5, DM9K_MAC_ADDR5);
 
-    /* Çå³ý Íø¿¨¶à²¥ÉèÖà */
+    /* 清除 网�多播设置 */
     for (i = 0; i < 8; i++)
     {
         dm9k_WriteReg(DM9K_REG_MAR + i, 0x00);
     }
 
-    /* ÉèÖà ¹ã²¥°ü ÉèÖà */
+    /* 设置 广播包 设置 */
     dm9k_WriteReg(DM9K_REG_MAR + 7, 0x80);
 }
 
 /*
 *********************************************************************************************************
-*	º¯ Êý Ãû: dm9k_reset
-*	¹¦ÄÜ˵Ã÷: Èí¼þ¸´Î»DM9KAE
-*	ÐÎ    ²Î: ÎÞ
-*	·µ »Ø Öµ: ÎÞ
+*	函 数 �: dm9k_reset
+*	功能说明: 软件��DM9KAE
+*	形    �: 无
+*	返 回 值: 无
 *********************************************************************************************************
 */
 void dm9k_reset(void)
 {
-    dm9k_WriteReg(DM9K_REG_NCR, DM9K_REG_RESET); /* ¶Ô DM9KA ½øÐÐÈí¼þÖØÖÃ */
-    OSTimeDly(10);                               /* delay 10us */
-    dm9k_WriteReg(DM9K_REG_NCR, DM9K_REG_RESET); /* ¶Ô DM9KA ½øÐÐÈí¼þÖØÖÃ */
-    OSTimeDly(10);                               /* delay 10us */
+    dm9k_WriteReg(DM9K_REG_NCR, DM9K_REG_RESET); /* 对 DM9KA 进行软件�置 */
+    us_delay(10);                                /* delay 10us */
+    dm9k_WriteReg(DM9K_REG_NCR, DM9K_REG_RESET); /* 对 DM9KA 进行软件�置 */
+    us_delay(10);                                /* delay 10us */
 
-    /* »ù±¾¼Ç´æÆ÷Ïà¹ØÉèÖà */
-    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_OFF);   /* ¿ªÆôÄÚ´æ×Ô»·Ä£Ê½ */
-    dm9k_WriteReg(DM9K_REG_TCR2, DM9K_TCR2_SET); /* ÉèÖà LED ÏÔʾģʽ1:È«Ë«¹¤ÁÁ£¬°ëË«¹¤Ãð */
+    /* 基本记存器相关设置 */
+    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_OFF);   /* 开�内存自环模� */
+    dm9k_WriteReg(DM9K_REG_TCR2, DM9K_TCR2_SET); /* 设置 LED 显示模�1:全�工亮,��工� */
 
-    /* Çå³ý¶àÓà×ÊѶ */
+    /* 清除多余资讯 */
     dm9k_WriteReg(DM9K_REG_NSR, 0x2c);
     dm9k_WriteReg(DM9K_REG_TCR, 0x00);
     dm9k_WriteReg(DM9K_REG_ISR, 0x3f);
 
 #ifdef DM9KA_FLOW_CONTROL
-    dm9k_WriteReg(DM9K_REG_BPTR, DM9K_BPTR_SET); /* °ëË«¹¤Á÷¿ØÉèÖà */
-    dm9k_WriteReg(DM9K_REG_FCTR, DM9K_FCTR_SET); /* È«Ë«¹¤Á÷¿ØÉèÖà */
-    dm9k_WriteReg(DM9K_REG_FCR, DM9K_FCR_SET);   /* ¿ªÆôÁ÷¿ØÉèÖà */
+    dm9k_WriteReg(DM9K_REG_BPTR, DM9K_BPTR_SET); /* ��工�控设置 */
+    dm9k_WriteReg(DM9K_REG_FCTR, DM9K_FCTR_SET); /* 全�工�控设置 */
+    dm9k_WriteReg(DM9K_REG_FCR, DM9K_FCR_SET);   /* 开��控设置 */
 #endif
 
 #ifdef DM9KA_UPTO_100M
-    /* DM9KAÎ޴˼ĴæÆ÷ */
-    dm9k_WriteReg(DM9K_REG_OTCR, DM9K_OTCR_SET); /* ¹¤×÷ƵÂʵ½ 100Mhz ÉèÖà */
+    /* DM9KA无此寄存器 */
+    dm9k_WriteReg(DM9K_REG_OTCR, DM9K_OTCR_SET); /* 工作频率到 100Mhz 设置 */
 #endif
 
 #ifdef Rx_Int_enable
-    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_SET); /* ¿ªÆô ÖжÏģʽ */
+    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_SET); /* 开� 中断模� */
 #else
-    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_OFF); /* ¹Ø±Õ ÖжÏģʽ */
+    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_OFF); /* 关闭 中断模� */
 #endif
 
-    dm9k_WriteReg(DM9K_REG_RCR, DM9K_RCR_SET); /* ¿ªÆô ½ÓÊÕ¹¤ÄÜ */
+    dm9k_WriteReg(DM9K_REG_RCR, DM9K_RCR_SET); /* 开� 接收工能 */
 
     SendPackOk = 0;
 }
 
 /*
 *********************************************************************************************************
-*	º¯ Êý Ãû: dm9k_phy_write
-*	¹¦ÄÜ˵Ã÷: Èí¼þ¸´Î»DM9KAE
-*	ÐÎ    ²Î: phy_reg £º PHY¼Ä´æÆ÷µØÖ·
-*			  writedata £º дÈëµÄÊý¾Ý
-*	·µ »Ø Öµ: ÎÞ
+*	函 数 �: dm9k_phy_write
+*	功能说明: 软件��DM9KAE
+*	形    �: phy_reg : PHY寄存器地�
+*			  writedata : 写入的数�
+*	返 回 值: 无
 *********************************************************************************************************
 */
 void dm9k_phy_write(uint8_t phy_reg, uint16_t writedata)
 {
-    /* ÉèÖÃдÈë PHY ¼Ä´æÆ÷µÄλÖà */
+    /* 设置写入 PHY 寄存器的�置 */
     dm9k_WriteReg(DM9K_REG_EPAR, phy_reg | DM9K_PHY);
 
-    /* ÉèÖÃдÈë PHY ¼Ä´æÆ÷µÄÖµ */
+    /* 设置写入 PHY 寄存器的值 */
     dm9k_WriteReg(DM9K_REG_EPDRH, (writedata >> 8) & 0xff);
     dm9k_WriteReg(DM9K_REG_EPDRL, writedata & 0xff);
 
-    dm9k_WriteReg(DM9K_REG_EPCR, 0x0a); /* ½«×ÊÁÏдÈë PHY ¼Ä´æÆ÷ */
+    dm9k_WriteReg(DM9K_REG_EPCR, 0x0a); /* 将资料写入 PHY 寄存器 */
     while (dm9k_ReadReg(DM9K_REG_EPCR) & 0x01)
-        ;                               /* ²éÑ°ÊÇ·ñÖ´ÐнáÊø */
-    dm9k_WriteReg(DM9K_REG_EPCR, 0x08); /* Çå³ýдÈëÃüÁî */
+        ;                               /* 查寻是�执行结� */
+    dm9k_WriteReg(DM9K_REG_EPCR, 0x08); /* 清除写入命令 */
 }
 
 /*
 *********************************************************************************************************
-*	º¯ Êý Ãû: dm9k_initnic
-*	¹¦ÄÜ˵Ã÷: ÅäÖÃDM9KAEоƬ£¨³õʼ»¯£©
-*	ÐÎ    ²Î: ÎÞ
-*	·µ »Ø Öµ: ÎÞ
+*	函 数 �: dm9k_initnic
+*	功能说明: �置DM9KAE芯片(�始化)
+*	形    �: 无
+*	返 回 值: 无
 *********************************************************************************************************
 */
 static void dm9k_initnic(void)
 {
-    dm9k_WriteReg(DM9K_REG_NCR, DM9K_REG_RESET); /* ¶Ô DM9KA ½øÐÐÈí¼þÖØÖÃ */
-    OSTimeDly(10);                               /* delay 10us */
+    dm9k_WriteReg(DM9K_REG_NCR, DM9K_REG_RESET); /* 对 DM9KA 进行软件�置 */
+    us_delay(10);                                /* delay 10us */
 
-    dm9k_hash_table(); /* ÉèÖà DM9KA MAC ¼° ¶à²¥*/
+    dm9k_hash_table(); /* 设置 DM9KA MAC � 多播*/
 
-    dm9k_reset(); /* ½øÐÐ DM9KA Èí¼þÉèÖÃ */
+    dm9k_reset(); /* 进行 DM9KA 软件设置 */
 
-    dm9k_WriteReg(DM9K_REG_GPR, DM9K_PHY_OFF); /* ¹Ø±Õ PHY £¬½øÐÐ PHY ÉèÖÃ*/
-    dm9k_phy_write(0x00, 0x8000);              /* ÖØÖà PHY µÄ¼Ä´æÆ÷ */
+    dm9k_WriteReg(DM9K_REG_GPR, DM9K_PHY_OFF); /* 关闭 PHY ,进行 PHY 设置*/
+    dm9k_phy_write(0x00, 0x8000);              /* �置 PHY 的寄存器 */
 #ifdef DM9KA_FLOW_CONTROL
-    dm9k_phy_write(0x04, 0x01e1 | 0x0400); /* ÉèÖà ×ÔÊÊӦģʽÏàÈݱí */
+    dm9k_phy_write(0x04, 0x01e1 | 0x0400); /* 设置 自适应模�相容表 */
 #else
-    dm9k_phy_write(0x04, 0x01e1);              /* ÉèÖà ×ÔÊÊӦģʽÏàÈݱí */
+    dm9k_phy_write(0x04, 0x01e1);              /* 设置 自适应模�相容表 */
 #endif
-    // dm9k_phy_write(0x00, 0x1000);					/* ÉèÖà »ù±¾Á¬½Óģʽ */
-    /* Á¬½ÓģʽÉèÖÃ
-      0x0000 : ¹Ì¶¨10M°ëË«¹¤
-      0x0100 : ¹Ì¶¨10MÈ«Ë«¹¤
-      0x2000 : ¹Ì¶¨100M°ëË«¹¤
-      0x2100 : ¹Ì¶¨100MÈ«Ë«¹¤
-      0x1000 : ×ÔÊÊӦģʽ
+    // dm9k_phy_write(0x00, 0x1000);					/* 设置 基本连接模� */
+    /* 连接模�设置
+      0x0000 : 固定10M��工
+      0x0100 : 固定10M全�工
+      0x2000 : 固定100M��工
+      0x2100 : 固定100M全�工
+      0x1000 : 自适应模�
     */
-    dm9k_phy_write(0x00, 0x1000); /* ÉèÖà »ù±¾Á¬½Óģʽ */
+    dm9k_phy_write(0x00, 0x1000); /* 设置 基本连接模� */
 
-    dm9k_WriteReg(DM9K_REG_GPR, DM9K_PHY_ON); /* ½áÊø PHY ÉèÖÃ, ¿ªÆô PHY */
+    dm9k_WriteReg(DM9K_REG_GPR, DM9K_PHY_ON); /* 结� PHY 设置, 开� PHY */
+
+    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_SET); /* 设置中断 */
+
+    EXTI_InitTypeDef EXTI_InitStructure;
+    NVIC_InitTypeDef NVIC_InitStructure;
+
+    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource14);
+
+    /* �置 EXTI LineXXX */
+    EXTI_InitStructure.EXTI_Line    = EXTI_Line2 | EXTI_Line3 | EXTI_Line7 | EXTI_Line8 | EXTI_Line11 | EXTI_Line13 | EXTI_Line14;
+    EXTI_InitStructure.EXTI_Mode    = EXTI_Mode_Interrupt;
+    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
+    EXTI_InitStructure.EXTI_LineCmd = ENABLE;
+    EXTI_Init(&EXTI_InitStructure);
+
+    NVIC_InitStructure.NVIC_IRQChannel                   = EXTI15_10_IRQn;
+    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
+    NVIC_InitStructure.NVIC_IRQChannelSubPriority        = 0;
+    NVIC_InitStructure.NVIC_IRQChannelCmd                = ENABLE;
+    NVIC_Init(&NVIC_InitStructure);
 
     // dm9k_debug_test();
 }
 
 /*
 *********************************************************************************************************
-*	º¯ Êý Ãû: dm9k_receive_packet
-*	¹¦ÄÜ˵Ã÷: ÅäÖÃDM9KAEоƬ£¨³õʼ»¯£©
-*	ÐÎ    ²Î: _uip_buf : ½ÓÊÕ½á¹û´æ·ÅµÄ»º³åÇøÖ¸Õë
-*	·µ »Ø Öµ: > 0 ±íʾ½ÓÊÕµÄÊý¾Ý³¤¶È, 0±íʾûÓÐÊý¾Ý
+*	函 数 �: dm9k_receive_packet
+*	功能说明: �置DM9KAE芯片(�始化)
+*	形    �: _uip_buf : 接收结果存放的缓冲区指针
+*	返 回 值: > 0 表示接收的数�长度, 0表示没有数�
 *********************************************************************************************************
 */
 uint16_t dm9k_receive_packet(uint8_t *_uip_buf)
@@ -279,35 +299,35 @@ uint16_t dm9k_receive_packet(uint8_t *_uip_buf)
 
     do
     {
-        ReceiveLength = 0; /* Çå³ý½ÓÊյij¤¶È */
+        ReceiveLength = 0; /* 清除接收的长度 */
         ReceiveData   = (uint16_t *)_uip_buf;
-        jump_packet   = 0;             /* Çå³ýÌø°ü¶¯×÷ */
-        dm9k_ReadReg(DM9K_REG_MRCMDX); /* ¶ÁÈ¡ÄÚ´æÊý¾Ý£¬µØÖ·²»Ôö¼Ó */
-        /* ¼ÆËãÄÚ´æÊý¾ÝλÖà */
+        jump_packet   = 0;             /* 清除跳包动作 */
+        dm9k_ReadReg(DM9K_REG_MRCMDX); /* 读�内存数�,地��增加 */
+        /* 计算内存数��置 */
         calc_MRR     = (dm9k_ReadReg(DM9K_REG_MRRH) << 8) + dm9k_ReadReg(DM9K_REG_MRRL);
         rx_checkbyte = dm9k_ReadReg(DM9K_REG_MRCMDX); /*  */
 
-        if (rx_checkbyte == DM9K_PKT_RDY) /* È¡ */
+        if (rx_checkbyte == DM9K_PKT_RDY) /* � */
         {
-            /* ¶ÁÈ¡·â°üÏà¹Ø×ÊѶ ¼° ³¤¶È */
+            /* 读��包相关资讯 � 长度 */
             NET_REG_ADDR = DM9K_REG_MRCMD;
             rx_status    = NET_REG_DATA;
             rx_length    = NET_REG_DATA;
 
-            /* ÈôÊÕµ½³¬¹ýϵͳ¿É³ÐÊܵķâ°ü£¬´Ë°üÌø¹ý */
+            /* 若收到超过系统�承�的�包,此包跳过 */
             if (rx_length > Max_Ethernet_Lenth)
                 jump_packet = 1;
 
 #ifdef Broadcast_Jump
-            /* ÈôÊÕµ½µÄ¹ã²¥»ò¶à²¥°ü³¬¹ýÌض¨³¤¶È£¬´Ë°üÌø¹ý */
+            /* 若收到的广播或多播包超过特定长度,此包跳过 */
             if (rx_status & 0x4000)
             {
                 if (rx_length > Max_Broadcast_Lenth)
                     jump_packet = 1;
             }
 #endif
-            /* ¼ÆËãÏÂÒ»¸ö°üµÄÖ¸Õëλ , Èô½ÓÊÕ³¤¶ÈΪÆæÊý£¬Ðè¼ÓÒ»¶ÔÆëż×Ö½Ú¡£*/
-            /* ÈôÊdz¬¹ý 0x3fff £¬ÔòÐè»Ø¹éÈƵ½ 0x0c00 ÆðʼλÖà */
+            /* 计算下一个包的指针� , 若接收长度为奇数,需加一对��字节。*/
+            /* 若是超过 0x3fff ,则需回归绕到 0x0c00 起始�置 */
             calc_MRR += (rx_length + 4);
             if (rx_length & 0x01)
                 calc_MRR++;
@@ -316,30 +336,30 @@ uint16_t dm9k_receive_packet(uint8_t *_uip_buf)
 
             if (jump_packet == 0x01)
             {
-                /* ½«Ö¸ÕëÒƵ½ÏÂÒ»¸ö°üµÄ°üͷλÖà */
+                /* 将指针移到下一个包的包头�置 */
                 dm9k_WriteReg(DM9K_REG_MRRH, (calc_MRR >> 8) & 0xff);
                 dm9k_WriteReg(DM9K_REG_MRRL, calc_MRR & 0xff);
                 continue;
             }
 
-            /* ¿ªÊ¼½«ÄÚ´æµÄ×ÊÁÏ°áµ½µ½ÏµÍ³ÖУ¬Ã¿´ÎÒƶ¯Ò»¸ö word */
+            /* 开始将内存的资料�到到系统中,�次移动一个 word */
             calc_len = (rx_length + 1) >> 1;
             for (i = 0; i < calc_len; i++)
                 ReceiveData[i] = NET_REG_DATA;
 
-            /* ½«°ü³¤»Ø±¨¸ø TCP/IP Éϲ㣬²¢¼õÈ¥×îáá 4 BYTE µÄ CRC-32 ¼ìºËÂë */
+            /* 将包长回报给 TCP/IP 上层,并�去最後 4 BYTE 的 CRC-32 检核� */
             ReceiveLength = rx_length - 4;
 
-            rx_int_count++; /* ÀÛ¼ÆÊÕ°ü´ÎÊý */
+            rx_int_count++; /* 累计收包次数 */
 
 #ifdef FifoPointCheck
             if (calc_MRR != ((dm9k_ReadReg(DM9K_REG_MRRH) << 8) + dm9k_ReadReg(DM9K_REG_MRRL)))
             {
 #ifdef Point_Error_Reset
-                dm9k_reset(); /* ÈôÊÇÖ¸Õë³ö´í£¬ÖØÖà */
+                dm9k_reset(); /* 若是指针出错,�置 */
                 return ReceiveLength;
 #endif
-                /*ÈôÊÇÖ¸Õë³ö´í£¬½«Ö¸ÕëÒƵ½ÏÂÒ»¸ö°üµÄ°üͷλÖà  */
+                /*若是指针出错,将指针移到下一个包的包头�置  */
                 dm9k_WriteReg(DM9K_REG_MRRH, (calc_MRR >> 8) & 0xff);
                 dm9k_WriteReg(DM9K_REG_MRRL, calc_MRR & 0xff);
             }
@@ -348,26 +368,26 @@ uint16_t dm9k_receive_packet(uint8_t *_uip_buf)
         }
         else
         {
-            if (rx_checkbyte == DM9K_PKT_NORDY) /* δÊÕµ½°ü */
+            if (rx_checkbyte == DM9K_PKT_NORDY) /* 未收到包 */
             {
                 dm9k_WriteReg(DM9K_REG_ISR, 0x3f); /*  */
             }
             else
             {
-                dm9k_reset(); /* ½ÓÊÕÖ¸Õë³ö´í£¬ÖØÖà */
+                dm9k_reset(); /* 接收指针出错,�置 */
             }
             return (0);
         }
-    } while (rx_int_count < Max_Int_Count); /* ÊÇ·ñ³¬¹ý×î¶à½ÓÊÕ·â°ü¼ÆÊý */
+    } while (rx_int_count < Max_Int_Count); /* 是�超过最多接收�包计数 */
     return 0;
 }
 
 /*
 *********************************************************************************************************
-*	º¯ Êý Ãû: dm9k_send_packet
-*	¹¦ÄÜ˵Ã÷: ·¢ËÍÒ»°üÊý¾Ý
-*	ÐÎ    ²Î: p_char : ·¢ËÍÊý¾Ý»º³åÇø
-*	·µ »Ø Öµ: length : Êý¾Ý³¤¶È
+*	函 数 �: dm9k_send_packet
+*	功能说明: ��一包数�
+*	形    �: p_char : ��数�缓冲区
+*	返 回 值: length : 数�长度
 *********************************************************************************************************
 */
 void dm9k_send_packet(uint8_t *p_char, uint16_t length)
@@ -378,21 +398,21 @@ void dm9k_send_packet(uint8_t *p_char, uint16_t length)
     uint16_t      calc_len;
     __IO uint16_t calc_MWR;
 
-    /* ¼ì²é DM9KA ÊÇ·ñ»¹ÔÚ´«ËÍÖУ¡ÈôÊǵȴýÖ±µ½´«ËͽáÊø */
+    /* 检查 DM9KA 是�还在传�中�若是等待直到传�结� */
     if (SendPackOk == Max_Send_Pack)
     {
         while (dm9k_ReadReg(DM9K_REG_TCR) & DM9K_TCR_SET)
         {
-            OSTimeDly(5);
+            us_delay(5);
         }
         SendPackOk = 0;
     }
 
-    SendPackOk++; /* ÉèÖô«ËͼÆÊý */
+    SendPackOk++; /* 设置传�计数 */
 
 #ifdef FifoPointCheck
-    /* ¼ÆËãÏÂÒ»¸ö´«Ë͵ÄÖ¸Õëλ , Èô½ÓÊÕ³¤¶ÈΪÆæÊý£¬Ðè¼ÓÒ»¶ÔÆëż×Ö½Ú¡£*/
-    /* ÈôÊdz¬¹ý 0x0bff £¬ÔòÐè»Ø¹éÈƵ½ 0x0000 ÆðʼλÖà */
+    /* 计算下一个传�的指针� , 若接收长度为奇数,需加一对��字节。*/
+    /* 若是超过 0x0bff ,则需回归绕到 0x0000 起始�置 */
     calc_MWR = (dm9k_ReadReg(DM9K_REG_MWRH) << 8) + dm9k_ReadReg(DM9K_REG_MWRL);
     calc_MWR += SendLength;
     if (SendLength & 0x01)
@@ -401,28 +421,28 @@ void dm9k_send_packet(uint8_t *p_char, uint16_t length)
         calc_MWR -= 0x0c00;
 #endif
 
-    dm9k_WriteReg(DM9K_REG_TXPLH, (SendLength >> 8) & 0xff); /* ÉèÖô«ËÍ·â°üµÄ³¤¶È */
+    dm9k_WriteReg(DM9K_REG_TXPLH, (SendLength >> 8) & 0xff); /* 设置传��包的长度 */
     dm9k_WriteReg(DM9K_REG_TXPLL, SendLength & 0xff);
 
-    /* ¿ªÊ¼½«ÏµÍ³µÄ×ÊÁÏ°áµ½µ½ÄÚ´æÖУ¬Ã¿´ÎÒƶ¯Ò»¸ö word */
+    /* 开始将系统的资料�到到内存中,�次移动一个 word */
     NET_REG_ADDR = DM9K_REG_MWCMD;
     calc_len     = (SendLength + 1) >> 1;
     for (i = 0; i < calc_len; i++)
         NET_REG_DATA = SendData[i];
 
-    dm9k_WriteReg(DM9K_REG_TCR, DM9K_TCR_SET); /* ½øÐд«ËÍ */
+    dm9k_WriteReg(DM9K_REG_TCR, DM9K_TCR_SET); /* 进行传� */
 
 #ifdef FifoPointCheck
     if (calc_MWR != ((dm9k_ReadReg(DM9K_REG_MWRH) << 8) + dm9k_ReadReg(DM9K_REG_MWRL)))
     {
 #ifdef Point_Error_Reset
-        /* ÈôÊÇÖ¸Õë³ö´í£¬µÈ´ý´ËÒ»·â°üËÍÍê , Ö®áá½øÐÐÖØÖà */
+        /* 若是指针出错,等待此一�包�完 , 之後进行�置 */
         while (dm9k_ReadReg(DM9K_REG_TCR) & DM9K_TCR_SET)
             bsp_DelayUS(5);
         dm9k_reset();
         return;
 #endif
-        /*ÈôÊÇÖ¸Õë³ö´í£¬½«Ö¸ÕëÒƵ½ÏÂÒ»¸ö´«ËÍ°üµÄ°üͷλÖà  */
+        /*若是指针出错,将指针移到下一个传�包的包头�置  */
         dm9k_WriteReg(DM9K_REG_MWRH, (calc_MWR >> 8) & 0xff);
         dm9k_WriteReg(DM9K_REG_MWRL, calc_MWR & 0xff);
     }
@@ -431,11 +451,11 @@ void dm9k_send_packet(uint8_t *p_char, uint16_t length)
 }
 
 /*******************************************************************************
- *	º¯ÊýÃû: etherdev_send
- *	²Î  Êý: p_char : Êý¾Ý»º³åÇø
- *			length : Êý¾Ý³¤¶È
- *	·µ  »Ø: ÎÞ
- *	¹¦  ÄÜ: uIP ½Ó¿Úº¯Êý,·¢ËÍÒ»°üÊý¾Ý
+ *	函数�: etherdev_send
+ *	�  数: p_char : 数�缓冲区
+ *			length : 数�长度
+ *	返  回: 无
+ *	功  能: uIP 接�函数,��一包数�
  */
 void etherdev_send(uint8_t *p_char, uint16_t length)
 {
@@ -448,11 +468,11 @@ uint16_t etherdev_read(uint8_t *p_char)
 }
 
 /*******************************************************************************
- *	º¯ÊýÃû: etherdev_chkmedia
- *	²Î  Êý: p_char : Êý¾Ý»º³åÇø
- *			length : Êý¾Ý³¤¶È
- *	·µ  »Ø: ÎÞ
- *	¹¦  ÄÜ: uIP ½Ó¿Úº¯Êý, ¼ì²âÍøÂçÁ¬½Ó״̬
+ *	函数�: etherdev_chkmedia
+ *	�  数: p_char : 数�缓冲区
+ *			length : 数�长度
+ *	返  回: 无
+ *	功  能: uIP 接�函数, 检测网络连接状�
  */
 void etherdev_chkmedia(void)
 {
@@ -460,16 +480,16 @@ void etherdev_chkmedia(void)
 
     while (!(dm9k_ReadReg(DM9K_REG_NSR) & DM9K_PHY))
     {
-        OSTimeDly(2000);
+        us_delay(2000);
     }
 }
 
 /*
 *********************************************************************************************************
-*	º¯ Êý Ãû: dm9k_interrupt
-*	¹¦ÄÜ˵Ã÷: Öжϴ¦Àíº¯Êý (webserverÀý³ÌδʹÓÃÖжÏ)
-*	ÐÎ    ²Î: ÎÞ
-*	·µ »Ø Öµ: ÎÞ
+*	函 数 �: dm9k_interrupt
+*	功能说明: 中断处�函数 (webserver例程未使用中断)
+*	形    �: 无
+*	返 回 值: 无
 *********************************************************************************************************
 */
 void dm9k_interrupt(void)
@@ -477,25 +497,25 @@ void dm9k_interrupt(void)
     uint8_t  save_reg;
     uint16_t isr_status;
 
-    save_reg = NET_REG_ADDR; /* ÔÝ´æËùʹÓõÄλÖà */
+    save_reg = NET_REG_ADDR; /* 暂存所使用的�置 */
 
-    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_OFF); /* ¹Ø±Õ DM9KA ÖÐ¶Ï */
-    isr_status = dm9k_ReadReg(DM9K_REG_ISR);   /* È¡µÃÖжϲúÉúÖµ */
+    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_OFF); /* 关闭 DM9KA 中断 */
+    isr_status = dm9k_ReadReg(DM9K_REG_ISR);   /* �得中断产生值 */
 
     if (isr_status & DM9K_RX_INTR)
-    { /* ¼ì²éÊÇ·ñΪ½ÓÊÕÖÐ¶Ï */
-        // dm9k_receive_packet();							/* Ö´ÐнÓÊÕ´¦Àí³ÌÐò */
+    { /* 检查是�为接收中断 */
+        // dm9k_receive_packet();							/* 执行接收处�程� */
     }
 
-    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_SET); /* ¿ªÆô DM9KA ÖÐ¶Ï */
-    NET_REG_ADDR = save_reg;                   /* »Ø¸´ËùʹÓõÄλÖà */
+    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_SET); /* 开� DM9KA 中断 */
+    NET_REG_ADDR = save_reg;                   /* 回�所使用的�置 */
 }
 
 /*******************************************************************************
- *	º¯ÊýÃû: dm9k_ReadID
- *	²Î  Êý: ÎÞ
- *	·µ  »Ø: ÎÞ
- *	¹¦  ÄÜ: ¶ÁȡоƬID
+ *	函数�: dm9k_ReadID
+ *	�  数: 无
+ *	返  回: 无
+ *	功  能: 读�芯片ID
  */
 uint32_t dm9k_ReadID(void)
 {
@@ -527,10 +547,10 @@ uint8_t dm9k_linkstat(void)
 #if 0
 	/*
 	*********************************************************************************************************
-	*	º¯ Êý Ãû: dm9k_debug_test
-	*	¹¦ÄÜ˵Ã÷: ²âÊÔDM9KAEµÄº¯Êý,ÓÃÓÚÅÅ´í
-	*	ÐÎ    ²Î: ÎÞ
-	*	·µ »Ø Öµ: ÎÞ
+	*	函 数 �: dm9k_debug_test
+	*	功能说明: 测试DM9KAE的函数,用于排错
+	*	形    �: 无
+	*	返 回 值: 无
 	*********************************************************************************************************
 	*/
 	void dm9k_debug_test(void)
@@ -542,10 +562,10 @@ uint8_t dm9k_linkstat(void)
 		uint16_t i;
 		uint16_t j;
 
-		dm9k_WriteReg(DM9K_REG_NCR, DM9K_REG_RESET);			/* ¶Ô DM9KA ½øÐÐÈí¼þÖØÖÃ */
-		OSTimeDly(10);								/* delay 10us */
-		dm9k_WriteReg(DM9K_REG_NCR, DM9K_REG_RESET);			/* ¶Ô DM9KA ½øÐÐÈí¼þÖØÖÃ */
-		OSTimeDly(10);								/* delay 10us */
+		dm9k_WriteReg(DM9K_REG_NCR, DM9K_REG_RESET);			/* 对 DM9KA 进行软件�置 */
+		us_delay(10);								/* delay 10us */
+		dm9k_WriteReg(DM9K_REG_NCR, DM9K_REG_RESET);			/* 对 DM9KA 进行软件�置 */
+		us_delay(10);								/* delay 10us */
 
 		check_device  = dm9k_ReadReg(DM9K_REG_VID_L);
 		check_device |= dm9k_ReadReg(DM9K_REG_VID_H) << 8;
@@ -643,9 +663,9 @@ uint8_t dm9k_linkstat(void)
 
 		printk("DM9K_DEBUG ==> PACKET SEND & INT TEST !! \n");
 		dm9k_WriteReg(DM9K_REG_NCR, DM9K_REG_RESET);
-		OSTimeDly(10);
+		us_delay(10);
 		dm9k_WriteReg(DM9K_REG_NCR, DM9K_REG_RESET);
-		OSTimeDly(10);
+		us_delay(10);
 
 		dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_OFF | DM9K_TX_INTR);
 
@@ -683,10 +703,10 @@ uint8_t dm9k_linkstat(void)
 
 	/*
 	*********************************************************************************************************
-	*	º¯ Êý Ãû: etherdev_chkmedia
-	*	¹¦ÄÜ˵Ã÷: ¼ì²âÍøÂçÁ¬½Ó״̬
-	*	ÐÎ    ²Î: ÎÞ
-	*	·µ »Ø Öµ: ÎÞ
+	*	函 数 �: etherdev_chkmedia
+	*	功能说明: 检测网络连接状�
+	*	形    �: 无
+	*	返 回 值: 无
 	*********************************************************************************************************
 	*/
 	void etherdev_chkmedia(void)
@@ -701,10 +721,10 @@ uint8_t dm9k_linkstat(void)
 
 
 	/*******************************************************************************
-	*	º¯ÊýÃû: etherdev_poll
-	*	²Î  Êý: ÎÞ
-	*	·µ  »Ø: ÎÞ
-	*	¹¦  ÄÜ: uIP ½Ó¿Úº¯Êý, ²ÉÓòéѯ·½Ê½½ÓÊÕÒ»¸öIP°ü
+	*	函数�: etherdev_poll
+	*	�  数: 无
+	*	返  回: 无
+	*	功  能: uIP 接�函数, 采用查询方�接收一个IP包
 	*/
 	/*
 	                              etherdev_poll()

+ 1 - 0
User/Bsp/dm9k/dm9k.h

@@ -13,6 +13,7 @@
 #ifndef _DM9K_H_
 #define _DM9K_H_
 
+#include "dwt.h"
 #include "includes.h"
 #include "lwip_dm9k.h"
 #include <inttypes.h>

+ 56 - 42
User/Bsp/eth/stm32f4x7_phy.c

@@ -45,8 +45,8 @@ void eth_init(void)
         EthStatus |= ETH_LINK_FLAG;
     }
 
-    /* Configure the PHY to generate an interrupt on change of link status */
-    Eth_Link_PHYITConfig(ETHERNET_PHY_ADDRESS);
+    // /* Configure the PHY to generate an interrupt on change of link status */
+    // Eth_Link_PHYITConfig(ETHERNET_PHY_ADDRESS);
 
     ETH_DMAITConfig(ETH_DMA_IT_R | ETH_DMA_IT_NIS, ENABLE);
 }
@@ -186,19 +186,27 @@ static void phy_gpio_config(void)
  * @param  None
  * @retval None
  */
-void Eth_Link_ITHandler(uint16_t PHYAddress)
+void ETH_CheckLinkStatus(uint16_t PHYAddress)
 {
-    /* Check whether the link interrupt has occurred or not */
-    if (((ETH_ReadPHYRegister(PHYAddress, PHY_MISR)) & PHY_LINK_STATUS) != 0)
+    static uint8_t status = 0;
+    uint32_t       t      = ETH_ReadPHYRegister(ETHERNET_PHY_ADDRESS, PHY_SR) & 1;
+
+    /* If we have link and previous check was not yet */
+    if (t && !status)
     {
-        if ((ETH_ReadPHYRegister(PHYAddress, PHY_SR) & 1))
-        {
-            netif_set_link_up(&gnetif);
-        }
-        else
-        {
-            netif_set_link_down(&gnetif);
-        }
+        /* Set link up */
+        netif_set_link_up(&gnetif);
+
+        status = 1;
+    }
+    /* If we don't have link and it was on previous check */
+    if (!t && status)
+    {
+        // EthLinkStatus = 1;
+        /* Set link down */
+        netif_set_link_down(&gnetif);
+
+        status = 0;
     }
 }
 
@@ -243,24 +251,24 @@ uint32_t Eth_Link_PHYITConfig(uint16_t PHYAddress)
  */
 void ETH_link_callback(struct netif *netif)
 {
-    __IO uint32_t timeout = 0;
-    uint32_t      tmpreg;
-    uint16_t      RegValue;
-    ip4_addr_t    ipaddr;
-    ip4_addr_t    netmask;
-    ip4_addr_t    gw;
+    __IO uint32_t   timeout = 0;
+    uint32_t        tmpreg;
+    uint16_t        RegValue;
+    struct ip4_addr ipaddr;
+    struct ip4_addr netmask;
+    struct ip4_addr gw;
 
     if (netif_is_link_up(netif))
     {
         /* Restart the auto-negotiation */
-        if (ETH_InitStructure.ETH_AutoNegotiation != ETH_AutoNegotiation_Disable)
+        if (ETH_InitStructure.ETH_AutoNegotiation !=
+            ETH_AutoNegotiation_Disable)
         {
             /* Reset Timeout counter */
             timeout = 0;
-
             /* Enable auto-negotiation */
-            ETH_WritePHYRegister(ETHERNET_PHY_ADDRESS, PHY_BCR, PHY_AutoNegotiation);
-
+            ETH_WritePHYRegister(ETHERNET_PHY_ADDRESS, PHY_BCR,
+                                 PHY_AutoNegotiation);
             /* Wait until the auto-negotiation will be completed */
             do
             {
@@ -269,22 +277,17 @@ void ETH_link_callback(struct netif *netif)
 
             /* Reset Timeout counter */
             timeout = 0;
-
             /* Read the result of the auto-negotiation */
             RegValue = ETH_ReadPHYRegister(ETHERNET_PHY_ADDRESS, PHY_SR);
 
-            /* Configure the MAC with the Duplex Mode fixed by the auto-negotiation process */
             if ((RegValue & PHY_DUPLEX_STATUS) != (uint16_t)RESET)
             {
-                /* Set Ethernet duplex mode to Full-duplex following the auto-negotiation */
                 ETH_InitStructure.ETH_Mode = ETH_Mode_FullDuplex;
             }
             else
             {
-                /* Set Ethernet duplex mode to Half-duplex following the auto-negotiation */
                 ETH_InitStructure.ETH_Mode = ETH_Mode_HalfDuplex;
             }
-            /* Configure the MAC with the speed fixed by the auto-negotiation process */
             if (RegValue & PHY_SPEED_STATUS)
             {
                 /* Set Ethernet speed to 10M following the auto-negotiation */
@@ -296,19 +299,20 @@ void ETH_link_callback(struct netif *netif)
                 ETH_InitStructure.ETH_Speed = ETH_Speed_100M;
             }
 
-            /*------------------------ ETHERNET MACCR Re-Configuration --------------------*/
+            /*------------ ETHERNET MACCR Re-Configuration -------------
+
             /* Get the ETHERNET MACCR value */
             tmpreg = ETH->MACCR;
 
             /* Set the FES bit according to ETH_Speed value */
             /* Set the DM bit according to ETH_Mode value */
-            tmpreg |= (uint32_t)(ETH_InitStructure.ETH_Speed | ETH_InitStructure.ETH_Mode);
+            tmpreg |= (uint32_t)(ETH_InitStructure.ETH_Speed |
+                                 ETH_InitStructure.ETH_Mode);
 
             /* Write to ETHERNET MACCR */
             ETH->MACCR = (uint32_t)tmpreg;
 
             _eth_delay_(ETH_REG_WRITE_DELAY);
-
             tmpreg     = ETH->MACCR;
             ETH->MACCR = tmpreg;
         }
@@ -332,13 +336,7 @@ void ETH_link_callback(struct netif *netif)
         /* When the netif is fully configured this function must be called.*/
         netif_set_up(&gnetif);
 
-        /* 打印调试信息 */
-        printf("LwIP Network Cable is now connected \r\n");
-
-#ifndef USE_DHCP
-        /* Display static IP address */
-        printf("LwIP Static IP address = %d.%d.%d.%d  \r\n", IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
-#endif /* USE_DHCP */
+        // EthLinkStatus = 0;
     }
     else
     {
@@ -350,8 +348,24 @@ void ETH_link_callback(struct netif *netif)
 
         /*  When the netif link is down this function must be called.*/
         netif_set_down(&gnetif);
-
-        /* 打印调试信息 */
-        printf("LwIP Network Cable is unplugged \r\n");
     }
-}
+}
+
+// void ETH_IRQHandler(void)
+// {
+//     OSIntEnter();
+
+//     /* frame received */
+//     if (SET == ETH_GetDMAITStatus(ETH_DMA_FLAG_R))
+//     {
+//         Eth_Link_ITHandler(0x01);
+//         /* clear the enet DMA Rx interrupt pending bits */
+//         ETH_DMAClearITPendingBit(ETH_DMA_FLAG_R);
+//         ETH_DMAClearITPendingBit(ETH_DMA_FLAG_NIS);
+
+//         /* give the semaphore to wakeup LwIP task */
+//         OSSemPost(g_enet_rx_sem);
+//     }
+
+//     OSIntExit();
+// }

+ 19 - 19
User/Bsp/interface/interface.c

@@ -17,7 +17,7 @@ Gpio_Clock clock_info[] = {
     {.type = kI2C1, .RCC_AXBPeriph = RCC_AHB1Periph, .AF_Clock = RCC_APB1Periph_I2C1},
     // {.type = kI2C2, .AXBPeriph_Clock = RCU_I2C2},
     // {.type = kADC0, .AXBPeriph_Clock = RCU_ADC0},
-    // {.type = kADC2, .AXBPeriph_Clock = RCU_ADC2},
+    // {.type = kADC3, .AXBPeriph_Clock = RCU_ADC2},
     {.type = kSPI1, .RCC_AXBPeriph = RCC_APB2Periph, .AF_Clock = RCC_APB2Periph_SPI1},
     {.type = kUart1, .RCC_AXBPeriph = RCC_APB2Periph, .AF_Clock = RCC_APB2Periph_USART1},
     {.type = kUart3, .RCC_AXBPeriph = RCC_APB1Periph, .AF_Clock = RCC_APB1Periph_USART3},
@@ -35,12 +35,12 @@ Gpio_Clock clock_info[] = {
 
 Interface_struct interface_info[] = {
     // I2C
-    // {.type = kI2C0, .GPIOx = GPIOB, .GPIO_Pin = GPIO_Pin_6, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOB, .GPIO_Pin = GPIO_Pin_6, .GPIO_AF = GPIO_AF_4}, .GPIO_OType = GPIO_OTYPE_OD, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_UP},
-    // {.type = kI2C0, .GPIOx = GPIOB, .GPIO_Pin = GPIO_Pin_7, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOB, .GPIO_Pin = GPIO_Pin_7, .GPIO_AF = GPIO_AF_4}, .GPIO_OType = GPIO_OTYPE_OD, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_UP},
+    // {.type = kI2C0, .GPIOx = GPIOB, .GPIO_Pin = GPIO_Pin_6, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOB, .GPIO_Pin = GPIO_Pin_6, .GPIO_AF = GPIO_AF_4}, .GPIO_OType = GPIO_OTYPE_OD, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_UP},
+    // {.type = kI2C0, .GPIOx = GPIOB, .GPIO_Pin = GPIO_Pin_7, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOB, .GPIO_Pin = GPIO_Pin_7, .GPIO_AF = GPIO_AF_4}, .GPIO_OType = GPIO_OTYPE_OD, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_UP},
     {.type = kI2C1, .GPIOx = GPIOH, .GPIO_Pin = GPIO_Pin_4, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOH, .GPIO_PinSource = GPIO_PinSource4, .GPIO_AF = GPIO_AF_I2C1}, .GPIO_OType = GPIO_OType_OD, .GPIO_Speed = GPIO_Speed_100MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
     {.type = kI2C1, .GPIOx = GPIOH, .GPIO_Pin = GPIO_Pin_5, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOH, .GPIO_PinSource = GPIO_PinSource5, .GPIO_AF = GPIO_AF_I2C1}, .GPIO_OType = GPIO_OType_OD, .GPIO_Speed = GPIO_Speed_100MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
-    // {.type = kI2C2, .GPIOx = GPIOA, .GPIO_Pin = GPIO_Pin_8, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOA, .GPIO_Pin = GPIO_Pin_8, .GPIO_AF = GPIO_AF_4}, .GPIO_OType = GPIO_OTYPE_OD, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_UP},
-    // {.type = kI2C2, .GPIOx = GPIOC, .GPIO_Pin = GPIO_Pin_9, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOC, .GPIO_Pin = GPIO_Pin_9, .GPIO_AF = GPIO_AF_4}, .GPIO_OType = GPIO_OTYPE_OD, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_UP},
+    // {.type = kI2C2, .GPIOx = GPIOA, .GPIO_Pin = GPIO_Pin_8, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOA, .GPIO_Pin = GPIO_Pin_8, .GPIO_AF = GPIO_AF_4}, .GPIO_OType = GPIO_OTYPE_OD, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_UP},
+    // {.type = kI2C2, .GPIOx = GPIOC, .GPIO_Pin = GPIO_Pin_9, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOC, .GPIO_Pin = GPIO_Pin_9, .GPIO_AF = GPIO_AF_4}, .GPIO_OType = GPIO_OTYPE_OD, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_UP},
 
     // can1
     {.type = kCAN1, .GPIOx = GPIOA, .GPIO_Pin = GPIO_Pin_11, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOA, .GPIO_PinSource = GPIO_PinSource11, .GPIO_AF = GPIO_AF_CAN1}, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_100MHz, .GPIO_PuPd = GPIO_PuPd_UP},
@@ -56,14 +56,14 @@ Interface_struct interface_info[] = {
     {.type = kSPI1, .GPIOx = GPIOB, .GPIO_Pin = GPIO_Pin_5, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOB, .GPIO_PinSource = GPIO_PinSource5, .GPIO_AF = GPIO_AF_SPI1}, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_DOWN},
     {.type = kSPI1, .GPIOx = SPI1_CS_PORT, .GPIO_Pin = SPI1_CS_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
 
-    //         // ADC
-    //         {.type = kADC2, .GPIOx = GPIOF, .GPIO_Pin = GPIO_Pin_3, .GPIO_Mode = GPIO_MODE_ANALOG, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_NOPULL},
-    //         {.type = kADC2, .GPIOx = GPIOF, .GPIO_Pin = GPIO_Pin_4, .GPIO_Mode = GPIO_MODE_ANALOG, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_NOPULL},
-    //         {.type = kADC2, .GPIOx = GPIOF, .GPIO_Pin = GPIO_Pin_5, .GPIO_Mode = GPIO_MODE_ANALOG, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_NOPULL},
-    //         {.type = kADC2, .GPIOx = GPIOF, .GPIO_Pin = GPIO_Pin_6, .GPIO_Mode = GPIO_MODE_ANALOG, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_NOPULL},
-    //         {.type = kADC2, .GPIOx = GPIOF, .GPIO_Pin = GPIO_Pin_7, .GPIO_Mode = GPIO_MODE_ANALOG, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_NOPULL},
-    //         {.type = kADC2, .GPIOx = GPIOC, .GPIO_Pin = GPIO_Pin_0, .GPIO_Mode = GPIO_MODE_ANALOG, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_NOPULL},
-    //         {.type = kADC2, .GPIOx = GPIOC, .GPIO_Pin = GPIO_Pin_2, .GPIO_Mode = GPIO_MODE_ANALOG, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_NOPULL},
+    // adc
+    {.type = kADC3, .GPIOx = GPIOF, .GPIO_Pin = GPIO_Pin_3, .GPIO_Mode = GPIO_Mode_AN, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
+    {.type = kADC3, .GPIOx = GPIOF, .GPIO_Pin = GPIO_Pin_4, .GPIO_Mode = GPIO_Mode_AN, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
+    {.type = kADC3, .GPIOx = GPIOF, .GPIO_Pin = GPIO_Pin_5, .GPIO_Mode = GPIO_Mode_AN, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
+    {.type = kADC3, .GPIOx = GPIOF, .GPIO_Pin = GPIO_Pin_6, .GPIO_Mode = GPIO_Mode_AN, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
+    {.type = kADC3, .GPIOx = GPIOF, .GPIO_Pin = GPIO_Pin_7, .GPIO_Mode = GPIO_Mode_AN, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
+    {.type = kADC3, .GPIOx = GPIOC, .GPIO_Pin = GPIO_Pin_0, .GPIO_Mode = GPIO_Mode_AN, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
+    {.type = kADC3, .GPIOx = GPIOC, .GPIO_Pin = GPIO_Pin_2, .GPIO_Mode = GPIO_Mode_AN, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
 
     // uart1
     {.type = kUart1, .GPIOx = GPIOA, .GPIO_Pin = GPIO_Pin_9, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOA, .GPIO_PinSource = GPIO_PinSource9, .GPIO_AF = GPIO_AF_USART1}, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_100MHz, .GPIO_PuPd = GPIO_PuPd_UP},
@@ -89,7 +89,7 @@ Interface_struct interface_info[] = {
     {.type = kEthernet_dm9101, .GPIOx = GPIOG, .GPIO_Pin = GPIO_Pin_13, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOG, .GPIO_PinSource = GPIO_PinSource13, .GPIO_AF = GPIO_AF_ETH}, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_100MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
     {.type = kEthernet_dm9101, .GPIOx = GPIOG, .GPIO_Pin = GPIO_Pin_14, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOG, .GPIO_PinSource = GPIO_PinSource14, .GPIO_AF = GPIO_AF_ETH}, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_100MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
     {.type = kEthernet_dm9101, .GPIOx = ETH_RESET_PORT, .GPIO_Pin = ETH_RESET_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_100MHz, .GPIO_PuPd = GPIO_PuPd_UP},
-    //         //    {.type = kEthernet_dm9101, .GPIOx = ETH_RXER_PORT,  .GPIO_Pin = ETH_RXER_PIN,  .GPIO_Mode = GPIO_MODE_INPUT,  .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_DOWN},
+    //         //    {.type = kEthernet_dm9101, .GPIOx = ETH_RXER_PORT,  .GPIO_Pin = ETH_RXER_PIN,  .GPIO_Mode = GPIO_MODE_INPUT,  .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_DOWN},
 
     // ethernet-dm9k
     {.type = kEthernet_dm9k, .GPIOx = GPIOD, .GPIO_Pin = GPIO_Pin_0, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOD, .GPIO_PinSource = GPIO_PinSource0, .GPIO_AF = GPIO_AF_FSMC}, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_100MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
@@ -115,7 +115,7 @@ Interface_struct interface_info[] = {
     {.type = kEthernet_dm9k, .GPIOx = GPIOE, .GPIO_Pin = GPIO_Pin_14, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOE, .GPIO_PinSource = GPIO_PinSource14, .GPIO_AF = GPIO_AF_FSMC}, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_100MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
     {.type = kEthernet_dm9k, .GPIOx = GPIOE, .GPIO_Pin = GPIO_Pin_15, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOE, .GPIO_PinSource = GPIO_PinSource15, .GPIO_AF = GPIO_AF_FSMC}, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_100MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
     {.type = kEthernet_dm9k, .GPIOx = GPIOG, .GPIO_Pin = GPIO_Pin_10, .GPIO_Mode = GPIO_Mode_AF, .AF_Info = {.GPIOx = GPIOG, .GPIO_PinSource = GPIO_PinSource10, .GPIO_AF = GPIO_AF_FSMC}, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_100MHz, .GPIO_PuPd = GPIO_PuPd_NOPULL},
-    {.type = kEthernet_dm9k, .GPIOx = DM9K_RESET_PORT, .GPIO_Pin = DM9K_RESET_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_UP},
+    {.type = kEthernet_dm9k, .GPIOx = DM9K_RESET_PORT, .GPIO_Pin = DM9K_RESET_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_UP},
     //         // input
     //         {.type = kInput, .In_Type = kLDetect, .GPIOx = LDetect1_PORT, .GPIO_Pin = LDetect1_PIN, .GPIO_Mode = GPIO_MODE_INPUT, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_High_Speed, .GPIO_PuPd = GPIO_PuPd_NOPULL},
 
@@ -135,10 +135,10 @@ Interface_struct interface_info[] = {
     //         {.type = kOutput, .Out_Type = kExtFaultLed, .GPIOx = ExtFaultLed_PORT, .GPIO_Pin = ExtFaultLed_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_High_Speed, .GPIO_PuPd = GPIO_PuPd_DOWN},
     //         {.type = kOutput, .Out_Type = kISOPRelayCtr, .GPIOx = ISOPRelayCtr_PORT, .GPIO_Pin = ISOPRelayCtr_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_High_Speed, .GPIO_PuPd = GPIO_PuPd_DOWN},
     //         {.type = kOutput, .Out_Type = kISONRelayCtr, .GPIOx = ISONRelayCtr_PORT, .GPIO_Pin = ISONRelayCtr_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_High_Speed, .GPIO_PuPd = GPIO_PuPd_DOWN},
-    //         {.type = kOutput, .Out_Type = kSoftI2C3_SDA, .GPIOx = SI2C3_SDA_PORT, .GPIO_Pin = SI2C3_SDA_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OTYPE_OD, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_UP},
-    //         {.type = kOutput, .Out_Type = kSoftI2C3_SCL, .GPIOx = SI2C3_SCL_PORT, .GPIO_Pin = SI2C3_SCL_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_UP},
-    //         {.type = kOutput, .Out_Type = kSoftI2C4_SDA, .GPIOx = SI2C4_SDA_PORT, .GPIO_Pin = SI2C4_SDA_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OTYPE_OD, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_UP},
-    // {.type = kOutput, .Out_Type = kSoftI2C4_SCL, .GPIOx = SI2C4_SCL_PORT, .GPIO_Pin = SI2C4_SCL_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Fast_Speed, .GPIO_PuPd = GPIO_PuPd_UP},
+    //         {.type = kOutput, .Out_Type = kSoftI2C3_SDA, .GPIOx = SI2C3_SDA_PORT, .GPIO_Pin = SI2C3_SDA_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OTYPE_OD, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_UP},
+    //         {.type = kOutput, .Out_Type = kSoftI2C3_SCL, .GPIOx = SI2C3_SCL_PORT, .GPIO_Pin = SI2C3_SCL_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_UP},
+    //         {.type = kOutput, .Out_Type = kSoftI2C4_SDA, .GPIOx = SI2C4_SDA_PORT, .GPIO_Pin = SI2C4_SDA_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OTYPE_OD, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_UP},
+    // {.type = kOutput, .Out_Type = kSoftI2C4_SCL, .GPIOx = SI2C4_SCL_PORT, .GPIO_Pin = SI2C4_SCL_PIN, .GPIO_Mode = GPIO_Mode_OUT, .GPIO_OType = GPIO_OType_PP, .GPIO_Speed = GPIO_Speed_50MHz, .GPIO_PuPd = GPIO_PuPd_UP},
 };
 
 void interface_init(void)

+ 1 - 1
User/Bsp/interface/interface.h

@@ -11,7 +11,7 @@ typedef enum
     kI2C1,
     kI2C2,
     kADC0,
-    kADC2,
+    kADC3,
     kSPI1,
     kUart1,
     kUart3,

+ 0 - 0
User/app/fly_config.c


+ 0 - 0
User/app/fly_config.h


+ 9 - 6
User/config/lwip/lwip_dm9k.c

@@ -3,8 +3,7 @@
 #include "lwip/tcpip.h"
 
 //*******************************************************************************
-struct netif *dm9k_netif = 0; // 定义一个网络接口
-
+struct netif dm9k_netif; // 定义一个网络接口
 /*函数声明*/
 #ifdef USE_DHCP
 static void lwip_dhcp_task(void const *pdata);
@@ -34,13 +33,13 @@ void lwip_dm9k_init(void)
     printf("默认网关..........................%d.%d.%d.%d\r\n", DM9K_GW_ADDR0, DM9K_GW_ADDR1, DM9K_GW_ADDR2, DM9K_GW_ADDR3);
 #endif
 
-    netif_add(dm9k_netif, &ipaddr, &netmask, &gw, NULL, &ethernetif_dm9k_init, &tcpip_input); //向网卡列表中添加一个网口
-    netif_set_default(dm9k_netif);                                                            //设置netif为默认网口
+    netif_add(&dm9k_netif, &ipaddr, &netmask, &gw, NULL, &ethernetif_dm9k_init, &tcpip_input); //向网卡列表中添加一个网口
+    netif_set_default(&dm9k_netif);                                                            //设置netif为默认网口
 
-    ethernet_link_status_updated(dm9k_netif);
+    ethernet_link_status_updated(&dm9k_netif);
 
 #if LWIP_NETIF_LINK_CALLBACK
-    netif_set_link_callback(dm9k_netif, ethernet_link_status_updated);
+    netif_set_link_callback(&dm9k_netif, ethernet_link_status_updated);
 #endif
     //操作OK.
 }
@@ -174,6 +173,10 @@ static void ethernet_link_status_updated(struct netif *netif)
         IP4_ADDR(&ipaddr, DM9K_IP_ADDR0, DM9K_IP_ADDR1, DM9K_IP_ADDR2, DM9K_IP_ADDR3);
         IP4_ADDR(&netmask, DM9K_NETMASK_ADDR0, DM9K_NETMASK_ADDR1, DM9K_NETMASK_ADDR2, DM9K_NETMASK_ADDR3);
         IP4_ADDR(&gw, DM9K_GW_ADDR0, DM9K_GW_ADDR1, DM9K_GW_ADDR2, DM9K_GW_ADDR3);
+        printf("网卡en的MAC地址为:................%d.%d.%d.%d.%d.%d\r\n", DM9K_MAC_ADDR0, DM9K_MAC_ADDR1, DM9K_MAC_ADDR2, DM9K_MAC_ADDR3, DM9K_MAC_ADDR4, DM9K_MAC_ADDR5);
+        printf("静态IP地址........................%d.%d.%d.%d\r\n", DM9K_IP_ADDR0, DM9K_IP_ADDR1, DM9K_IP_ADDR2, DM9K_IP_ADDR3);
+        printf("子网掩码..........................%d.%d.%d.%d\r\n", DM9K_NETMASK_ADDR0, DM9K_NETMASK_ADDR1, DM9K_NETMASK_ADDR2, DM9K_NETMASK_ADDR3);
+        printf("默认网关..........................%d.%d.%d.%d\r\n", DM9K_GW_ADDR0, DM9K_GW_ADDR1, DM9K_GW_ADDR2, DM9K_GW_ADDR3);
         netif_set_addr(netif, &ipaddr, &netmask, &gw);
 
 #endif

+ 6 - 6
User/config/lwip/lwip_dm9k.h

@@ -4,12 +4,12 @@
 //////////////////////////////////////////////////////////////////////////////////
 
 /* 定义网卡的 MAC 地址 */
-#define DM9K_MAC_ADDR0 0x00
-#define DM9K_MAC_ADDR1 0x60
-#define DM9K_MAC_ADDR2 0x6e
-#define DM9K_MAC_ADDR3 0x90
-#define DM9K_MAC_ADDR4 0x00
-#define DM9K_MAC_ADDR5 0xae
+#define DM9K_MAC_ADDR0 2
+#define DM9K_MAC_ADDR1 0
+#define DM9K_MAC_ADDR2 0
+#define DM9K_MAC_ADDR3 0
+#define DM9K_MAC_ADDR4 0
+#define DM9K_MAC_ADDR5 0
 
 /* static IP address: IP_ADDR0.IP_ADDR1.IP_ADDR2.IP_ADDR3 */
 #define DM9K_IP_ADDR0 192

+ 2 - 2
User/config/lwip/lwip_eth.c

@@ -70,7 +70,7 @@ void lwip_eth_setup(void)
     /* 注册默认网络接口.*/
     netif_set_default(&gnetif);
 
-    if (EthStatus == (ETH_INIT_FLAG | ETH_LINK_FLAG))
+    if (EthStatus == (ETH_INIT_FLAG))
     {
         printf("LwIP Finish interface....\r\n");
         gnetif.flags |= NETIF_FLAG_LINK_UP;
@@ -81,7 +81,7 @@ void lwip_eth_setup(void)
     {
         netif_set_down(&gnetif);
     }
-    netif_set_link_callback(&gnetif, ETH_link_callback);
+    // netif_set_link_callback(&gnetif, ETH_link_callback);
 }
 
 #ifdef USE_DHCP

+ 6 - 6
User/config/lwip/lwip_eth.h

@@ -9,17 +9,17 @@
 //#define TIMEOUT_CHECK_USE_LWIP
 /* MAC address: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
 #define MAC_ADDR0 2
-#define MAC_ADDR1 0xA
-#define MAC_ADDR2 0xF
-#define MAC_ADDR3 0xE
-#define MAC_ADDR4 0xD
-#define MAC_ADDR5 6
+#define MAC_ADDR1 0
+#define MAC_ADDR2 0
+#define MAC_ADDR3 0
+#define MAC_ADDR4 0
+#define MAC_ADDR5 0
 
 /* static IP address: IP_ADDR0.IP_ADDR1.IP_ADDR2.IP_ADDR3 */
 #define IP_ADDR0 192
 #define IP_ADDR1 168
 #define IP_ADDR2 1
-#define IP_ADDR3 150
+#define IP_ADDR3 40
 
 /* remote IP address: IP_S_ADDR0.IP_S_ADDR1.IP_S_ADDR2.IP_S_ADDR3 */
 #define IP_S_ADDR0 192

+ 2 - 0
User/config/lwip/lwipopts.h

@@ -118,6 +118,8 @@
 /* Lwip debug options */
 #define LWIP_DEBUG 0
 
+#define CHECKSUM_BY_HARDWARE
+
 #ifdef CHECKSUM_BY_HARDWARE
 /* CHECKSUM_GEN_IP==0: generate checksums by hardware for outgoing IP packets.*/
 #define CHECKSUM_GEN_IP 0

+ 11 - 6
User/config/lwip/port/ethernetif_dm9k.c

@@ -106,8 +106,6 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
         {
             NET_REG_DATA = ((uint16_t *)q->payload)[i];
         }
-
-        //		UsartSend((uint8_t *)q->payload, p->tot_len);
     }
 
     dm9k_WriteReg(DM9K_REG_TXPLH, (framelen >> 8) & 0xff); /* 设置传送封包的长度 */
@@ -130,7 +128,6 @@ static struct pbuf *low_level_input(struct netif *netif)
     framelen = etherdev_read(Rx_Buff[current_pbuf_idx]);
     if (framelen)
     {
-
         // p = pbuf_alloced_custom(PBUF_RAW, framelen, PBUF_REF, custom_pbuf[current_pbuf_idx], Rx_Buff[current_pbuf_idx], Max_Ethernet_Lenth);
         if (current_pbuf_idx < (DM9K_RX_DESC_CNT - 1))
         {
@@ -220,6 +217,16 @@ static void pbuf_free_custom(struct pbuf *p)
     }
 }
 
+void EXTI15_10_IRQHandler(void)
+{
+
+    if (EXTI_GetITStatus(EXTI_Line14) != RESET)
+    {
+        BSP_GPIO15_EXTI_Callback();
+        EXTI_ClearITPendingBit(EXTI_Line14); /* 清除中断标志位 */
+    }
+}
+
 /**
  * @brief  Ethernet Rx Transfer completed callback
  * @param  heth: ETH handle
@@ -232,16 +239,14 @@ void BSP_GPIO15_EXTI_Callback(void)
 
     save_reg = NET_REG_ADDR; /* 暂存所使用的位置 */
 
-    //	dm9k_WriteReg(dm9k_REG_IMR, dm9k_IMR_OFF);			/* 关闭 dm9kA 中断 */
     isr_status = dm9k_ReadReg(DM9K_REG_ISR); /* 取得中断产生值 */
     dm9k_WriteReg(DM9K_REG_ISR, isr_status); /* 清除中断产生值 */
 
     if (isr_status & DM9K_RX_INTR) /* 检查是否为接收中断 */
     {
-        // osSemaphoreRelease(RxPktSemaphore); /* 执行接收处理程序 */
+        OSSemPost(g_dm9k_rx_sem); /* 执行接收处理程序 */
     }
 
-    //	dm9k_WriteReg(dm9k_REG_IMR, dm9k_IMR_SET);			/* 开启 dm9kA 中断 */
     NET_REG_ADDR = save_reg; /* 回复所使用的位置 */
 }
 

+ 1 - 0
User/config/lwip/port/ethernetif_dm9k.h

@@ -6,4 +6,5 @@
 
 err_t ethernetif_dm9k_init(struct netif *netif);
 void  ethernet_dm9k_link_thread(void const *argument);
+void  BSP_GPIO15_EXTI_Callback(void);
 #endif

+ 116 - 49
User/config/lwip/port/ethernetif_eth.c

@@ -123,15 +123,11 @@ static void low_level_init(struct netif *netif)
     /* Initialize Rx Descriptors list: Chain Mode  */
     ETH_DMARxDescChainInit(DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);
 
-    // // /* enable ethernet Rx interrrupt */
-    // {
-    //     int i;
-    //     for (i = 0; i < ETH_RXBUFNB; i++)
-    //     {
-
-    //         ETHDM(&DMARxDscrTab[i], ENABLE);
-    //     }
-    // }
+    /* Enable Ethernet Rx interrrupt */
+    for (i = 0; i < ETH_RXBUFNB; i++)
+    {
+        ETH_DMARxDescReceiveITConfig(&DMARxDscrTab[i], ENABLE);
+    }
 
 #ifdef CHECKSUM_BY_HARDWARE
     /* Enable the TCP, UDP and ICMP checksum insertion for the Tx frames */
@@ -176,13 +172,16 @@ static void low_level_init(struct netif *netif)
 
 static err_t low_level_output(struct netif *netif, struct pbuf *p)
 {
-    static OS_EVENT *p_enet_tx_sem = NULL;
-    INT8U            err;
-    struct pbuf     *q;
-    uint8_t         *buffer;
-    FrameTypeDef     frame;
-    uint16_t         framelength = 0;
-    ErrorStatus      reval       = ERROR;
+    static OS_EVENT         *p_enet_tx_sem = NULL;
+    INT8U                    err;
+    struct pbuf             *q;
+    u8                      *buffer;
+    __IO ETH_DMADESCTypeDef *DmaTxDesc;
+    uint16_t                 framelength     = 0;
+    uint32_t                 bufferoffset    = 0;
+    uint32_t                 byteslefttocopy = 0;
+    uint32_t                 payloadoffset   = 0;
+
     SYS_ARCH_DECL_PROTECT(sr);
 
     if (NULL == p_enet_tx_sem)
@@ -194,39 +193,62 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
 
     SYS_ARCH_PROTECT(sr);
 
-    while ((uint32_t)RESET != (DMATxDescToSet->Status & ETH_DMATxDesc_OWN))
-    {
-    }
-    /* get received frame */
-    frame = ETH_Get_Received_Frame();
-
-    /* Obtain the size of the packet and put it into the "len" variable. */
-    buffer = (u8 *)frame.buffer;
+    DmaTxDesc    = DMATxDescToSet;
+    buffer       = (u8 *)(DmaTxDesc->Buffer1Addr);
+    bufferoffset = 0;
 
     for (q = p; q != NULL; q = q->next)
     {
-        memcpy((uint8_t *)&buffer[framelength], q->payload, q->len);
-        framelength = framelength + q->len;
+        if ((DmaTxDesc->Status & ETH_DMATxDesc_OWN) != (u32)RESET)
+        {
+            goto error;
+        }
+
+        /* Get bytes in current lwIP buffer  */
+        byteslefttocopy = q->len;
+        payloadoffset   = 0;
+
+        /* Check if the length of data to copy is bigger than Tx buffer size*/
+        while ((byteslefttocopy + bufferoffset) > ETH_TX_BUF_SIZE)
+        {
+            /* Copy data to Tx buffer*/
+            memcpy((u8_t *)((u8_t *)buffer + bufferoffset), (u8_t *)((u8_t *)q->payload + payloadoffset), (ETH_TX_BUF_SIZE - bufferoffset));
+
+            /* Point to next descriptor */
+            DmaTxDesc = (ETH_DMADESCTypeDef *)(DmaTxDesc->Buffer2NextDescAddr);
+
+            /* Check if the buffer is available */
+            if ((DmaTxDesc->Status & ETH_DMATxDesc_OWN) != (u32)RESET)
+            {
+                goto error;
+            }
+
+            buffer = (u8 *)(DmaTxDesc->Buffer1Addr);
+
+            byteslefttocopy = byteslefttocopy - (ETH_TX_BUF_SIZE - bufferoffset);
+            payloadoffset   = payloadoffset + (ETH_TX_BUF_SIZE - bufferoffset);
+            framelength     = framelength + (ETH_TX_BUF_SIZE - bufferoffset);
+            bufferoffset    = 0;
+        }
+
+        /* Copy the remaining bytes */
+        memcpy((u8_t *)((u8_t *)buffer + bufferoffset), (u8_t *)((u8_t *)q->payload + payloadoffset), byteslefttocopy);
+        bufferoffset = bufferoffset + byteslefttocopy;
+        framelength  = framelength + byteslefttocopy;
     }
 
     /* Prepare transmit descriptors to give to DMA*/
-    reval = ETH_Prepare_Transmit_Descriptors(framelength);
+    ETH_Prepare_Transmit_Descriptors(framelength);
 
-    SYS_ARCH_UNPROTECT(sr);
+/* Give semaphore and exit */
+error:
 
     /* give semaphore and exit */
     OSSemPost(p_enet_tx_sem);
 
-    if (SUCCESS == reval)
-    {
-        return ERR_OK;
-    }
-    else
-    {
-        while (1)
-        {
-        }
-    }
+    SYS_ARCH_UNPROTECT(sr);
+
+    return ERR_OK;
 }
 
 /**
@@ -239,14 +261,18 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
  */
 static struct pbuf *low_level_input(struct netif *netif)
 {
-    struct pbuf *p = NULL, *q;
-    uint32_t     l = 0;
-    u16_t        len;
-    FrameTypeDef frame;
-    uint8_t     *buffer;
+    struct pbuf             *p = NULL, *q;
+    u32_t                    len;
+    FrameTypeDef             frame;
+    u8                      *buffer;
+    __IO ETH_DMADESCTypeDef *DMARxDesc;
+    uint32_t                 bufferoffset    = 0;
+    uint32_t                 payloadoffset   = 0;
+    uint32_t                 byteslefttocopy = 0;
+    uint32_t                 i               = 0;
 
     /* get received frame */
-    frame = ETH_Get_Received_Frame();
+    frame = ETH_Get_Received_Frame_interrupt();
 
     /* Obtain the size of the packet and put it into the "len" variable. */
     len    = frame.length;
@@ -260,15 +286,56 @@ static struct pbuf *low_level_input(struct netif *netif)
 
     if (p != NULL)
     {
+        DMARxDesc    = frame.descriptor;
+        bufferoffset = 0;
         for (q = p; q != NULL; q = q->next)
         {
-            memcpy((uint8_t *)q->payload, (u8_t *)&buffer[l], q->len);
-            l = l + q->len;
+            byteslefttocopy = q->len;
+            payloadoffset   = 0;
+
+            /* Check if the length of bytes to copy in current pbuf is bigger than Rx buffer size*/
+            while ((byteslefttocopy + bufferoffset) > ETH_RX_BUF_SIZE)
+            {
+                /* Copy data to pbuf*/
+                memcpy((u8_t *)((u8_t *)q->payload + payloadoffset), (u8_t *)((u8_t *)buffer + bufferoffset), (ETH_RX_BUF_SIZE - bufferoffset));
+
+                /* Point to next descriptor */
+                DMARxDesc = (ETH_DMADESCTypeDef *)(DMARxDesc->Buffer2NextDescAddr);
+                buffer    = (unsigned char *)(DMARxDesc->Buffer1Addr);
+
+                byteslefttocopy = byteslefttocopy - (ETH_RX_BUF_SIZE - bufferoffset);
+                payloadoffset   = payloadoffset + (ETH_RX_BUF_SIZE - bufferoffset);
+                bufferoffset    = 0;
+            }
+
+            /* Copy remaining data in pbuf */
+            memcpy((u8_t *)((u8_t *)q->payload + payloadoffset), (u8_t *)((u8_t *)buffer + bufferoffset), byteslefttocopy);
+            bufferoffset = bufferoffset + byteslefttocopy;
+        }
+
+        /* Release descriptors to DMA */
+        DMARxDesc = frame.descriptor;
+
+        /* Set Own bit in Rx descriptors: gives the buffers back to DMA */
+        for (i = 0; i < DMA_RX_FRAME_infos->Seg_Count; i++)
+        {
+            DMARxDesc->Status = ETH_DMARxDesc_OWN;
+            DMARxDesc         = (ETH_DMADESCTypeDef *)(DMARxDesc->Buffer2NextDescAddr);
         }
-    }
 
-    ETH_Get_Received_Frame_interrupt();
+        /* Clear Segment_Count */
+        DMA_RX_FRAME_infos->Seg_Count = 0;
+        /* added for test*/
+    }
 
+    /* When Rx Buffer unavailable flag is set: clear it and resume reception */
+    if ((ETH->DMASR & ETH_DMASR_RBUS) != (u32)RESET)
+    {
+        /* Clear RBUS ETHERNET DMA flag */
+        ETH->DMASR = ETH_DMASR_RBUS;
+        /* Resume DMA reception */
+        ETH->DMARPDR = 0;
+    }
     return p;
 }
 
@@ -343,4 +410,4 @@ err_t ethernetif_eth_init(struct netif *netif)
     low_level_init(netif);
 
     return ERR_OK;
-}
+}

+ 17 - 0
User/project_var.h

@@ -0,0 +1,17 @@
+#ifndef __PROJECT_VAR_H
+#define __PROJECT_VAR_H
+
+typedef unsigned long long INT64U;
+typedef signed long long   INT64S;
+
+// project version
+#define SW_VERSION_HD0 'C'
+#define SW_VERSION_HD1 'C'
+#define SW_VERSION_HD2 'U'
+#define SW_VERSION_PJ0 0
+#define SW_VERSION_PJ1 0
+#define SW_VERSION0    1
+#define SW_VERSION1    0
+#define SW_VERSION2    2
+
+#endif

+ 0 - 1
User/stm32f4xx_it.c

@@ -34,7 +34,6 @@
 #include "stm32f4x7_eth.h"
 #include "stm32f4xx.h"
 
-extern OS_EVENT *p_semaphore;
 extern OS_EVENT *g_enet_rx_sem;
 /** @addtogroup Template_Project
  * @{