Modify code format
This commit is contained in:
parent
0131018884
commit
49ae4ab614
|
@ -31,7 +31,7 @@ struct net_device
|
|||
};
|
||||
|
||||
static struct net_device luminaryif_dev_entry;
|
||||
static struct net_device *luminaryif_dev =&luminaryif_dev_entry;
|
||||
static struct net_device *luminaryif_dev = &luminaryif_dev_entry;
|
||||
static struct rt_semaphore tx_sem;
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -117,7 +117,7 @@ void luminaryif_isr(void)
|
|||
//
|
||||
// Check to see if an RX Interrupt has occured.
|
||||
//
|
||||
if(ulTemp & ETH_INT_RX)
|
||||
if (ulTemp & ETH_INT_RX)
|
||||
{
|
||||
//
|
||||
// Indicate that a packet has been received.
|
||||
|
@ -125,35 +125,37 @@ void luminaryif_isr(void)
|
|||
rt_err_t result;
|
||||
|
||||
/* a frame has been received */
|
||||
result = eth_device_ready((struct eth_device*)&(luminaryif_dev->parent));
|
||||
result = eth_device_ready((struct eth_device *)&(luminaryif_dev->parent));
|
||||
|
||||
if(result != RT_EOK) rt_set_errno(-RT_ERROR);
|
||||
if (result != RT_EOK)
|
||||
rt_set_errno(-RT_ERROR);
|
||||
|
||||
//
|
||||
// Disable Ethernet RX Interrupt.
|
||||
//
|
||||
EthernetIntDisable(ETH_BASE, ETH_INT_RX);
|
||||
}
|
||||
if(ulTemp & ETH_INT_TX)
|
||||
if (ulTemp & ETH_INT_TX)
|
||||
{
|
||||
/* A frame has been transmitted. */
|
||||
rt_sem_release(&tx_sem);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* control the interface */
|
||||
rt_err_t luminaryif_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
switch(cmd)
|
||||
switch (cmd)
|
||||
{
|
||||
case NIOCTL_GADDR:
|
||||
/* get mac address */
|
||||
if(args) rt_memcpy(args, luminaryif_dev_entry.dev_addr, 6);
|
||||
else return -RT_ERROR;
|
||||
if (args)
|
||||
rt_memcpy(args, luminaryif_dev_entry.dev_addr, 6);
|
||||
else
|
||||
return -RT_ERROR;
|
||||
break;
|
||||
|
||||
default :
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -173,14 +175,14 @@ rt_err_t luminaryif_close(rt_device_t dev)
|
|||
}
|
||||
|
||||
/* Read */
|
||||
rt_size_t luminaryif_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size)
|
||||
rt_size_t luminaryif_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
|
||||
{
|
||||
rt_set_errno(-RT_ENOSYS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Write */
|
||||
rt_size_t luminaryif_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
|
||||
rt_size_t luminaryif_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
|
||||
{
|
||||
rt_set_errno(-RT_ENOSYS);
|
||||
return 0;
|
||||
|
@ -210,11 +212,11 @@ rt_err_t luminaryif_tx(rt_device_t dev, struct pbuf *p)
|
|||
//
|
||||
// Wait for space available in the TX FIFO.
|
||||
//
|
||||
while(!EthernetSpaceAvail(ETH_BASE))
|
||||
while (!EthernetSpaceAvail(ETH_BASE))
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Fill in the first two bytes of the payload data (configured as padding
|
||||
// with ETH_PAD_SIZE = 2) with the total length of the payload data
|
||||
// (minus the Ethernet MAC layer header).
|
||||
|
@ -231,7 +233,7 @@ rt_err_t luminaryif_tx(rt_device_t dev, struct pbuf *p)
|
|||
//
|
||||
// Copy data from the pbuf(s) into the TX Fifo.
|
||||
//
|
||||
for(q = p; q != NULL; q = q->next)
|
||||
for (q = p; q != NULL; q = q->next)
|
||||
{
|
||||
//
|
||||
// Intialize a char pointer and index to the pbuf payload data.
|
||||
|
@ -243,7 +245,7 @@ rt_err_t luminaryif_tx(rt_device_t dev, struct pbuf *p)
|
|||
// If the gather buffer has leftover data from a previous pbuf
|
||||
// in the chain, fill it up and write it to the Tx FIFO.
|
||||
//
|
||||
while((iBuf < q->len) && (iGather != 0))
|
||||
while ((iBuf < q->len) && (iGather != 0))
|
||||
{
|
||||
//
|
||||
// Copy a byte from the pbuf into the gather buffer.
|
||||
|
@ -260,7 +262,7 @@ rt_err_t luminaryif_tx(rt_device_t dev, struct pbuf *p)
|
|||
// If the gather index is 0 and the pbuf index is non-zero,
|
||||
// we have a gather buffer to write into the Tx FIFO.
|
||||
//
|
||||
if((iGather == 0) && (iBuf != 0))
|
||||
if ((iGather == 0) && (iBuf != 0))
|
||||
{
|
||||
HWREG(ETH_BASE + MAC_O_DATA) = ulGather;
|
||||
ulGather = 0;
|
||||
|
@ -270,9 +272,9 @@ rt_err_t luminaryif_tx(rt_device_t dev, struct pbuf *p)
|
|||
// Copy words of pbuf data into the Tx FIFO, but don't go past
|
||||
// the end of the pbuf.
|
||||
//
|
||||
if((iBuf % 4) != 0)
|
||||
if ((iBuf % 4) != 0)
|
||||
{
|
||||
while((iBuf + 4) <= q->len)
|
||||
while ((iBuf + 4) <= q->len)
|
||||
{
|
||||
ulTemp = (pucBuf[iBuf++] << 0);
|
||||
ulTemp |= (pucBuf[iBuf++] << 8);
|
||||
|
@ -288,7 +290,7 @@ rt_err_t luminaryif_tx(rt_device_t dev, struct pbuf *p)
|
|||
//
|
||||
pulBuf = (unsigned long *)&pucBuf[iBuf];
|
||||
|
||||
while((iBuf + 4) <= q->len)
|
||||
while ((iBuf + 4) <= q->len)
|
||||
{
|
||||
HWREG(ETH_BASE + MAC_O_DATA) = *pulBuf++;
|
||||
iBuf += 4;
|
||||
|
@ -298,7 +300,7 @@ rt_err_t luminaryif_tx(rt_device_t dev, struct pbuf *p)
|
|||
// Check if leftover data in the pbuf and save it in the gather
|
||||
// buffer for the next time.
|
||||
//
|
||||
while(iBuf < q->len)
|
||||
while (iBuf < q->len)
|
||||
{
|
||||
//
|
||||
// Copy a byte from the pbuf into the gather buffer.
|
||||
|
@ -326,7 +328,7 @@ rt_err_t luminaryif_tx(rt_device_t dev, struct pbuf *p)
|
|||
lwip_stats.link.xmit++;
|
||||
#endif
|
||||
|
||||
return(ERR_OK);
|
||||
return (ERR_OK);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -335,7 +337,7 @@ rt_err_t luminaryif_tx(rt_device_t dev, struct pbuf *p)
|
|||
// of the incoming packet from the interface into the pbuf.
|
||||
//
|
||||
//*****************************************************************************
|
||||
struct pbuf * luminaryif_rx(rt_device_t dev)
|
||||
struct pbuf *luminaryif_rx(rt_device_t dev)
|
||||
{
|
||||
struct pbuf *p, *q;
|
||||
u16_t len;
|
||||
|
@ -343,14 +345,14 @@ struct pbuf * luminaryif_rx(rt_device_t dev)
|
|||
int i;
|
||||
unsigned long *ptr;
|
||||
|
||||
if(!EthernetPacketAvail(ETH_BASE))
|
||||
if (!EthernetPacketAvail(ETH_BASE))
|
||||
{
|
||||
//
|
||||
// Enable Ethernet RX Interrupt.
|
||||
//
|
||||
EthernetIntEnable(ETH_BASE, ETH_INT_RX);
|
||||
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -366,7 +368,7 @@ struct pbuf * luminaryif_rx(rt_device_t dev)
|
|||
//
|
||||
p = pbuf_alloc(PBUF_LINK, len, PBUF_RAM);
|
||||
|
||||
if(p != NULL)
|
||||
if (p != NULL)
|
||||
{
|
||||
//
|
||||
// Place the first word into the first pbuf location.
|
||||
|
@ -379,7 +381,7 @@ struct pbuf * luminaryif_rx(rt_device_t dev)
|
|||
// Process all but the last buffer in the pbuf chain.
|
||||
//
|
||||
q = p;
|
||||
while(q != NULL)
|
||||
while (q != NULL)
|
||||
{
|
||||
//
|
||||
// Setup a byte pointer into the payload section of the pbuf.
|
||||
|
@ -390,7 +392,7 @@ struct pbuf * luminaryif_rx(rt_device_t dev)
|
|||
// Read data from FIFO into the current pbuf
|
||||
// (assume pbuf length is modulo 4)
|
||||
//
|
||||
for(i = 0; i < q->len; i += 4)
|
||||
for (i = 0; i < q->len; i += 4)
|
||||
{
|
||||
*ptr++ = HWREG(ETH_BASE + MAC_O_DATA);
|
||||
}
|
||||
|
@ -416,7 +418,7 @@ struct pbuf * luminaryif_rx(rt_device_t dev)
|
|||
//
|
||||
// Just read all of the remaining data from the FIFO and dump it.
|
||||
//
|
||||
for(i = 4; i < len; i+=4)
|
||||
for (i = 4; i < len; i += 4)
|
||||
{
|
||||
ulTemp = HWREG(ETH_BASE + MAC_O_DATA);
|
||||
}
|
||||
|
@ -431,7 +433,7 @@ struct pbuf * luminaryif_rx(rt_device_t dev)
|
|||
EthernetIntEnable(ETH_BASE, ETH_INT_RX);
|
||||
}
|
||||
|
||||
return(p);
|
||||
return (p);
|
||||
}
|
||||
|
||||
int rt_hw_luminaryif_init(void)
|
||||
|
@ -456,7 +458,7 @@ int rt_hw_luminaryif_init(void)
|
|||
FlashUserSet(0x12345678, 0x12345678);
|
||||
/* Configure the hardware MAC address */
|
||||
FlashUserGet(&ulUser0, &ulUser1);
|
||||
if((ulUser0 == 0xffffffff) || (ulUser1 == 0xffffffff))
|
||||
if ((ulUser0 == 0xffffffff) || (ulUser1 == 0xffffffff))
|
||||
{
|
||||
rt_kprintf("Fatal error in geting MAC address\n");
|
||||
}
|
||||
|
@ -492,4 +494,3 @@ int rt_hw_luminaryif_init(void)
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue