예제 #1
0
파일: tasks.c 프로젝트: Anon0/openiBoot
error_t task_yield()
{
	EnterCriticalSection();
	if(CurrentRunning == IRQTask)
	{
		LeaveCriticalSection();

		bufferPrintf("tasks: Can't swap during ISR!\r\n");
		return EINVAL;
	}

	TaskDescriptor *next = CurrentRunning->taskList.next;
	if(next != CurrentRunning)
	{
		// We have another thread to schedule! -- Ricky26
		
		//bufferPrintf("tasks: Swapping from %s to %s.\n", CurrentRunning->taskName, next->taskName);
		SwapTask(next);
		//bufferPrintf("tasks: Swapped from %s to %s.\n", CurrentRunning->taskName, next->taskName);

		LeaveCriticalSection();
		return SUCCESS_VALUE(1);
	}

	LeaveCriticalSection();
	return SUCCESS_VALUE(0); // didn't yield
}
예제 #2
0
파일: tasks.c 프로젝트: Anon0/openiBoot
error_t task_wait_timeout(int _ms)
{
	CurrentRunning->wasWoken = 0;
	task_sleep(_ms);

	return SUCCESS_VALUE(CurrentRunning->wasWoken);
}
예제 #3
0
파일: nor.c 프로젝트: DeanBoro/openiBoot
static error_t nor_read(mtd_t *_dev, void *_dest, uint32_t _off, int _amt)
{
	uint16_t* alignedBuffer = (uint16_t*)_dest;
	int len = _amt;
	for(; len >= 2; len -= 2)
	{
		*alignedBuffer = GET_REG16(NOR + _off);
		_off += 2;
		alignedBuffer++;
	}

	if(len > 0) {
		uint16_t lastWord = GET_REG16(NOR + _off);
		uint8_t* unalignedBuffer = (uint8_t*) alignedBuffer;
		*unalignedBuffer = *((uint8_t*)(&lastWord));
	}

	return SUCCESS_VALUE(_amt);
}