Esempio n. 1
0
CQueueType Queue_Head(CQueue &q)
{
    assert(Queue_IsEmpty(q) == false);
    if (Queue_IsEmpty(q))
    {
        return CQueueType();
    }
    return q.pData[q.head];
}
Esempio n. 2
0
CQueueType Queue_Tail(CQueue &q)
{
    assert(Queue_IsEmpty(q) == false);
    if (Queue_IsEmpty(q))
    {
        return CQueueType();
    }
    return q.pData[q.tail];
}
Esempio n. 3
0
CQueueType Queue_Dequeue(CQueue &q)
{
    assert(Queue_IsEmpty(q) == false);
    if (Queue_IsEmpty(q))
    {
        return CQueueType();
    }
    --q.size;
    q.head %= q.capacity;
    return q.pData[q.head++];
}
Esempio n. 4
0
void SPI_Transfer(spi_configuration* configuration, uint8_t* output, uint8_t* input, uint8_t length, completion_handler handler)
{
	if (Queue_IsFull(operationQueue))
	{
		return;
	}

	bool isIdle;

	ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
	{
		isIdle = Queue_IsEmpty(operationQueue);
	}

	operation* o = Queue_Head(operationQueue);

	o->configuration = configuration;
	o->output = output;
	o->input = input;
	o->length = length;
	o->handler = handler;

	Queue_AdvanceHead(operationQueue);

	if (isIdle) // just check some register bit instead of isIdle?
	{
		// power up peripheral

		PowerManager_RequestResource(PROCESSOR_RESOURCE_IO_CLOCK); // don't let it sleep

		ExecuteOperation();
	}
}