4002|4

63

帖子

0

TA的资源

一粒金砂(初级)

楼主
 

DM9000的问题,弄很久了,大家帮忙啊 [复制链接]

平台是S3C2410 DM9000连在ngsc1上
我主要是把dm9000的功能先加到eboot中,使之可以在eboot中下载内核文件
现在,已经可以读到DM9000的产品ID
这个说明硬件和时序都没什么问题。
但是在发送sent bootme to 255.255.255.255的时候,在网口的数据tx+ tx-都没有数据输出
(从平滑的直线编程有小幅度的类波形输出)
在电脑主机方面也收不到任何的数据
dm9000的代码(初始化和发送的代码):



  1. #include
  2. #include


  3. #define DM9000_ID                0x90000A46

  4. // Hash creation constants.
  5. //
  6. #define CRC_PRIME               0xFFFFFFFF;
  7. #define CRC_POLYNOMIAL          0x04C11DB6;


  8. #define IOREAD(o)                                        ((UCHAR)*((volatile UCHAR *)(o)))
  9. #define IOWRITE(o, d)                                *((volatile UCHAR *)(o)) = (UCHAR)(d)

  10. #define IOREAD16(o)                                        ((USHORT)*((volatile USHORT *)(o)))
  11. #define IOWRITE16(o, d)                                *((volatile USHORT *)(o)) = (USHORT)(d)

  12. #define IOREAD32(o)                                        ((ULONG)*((volatile ULONG *)(o)))
  13. #define IOWRITE32(o, d)                                *((volatile ULONG *)(o)) = (ULONG)(d)

  14. #define MEMREAD(o)                                        ((USHORT)*((volatile USHORT *)(dwEthernetMemBase + (o))))
  15. #define MEMWRITE(o, d)                                *((volatile USHORT *)(dwEthernetMemBase + (o))) = (USHORT)(d)

  16. static DWORD dwEthernetIOBase;
  17. static DWORD dwEthernetDataPort;

  18. static UCHAR DM9000_iomode;
  19. static USHORT hash_table[4];

  20. static DWORD dwEthernetMemBase;

  21. //V1.02
  22. static UCHAR DM9000_rev;       

  23. #define DM9000_DWORD_MODE                1
  24. #define DM9000_BYTE_MODE                2
  25. #define DM9000_WORD_MODE                0

  26. //#define DM9000_MEM_MODE
  27. #ifdef        DM9000_MEM_MODE

  28. #define READ_REG1                                        ReadReg
  29. #define READ_REG2                                        MEMREAD

  30. #define WRITE_REG1                                        WriteReg
  31. #define WRITE_REG2                                        MEMWRITE

  32. #else

  33. #define READ_REG1                                        ReadReg
  34. #define READ_REG2                                        ReadReg

  35. #define WRITE_REG1                                        WriteReg
  36. #define WRITE_REG2                                        WriteReg

  37. #endif

  38. static        BOOL bIsPacket;


  39. static UCHAR
  40. ReadReg(USHORT offset)
  41. {
  42.         IOWRITE(dwEthernetIOBase, offset);
  43.         return IOREAD(dwEthernetDataPort);
  44. }

  45. static void
  46. WriteReg(USHORT offset, UCHAR data)
  47. {
  48.         IOWRITE(dwEthernetIOBase, offset);
  49.         IOWRITE(dwEthernetDataPort, data);
  50. }


  51. /*
  52.     @func   BYTE | CalculateHashIndex | Computes the logical addres filter hash index value.  This used when there are multiple
  53.                                             destination addresses to be filtered.
  54.     @rdesc  Hash index value.
  55.     @comm   
  56.     @xref   
  57. */
  58. BYTE CalculateHashIndex( BYTE  *pMulticastAddr )
  59. {
  60.    DWORD CRC;
  61.    BYTE  HashIndex;
  62.    BYTE  AddrByte;
  63.    DWORD HighBit;
  64.    int   Byte;
  65.    int   Bit;

  66.    // Prime the CRC.
  67.    CRC = CRC_PRIME;

  68.    // For each of the six bytes of the multicast address.
  69.    for ( Byte=0; Byte<6; Byte++ )
  70.    {
  71.       AddrByte = *pMulticastAddr++;

  72.       // For each bit of the byte.
  73.       for ( Bit=8; Bit>0; Bit-- )
  74.       {
  75.          HighBit = CRC >> 31;
  76.          CRC <<= 1;

  77.          if ( HighBit ^ (AddrByte & 1) )
  78.          {
  79.             CRC ^= CRC_POLYNOMIAL;
  80.             CRC |= 1;
  81.          }

  82.          AddrByte >>= 1;
  83.       }
  84.    }

  85.    // Take the least significant six bits of the CRC and copy them
  86.    // to the HashIndex in reverse order.
  87.    for( Bit=0,HashIndex=0; Bit<6; Bit++ )
  88.    {
  89.       HashIndex <<= 1;
  90.       HashIndex |= (BYTE)(CRC & 1);
  91.       CRC >>= 1;
  92.    }

  93.    return(HashIndex);
  94. }

  95. void DM9000_Delay(DWORD dwCounter)
  96. {
  97.         //        Simply loop...
  98.         while (dwCounter--);
  99. }       

  100. void dm9000_hash_table(USHORT *mac)
  101. {
  102.         USHORT i, oft;

  103.         /* Set Node address */
  104.         WRITE_REG1(0x10, (UINT8)(mac[0] & 0xFF));
  105.         WRITE_REG1(0x11, (UINT8)(mac[0] >> 8));
  106.         WRITE_REG1(0x12, (UINT8)(mac[1] & 0xFF));
  107.         WRITE_REG1(0x13, (UINT8)(mac[1] >> 8));
  108.         WRITE_REG1(0x14, (UINT8)(mac[2] & 0xFF));
  109.         WRITE_REG1(0x15, (UINT8)(mac[2] >> 8));       

  110.         /* Clear Hash Table */
  111.         for (i = 0; i < 4; i++)
  112.                 hash_table[i] = 0x0;

  113.         /* broadcast address */
  114.         hash_table[3] = 0x8000;
  115.         /* Write the hash table to MAC MD table */
  116.         for (i = 0, oft = 0x16; i < 4; i++)
  117.         {
  118.                 WRITE_REG1(oft++, (UINT8)(hash_table[i] & 0xff));
  119.                 WRITE_REG1(oft++, (UINT8)((hash_table[i] >> 8) & 0xff));
  120.         }
  121.                

  122. }

  123. /*
  124. * This function is used to detect DM9000 chip
  125. * input : void
  126. * return : TRUE, detect DM9000
  127. *          FALSE, Not find DM9000
  128. */
  129. static BOOL Probe(void)
  130. {
  131.         BOOL r = FALSE;
  132.         DWORD id_val;
  133.        
  134.         id_val = READ_REG1(0x28);
  135.         id_val |= READ_REG1(0x29) << 8;
  136.         id_val |= READ_REG1(0x2a) << 16;
  137.         id_val |= READ_REG1(0x2b) << 24;
  138.        
  139.         if (id_val == DM9000_ID) {
  140.                 RETAILMSG(1, (TEXT("INFO: Probe: DM9000 is detected.\r\n")));
  141.                 DM9000_rev = READ_REG1(0x2c);
  142.                
  143.                 r = TRUE;
  144.         }
  145.         else {
  146.                 RETAILMSG(1, (TEXT("ERROR: Probe: Can not find DM9000.\r\n")));
  147.         }

  148.         return r;
  149. }


  150. /*
  151. * This function enables TX/RX interrupt mask
  152. * input : void
  153. * return : viod
  154. */
  155. void DM9000DBG_EnableInts(void)
  156. {
  157.         /*only enable RX interrupt*/
  158.         WRITE_REG1(0xff, 0x81);
  159. }
  160. /*
  161. * This function disables TX/RX interrupt mask
  162. * input : void
  163. * return void
  164. */

  165. void DM9000DBG_DisableInts(void)
  166. {
  167.         WRITE_REG1(0xff, 0x80);
  168. }

  169. /* Send a data block via Ethernet. */

  170. static USHORT dm9000_send (BYTE *pbData, USHORT length)
  171. {       
  172.         int i;
  173.         int tmplen;


  174.         IOWRITE(dwEthernetIOBase, 0xf8);        /* data copy ready set */
  175.         /* copy data to FIFO */
  176.         switch (DM9000_iomode)
  177.         {
  178.                 case DM9000_BYTE_MODE:
  179.                         tmplen = length ;               
  180.                         for (i = 0; i < tmplen; i++)
  181.                                 IOWRITE(dwEthernetDataPort, ((UCHAR *)pbData)[i]);
  182.                          break;
  183.                 case DM9000_WORD_MODE:
  184.                         tmplen = (length+1)/2;
  185.                         for (i = 0; i < tmplen; i++)
  186.                                        IOWRITE16(dwEthernetDataPort, ((USHORT *)pbData)[i]);
  187.                         break;
  188.                 case DM9000_DWORD_MODE:
  189.                         tmplen = (length+3)/4;
  190.                         for (i = 0; i < tmplen; i++)
  191.                                        IOWRITE32(dwEthernetDataPort, ((ULONG *)pbData)[i]);
  192.                 default:
  193.                         EdbgOutputDebugString("[DM9000][TX]Move data error!!!");
  194.                         break;
  195.         }
  196.         /*set packet leng */
  197.         WRITE_REG1(0xfd, (length >> 8) & 0xff);  
  198.         WRITE_REG1(0xfc, length & 0xff);
  199.         /* start transmit */
  200.         WRITE_REG1(0x02, 1);
  201.        
  202.         /*wait TX complete*/
  203.         while(1)
  204.         {
  205.                 if (READ_REG1(0xfe) & 2) {        //TX completed
  206.                         WRITE_REG1(0xfe, 2);
  207.                         break;
  208.                 }
  209.                 DM9000_Delay(1000);
  210.         }
  211.         return 0;
  212. }

  213. /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
  214. /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/

  215. BOOL DM9000DBG_Init(BYTE *iobase, ULONG membase, USHORT MacAddr[3])
  216. {
  217.         BOOL r = FALSE;

  218.         bIsPacket         = FALSE;
  219.         dwEthernetIOBase  = (DWORD)iobase;
  220.         dwEthernetDataPort = dwEthernetIOBase + 4;
  221.         dwEthernetMemBase = membase;
  222.    
  223.             r = Probe();        /*Detect DM9000 */
  224.    
  225.         EdbgOutputDebugString("DM9000: MAC Address: %x:%x:%x:%x:%x:%x\r\n",
  226.                                 MacAddr[0] & 0x00FF, MacAddr[0] >> 8,
  227.                                 MacAddr[1] & 0x00FF, MacAddr[1] >> 8,
  228.                                 MacAddr[2] & 0x00FF, MacAddr[2] >> 8);

  229.         /* set the internal PHY power-on, GPIOs normal */
  230.         WRITE_REG1(0x1f, 0);        /* GPR (reg_1Fh)bit GPIO0=0 pre-activate PHY */       
  231.         DM9000_Delay(200000000);

  232.         /* do a software reset */
  233.         WRITE_REG1(0x0, 3);        /* NCR (reg_00h) bit[0] RST=1 & Loopback=1, reset on */
  234.         DM9000_Delay(200000000);
  235.         WRITE_REG1(0x0, 3);        /* NCR (reg_00h) bit[0] RST=1 & Loopback=1, reset on */       
  236.         DM9000_Delay(200000000);

  237.         /* I/O mode */
  238.         DM9000_iomode = READ_REG1(0xfe) >> 6; /* ISR bit7:6 keeps I/O mode */

  239.         /* Program operating register */
  240.         WRITE_REG1(0x0, 0);
  241.         WRITE_REG1(0x02, 0);        /* TX Polling clear */
  242.         WRITE_REG1(0x2f, 0);        /* Special Mode */
  243.         WRITE_REG1(0x01, 0x2c);        /* clear TX status */
  244.         WRITE_REG1(0xfe, 0x0f); /* Clear interrupt status */

  245.         /* Set address filter table */
  246.         dm9000_hash_table(MacAddr);

  247.         /* Activate DM9000A/DM9010 */
  248.         WRITE_REG1(0x05, 0x30 | 1);        /* Discard long packet and CRC error packets*//* RX enable */                                       
  249.         WRITE_REG1(0xff, 0x80);         /* Enable SRAM automatically return */
  250.                                
  251.         /* wait link ok */
  252.         while(1)
  253.         {
  254.                 if(READ_REG1(0x01)&0x40)
  255.                              break;
  256.         }                       
  257.        
  258.         return r;
  259. }

  260. //----------------------------------------------------------------------





