Пример #1
0
void main()
{
	HW_INIT();

	RF_Init();

	RF_ListenOff();

	for (;;)
	{
		HW_SLEEP_MS(g_sysConfig.timeToWakeup);
		OnWakeup();

		HW_SLEEP_MS(100);
		RF_ListenOn();

		HW_SLEEP_MS(g_sysConfig.timeToTurnOffRF);
		RF_ListenOff();

		if (HW_NRF_HAS_INTERRUPT())
		{
			OnRfPacket();

			HW_NRF_CLEAR_INTERRUPT();
		}
	}
}
Пример #2
0
void Win32SyncManager::ScheduleTask(Task next, bool atTermination){
	Task currTid = (Task)TlsGetValue(tlsCurrentTaskId);
	if(!atTermination)
		assert(runningTid == currTid);
	if(runningTid == next){
		if(atTermination){
			assert("Schedule running_tid at termination");
		}
		return;
	}

	Semaphore* currSem = 0;
	Semaphore* nextSem = syncVarIdManager->GetTaskSemaphore(next);
	//if(atTermination){
	//	assert(currSem->IsNull());
	//}
	if(!atTermination){
		currSem = syncVarIdManager->GetTaskSemaphore(runningTid);
	}
	runningTid = next;
	nextSem->AtomicUpDown(currSem);
	if(!atTermination){
		OnWakeup();
	}

	//nextSem->Up();

	//if(!atTermination){
	//	currSem->Down();	
	//	OnWakeup();
	//}
}
Пример #3
0
void Win32SyncManager::ThreadBegin(Semaphore sem){
	sem.Down();
	OnWakeup();
	TlsSetValue(tlsCurrentTaskId, (LPVOID)runningTid);
	Chess::TaskBegin();
#ifndef UNDER_CE
	//A thread starts in an alertable state (i.e. Executes APCs that are queued before starting)
	WrappersOnAlertableState(runningTid);
#endif
}