Merged in rnouse/nuttx (pull request #5)

Make FTMAC100 independent from board-specific low-level functions. Typo in net/skeleton.
This commit is contained in:
Gregory Nutt 2015-07-31 06:23:57 -06:00
commit 8284e1cdc1
2 changed files with 46 additions and 63 deletions

View File

@ -174,13 +174,6 @@ static struct ftmac100_driver_s g_ftmac100[CONFIG_FTMAC100_NINTERFACES]
* Private Function Prototypes
****************************************************************************/
/* FIXME: import low-level functions for IRQ setup */
extern inline void ftintc010_set_trig_mode(int irq, int mode);
extern inline void ftintc010_set_trig_level(int irq, int level);
extern inline void ftintc010_unmask_irq(int irq);
extern inline void ftintc010_mask_irq(int irq);
/* Common TX logic */
static int ftmac100_transmit(FAR struct ftmac100_driver_s *priv);
@ -626,13 +619,20 @@ static void ftmac100_receive(FAR struct ftmac100_driver_s *priv)
FAR struct ftmac100_rxdes_s *rxdes;
FAR uint8_t *data;
uint32_t len;
int found;
do
{
found = false;
rxdes = ftmac100_current_rxdes(priv);
while (!(rxdes->rxdes0 & FTMAC100_RXDES0_RXDMA_OWN))
{
if (rxdes->rxdes0 & FTMAC100_RXDES0_FRS)
goto found_segment;
{
found = true;
break;
}
/* Clear status bits */
@ -642,21 +642,19 @@ static void ftmac100_receive(FAR struct ftmac100_driver_s *priv)
rxdes = ftmac100_current_rxdes(priv);
}
ndbg("\nNOT FOUND\nCurrent RX %d rxdes0=%08x\n",
if (!found)
{
nvdbg("\nNOT FOUND\nCurrent RX %d rxdes0=%08x\n",
priv->rx_pointer, rxdes->rxdes0);
return;
found_segment:
}
len = FTMAC100_RXDES0_RFL(rxdes->rxdes0);
data = (uint8_t *)rxdes->rxdes2;
ndbg ("RX buffer %d (%08x), %x received (%d)\n",
nvdbg ("RX buffer %d (%08x), %x received (%d)\n",
priv->rx_pointer, data, len, (rxdes->rxdes0 & FTMAC100_RXDES0_LRS));
do
{
/* Check for errors and update statistics */
/* Check if the packet is a valid size for the uIP buffer configuration */
@ -768,15 +766,14 @@ found_segment:
}
}
#endif
}
while (0); /* While there are more packets to be processed */
priv->rx_pointer = (priv->rx_pointer + 1) & (CONFIG_FTMAC100_RX_DESC - 1);
rxdes->rxdes1 &= FTMAC100_RXDES1_EDORR;
rxdes->rxdes1 |= FTMAC100_RXDES1_RXBUF_SIZE(RX_BUF_SIZE);
rxdes->rxdes0 |= FTMAC100_RXDES0_RXDMA_OWN;
}
while (true); /* While there are more packets to be processed */
}
/****************************************************************************
* Function: ftmac100_txdone
@ -973,10 +970,7 @@ static void ftmac100_interrupt_work(FAR void *arg)
/* Re-enable Ethernet interrupts */
// up_enable_irq(CONFIG_FTMAC100_IRQ);
ftintc010_unmask_irq(CONFIG_FTMAC100_IRQ);
// ftintc010_set_trig_mode(CONFIG_FTMAC100_IRQ, 0);
// ftintc010_set_trig_level(CONFIG_FTMAC100_IRQ, 0);
up_enable_irq(CONFIG_FTMAC100_IRQ);
}
#endif
@ -1014,10 +1008,7 @@ static int ftmac100_interrupt(int irq, FAR void *context)
priv->status = getreg32 (&iobase->isr);
// up_disable_irq(CONFIG_FTMAC100_IRQ);
ftintc010_mask_irq(CONFIG_FTMAC100_IRQ);
// ftintc010_set_trig_mode(CONFIG_FTMAC100_IRQ, 1);
// ftintc010_set_trig_level(CONFIG_FTMAC100_IRQ, 1);
up_disable_irq(CONFIG_FTMAC100_IRQ);
putreg32 (INT_MASK_ALL_DISABLED, &iobase->imr);
@ -1145,10 +1136,7 @@ static void ftmac100_txtimeout_expiry(int argc, uint32_t arg, ...)
* condition with interrupt work that is already queued and in progress.
*/
// up_disable_irq(CONFIG_FTMAC100_IRQ);
ftintc010_mask_irq(CONFIG_FTMAC100_IRQ);
// ftintc010_set_trig_mode(CONFIG_FTMAC100_IRQ, 1);
// ftintc010_set_trig_level(CONFIG_FTMAC100_IRQ, 1);
up_disable_irq(CONFIG_FTMAC100_IRQ);
/* Cancel any pending poll or interrupt work. This will have no effect
* on work that has already been started.
@ -1337,10 +1325,7 @@ static int ftmac100_ifup(struct net_driver_s *dev)
/* Enable the Ethernet interrupt */
priv->ft_bifup = true;
// up_enable_irq(CONFIG_FTMAC100_IRQ);
ftintc010_unmask_irq(CONFIG_FTMAC100_IRQ);
ftintc010_set_trig_mode(CONFIG_FTMAC100_IRQ, 0);
ftintc010_set_trig_level(CONFIG_FTMAC100_IRQ, 0);
up_enable_irq(CONFIG_FTMAC100_IRQ);
return OK;
}
@ -1369,10 +1354,7 @@ static int ftmac100_ifdown(struct net_driver_s *dev)
/* Disable the Ethernet interrupt */
flags = irqsave();
// up_disable_irq(CONFIG_FTMAC100_IRQ);
ftintc010_mask_irq(CONFIG_FTMAC100_IRQ);
// ftintc010_set_trig_mode(CONFIG_FTMAC100_IRQ, 1);
// ftintc010_set_trig_level(CONFIG_FTMAC100_IRQ, 1);
up_disable_irq(CONFIG_FTMAC100_IRQ);
/* Cancel the TX poll timer and TX timeout timers */

View File

@ -174,6 +174,7 @@ static int skel_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac);
#ifdef CONFIG_NET_ICMPv6
static void skel_ipv6multicast(FAR struct skel_driver_s *priv);
#endif
#endif
/****************************************************************************
* Private Functions