Exemplo n.º 1
0
int SDL_main(int argc, char *argv[])
{
    int ret = 0;

	ret = UpgradeInit();
    if (ret)
        goto end;
	
    if (SDL_Init(SDL_INIT_VIDEO) < 0)
        printf("Couldn't initialize SDL: %s\n", SDL_GetError());

	logic_init();	
	WebServerInit();
    SceneInit();
    SceneLoad();
    AudioInit();
    ret = SceneRun();
	dprintf(" SceneRun exit !!!\n");

	FeetDog_Exit();
    SceneExit();
	if (ret != QUIT_UPGRADE_WEB)
        WebServerExit();

	NetworkExit();
	uninit_auTimer();
	SDL_Quit();

end:
    ret = UpgradeProcess(ret);
    itp_codec_standby();	
    exit(ret);
    return ret;
}
Exemplo n.º 2
0
static void init_all(void) {
  led_group(LED_ALL, false);
  logic_init();
  flipflop_init();
  counter_init();
  shiftreg_init();
  povmsg_init();
  dice_init();
  game_init();
  select = modeDefault;
  mode = modeDefault;
  sparkle_delay = SPARKLE_DELAY_DFLT;
  sparkle_timer = 0;
  select_timer = 0;
  off_timer = 0;
  idle_timer = 0;
}
Exemplo n.º 3
0
int main(void)
{

    char wdrst = 0;
    uint8_t mcusr;

    mcusr = MCUSR;
    if ( mcusr & _BV(WDRF) ) {
        wdrst = 1;
    }
    MCUSR = 0;
    wdt_disable();

    cli();
#ifdef LED1
    LED1 = 1;
#endif
    uart_init(UART_BAUD_SELECT_DOUBLE_SPEED(115200,F_CPU));
    stdout = &mystdout;
    sei();

    if ( wdrst ) {
        kputs("\n***WATCHDOG RESET***\n");
    }

    wdt_enable(WDTO_8S);
    wdt_reset();
    kputs("\nSetting DDR registers\n");
    DDRA = DDRA_SETTING;
    DDRB = DDRB_SETTING;
    DDRC = DDRC_SETTING;
    DDRD = DDRD_SETTING;
    DIDR0 = 0;
    DIDR1 = 0;
    /*
    kputs("Hi i2c\n");
    i2c_init();
    kputs("Hi humid\n");
    humid_init();
    humid_sleep();
    kputs("Hi accel\n");
    accel_init();
    accel_sleep();
    kputs("Hi light\n");
    light_init();
    light_sleep();
    kputs("Hi PIR\n");
    pir_wake();
    kputs("Hi RTC\n");
    rtctimer_init();
    kputs("Go away RTC\n");
    DDRC &= 0x3F;
    PORTC |= 0xC0;

    kputs("Go to sleep\n");
    uart_flush();
    ACSR = (1<<ACD);
    LED1 = LED2 = 0;
    cli();
    wdt_disable();
    SMCR = (2<<SM0) | (1<<SE);	 //Enable Power-Down Mode
    while(1) {
    	asm volatile ("sleep"); // __sleep(); // Go to sleep
    }
    */
    kputs("Initializing PCINT\n");
    pcint_init();

    kputs("Initializing Reports\n");
    report_init();

    board_init_devices();

    kputs("Initializing wireless mote\n");
    wdt_reset();
    datalink_init();


    /*
    PIR_VCC = 1;
    while(1) {
    	if(PIR_OUT_PIN) {
    		kputs("ON\n");
    	} else {
    		kputs("OFF\n");
    	}
    	_delay_ms(50);
    }*/

    kputs("Powering down all devices\n");
    board_power_down_devices();

    kputs("Init logic subsystem\n");
    logic_init();

    /*
    kputs("Turning on always-on devices\n");
    pir_wake();
    accel_wake();
    */

    board_setup_reporting();

    kputs("Starting RTC clock\n");
    rtctimer_init();
    rtctimer_set_periodic_alarm(report_interval_needed(),&rtc_timer_cb);
    wdt_reset();
    wdt_disable();
    while(1)
    {
        //wdt_enable(WDTO_2S);
        //wdt_reset();
        pcint_check();
        rtctimer_check_alarm();
        wdt_disable();

        datalink_tick();

#ifdef USE_PN532
        rtc_timer_cb(); // causes monitor list to be run
#else
#if defined LOW_POWER // do we have a RTC clock and battery-powered
        avr_sleep();
#else
        avr_doze();
#endif
#endif
    }
}
Exemplo n.º 4
0
/*
 * Play soccer
 */
