/**
  * @}
  */
void EXTI0_IRQHandler(void)
{
    uint8_t EIR_dat = 0x00;

    EIR_dat = enc28j60Read(EIR);

    if(EXTI_GetITStatus(EXTI_Line0) != RESET)				  //判别是否有数据包到达
    {
        if(EIR_dat&0x40) {	//检测PKTIF中断请求标志位,接收中断
            ETH_INT=1;
            //printf("PKTIF\n");
        }
        else if(EIR_dat&0x01) {	//检测RXERIF中断请求标志位,接收错误中断
            ETH_INT=1;
            //printf("RXERIF\n");
        }
        else if(EIR_dat&0x10) {
            //链路状态改变中断需要读取PHIR清除中断标志位
            //printf("link state changed\n");
            if(enc28j60PhyRead(PHIR)&0x14) {
                if(enc28j60PhyRead(PHSTAT2)&0x0400) {
                    printf("link activate\n");
                }
                else {
                    printf("link invalid\n");
                    //enc28j60WriteOp(ENC28J60_SOFT_RESET, 0, ENC28J60_SOFT_RESET);
                }
            }
        }
        //ethernetif_input(网口名);								  //设置接收完成标志
        EXTI_ClearITPendingBit(EXTI_Line0);					  //清除中断请求标志
    }
}
Example #2
0
	enc424j600GetMACAddr(macaddr.addr);
#endif

#if !CONFIG_LIB_CONTIKI_IPV6
	// Set up timers
	timer_set(&arp_timer, CLOCK_SECOND * 10);
#endif

	uip_setethaddr(macaddr);
}

static void update_status(void) {
	network_status_t new = net_status;

#if CONFIG_DRIVERS_ENC28J60
	uint16_t phstat1 = enc28j60PhyRead(PHSTAT1);
	uint16_t phstat2 = enc28j60PhyRead(PHSTAT2);

	new.link = (phstat1 & PHSTAT1_LLSTAT) ? 1 : 0;
	new.speed_100m = 0; // this chip only does 10M
	new.full_duplex = (phstat2 & PHSTAT2_DPXSTAT) ? 1 : 0;
#endif

#if CONFIG_DRIVERS_ENC424J600
	uint16_t phstat1 = enc424j600ReadPHYReg(PHSTAT1);
	uint16_t phstat3 = enc424j600ReadPHYReg(PHSTAT3);

	new.link = (phstat1 & PHSTAT1_LLSTAT) ? 1 : 0;
	new.speed_100m = (phstat3 & PHSTAT3_SPDDPX1) ? 1 : 0;
	new.full_duplex = (phstat3 & PHSTAT3_SPDDPX2) ? 1 : 0;
#endif