关于enc28j60格式过滤的理解之一

    // do bank 1 stuff, packet filter:
    // For broadcast packets we allow only ARP packtets
    // All other packets should be unicast only for our mac (MAADR)
    //
    // The pattern to match on is therefore
    // Type     ETH.DST
    // ARP      BROADCAST
    // 06 08 -- ff ff ff ff ff ff -> ip checksum for theses bytes=f7f9
  // 0x0806:地址解析协议(ARP:Address Resolution Protocol)

  // [06 08 ff ff ff ff ff ff] 的 TCP/IP校验和 = F9F7
    // in binary these poitions are:11 0000 0011 1111
    // This is hex 303F->EPMM0=0x3f,EPMM1=0x30
   
    enc28j60Write(ERXFCON, ERXFCON_UCEN|ERXFCON_CRCEN|ERXFCON_PMEN);
    enc28j60Write(EPMM0, 0x3f);   // 格式匹配: 目标MAC地址(后6个字节)+来源MAC地址(前2个字节)
    enc28j60Write(EPMM1, 0x30);  // 格式匹配: 来源MAC地址(后4个字节)+ARP格式(前2个字节)+保留(另外2个字节)
    enc28j60Write(EPMCSL, 0xf9);
    enc28j60Write(EPMCSH, 0xf7);   
    enc28j60Write(MACON1, MACON1_MARXEN|MACON1_TXPAUS|MACON1_RXPAUS);
    // bring MAC out of reset
    enc28j60Write(MACON2, 0x00);

posted @ 2014-09-05 17:30  joyce3800  阅读(554)  评论(0编辑  收藏  举报