Ejemplo n.º 1
0
Archivo: main.c Proyecto: prophile/dim3
int main(int argc,char *argv[])
{
	bool			app_start_ok;
	char			err_str[256];
	
		// setup paths

	if (!file_paths_setup(&setup.file_path_setup,FALSE)) {
		app_report_error("dim3 requires a data folder with project files.");
		return(0);
	}
	
		// check for required OS
		
	if (!app_check_os_support(err_str)) {
		app_report_error(err_str);
		return(0);
	}

		// check if editor is launching engine and
		// if a map needs to be auto-loaded
		
	app_check_editor_link();

		// run dim3
		
	err_str[0]=0x0;
	
	app_start_ok=app_start(err_str);
	if (app_start_ok) {

		game_loop_pause=FALSE;
		game_loop_quit=FALSE;
		
		while (!game_loop_quit) {
			if (!loop_main(err_str)) break;
		}
		
		app_end();

	}
	
		// if app couldn't start, then let user reset setup
		
	if (err_str[0]!=0x0) {
		if (app_start_ok) {
			app_report_error(err_str);
		}
		else {
			app_report_error_ask_fix_setup(err_str);
		}
	}
	
	return(0);
}
static void rvn_loc_cmd_restart(uint8_t *cmd)
{
    // Now its OK to ACK the packet
    SIPC_ACK_PACKET();
    
    // Send response
    send_loc_simple_rsp(RVN_LOC_RSP_OK);
    
    // move interrutp vectors to app section, and start application program
    intvecs_to_app();
    app_start();
}
Ejemplo n.º 3
0
/* main program starts here */
void main(void)
{	
	/* here we learn how we were reset */
	reset_reason = MCUSR;
	MCUSR = 0;

	/* stop watchdog */
	WDTCSR |= _BV(WDCE) | _BV(WDE);
	WDTCSR = 0;
	
	/* start app right ahead if this was watchdog */
	if ((reset_reason & _BV(WDRF))) app_start();

	/* this is needed because of the __attribute__ naked, section .init 9 */
	/* from now, we can call functions :-) */
	asm volatile ( "clr __zero_reg__" );
	SP=RAMEND;

	/* test if we should skip to the app immediately... */
	if (bootloader_skip_condition()) app_start();

	/* warning: this means that the rest of the bootloader only runs,  */
	/*          if the bootloader_skip_condition returnd false !!!     */

#ifndef DISABLE_MMC
	/* lets first try the mmc */
	mmc_updater();
#endif

#ifndef DISABLE_SERIAL
	/* the fall back to serial */
	stk500v1();
#endif
		
	/* we reset via watchdog */
	/* in order to re-enable the RWW section (see prog_flash.c...) */
	WDTCSR = _BV(WDE);
	while (1); // 16 ms
}
Ejemplo n.º 4
0
/*********************************************************
 ******************    Main Function    ******************
 *********************************************************/
