/* Ends a transmission of an ethernet frame to the ethernet controller. 
This will make sure that data is correctly padded. And will not return until the packet is sent. */
void KSZ8851SNL_TransmitEnd(uint16_t length)
/* Ends a transmission of an ethernet frame to the ethernet controller. 
This will make sure that data is correctly padded. And will not return until the packet is sent. */
void KSZ8851SNL_TransmitEnd(uint16_t length)
{
  uint16_t data;
  uint16_t padding;
  uint8_t dummy[4] = {0x00};
  if (length % 4)
  {
    padding = 4 - (length % 4);
    KSZ8851SNL_SPI_WriteFifo(padding, dummy);
  }
  KSZ8851SNL_SPI_WriteFifoEnd();
  data = KSZ8851SNL_SPI_ReadRegister(RXQCR) & (~RXQ_START_DMA);
  KSZ8851SNL_SPI_WriteRegister(RXQCR, data);
  data = KSZ8851SNL_SPI_ReadRegister(TXQCR) | TXQ_ENQUEUE;
  KSZ8851SNL_SPI_WriteRegister(TXQCR, data);
}