예제 #1
0
int main (int argc, char **argv)
{
	struct gengetopt_args_info opts;
	struct vfi_source *s;
	struct vfi_dev *dev;

	vfi_open(&dev,NULL,opts.timeout_arg);

	cmdline_parser_init(&opts);

	cmdline_parser(argc,argv,&opts);

	if (opts.file_given) {
		vfi_setup_file(dev,&s,fopen(opts.file_arg,"r"));
		process_commands(dev,s,&opts);
	}

	if (opts.inputs_num) {
		setup_inputs(dev,&s,&opts);
		process_commands(dev,s,&opts);
	}

	if (opts.interactive_given) {
		vfi_setup_file(dev,&s,stdin);
		process_commands(dev,s,&opts);
	}

	vfi_close(dev);

	return 0;
}
예제 #2
0
void
init_game(Memory *memory, GameState *game_state, Keys *keys, u64 time_us, u32 argc, char *argv[])
{
    game_state->init = true;

    game_state->single_step = false;
    game_state->sim_ticks_per_s = 5;

    game_state->finish_sim_step_move = false;

    if (argc > 1)
    {
        game_state->filename = argv[1];
    }
    else
    {
        printf("Error: No Maze filename supplied.\n");
        exit(1);
    }

    setup_inputs(keys, &game_state->inputs);

    load_bitmap(&game_state->particles.spark_bitmap, "particles/spark.bmp");
    load_bitmap(&game_state->particles.cross_bitmap, "particles/cross.bmp");
    load_bitmap(&game_state->particles.blob_bitmap,  "particles/blob.bmp");
    load_bitmap(&game_state->particles.smoke_bitmap, "particles/smoke.bmp");
    load_bitmap(&game_state->bitmaps.tile, "tile.bmp");
    load_bitmap(&game_state->bitmaps.font, "font.bmp");

    load_cell_bitmaps(&game_state->cell_bitmaps);

    strcpy(game_state->persistent_str, "Init!");

    init_ui(&game_state->ui);
}
예제 #3
0
extern "C" void setup()
{
  // first check if user wants to dialog
  // if not then ..
  // read config
  setup_outputs();
  setup_events();
  setup_inputs(); 
}
예제 #4
0
파일: ecu.c 프로젝트: mridley/emuecu
int main(void)
{
  uart0_init();

  setup_timers();

  setup_inputs();
  
  printf("EMU ECU\n");
 
  sei(); // Enable Global Interrupt

  uint16_t engine_stop_ms = ticks_ms();

  uint16_t loop_ms = 0;
  while (1)
  {
    uint16_t curr_rpm = rpm();
    if (!curr_rpm)
    {
      // keep the stop time sliding for when we attempt to start again
      if ((ticks_ms() - engine_stop_ms) > DWELL_TIME_MS)
      {
        engine_stop_ms = ticks_ms() - DWELL_TIME_MS;
      }
    }
    if (!ignition_enabled())
    {
      if (curr_rpm > 0 && (ticks_ms() - engine_stop_ms) > DWELL_TIME_MS)
      {
        ignition_enable();
        pump_enable();
        printf("engine start\n");
      }
    }
    else
    {
      if (curr_rpm > RPM_LIMIT)
      {
        printf("overrev - forced engine stop\n");
        ignition_disable();
        pump_disable();
        engine_stop_ms = ticks_ms();
      }
      if (!curr_rpm)
      {
        printf("engine has stopped\n");
        ignition_disable();
        pump_disable();
      }
    }

    uint16_t pwm_in = pwm_input();
    uint16_t pwm_out = clamp_pwm(pwm_in);
    set_pwm(0, pwm_out);

    const float t_scale = 1.0 / (float)(PWM_MAX - PWM_MIN);
    float throttle = (float)(pwm_out - PWM_MIN) * t_scale;

    update_inj_row(throttle);

    uint16_t ms = ticks_ms();
    //uint32_t us = ticks_us();

    if ((ms - loop_ms) >= 1000)
    {
      loop_ms += 1000;
      //start_adc();
      //int16_t a = analogue(0);

      //printf("pwm_in=%u pwm_out=%u us=%lu a0=%d\n", pwm_in, pwm_out, us, a);
      printf("pwm=%d throttle=%d rpm=%u ticks=%u \n", pwm_in, (int)(100*throttle), rpm(), inj_ticks_(rpm()));
    }
    //sleep(1000);
    //_delay_ms(1000);
  }  
}