コード例 #1
0
void CSIF::ProcessPackets()
{
	if(m_packetProcessed && !m_packetQueue.empty())
	{
		assert(m_packetQueue.size() > 4);
		uint32 size = *reinterpret_cast<uint32*>(&m_packetQueue[0]);
		SendDMA(&m_packetQueue[4], size);
		m_packetQueue.erase(m_packetQueue.begin(), m_packetQueue.begin() + 4 + size);
		m_packetProcessed = false;
	}
}
コード例 #2
0
ファイル: i2c.cpp プロジェクト: rolandmuncie/libarmpit-cortex
bool I2C::_MasterWrite (uint8_t* data, uint32_t data_size, uint8_t slave_addr, uint8_t* preg_addr)
{
    if (!WaitStatus(I2C::BUSY, false))
    {
        //ClearBUSY();
        _stuckBUSY= true;
        return false;
    }

    SendStart(true);

    if (!WaitStatus(I2C::MASTER_EV5, true))
        return false;

    Send7bitAddress(slave_addr, true);

    if (!WaitStatus(I2C::MASTER_EV6_TRA, true)) //MSL | BUSY | ADDR | TXE | TRA
        return false;

    ////////////////////////////////////////////////////////////////////////////
    if (preg_addr)
    {
        SendByte(*preg_addr);
        if (!WaitStatus(I2C::MASTER_EV8_2, true))  //TRA, BUSY, MSL, TXE and BTF
            return false;
    }
    ////////////////////////////////////////////////////////////////////////////

    if (data_size == 1)
    {
        SendByte(*data);

        if (!WaitStatus(I2C::MASTER_EV8, true))  //TRA, BUSY, MSL, TXE and BTF
            return false;

        SendStop(true);

        return true;

    }
    else
    {
        return SendDMA (data, data_size);
    }

}