Пример #1
0
int main() {
	chipInit();

	timer0Init();
	//init_adc(ADC_CHANS, INT_VREF_TYPE);
	adcInit(0, AVCC_VREF_TYPE);
	uart_init();
	w1Init();

	sei();

	ee_magic = MAGIC16;
	initCommands();
	initVM();
	ee_magic = 0;

	while (1) {
		char tticks = getClearTimerTicks();
		while (tticks) {
			tticks--;
			ds18b20_step(0, TIME_UNIT);
			ds18b20_step(1, TIME_UNIT);
			vmStep(TIME_UNIT);
			handlePWM(TIME_UNIT);
		}
		handleIO();
	}
	return 0;
}
Пример #2
0
unsigned __stdcall workerLoop(void* arg)
{   
	auto pTCPServer = static_cast<TCPServer*>(arg);

	unsigned long transferedBytes = 0;
	PSocketContext  pSocketContext = nullptr;
	OVERLAPPED *pOverlapped = nullptr;
	BOOL ret = false;

	while(true) {
		ret = GetQueuedCompletionStatus(pTCPServer->getIOCP(), 
			&transferedBytes, (PULONG_PTR)&pSocketContext, 
			&pOverlapped, INFINITE);

		if(nullptr == pSocketContext){
			break;// 退出通知
		}
		
		auto pIOContext = CONTAINING_RECORD(pOverlapped, 
			IOContext, overlapped);
		if(!pTCPServer->handleIO(pSocketContext, pIOContext, ret)) {
			break;
		}
	}

	return 0;
}
int main() {
    handleIO();
    return 0;
}