Changeset 327 for UsbWattMeter
- Timestamp:
- Nov 27, 2017, 1:24:02 PM (5 years ago)
- Location:
- UsbWattMeter/trunk/lwip-1.4.1/ports/grsakura
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
UsbWattMeter/trunk/lwip-1.4.1/ports/grsakura/ether_phy.c
r167 r327 121 121 switch(state){ 122 122 case PHY_STATE_RESET: 123 #ifndef __RX124 reset++;125 if(reset < 2){126 #endif127 /* リンク完了の確認 */128 if(!phy_is_link(phy_addr))129 return PHY_STATE_RESET;130 #ifndef __RX131 }132 reset = 0;133 #endif134 123 /* オートネゴシエーションのお知らせを有効に設定 */ 135 124 phy_write_reg(phy_addr, PHY_AN_ADVERTISEMENT_REGISTER, … … 140 129 phy_write_reg(phy_addr, PHY_CONTROL_REGISTER, PHY_CONTROL_SPEED_SELECT | PHY_CONTROL_A_N_ENABLE); 141 130 131 /* continue; */ 132 case PHY_STATE_LINKE_WAIT: 133 #ifndef __RX 134 reset++; 135 if(reset < 2){ 136 #endif 137 /* リンク完了の確認 */ 138 if(!phy_is_link(phy_addr)) 139 return PHY_STATE_LINKE_WAIT; 140 #ifndef __RX 141 } 142 reset = 0; 143 #endif 142 144 /* continue; */ 143 145 case PHY_STATE_LINKED: -
UsbWattMeter/trunk/lwip-1.4.1/ports/grsakura/ether_phy.h
r167 r327 54 54 PHY_STATE_RESETING, 55 55 PHY_STATE_RESET, 56 PHY_STATE_LINKE_WAIT, 56 57 PHY_STATE_LINKED, 57 58 PHY_STATE_NEGOTIATED, -
UsbWattMeter/trunk/lwip-1.4.1/ports/grsakura/if_rx62n.c
r167 r327 306 306 } 307 307 308 /* 送受信を有効 */ 309 rx62n_set_ecmr(netif, 1); 310 308 311 /* NIC からの割り込みを許可する。*/ 309 312 ret = ena_int(INTNO_IF_RX62N_TRX); … … 507 510 struct ethernetif *ethernetif; 508 511 PHY_MODE_T mode; 512 uint8_t phy_addr = 0; 509 513 510 514 ethernetif = netif->state; 511 515 512 516 if(ethernetif->state == PHY_STATE_NEGOTIATED){ 513 ethernetif->link_now = phy_is_link( 0);517 ethernetif->link_now = phy_is_link(phy_addr); 514 518 if(!ethernetif->link_now) 515 519 ethernetif->state = PHY_STATE_RESET; … … 518 522 519 523 /* PHYの初期化 */ 520 ethernetif->state = phy_initialize(ethernetif->state, 0, &mode);524 ethernetif->state = phy_initialize(ethernetif->state, phy_addr, &mode); 521 525 if(ethernetif->state != PHY_STATE_NEGOTIATED){ 522 526 return false; … … 547 551 548 552 if(ethernetif->link_pre != ethernetif->link_now){ 549 if(rx62n_link(netif)){ 550 bool_t cng = ethernetif->link_pre != ethernetif->link_now; 551 ethernetif->link_pre = ethernetif->link_now; 552 /* リンク状態に変化あり */ 553 if(cng){ 554 if (ethernetif->link_pre) { 555 netif_set_link_up(netif); 556 } 557 else { 558 netif_set_link_down(netif); 559 } 553 ethernetif->link_pre = ethernetif->link_now; 554 /* リンク状態に変化あり */ 555 if (rx62n_link(netif)) { 556 netif_set_link_up(netif); 557 } 558 else { 559 netif_set_link_down(netif); 560 } 561 562 if (ethernetif->state != PHY_STATE_NEGOTIATED) { 563 ethernetif->link_pre = !ethernetif->link_now; 564 sig_sem(ethernetif->sem_rev); 565 } 566 567 return; 568 } 569 570 for (;;) { 571 /* move received packet into a new pbuf */ 572 p = low_level_input(netif); 573 /* no packet could be read, silently ignore this */ 574 if (p == NULL) return; 575 /* points to packet payload, which starts with an Ethernet header */ 576 ethhdr = p->payload; 577 578 switch (htons(ethhdr->type)) { 579 /* IP or ARP packet? */ 580 case ETHTYPE_IP: 581 case ETHTYPE_ARP: 582 #if PPPOE_SUPPORT 583 /* PPPoE packet? */ 584 case ETHTYPE_PPPOEDISC: 585 case ETHTYPE_PPPOE: 586 #endif /* PPPOE_SUPPORT */ 587 /* full packet send to tcpip_thread to process */ 588 if (netif->input(p, netif) != ERR_OK) { 589 LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); 590 pbuf_free(p); 591 p = NULL; 560 592 } 561 } 562 563 if (ethernetif->state != PHY_STATE_NEGOTIATED) 564 sig_sem(ethernetif->sem_rev); 565 566 return; 567 } 568 569 /* move received packet into a new pbuf */ 570 p = low_level_input(netif); 571 /* no packet could be read, silently ignore this */ 572 if (p == NULL) return; 573 /* points to packet payload, which starts with an Ethernet header */ 574 ethhdr = p->payload; 575 576 switch (htons(ethhdr->type)) { 577 /* IP or ARP packet? */ 578 case ETHTYPE_IP: 579 case ETHTYPE_ARP: 580 #if PPPOE_SUPPORT 581 /* PPPoE packet? */ 582 case ETHTYPE_PPPOEDISC: 583 case ETHTYPE_PPPOE: 584 #endif /* PPPOE_SUPPORT */ 585 /* full packet send to tcpip_thread to process */ 586 if (netif->input(p, netif) != ERR_OK) { 587 LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); 593 break; 594 595 default: 588 596 pbuf_free(p); 589 597 p = NULL; 590 } 591 break; 592 593 default: 594 pbuf_free(p); 595 p = NULL; 596 break; 598 break; 599 } 597 600 } 598 601 }
Note:
See TracChangeset
for help on using the changeset viewer.