示例#1
0
ER load_application(const void *mod_data, SIZE mod_data_sz) {
	ER ercd;

//	ev3_led_set_color(LED_GREEN);
//	chg_status(STATUS_RUNNING);

#if 0
	// Wait for pressing center button
    SYSTIM time = 0;
    uint32_t ledcolor = 0;
	syslog(LOG_NOTICE, "Press center button to run the application.");
	while(!global_brick_info.button_pressed[BRICK_BUTTON_ENTER]) {
		SYSTIM newtime;
		get_tim(&newtime);
		if (newtime - time > 500) { // Blink LED
			brick_misc_command(MISCCMD_SET_LED, ledcolor);
			ledcolor ^= TA_LED_RED | TA_LED_GREEN;
			time = newtime;
		}
	}
	while(global_brick_info.button_pressed[BRICK_BUTTON_ENTER]) {
		SYSTIM newtime;
		get_tim(&newtime);
		if (newtime - time > 500) { // Blink LED
			brick_misc_command(MISCCMD_SET_LED, ledcolor);
			ledcolor ^= TA_LED_RED | TA_LED_GREEN;
			time = newtime;
		}
	}
#endif

	brick_misc_command(MISCCMD_SET_LED, TA_LED_GREEN);
	platform_soft_reset();
	ercd = dmloader_ins_ldm(mod_data, mod_data_sz, 1);
	if (ercd != E_OK) {
		syslog(LOG_ERROR, "Failed to load application, ercd: %d", ercd);
	} else {
		app_loaded = true;
		SVC_PERROR(sta_alm(APP_TER_BTN_ALM, 0));
		SVC_PERROR(wai_sem(APP_TER_SEM));
		syslog(LOG_NOTICE, "Terminate application.");
		SVC_PERROR(dmloader_rmv_ldm(1));
		brick_misc_command(MISCCMD_SET_LED, TA_LED_GREEN);
	}
//	chg_status(STATUS_IDLE);
	platform_soft_reset();
	tslp_tsk(500);

	return ercd;
}
示例#2
0
void application_unload() {
	ER ercd;
	if (app_loaded) {
		syslog(LOG_NOTICE, "Terminate application.");
		ercd = dmloader_rmv_ldm(1);
		assert(ercd == E_OK);
		app_loaded = false;
		platform_soft_reset();
		brick_misc_command(MISCCMD_SET_LED, TA_LED_GREEN);
	}
}
示例#3
0
ER load_application(const void *mod_data, SIZE mod_data_sz) {
	ER ercd;

	platform_soft_reset();
	ercd = dmloader_ins_ldm(mod_data, mod_data_sz, 1);


	if (ercd == E_OK) {
		brick_misc_command(MISCCMD_SET_LED, TA_LED_GREEN);
		app_loaded = true;
	} else {
		syslog(LOG_ERROR, "Failed to load application, ercd: %d", ercd);
	}

	return ercd;
}
示例#4
0
void ev3_main_task(intptr_t exinf) {
    ER_UINT ercd;

    // Pause application at first
    platform_pause_application(true);

    /**
     * Initialize FatFS
     */
    initialize_fatfs_dri();

    /**
     * Load configurations
     */
    ev3rt_load_configuration();

    /**
     * Initialize LCD
     */
    initialize_lcd_dri();

    /**
     * Initialize EV3RT console and open its SIO port.
     */
    initialize_console_dri();
    ercd = serial_opn_por(SIO_PORT_LCD);
    if (ercd < 0 && MERCD(ercd) != E_OBJ) {
        syslog(LOG_ERROR, "%s (%d) reported by `serial_opn_por'.",
                                    itron_strerror(ercd), SERCD(ercd));
    }
    SVC_PERROR(serial_ctl_por(SIO_PORT_LCD, IOCTL_NULL));

    platform_pause_application(false);

    is_initialized = false;

//    syslog(LOG_NOTICE, "Sample program starts (exinf = %d).", (int_t) exinf);

    /**
     * Initialize all drivers
     */
	for(uint32_t i = 0; i < tnum_drivers; ++i)
		if (drivers[i].init_func != NULL) drivers[i].init_func(0);

	platform_soft_reset();

	// Banner
	syslog(LOG_NOTICE, "");
	syslog(LOG_NOTICE, "");
	syslog(LOG_NOTICE, "");
	syslog(LOG_NOTICE, "");
	syslog(LOG_NOTICE, "   _____   ______ ___  ______");
	syslog(LOG_NOTICE, "  / __/ | / /_  // _ \/_  __/");
	syslog(LOG_NOTICE, " / _/ | |/ //_ </ , _/ / /");
	syslog(LOG_NOTICE, "/___/ |___/____/_/|_| /_/");
	syslog(LOG_NOTICE, "=============================");
	syslog(LOG_NOTICE, "Powered by TOPPERS/HRP2 RTOS");
	syslog(LOG_NOTICE, "Initialization is completed..");

	platform_pause_application(true);

	is_initialized = true;

	brick_misc_command(MISCCMD_SET_LED, TA_LED_GREEN);

#if 0 // Legacy code
    initialize_analog_dri();
    initialize_uart_dri();
	initialize_motor_dri();
	initialize_sound_dri();
	initialize_fatfs_dri();
	//    initialize_ev3();



//    syslog(LOG_ERROR, "TEST ZMODEM");
//    uint8_t c;
//    while(1) {
//    	serial_rea_dat(SIO_PORT_UART, &c, 1);
//		ER ercd;
//		switch (c) {
//		case 'r':
//			ercd = zmodem_recv_file(app_text_mempool, sizeof(app_text_mempool));
//			syslog(LOG_ERROR, "ZMODEM ercd = %d.", ercd);
//			break;
//		default:
//			syslog(LOG_ERROR, "Key %c pressed.", c);
//		}
//    }


    //EV3::ev3 = new EV3::EV3();

//#define TEST_ANALOG_SENSOR
//

//#ifdef TEST_ANALOG_SENSOR

//    while(1) {
//        /*
//         *  Debug Analog Port 2
//         */
//        int sv = analog_get_short(1);
//        printk("Sensor PIN1: %d\n", sv);
//        printk("Sensor PIN6: %d\n", analog_get_short_pin6(1));
//
//        GPIO67.OUT_DATA ^= GPIO_ED_PIN7 | GPIO_ED_PIN14;
//        target_fput_log('H');
//        target_fput_log('E');
//        target_fput_log('R');
//        target_fput_log('E');
//        target_fput_log('\n');
//        tslp_tsk(1000);
//    }
//#endif
//#ifdef TEST_UART
//  //init_pwm();
//  //ev3_motor_set_speed(PortA, 50);
//  //tslp_tsk(3000);
//  //ev3_motor_brake(PortA, true);
//  init_uart();
//  while(1) {
//      /*
//       *  Debug UART Port 2
//       */
//      int sv = uart_get_short(1);
//      printk("Sensor value: %d\n", sv);
//
//      GPIO67.OUT_DATA ^= GPIO_ED_PIN7 | GPIO_ED_PIN14;
//      target_fput_log('H');
//      target_fput_log('E');
//      target_fput_log('R');
//      target_fput_log('E');
//      target_fput_log('\n');
//      tslp_tsk(1000);
//  }
//#endif
#endif

}