int main(int agrc, char *agrv[])
{
    /* return value of function main */
    int ret = 0; 

    if (agrc < 2) return 0;
    
    set_app_state_file_path(app_file_path);
    if (!strcmp(agrv[1], "state")) {
        ret = app_state();
        print_app_state(app_name, ret);
    } else if (!strcmp(agrv[1], "start")) {
        ret = app_start();
    } else if (!strcmp(agrv[1], "stop")) {
        ret = app_stop();
    } else if (!strcmp(agrv[1], "restart")) {
        ret = app_stop();
        sleep(1);
        ret = app_start();
    }
    return ret;
}
Ejemplo n.º 5
0
int main() {
  app_setup();

  app_start();

  // Clear the timer and enable timer interrupt
  __enable_interrupt();

  // infinite loop
  while (1) {}

  return 0;
}
Ejemplo n.º 6
0
/* This function is called by the driver when an interrupt is serviced. */
void user_isr() {
  // check if this interrupt was due to an I2C error
  uint16_t I2CErrors = get_i2c_errors();
  if (I2CErrors != 0) {
    ack_i2c_error();
    // disable and enable the app. to leave "error" state
    app_stop();
    app_start();
    return;
  }
  // handle new value
  uint16_t SensorValue = app_get_value();
  // ...
}
static void rvn_loc_cmd_app_start(uint8_t *cmd)
{
    // Now its OK to ACK the packet
    SIPC_ACK_PACKET();
    
    // Send response
    send_loc_simple_rsp(RVN_LOC_RSP_OK);
 
    // Move interrutp vectors to app section, and start application program
    uint8_t mcucr = MCUCR & ~(1<<IVSEL) & ~(1<<IVCE);
    MCUCR |= (1<<IVCE);
    MCUCR = mcucr;
    
    app_start();
}
Ejemplo n.º 8
0
int main() {
  // Stop watchdog timer
  WDTCTL = WDTPW + WDTHOLD;

  app_setup();

  app_start();

  // Clear the timer and enable timer interrupt
  __enable_interrupt();

  // infinite loop
  while (1) {
    LPM3;
  }

  return 0;
}
Ejemplo n.º 9
0
/* This function is called by the driver when an interrupt is serviced. */
void user_isr() {
  // check if this interrupt was due to an I2C error
  uint16_t I2CErrors = get_i2c_errors();
  if (I2CErrors != 0) {
    ack_i2c_error();
    // disable and enable the app. to leave "error" state
    app_stop();
    app_start();
    return;
  }
  // handle new value
#ifdef SIMULATION
  uint16_t SensorValue = app_get_value();
#else
  printf("New value: ");
  PrintSensorValue();
  printf("\r\n");
#endif
}
Ejemplo n.º 10
0
Archivo: wave.c Proyecto: zdjjqllm/wave
int wave_start(){
    struct sec_db* sdb;
    int res;
    sdb = init_sec_db();
    if(sdb == NULL){
        return -1;
    }
    if(atexit(wave_exit_fun)){
        wave_error_printf("注册退出程序失败");
        return -1;
    }
    if(wme_serv_start(sdb))
        return -1;
    if(wave_cmp_start(sdb))
        return -1;
    if( app_start(sdb))
        return -1;
    return 0;
}
Ejemplo n.º 11
0
int main(void)
{
    app_start(0, NULL);

    for(;;)
    {
        // send notification outside of interrupt context
        if (sendHello)
        {
            ble_error_t result = bts->updateCharacteristicValue((const uint8_t*)"hello", 5);

            if (result == BLE_ERROR_NONE)
            {
                sendHello = false;
            }
        }

        ble.waitForEvent();
    }
}
void _fw_usbfifo_recv_command(VBUF *buf)
{
	A_UINT8 *cmd_data;
	A_UINT32 tmp;

	cmd_data = (A_UINT8 *)(buf->desc_list->buf_addr + buf->desc_list->data_offset);
	tmp = *((A_UINT32 *)cmd_data);
	if ( tmp == 0xFFFFFFFF ) {	
		// reset usb/wlan dma
		_fw_reset_dma_fifo();

		// restore gpio setting and usb/wlan dma state
		_fw_restore_dma_fifo();

		// set clock to bypass mode - 40Mhz from XTAL 
		HAL_WORD_REG_WRITE(MAGPIE_REG_CPU_PLL_BYPASS_ADDR, (BIT0|BIT4));

		A_DELAY_USECS(100); // wait for stable

		HAL_WORD_REG_WRITE(MAGPIE_REG_CPU_PLL_ADDR, (BIT16));

		A_DELAY_USECS(100); // wait for stable
		A_UART_HWINIT((40*1000*1000), 19200);

		A_CLOCK_INIT(40);

		if (!bEepromExist) { //jump to flash boot (eeprom data in flash)
			bJumptoFlash = TRUE;
			A_PRINTF("Jump to Flash BOOT\n");
			app_start();
		}else{
			A_PRINTF("receive the suspend command...\n");
			// reboot.....
			A_USB_JUMP_BOOT();	        
		}

	} else {
		m_origUsbfifoRecvCmd(buf);
	}
}
Ejemplo n.º 13
0
main(int argc, char *argv[])
{
  DWORD time_out = 0;
  char *u3_is_device_available;
#if 0 
  char **envptr;
  char *envval;
# endif 
  u3_is_device_available = getenv("U3_IS_DEVICE_AVAILABLE");

  if(u3_is_device_available && !strncmp(u3_is_device_available, "true", 4))
    /* the device is available - wait for user to respond to any dialogs */
    time_out = INFINITE;
#if 0
  for(envptr = environmentvars; *envptr; envptr++) {
    envval = getenv(*envptr);

    MessageBox(NULL,
	       envval ? envval : "NULL",
	       *envptr,
	       MB_YESNO|MB_TOPMOST|MB_ICONQUESTION);
  }
#endif

  if(argc > 1) {

    if(!strncmp(argv[1], "hostConfigure", 13))
      host_configure();
    else if(!strncmp(argv[1], "appStart", 9))
      app_start(argc, argv);
    else if(!strncmp(argv[1], "appStop", 8))
      app_stop(time_out);
    else if(!strncmp(argv[1], "hostCleanUp", 11))
      host_clean_up();

  }

  exit(0);
}
Ejemplo n.º 14
0
int main(int argc, char *argv[])
{
    (void)argc;
    (void)argv;
    int res;
    int ret_val = 0;

    app_trace(TRACE_INFO, " << FAX HANDLING APPLICATION BU!!! >>");

    res = app_init();
    if(res)
    {
        app_trace(TRACE_ERR, "App init failed (%d)", res);
        ret_val = -1; goto _exit;
    }

    app_start();

    app_destroy();

_exit:
    return ret_val;
}
Ejemplo n.º 15
0
int main() {
  // Stop watchdog timer
  WDTCTL = WDTPW + WDTHOLD;

  app_setup();

#ifndef SIMULATION
  // Initialize UART
  UART_BAUD = BAUD;
  UART_CTL  = UART_EN | UART_IEN_RX;
#endif

  app_start();

  // Clear the timer and enable timer interrupt
  __enable_interrupt();

#ifndef SIMULATION
  puts("ADT7310P32S16L Test\r");   // adds a \n itself
  
  printf("Current value: ");
  PrintSensorValue();
  printf("\r\n");
#endif

  // infinite loop
  while (1) {
    LPM3;   // switch off MClk (CPU, RAMs) and SMClk (peripherals), Reconf.Module is directly clocked by Clk_i
#ifndef SIMULATION
    printf("New value: ");
    PrintSensorValue();
    printf("\r\n");
#endif
  }

  return 0;
}
Ejemplo n.º 16
0
void app_run(void) {
    typedef void (*app_ptr_t)(void) __attribute__ ((noreturn));
    app_ptr_t app_start = (app_ptr_t)0;
    app_start();
}
Ejemplo n.º 17
0
/*
 * Default startup routine.
 * Call it from main()
 * Look at squat.c
 */
