示例#1
0
文件: tasks.cpp 项目: pculka/SkyDrop
void task_system_loop()
{
	wdt_reset();

	//task switching outside interrupt
	if (new_task != actual_task)
	{
		DEBUG("Switching task %d to %d\n", actual_task, new_task);
		if (actual_task != NO_TASK)
		{
			task_stop_array[actual_task]();

			//XXX: this will guarantee that task switched from the powerdown task will be vanilla
			if (new_task == TASK_POWERDOWN)
				SystemReset();
		}

		actual_task = new_task;

		task_init_array[actual_task]();
	}

	//check USB and send IRQ
	if (usb_state != USB_CONNECTED)
	{
		usb_state = USB_CONNECTED;
		task_irqh(TASK_IRQ_USB, &usb_state);
	}

	buttons_step();
	if (powerdown_lock.Active() == false)
	{
		battery_step();
	}
}
示例#2
0
void task_powerdown_loop()
{
	//do not go to the Power down when there is another lock pending (button, buzzer)
	if ((task_sleep_lock == 1 && powerdown_lock.Active()) && powerdown_loop_break == false)
	{
		uart_stop();

		powerdown_sleep();

		uart_low_speed();
	}
}