Exemplo n.º 1
0
void UartDevice::OnTxEmpty(Uart *uart)
{
    TxBuffer::Block *block = m_tx_buf->GetActiveBlock();
    while (block && block->it == block->size)
    {
        block = m_tx_buf->NextBlock();
    }
    if (!block)
    {
        DisableTx();
        return;
    }

    const size_t size = block->size - block->it;
    switch (block->type)
    {
    case TxBuffer::Block::kByteAry:
        block->it += uart->PutBytes(block->data.byte_ + block->it, size);
        break;

    case TxBuffer::Block::kString:
        block->it += uart->PutBytes((const Byte*)block->data.string_->data()
                                    + block->it, size);
        break;

    case TxBuffer::Block::kVector:
        block->it += uart->PutBytes(block->data.vector_->data() + block->it,
                                    size);
        break;
    }
}
/**
* @brief  This routine will transmit the element from Tx Buffer.
* @param  None.
* @retval uint8_t Status.
*/
uint8_t TxBuffer_SendElement(void)
{
  if(ITERATOR < INDEX_Tx)
  {
    return TransmitBuffer[ITERATOR++];
  }
  else 
  {
    DisableTx();
  }
  return 0x00;
}
Exemplo n.º 3
0
void UartDevice::NextTxDma()
{
    TxBuffer::Block *block = m_tx_buf->GetActiveBlock();
    while (block && block->it == block->size)
    {
        block = m_tx_buf->NextBlock();
    }
    if (!block)
    {
        DisableTx();
        return;
    }

    switch (block->type)
    {
    case TxBuffer::Block::kByteAry:
        m_dma_config->src.addr = block->data.byte_;
        break;

    case TxBuffer::Block::kString:
        m_dma_config->src.addr = (void*)block->data.string_->data();
        break;

    case TxBuffer::Block::kVector:
        m_dma_config->src.addr = block->data.vector_->data();
        break;
    }
    m_dma_config->major_count = block->size;

    if (m_dma)
    {
        DmaManager::Delete(m_dma);
    }
    m_dma = DmaManager::New(*m_dma_config, m_tx_dma_channel);
    m_dma->Start();
}