int
main_stub(int argc, char *argv[])
{
	void *self = 0;
	char *name = 0;
	struct app_t *app = 0;
	struct api_t *api = 0;
	app_getopt opts;

	opts.argc = argc;
	opts.argv = argv;

	if(lt_dlinit())
		return E_DL;

	self = lt_dlopen(NULL);

	if(NULL == self)
		return E_DL;

	/* Get '-a' ie. '--app' */
	name = get_app_opt(argc, argv);

	/* Reflection? */
	if(name)
		api = lt_dlsym(self, name);
	else
		api = lt_dlsym(self, "sipware"); 

	if(NULL == api)
		return E_APP;

	/*
	 * As the matter of fact we got api, not app
	 */
	app = api->data;

	/*
	 * Try to boot
	 */
	if(app->data)
	{
		struct module_t *m = app->data;

		if(m->boot)
			ctx = m->boot(NULL, app, &opts);
		else
			ctx = app_boot(NULL, app, &opts);
	}
	else
		ctx = app_boot(NULL, app, &opts);

	if(NULL == ctx)
		return E_CTX;

	/* Set log using command line arg */
	app_set_log(app,app_opt_check(app, 'd', argc, argv), CTX_STDERR);

	/* Module path */
        set_path(app->ctx, app_opt_check(app, 'P', argc, argv));

	if(NULL == get_path(app->ctx))
		return E_CONF;

	/* Config file */
        set_cfg_file(app->ctx, app_opt_check(app, 'f', argc, argv));

	if(NULL == get_cfg_file(app->ctx))
		return E_CONF;

	/* Init parsers subsystem */
	if(!parser_sys_init(app->ctx))
		return E_SYS;

	log(ctx,4,"Ok %s\n", app->name);

	/* Search for '-D' on command line */
	{
		char *dbg_ptr;

		dbg_ptr = app_opt_check(app, 'D', argc, argv);
		log(ctx,6,"Ok\n");

		/*
		 * Need better way to syslog (facility,prio,...)
		 * Hardcoded for now
		 */
		if(dbg_ptr)
		{	
			ctx->cfg->basic->debug = atoi(dbg_ptr);
			ctx->cfg->basic->prio = LOG_NOTICE;
			CLR_BIT(app->type, APP_DAEMON);
			openlog(NULL, LOG_PID|LOG_NDELAY, LOG_NOTICE);
			set_print_log(ctx, syslog);
			log(ctx, 0, "Daemon or not? %d\n", ctx->cfg->basic->debug);
		}
		else
		{
			dbg_ptr = app_opt_check(app, 'd', argc, argv);

			if(dbg_ptr)
			{
				ctx->cfg->basic->debug = atoi(dbg_ptr);
				ctx->cfg->basic->prio = atoi(dbg_ptr);
				set_print_log(ctx, lprint);
				log(ctx, 0, "daemon or not2? %d\n", ctx->cfg->basic->debug);
			}
			else
			{
				ctx->cfg->basic->debug = 1;
				ctx->cfg->basic->prio = 1;
			}
		}
	}

	/* Will start module->preload */
	if(app_preload(app, argc, argv))
		return E_APP;

	/* Start module->main */
	if(app_start(app, argc, argv))
		return E_APP; 

	if(app_finish(app, 0))
		log(ctx,0,"finish problem.\n");
	else
		log(ctx,0,"finish ok.\n");

        return E_NONE;
}
Ejemplo n.º 18
0
int main(void)
{
    app_start(0, NULL);
    return 0;
}
Ejemplo n.º 19
0
int main(){
    app_start(0, (char**)0);
    return 0;
}
void main(void) {
#else
int main(void) {
#endif
    
    uint32_t blcc;
    
    // Prevent optimizing of bootloader revision in progmem
    volatile uint16_t tmp2 = ATmega3290p_bl_rev;
    
    // Disable watchdog
    watchdog_disable();
    
    
    // Configuring LCD with Extern clock (TOSC, 32.768kHz)
    //                      32786 Hz          32786 Hz
    //  frame_rate = ------------------ = ------------- = 32 Hz
    //               8 * .prescl * .div     8 * 16 * 8
    //
    lcd_config_t lcd_config = LCD_DEFAULT_CONFIG;
    
    // Initialization
    if (true != avr_init()) {               // Generic MCU initialization
        error_handler();
    } else if (df_init() != 0) {            // Data flash initialization
        error_handler();
    } else if (lcd_init(lcd_config) != 0) { // Display
        error_handler();
    } else if (led_init() != 0) {           // Led
        error_handler();
    }
    
   
    /* start timer 2*/
    ASSR |= (1<<AS2);    // Asynchronous operation
    TCCR2A &= ~((1<<CS22)|(1<<CS21)|(1<<CS20));
    TCCR2A |= (1<<CS20);
    
    
    // Check shorting of "Factory default pins"
    uint8_t prr = PRR;
	PRR &= ~(1 << PRADC);
	DIDR1 &= ~((1 << AIN1D)|(1 << AIN0D));
	PRR = prr;
    
    BOOT_DDR |= (1 << BOOT_TX);  // Tx output
    BOOT_PORT &= ~(1 << BOOT_TX);  // Tx low
    
    BOOT_DDR &= ~(1 << BOOT_RX); // Rx input
    BOOT_PORT |= (1 << BOOT_RX); // Rx pullup on
    
    if ((BOOT_PIN & (1 << BOOT_RX)) != (1 << BOOT_RX)) { // Rx pin low?
        /* Check that RX goes high when TX is pulled high. */
        BOOT_PORT |= (1 << BOOT_TX);                            // Set Tx high
        
        nop();
        nop();
        nop();
        nop();
        
        if ((BOOT_PIN & (1 << BOOT_RX)) == (1 << BOOT_RX)) {    // Rx high?
            intvecs_to_boot(); // move interrutp vectors to boot section, and start boot loader
            sei();
            
            // Check supply voltage
            if (supply_voltage_read() < 2600) {
                lcd_puts("LOW BAT");
                error_handler();
            }
            
            BLCC_WRITE(BLCC_NORMAL_APP_START); // write communication channel in case abnormal exit of boot loader (power off etc.)
            
            lcd_symbol_set(LCD_SYMBOL_RAVEN);
            lcd_puts("WRITING");
            led_status_set(LED_FAST_BLINK);
            do_fw_upgrade(M3290P_FLASH_FD_IMG_ADR);

            // Signal ATmega3290p application program that FW upgrade is complete
            // This makes the application program continue upgrade ATmega1284p after booting
            BLCC_WRITE(BLCC_LOAD_FACTORY_DEFAULT);
            
            app_start();    // start application program
        }
    }
    
    // Read bootloader communication channel in EEPROM and take proper action
    BLCC_READ(blcc);
    if (blcc == BLCC_FW_UPGRADE_START_REQUEST_FROM_APP) {
        intvecs_to_boot(); // move interrutp vectors to boot section, and start boot loader
        sei();
        
        // Check supply voltage
        if (supply_voltage_read() < 2600) {
            lcd_puts("LOW BAT");
            error_handler();
        }
        
        BLCC_WRITE(BLCC_NORMAL_APP_START); // write communication channel in case abnormal exit of boot loader (power off etc.)
        
        lcd_symbol_set(LCD_SYMBOL_RAVEN);
        lcd_puts("WRITING");
        led_status_set(LED_FAST_BLINK);
        do_fw_upgrade(M3290P_FLASH_USR_IMG_ADR);
        
        // Signal ATmega3290p application program that FW upgrade is complete
        BLCC_WRITE(BLCC_FW_UPGRADE_COMPLETE);
        reboot();
    } else if (blcc == BLCC_FW_UPGRADE_COMPLETE) {
        BLCC_WRITE(BLCC_FW_UPGRADE_COMPLETE);
        sei();
        app_start();    // start application program
    } else if (blcc == BLCC_RESTART_REQUEST_FROM_APP) {
        /* Start application program*/
        BLCC_WRITE(BLCC_NORMAL_APP_START);
        sei();
        app_start();
    } else {
        /*else, start application program*/
        BLCC_WRITE(BLCC_NORMAL_APP_START);
        sei();
        app_start();
    }
}
Ejemplo n.º 21
0
int main(int argc, char **argv)
{
    app_start(argc, argv);
}
Ejemplo n.º 22
0
void monitor(void)
{
        ch = bootldrgetch();
        if(ch=='!') {
          ch = bootldrgetch();
          if(ch=='!') {

#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__)
            uint16_t extaddr;
#endif
            int i;
            uint8_t addrl, addrh;

#ifdef CRUMB128
            PGM_P welcome = {"ATmegaBOOT / Crumb128 - (C) J.P.Kyle, E.Lins - 050815\n\r"};
#elif defined PROBOMEGA128
            PGM_P welcome = {"ATmegaBOOT / PROBOmega128 - (C) J.P.Kyle, E.Lins - 050815\n\r"};
#elif defined SAVVY128
            PGM_P welcome = {"ATmegaBOOT / Savvy128 - (C) J.P.Kyle, E.Lins - 050815\n\r"};
#elif defined __AVR_ATmega1280__ 
            PGM_P welcome = {"ATmegaBOOT / Arduino Mega - (C) Arduino LLC - 090930\n\r" };
#endif

            /* turn on LED */
            LED_DDR |= _BV(LED);
            LED_PORT &= ~_BV(LED);

            /* print a welcome message and command overview */
            for(i=0; welcome[i] != '\0'; ++i) {
              myputch(welcome[i]);
            }

            /* test for valid commands */
            for(;;) {
              myputch('\n');
              myputch('\r');
              myputch(':');
              myputch(' ');

              ch = bootldrgetch();
              myputch(ch);

              /* toggle LED */
              if(ch == 't') {
                if(bit_is_set(LED_PIN,LED)) {
                  LED_PORT &= ~_BV(LED);
                  myputch('1');
                } else {
                  LED_PORT |= _BV(LED);
                  myputch('0');
                }
              } 

              /* read byte from address */
              else if(ch == 'r') {
                ch = bootldrgetch(); myputch(ch);
                addrh = gethex();
                addrl = gethex();
                myputch('=');
                ch = *(uint8_t *)((addrh << 8) + addrl);
                puthex(ch);
              }

              /* write a byte to address  */
              else if(ch == 'w') {
                ch = bootldrgetch(); myputch(ch);
                addrh = gethex();
                addrl = gethex();
                ch = bootldrgetch(); myputch(ch);
                ch = gethex();
                *(uint8_t *)((addrh << 8) + addrl) = ch;
              }

              /* read from uart and echo back */
              else if(ch == 'u') {
                for(;;) {
                  myputch(bootldrgetch());
                }
              }
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__)
              /* external bus loop  */
              else if(ch == 'b') {
                myputch('b');
                myputch('u');
                myputch('s');
                MCUCR = 0x80;
                XMCRA = 0;
                XMCRB = 0;
                extaddr = 0x1100;
                for(;;) {
                  ch = *(volatile uint8_t *)extaddr;
                  if(++extaddr == 0) {
                    extaddr = 0x1100;
                  }
                }
              }
#endif

              else if(ch == 'j') {
                app_start();
              }

            } /* end of monitor functions */

          }
        }
      }