Download Wireless Ethernet LAN Adaptor
Transcript
}
Function Assemble
Function Assemble
{
found = false;
repeat
if (SerialRxBDindex == Max_SerialRxBD_Size)
SerialRxBDindex = 0;
else
SerialRxBDindex++;
/* Find next unprocessed BD in Serial RxBD table;
It is guaranteed that there will be at least 1 not
Empty entry else this function won’t be called.
*/
if (SerialRxBD[SerialRxBDindex].Empty == 0)
{
Found_free_serial_RxBD = true;
(Serial) Rx_Byte_Ptr =
SerialRxBD[SerialRxBDindex].Buffer_Ptr;
(Serial) Rx_Byte_Length =
SerialRxBD[SerialRxBDindex].Length;
}
until (Found_free_serial_RxBD);
if (BD is the first BD for new packet)
{
/* find an empty Ethernet Tx slot to store the serial data
If there are not free Tx slot, this will loop forever.
Meanwhile, the CPM will keep processing data in
background and update the BD. Hopefully, there will be
an empty slot eventually.
*/
found_free_ethernet_TxDB = false;
Repeat
if (Ethernet_TxBDindex == Max_Ethernet_TxBD_Size)
Ethernet_TxBDindex = 0;
else
Ethernet_TxBDindex++;
If (EthernetTxBD[Ethernet_TxBDindex].Ready == 0)
Found_free_ethernet_TxDB = true;
Until (found_free_ethernet_TxDB);
Current_Packet_Length = 0;
(Ethernet) Tx_Buffer_Ptr = (Serial) Rx_Byte_Ptr;
}
else if (received data contain "end of packet" sequence)
{
D-22