software/libnet/microudp: simplify txbuffer managment
This commit is contained in:
parent
3441eb05cb
commit
13a76ec7fb
|
@ -116,15 +116,12 @@ typedef union {
|
||||||
|
|
||||||
static unsigned int rxlen;
|
static unsigned int rxlen;
|
||||||
static ethernet_buffer *rxbuffer;
|
static ethernet_buffer *rxbuffer;
|
||||||
static unsigned int txslot;
|
|
||||||
static unsigned int txlen;
|
static unsigned int txlen;
|
||||||
static ethernet_buffer *txbuffer;
|
static ethernet_buffer *txbuffer;
|
||||||
static ethernet_buffer *txbuffer0;
|
|
||||||
static ethernet_buffer *txbuffer1;
|
|
||||||
|
|
||||||
static void send_packet(void)
|
static void send_packet(void)
|
||||||
{
|
{
|
||||||
|
unsigned int txslot;
|
||||||
#ifndef HW_PREAMBLE_CRC
|
#ifndef HW_PREAMBLE_CRC
|
||||||
unsigned int crc;
|
unsigned int crc;
|
||||||
crc = crc32(&txbuffer->raw[8], txlen-8);
|
crc = crc32(&txbuffer->raw[8], txlen-8);
|
||||||
|
@ -144,15 +141,13 @@ static void send_packet(void)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ethmac_sram_reader_slot_write(txslot);
|
|
||||||
ethmac_sram_reader_length_write(txlen);
|
ethmac_sram_reader_length_write(txlen);
|
||||||
while(!(ethmac_sram_reader_ready_read()));
|
|
||||||
ethmac_sram_reader_start_write(1);
|
ethmac_sram_reader_start_write(1);
|
||||||
txslot = (txslot+1)%2;
|
while(!(ethmac_sram_reader_ready_read()));
|
||||||
if (txslot)
|
txslot = ethmac_sram_reader_slot_read();
|
||||||
txbuffer = txbuffer1;
|
txbuffer = (ethernet_buffer *)(ETHMAC_BASE + ETHMAC_SLOT_SIZE * (ETHMAC_RX_SLOTS + txslot));
|
||||||
else
|
txslot = (txslot+1)%ETHMAC_TX_SLOTS;
|
||||||
txbuffer = txbuffer0;
|
ethmac_sram_reader_slot_write(txslot);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char my_mac[6];
|
static unsigned char my_mac[6];
|
||||||
|
@ -412,13 +407,6 @@ void microudp_start(const unsigned char *macaddr, unsigned int ip)
|
||||||
ethmac_sram_reader_ev_pending_write(ETHMAC_EV_SRAM_READER);
|
ethmac_sram_reader_ev_pending_write(ETHMAC_EV_SRAM_READER);
|
||||||
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
|
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
|
||||||
|
|
||||||
txbuffer0 = (ethernet_buffer *)(ETHMAC_BASE + 2*ETHMAC_SLOT_SIZE);
|
|
||||||
txbuffer1 = (ethernet_buffer *)(ETHMAC_BASE + 3*ETHMAC_SLOT_SIZE);
|
|
||||||
|
|
||||||
txslot = 0;
|
|
||||||
|
|
||||||
txbuffer = txbuffer0;
|
|
||||||
|
|
||||||
for(i=0;i<6;i++)
|
for(i=0;i<6;i++)
|
||||||
my_mac[i] = macaddr[i];
|
my_mac[i] = macaddr[i];
|
||||||
my_ip = ip;
|
my_ip = ip;
|
||||||
|
@ -427,6 +415,10 @@ void microudp_start(const unsigned char *macaddr, unsigned int ip)
|
||||||
for(i=0;i<6;i++)
|
for(i=0;i<6;i++)
|
||||||
cached_mac[i] = 0;
|
cached_mac[i] = 0;
|
||||||
|
|
||||||
|
ethmac_sram_reader_slot_write(0);
|
||||||
|
txbuffer = (ethernet_buffer *)(ETHMAC_BASE + ETHMAC_SLOT_SIZE * ETHMAC_RX_SLOTS);
|
||||||
|
|
||||||
|
|
||||||
rxbuffer = (ethernet_buffer *)ETHMAC_BASE;
|
rxbuffer = (ethernet_buffer *)ETHMAC_BASE;
|
||||||
rx_callback = (udp_callback)0;
|
rx_callback = (udp_callback)0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue