Example #1
0
/*
 * uIP send function wrapping the EMAC functions.
 */
static void network_device_send(void) {
  MACTransmitDescriptor td;

  if (macWaitTransmitDescriptor(&ETHD1, &td, MS2ST(SEND_TIMEOUT)) == RDY_OK) {
    if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN)
      macWriteTransmitDescriptor(&td, uip_buf, uip_len);
    else {
      macWriteTransmitDescriptor(&td, uip_buf, UIP_LLH_LEN + UIP_TCPIP_HLEN);
      macWriteTransmitDescriptor(&td, uip_appdata,
                                 uip_len - (UIP_LLH_LEN + UIP_TCPIP_HLEN));
    }
    macReleaseTransmitDescriptor(&td);
  }
  /* Dropped... */
}
Example #2
0
/*
 * Transmits a frame.
 */
static err_t low_level_output(struct netif *netif, struct pbuf *p) {
  struct pbuf *q;
  MACTransmitDescriptor td;

  (void)netif;
  if (macWaitTransmitDescriptor(&ETHD1, &td, MS2ST(LWIP_SEND_TIMEOUT)) != MSG_OK)
    return ERR_TIMEOUT;

#if ETH_PAD_SIZE
  pbuf_header(p, -ETH_PAD_SIZE);        /* drop the padding word */
#endif

  /* Iterates through the pbuf chain. */
  for(q = p; q != NULL; q = q->next)
    macWriteTransmitDescriptor(&td, (uint8_t *)q->payload, (size_t)q->len);
  macReleaseTransmitDescriptor(&td);

#if ETH_PAD_SIZE
  pbuf_header(p, ETH_PAD_SIZE);         /* reclaim the padding word */
#endif

  LINK_STATS_INC(link.xmit);

  return ERR_OK;
}