Example #1
0
int
main(void)
{
	unsigned timeout = 0;

	/* do board-specific initialisation */
	board_init();

#ifdef INTERFACE_USART
	/* XXX sniff for a USART connection to decide whether to wait in the bootloader? */
	timeout = BOOTLOADER_DELAY;
#endif

#ifdef INTERFACE_I2C
# error I2C bootloader detection logic not implemented
#endif

	/* if the app left a cookie saying we should wait, then wait */
	if (should_wait())
		timeout = BOOTLOADER_DELAY;

#ifdef BOARD_FORCE_BL_PIN
	/* if the force-BL pin state matches the state of the pin, wait in the bootloader forever */
	if (BOARD_FORCE_BL_VALUE == gpio_get(BOARD_FORCE_BL_PORT, BOARD_FORCE_BL_PIN))
		timeout = 0xffffffff;
#endif

	/* look for the magic wait-in-bootloader value in backup register zero */


	/* if we aren't expected to wait in the bootloader, try to boot immediately */
	if (timeout == 0) {
		/* try to boot immediately */
		jump_to_app();

		/* if we returned, there is no app; go to the bootloader and stay there */
		timeout = 0;
	}

	/* configure the clock for bootloader activity */
	rcc_clock_setup_in_hsi_out_24mhz();

	/* start the interface */
	cinit(BOARD_INTERFACE_CONFIG);

	while (1)
	{
		/* run the bootloader, possibly coming back after the timeout */
		bootloader(timeout);

		/* look to see if we can boot the app */
		jump_to_app();

		/* boot failed; stay in the bootloader forever next time */
		timeout = 0;
	}
}
void t_combat_ai_ranged_single_action::perform_action(void)
{
	t_battlefield& battlefield = m_battlefield;

	if (should_wait( *battlefield.get_acting_creature(), *m_target ))
	{
		battlefield.wait_action();
		return;
	}
	battlefield.begin_ranged_attack( m_target );
}