void soccer_run(void)
{
	unsigned int  timeBase, ballCount;
	GolfBall      golfBall[MAX_GOLF_BALLS];
	Goal          goalBlue;
	Goal          goalYellow;
	int 		  maxTime = 0;

#ifdef DEBUG
	int* 		  debugInfo;
#endif

	// initialize logic module
	logic_init();

	// play soccer until play switch is set off
	while(1/*srv_getPlaySwitchState() == switchOn*/)
	{
		MEASURE_START;
		// check exit condition

		// get time base
		timeBase = systemTime_getSystemTimeBase();
		if (timeBase & SYSTEM_MAIN_LOOP_TIME_BASE)
		{
			// take picture
			camera_grabFrame();
			// find golf balls, no markings needed
			ballCount = colors_searchGolfBalls((unsigned char *)FRAME_BUF, &golfBall[0], NO_MARKING);
			// find both goals
			colors_searchGoal((unsigned char *)FRAME_BUF, &goalBlue, colorBlue, NO_MARKING);
			colors_searchGoal((unsigned char *)FRAME_BUF, &goalYellow, colorYellow, NO_MARKING);
			// handle logic (attacking goal specified by switch)
			if (srv_isBlueGoalSelected())
            {
			    // Blue is opponent's, yellow is my own goal
			    logic_handleLogic(ballCount, &golfBall[0], &goalBlue, &goalYellow);
            }
            else
            {
                //  Yellow is opponent's, blue is my own goal
                logic_handleLogic(ballCount, &golfBall[0], &goalYellow, &goalBlue);
            }
		}
		if (timeBase & SYSTEM_3x_MAIN_LOOP_TIME_BASE)
		{
			//uart_uart2SetCharsToBuffer(buf, 3);
			//uart_uart2SendBuffer();
		}
		if (timeBase & SYSTEM_12x_MAIN_LOOP_TIME_BASE)
		{
			io_LED2Toggle();
			//printf("Loop time: %d", maxTime);
			// enable IR receivers
			//timer_enableTimer(TIMER3);
			//timer_enableTimer(TIMER7);
			//printf("left: %d, right: %d", timer_getTimerWidth(TIMER7), timer_getTimerWidth(TIMER3) );
#ifdef DEBUG
			// debug data
			debugInfo = debug_getDebugInfo();
			printf("%d %d %d %d %d %d %d %d %d %d %d %d", *debugInfo, *(debugInfo + 1), *(debugInfo + 2), *(debugInfo + 3),
								*(debugInfo + 4), *(debugInfo + 5), *(debugInfo + 6), *(debugInfo + 7),
									*(debugInfo + 8), *(debugInfo + 9), *(debugInfo + 10), *(debugInfo + 11) );


#endif
		}
		MEASURE_STOP;
		if ( MEASURE_RESULT > maxTime ) maxTime = MEASURE_RESULT;
		// keep in loop until 30 ms elapsed from last time
		while (!systemTime_checkMainLoopDuration())
		{
			doIdleTime();
		}
	}
}
Exemplo n.º 5
0
/*===========================================================================*/
int main(void)
{
	/*
	 * System initializations.
	 * - HAL initialization, this also initializes the configured device drivers
	 *   and performs the board-specific initializations.
	 * - Kernel initialization, the main() function becomes a thread and the
	 *   RTOS is active.
	 */

	halInit();
	chSysInit();


	/*
	 * kruciální řádek protože pokud se to zapne bez debugru tak je tam
	 * jenom bordel a když se to pak srovnává s NULL tak se to cely
	 * vymrdá a skoči do unhandled exception
	 */
	uint8_t i;
	for (i = 0 ; i< 60 ; i++)
		logic_pointery[i] = NULL;

	//test_logic_fill();

	chThdSleepMilliseconds(100);

	/*
	 * Activates the USB driver and then the USB bus pull-up on D+.
	 */
	usb_user_init();

	/*
	 * Shell manager initialization.
	 */
	shellInit();

	/*
	 * Init tft display ssd1289 and gui
	 */
	gui_init();


	/**
	 * @brief start the whole bad thing
	 */
	logic_init();

	/*
	 * start external interrupt system
	 */
	extStart(&EXTD1, &extcfg);

	/*
	 * start wah thread
	 */
	wah_init();

	/*
	 * Normal main() thread activity, in this demo it does nothing except
	 * sleeping in a loop and check the button state.
	 */

	EventListener el;
	chEvtRegister(&event_touch, &el, TOUCH_PUSH);

#ifdef I2C_TEST
	i2c_test();
#endif

	gui_thread();

	while(TRUE);
}