arch/arm/src/lpc17xx/lpc17_ethernet.c
/****************************************************************************
 * Function: lpc17_transmit
 *
 * Description:
 *   Start hardware transmission.  Called either from the txdone interrupt
 *   handling or from watchdog based polling.
 *
 * Parameters:
 *   priv  - Reference to the driver state structure
 *
 * Returned Value:
 *   OK on success; a negated errno on failure
 *
 * Assumptions:
 *   May or may not be called from an interrupt handler.  In either case,
 *   global interrupts are disabled, either explicitly or indirectly through
 *   interrupt handling logic.
 *
 ****************************************************************************/
lpc17_transmit
Description:
Start hardware transmission.  Called either from the txdone interrupt
handling or from watchdog based polling.

priv  - Reference to the driver state structure

Returned Value:
OK on success; a negated errno on failure

May or may not be called from an interrupt handler.  In either case,
global interrupts are disabled, either explicitly or indirectly through
interrupt handling logic.
lpc17_transmit Description : Start hardware transmission . Called either from the txdone interrupt handling or from watchdog based polling . priv - Reference to the driver state structure Returned Value : OK on success ; a negated errno on failure May or may not be called from an interrupt handler . In either case global interrupts are disabled either explicitly or indirectly through interrupt handling logic .
static int lpc17_transmit(struct lpc17_driver_s *priv)
{
  uint32_t *txdesc;
  void     *txbuffer;
  unsigned int prodidx;
  DEBUGASSERT(lpc17_txdesc(priv) == OK);
  EMAC_STAT(priv, tx_packets);
  lpc17_dumppacket("Transmit packet",
                   priv->lp_dev.d_buf, priv->lp_dev.d_len);
  prodidx = lpc17_getreg(LPC17_ETH_TXPRODIDX) & ETH_TXPRODIDX_MASK;
  txdesc   = (uint32_t*)(LPC17_TXDESC_BASE + (prodidx << 3));
  txbuffer = (void*)*txdesc++;
  *txdesc  = TXDESC_CONTROL_INT | TXDESC_CONTROL_LAST | TXDESC_CONTROL_CRC |
             (priv->lp_dev.d_len - 1);
  DEBUGASSERT(priv->lp_dev.d_len <= LPC17_MAXPACKET_SIZE);
  memcpy(txbuffer, priv->lp_dev.d_buf, priv->lp_dev.d_len);
  if (++prodidx >= CONFIG_NET_NTXDESC)
    {
      prodidx = 0;
    }
  lpc17_putreg(prodidx, LPC17_ETH_TXPRODIDX);
  priv->lp_inten |= ETH_TXINTS;
  lpc17_putreg(priv->lp_inten, LPC17_ETH_INTEN);
  (void)wd_start(priv->lp_txtimeout, LPC17_TXTIMEOUT, lpc17_txtimeout_expiry,
                 1, (uint32_t)priv);
  return OK;
}
static int lpc17_transmit ( struct lpc17_driver_s * priv ) { uint32_t * txdesc ; void * txbuffer ; unsigned int prodidx ; DEBUGASSERT ( lpc17_txdesc ( priv ) == OK ) ; EMAC_STAT ( priv , tx_packets ) ; lpc17_dumppacket ( " " , priv -> lp_dev . d_buf , priv -> lp_dev . d_len ) ; prodidx = lpc17_getreg ( LPC17_ETH_TXPRODIDX ) & ETH_TXPRODIDX_MASK ; txdesc = ( uint32_t * ) ( LPC17_TXDESC_BASE + ( prodidx << 3 ) ) ; txbuffer = ( void * ) * txdesc ++ ; * txdesc = TXDESC_CONTROL_INT | TXDESC_CONTROL_LAST | TXDESC_CONTROL_CRC | ( priv -> lp_dev . d_len - 1 ) ; DEBUGASSERT ( priv -> lp_dev . d_len <= LPC17_MAXPACKET_SIZE ) ; memcpy ( txbuffer , priv -> lp_dev . d_buf , priv -> lp_dev . d_len ) ; if ( ++ prodidx >= CONFIG_NET_NTXDESC ) { prodidx = 0 ; } lpc17_putreg ( prodidx , LPC17_ETH_TXPRODIDX ) ; priv -> lp_inten |= ETH_TXINTS ; lpc17_putreg ( priv -> lp_inten , LPC17_ETH_INTEN ) ; ( void ) wd_start ( priv -> lp_txtimeout , LPC17_TXTIMEOUT , lpc17_txtimeout_expiry , 1 , ( uint32_t ) priv ) ; return OK ; }
Function: lpc17_transmit
 Description:
   Start hardware transmission.
Function : lpc17_transmit Description : Start hardware transmission .
/* Verify that the hardware is ready to send another packet.  If we get
   * here, then we are committed to sending a packet; Higher level logic
   * must have assured that there is no transmission in progress.
   */ /* Increment statistics and dump the packet *if so configured) */ /* Get the current producer index */ /* Get the packet address from the descriptor and set the descriptor control
   * fields.
   */ /* Copy the packet data into the Tx buffer assignd to this descriptor.  It
   * should fit because each packet buffer is the MTU size and breaking up
   * largerTCP messasges is handled by higher level logic.  The hardware
   * does, however, support breaking up larger messages into many fragments,
   * however, that capability is not exploited here.
   *
   * This would be a great performance improvement:  Remove the buffer from
   * the lp_dev structure and replace it a pointer directly into the EMAC
   * DMA memory.  This could eliminate the following, costly memcpy.
   */ /* Bump the producer index, making the packet available for transmission. */ /* Wrap back to index zero */ /* Enable Tx interrupts */ /* Setup the TX timeout watchdog (perhaps restarting the timer) */