复制代码

最新回复

您好,不知道前面各位的问题解了没,你们说的问题小弟并不太懂,但我们目前是divacom在中国区域的总代理,从03年来一直专注于做DM9000及DIVACOM全线产品,通过我们可以找到原厂的工程师做技术支持,当然,是免费提供的,说不定我能帮得上大家的忙,以下是我的联系方式    QQ:1259987438 电话:027-87163610 (0)13554272382 王洪武  详情 回复 发表于 2009-12-14 13:14
点赞 关注

回复
举报

73

帖子

0

TA的资源

一粒金砂(初级)

推荐
 
多调试
 
 

回复

86

帖子

0

TA的资源

一粒金砂(初级)

沙发
 
没有做过,我只用USB弄。网线太烦了。真的帮不了你。

2440的 DM9000优龙有,但是他没有实现网线下载。他是用USB的,如果楼主非要使用网线,那么可以参考立宇泰的BSP(CS8900)实现。

这个东西确实有点难度,你实在觉得难,可以看看周立功的是怎么做的。貌似他的DM9000驱动是以DLL形式发布的。
 
 
 

回复

63

帖子

0

TA的资源

一粒金砂(初级)

4
 
不知道解了没,您的问题具体我不太清楚,不过我们公司是DIVACOM在中国区域的总代理,多年来一直专注于做DM9000及DIVACOM全线产品,通过我们可以的到原厂的工程师做的、技术支持,当然,是免费提供的,我的联系方式    QQ:1259987438 电话:027-8765163610 (0)13554272382 王先生
 
 
 

回复

65

帖子

0

TA的资源

一粒金砂(初级)

5
 
您好,不知道前面各位的问题解了没,你们说的问题小弟并不太懂,但我们目前是divacom在中国区域的总代理,从03年来一直专注于做DM9000及DIVACOM全线产品,通过我们可以找到原厂的工程师做技术支持,当然,是免费提供的,说不定我能帮得上大家的忙,以下是我的联系方式    QQ:1259987438 电话:027-87163610 (0)13554272382 王洪武
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/6 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表