コード例 #1
0
static int thread_proc(void *arg)
#endif /* HAVE_PTHREAD */
{
	struct threadpool *tp = (struct threadpool *) arg;
	int index;

	enter_critical_section(tp);
	index = ++tp->thread_index;

	for(;;) {
		tp->wait_count--;
		if (!tp->wait_count)
			signal_completion(tp);
		wait_for_exec(tp);
		if (tp->thread_die)
			break;
		exec_loop(tp, index);
	}

	if (!(--tp->wait_count))
		signal_completion(tp);
	leave_critical_section(tp);

	return 0;
}
コード例 #2
0
void tp_exec(threadpool_t pool, LIST *list)
{
	struct threadpool *tp = (struct threadpool *) pool;

	enter_critical_section(tp);
	tp->list = list->first;
	/* tp->wait_count = list->size; */
	tp->wait_count = tp->thread_count;
	signal_exec(tp);
	exec_loop(tp, 0);
	if (tp->wait_count)
		wait_for_completion(tp);
	leave_critical_section(tp);
}
コード例 #3
0
ファイル: main_m0.c プロジェクト: bebtio/pixy-dev
int main(void)
{
	//CTIMER_DECLARE();
#if 0
	uint32_t memory = SRAM1_LOC;
	uint32_t lut = SRAM1_LOC;

	//while(1);
	memset((void *)QQ_LOC, 0x01, 0x3000);
	g_qqueue->writeIndex = 0;
	g_qqueue->produced = 0;
	g_qqueue->consumed = 0;

 	while(1)
 		getRLSFrame(&memory, &lut); 
#endif
#if 0
	int i = 0x12345678;
	foo(&i);
	printf("%d\n", i);
	while(1);
#endif
#if 0
	int i;
	uint32_t lut = SRAM1_LOC;
 	uint32_t memory = SRAM1_LOC+0x1000;
	uint8_t *plut = (uint8_t *)lut;
	for (i=0; i<0x4000; i++)
		plut[i] = i%5==0 ? 1 : 0;
	
 	while(1)
 		getRLSFrame(&memory, &lut); 

#endif
#if 1
	_DBG("M0 start\n");

	chirpOpen();
	exec_init();
	frame_init();
	rls_init();

#if 0
	while(1)
	{
		if (g_foo)
			loop0();
	}
#endif

#if 0
	vsync();
#endif
#if 0
	//while(g_loop);
	uint8_t type = CAM_GRAB_M1R2;
	uint32_t memory = SRAM1_LOC;
	uint16_t offset = 0;
	uint16_t width = 320;
	uint16_t height = 200;
	while(1)
	{
		 getFrame(&type, &memory, &offset, &offset, &width, &height);
		 i++;

		 if (i%50==0)
		 {
			 _DBD32(i), _CR();
		 }
	}
#endif
	//printf("M0 ready\n");
	exec_loop();
#endif
#if 0
	while(1)
	{
		CTIMER_START();
		syncM1((uint32_t *)&LPC_GPIO_PORT->PIN[1], 0x2000);
		CTIMER_STOP();
		
		printf("%d\n", CTIMER_GET());
	}	
#endif
#if 0
{
	uint32_t i;
	uint8_t *lut = (uint8_t *)SRAM1_LOC + 0x10000;
	uint32_t memory = SRAM1_LOC;
	uint32_t size = SRAM1_SIZE/2;
	for (i=0; i<0x10000; i++)
		lut[i] = 0;
	lut[0xb400] = 0;
	lut[0xb401] = 1;
	lut[0xb402] = 1;
	lut[0xb403] = 1;
	lut[0xb404] = 0;
	lut[0xb405] = 1;
	lut[0xb406] = 1;
	lut[0xb407] = 0;
	lut[0xb408] = 0;
	lut[0xb409] = 0;

	while(1)
 		getRLSFrame(&memory, &size); //, (uint32_t *)&lut);
}
#endif

return 0;
}
コード例 #4
0
ファイル: simengine_api.c プロジェクト: joshuaecook/simengine
// simEngine API: simengine_runmodel()
//
//    executes the model for the given parameters, states and simulation time
EXTERN_C
simengine_result *simengine_runmodel(double start_time, double stop_time, unsigned int num_models, double *inputs, double *states, simengine_alloc *alloc){
  CDATAFORMAT model_states[NUM_MODELS * NUM_STATES];
  CDATAFORMAT parameters[NUM_MODELS * NUM_INPUTS];
  unsigned int stateid;
  unsigned int modelid;
  unsigned int inputid;
  unsigned int outputid;
	     
  // Set up allocation functions
  if(alloc){
    se_alloc.malloc = alloc->malloc;
    se_alloc.realloc = alloc->realloc;
    se_alloc.free = alloc->free;
  }
	     
  // Create result structure
  simengine_result *seresult = (simengine_result*)se_alloc.malloc(sizeof(simengine_result));
	     
  // Couldn't allocate return structure, return NULL
  if(!seresult) return NULL;
	     
  // Check that the number of models matches
  if(num_models != semeta.num_models){
    seresult->status = ERRNUMMDL;
    seresult->status_message = (char*) simengine_errors[ERRNUMMDL];
    seresult->outputs = NULL;
    seresult->final_states = NULL;
    seresult->final_time = NULL;
    return seresult;
  }
	     
  // Allocate return structures
  if(seint.num_outputs){
    seresult->outputs = (simengine_output*)se_alloc.malloc(semeta.num_models * seint.num_outputs * sizeof(simengine_output));
  }
  else{
    seresult->outputs = NULL;
  }
  if(seint.num_states){
    seresult->final_states = (double*)se_alloc.malloc(semeta.num_models * seint.num_states * sizeof(double));
  }
  else{
    seresult->final_states = NULL;
  }
  seresult->final_time = (double*)se_alloc.malloc(semeta.num_models * sizeof(double));
  if((seint.num_outputs && !seresult->outputs) || (seint.num_states && !seresult->final_states) ||!seresult->final_time){
    seresult->status = ERRMEM;
    seresult->status_message = (char*) simengine_errors[ERRMEM];
    seresult->outputs = NULL;
    seresult->final_states = NULL;
    seresult->final_time = NULL;
    return seresult;
  }
	     
  // Copy inputs and state initial values to internal representation
  for(modelid=0; modelid<semeta.num_models; modelid++){
    for(stateid=0;stateid<seint.num_states;stateid++){
      model_states[TARGET_IDX(seint.num_states, semeta.num_models, stateid, modelid)] = states[AS_IDX(seint.num_states, semeta.num_models, stateid, modelid)];
    }
    for(inputid=0;inputid<seint.num_inputs;inputid++){
      parameters[TARGET_IDX(seint.num_inputs, semeta.num_models, inputid, modelid)] = inputs[AS_IDX(seint.num_inputs, semeta.num_models, inputid, modelid)];
    }
  }
	     
  // Initialization of output structures
  for (modelid = 0; modelid < semeta.num_models; ++modelid) {
    for (outputid = 0; outputid < seint.num_outputs; ++outputid) {
      seresult->outputs[AS_IDX(seint.num_outputs, semeta.num_models, outputid, modelid)].alloc = START_SIZE;
      seresult->outputs[AS_IDX(seint.num_outputs, semeta.num_models, outputid, modelid)].num_quantities = seint.output_num_quantities[outputid];
      seresult->outputs[AS_IDX(seint.num_outputs, semeta.num_models, outputid, modelid)].num_samples = 0;
      seresult->outputs[AS_IDX(seint.num_outputs, semeta.num_models, outputid, modelid)].data = (double*)se_alloc.malloc(START_SIZE*seint.output_num_quantities[outputid]*sizeof(double));
    }
  }

  // Initialize the solver properties
  solver_props *props = init_solver_props(start_time, stop_time, parameters, model_states, seresult->outputs);
  // Run the model
  seresult->status = exec_loop(props);
  seresult->status_message = (char*) simengine_errors[seresult->status];
	     
  // Copy state values back to state initial value structure
  for(modelid=0; modelid<semeta.num_models; modelid++){
    seresult->final_time[modelid] = props->time[modelid]; // Time from the first solver
    for(stateid=0;stateid<seint.num_states;stateid++){
      seresult->final_states[AS_IDX(seint.num_states, semeta.num_models, stateid, modelid)] = model_states[TARGET_IDX(seint.num_states, semeta.num_models, stateid, modelid)];
    }
  }

  free_solver_props(props);

  return seresult;
}
コード例 #5
0
ファイル: main_m4.cpp プロジェクト: BallisticPain/pixy
int main(void) 
{

// 	pixyInit(SRAM3_LOC, &LR0[0], sizeof(LR0));
#if 0
	pixyInit();

	cc_init(g_chirpUsb);
	ser_init();
	exec_init(g_chirpUsb);
#endif

#if 1		/* test loop */
	pixyInit();
	exec_init(g_chirpUsb);
#if 0
	int i = 0;
	cam_setMode(1);
	while(1)
	{
		//uint8_t reg = cam_getRegister(0x0a);
		g_chirpUsb->service();
		cprintf("hello world %d\n", i++);
	}
#endif
#if 0
	while(1)
	{
		uint8_t *frame = (uint8_t *)SRAM1_LOC;
		int res;

		res = cam_getFrame(frame, SRAM1_SIZE, CAM_GRAB_M1R2, 0, 0, CAM_RES2_WIDTH, CAM_RES2_HEIGHT);
		i++;
		if (i%50==0)
		{
			lpc_printf("%d\n", i);
		}

	}
#endif
#endif

#if 1
	exec_addProg(&g_progBlobs);
	ptLoadParams();
	exec_addProg(&g_progPt);
	exec_addProg(&g_progVideo, true);
	exec_loop();
#endif

#if 0

	//prm_format();
	ColorModel model, *model2;
	uint32_t len;
	model.m_hue[0].m_slope = 1.0;
	model.m_hue[0].m_yi = 2.0;
	model.m_hue[1].m_slope = 3.0;
	model.m_hue[1].m_yi = 4.0;
	model.m_sat[0].m_slope = 5.0;
	model.m_sat[0].m_yi = 6.0;
	model.m_sat[1].m_slope = 7.0;
	model.m_sat[1].m_yi = 8.0;
	prm_add("signature1", "Color signature 1", INTS8(sizeof(ColorModel), &model), END);
	prm_set("signature1", INTS8(sizeof(ColorModel), &model), END);
	model.m_hue[0].m_slope = 9.0;
	model.m_hue[0].m_yi = 10.0;
	model.m_hue[1].m_slope = 11.0;
	model.m_hue[1].m_yi = 12.0;
	model.m_sat[0].m_slope = 13.0;
	model.m_sat[0].m_yi = 14.0;
	model.m_sat[1].m_slope = 15.0;
	model.m_sat[1].m_yi = 16.0;
	prm_add("signature2", "Color signature 2", INTS8(sizeof(ColorModel), &model), END);
	prm_set("signature2", INTS8(sizeof(ColorModel), &model), END);
	prm_get("signature1", &len, &model2, END);
	model.m_hue[0].m_slope = 17.0;
	model.m_hue[0].m_yi = 18.0;
	model.m_hue[1].m_slope = 19.0;
	model.m_hue[1].m_yi = 20.0;
	model.m_sat[0].m_slope = 21.0;
	model.m_sat[0].m_yi = 22.0;
	model.m_sat[1].m_slope = 23.0;
	model.m_sat[1].m_yi = 24.0;
	prm_get("signature1", &len, &model2, END);

	prm_set("signature1", INTS8(sizeof(ColorModel), &model), END);
	prm_get("signature1", &len, &model2, END);
	prm_get("signature2", &len, &model2, END);
	 

#endif
#if 0
	#define DELAY 1000000
	rcs_setFreq(100);
	rcs_setLimits(0, -200, 200);
	rcs_setLimits(1, -200, 200);
	while(1)
	{
		rcs_setPos(0, 0);
		delayus(DELAY);
		rcs_setPos(0, 500);
		delayus(DELAY);
		rcs_setPos(0, 1000);
		delayus(DELAY);
		rcs_setPos(1, 0);
		delayus(DELAY);
		rcs_setPos(1, 500);
		delayus(DELAY);
		rcs_setPos(1, 1000);
		delayus(DELAY);
	}

#endif
#if 0
	while(1)
	{
		g_chirpUsb->service();
		handleButton();
	}
#endif
}
コード例 #6
0
ファイル: simengine_api.c プロジェクト: joshuaecook/simengine
// simengine_runmodel()
//
//    executes the model for the given parameters, states and simulation time
simengine_result *simengine_runmodel(simengine_opts *opts){
  double start_time = opts->start_time;
  double stop_time = opts->stop_time;
  unsigned int num_models = opts->num_models;
  const char *outputs_dirname = opts->outputs_dirname;

  CDATAFORMAT model_states[PARALLEL_MODELS * NUM_STATES];
  unsigned int stateid;
  unsigned int modelid;

  unsigned int models_executed;
  unsigned int models_per_batch;

  double *progress;
  int progress_fd;

  int output_fd;

  int resuming = 0;
  int random_initialized = 0;

# if defined TARGET_GPU
  gpu_init();
# endif

  open_progress_file(outputs_dirname, &progress, &progress_fd, num_models);
	     
  // Create result structure
  simengine_result *seresult = (simengine_result*)malloc(sizeof(simengine_result));
	     
  // Couldn't allocate return structure, return NULL
  if(!seresult) return NULL;
	     
  if(seint.num_states){
    seresult->final_states = (double*)malloc(num_models * seint.num_states * sizeof(double));
  }
  else{
    seresult->final_states = NULL;
  }
  seresult->final_time = (double*)malloc(num_models * sizeof(double));
  if((seint.num_states && !seresult->final_states) ||!seresult->final_time){
    seresult->status = ERRMEM;
    seresult->status_message = (char*) simengine_errors[ERRMEM];
    seresult->final_states = NULL;
    seresult->final_time = NULL;
    return seresult;
  }

  init_output_buffers(outputs_dirname, &output_fd);

  // Run the parallel simulation repeatedly until all requested models have been executed
  for(models_executed = 0 ; models_executed < num_models; models_executed += PARALLEL_MODELS){
    models_per_batch = MIN(num_models - models_executed, PARALLEL_MODELS);
    
    // Copy inputs and state initial values to internal representation
    unsigned int modelid_offset = global_modelid_offset + models_executed;
#if NUM_CONSTANT_INPUTS > 0
#if defined TARGET_GPU
    host_constant_inputs = (CDATAFORMAT *)malloc(PARALLEL_MODELS * NUM_CONSTANT_INPUTS * sizeof(CDATAFORMAT));
#else
    host_constant_inputs = constant_inputs;
#endif
#else
    CDATAFORMAT *host_constant_inputs = NULL;
#endif

#if NUM_SAMPLED_INPUTS > 0
#if defined TARGET_GPU
    host_sampled_inputs = (sampled_input_t *)malloc(STRUCT_SIZE * NUM_SAMPLED_INPUTS * sizeof(sampled_input_t));
#else
    host_sampled_inputs = sampled_inputs;
#endif
#else
    sampled_input_t *host_sampled_inputs = NULL;
#endif

    resuming = initialize_states(model_states, outputs_dirname, num_models, models_per_batch, modelid_offset);
    initialize_inputs(host_constant_inputs, host_sampled_inputs, outputs_dirname, num_models, models_per_batch, modelid_offset, start_time);

#if defined TARGET_GPU && NUM_CONSTANT_INPUTS > 0
    CDATAFORMAT *g_constant_inputs;
    cutilSafeCall(cudaGetSymbolAddress((void **)&g_constant_inputs, constant_inputs));
    cutilSafeCall(cudaMemcpy(g_constant_inputs, host_constant_inputs, PARALLEL_MODELS * NUM_CONSTANT_INPUTS * sizeof(CDATAFORMAT), cudaMemcpyHostToDevice));
#endif

#if defined TARGET_GPU && NUM_SAMPLED_INPUTS > 0
    sampled_input_t *g_sampled_inputs;
    cutilSafeCall(cudaGetSymbolAddress((void **)&g_sampled_inputs, sampled_inputs));
    cutilSafeCall(cudaMemcpy(g_sampled_inputs, host_sampled_inputs, STRUCT_SIZE * NUM_SAMPLED_INPUTS * sizeof(sampled_input_t), cudaMemcpyHostToDevice));
#endif

    // Initialize the solver properties and internal simulation memory structures
    solver_props *props = init_solver_props(start_time, stop_time, models_per_batch, model_states, models_executed+global_modelid_offset);

    // Initialize random number generator
    if (!random_initialized || opts->seeded) {
      random_init(models_per_batch);
      random_initialized = 1;
    }

    // If no initial states were passed in
    if(!resuming){
      if(seint.num_states > 0){
	// Initialize default states in next_states
	for(modelid=0;modelid<models_per_batch;modelid++){
	  init_states(props, modelid);
	  // Copy states from next_states to model_states
	  unsigned int iterid;
	  for(iterid=0;iterid<seint.num_iterators;iterid++){
	    solver_writeback(&props[iterid], modelid);
	  }
	}
      }
    }

    // Run the model
    seresult->status = exec_loop(props, outputs_dirname, progress + models_executed, resuming);
    seresult->status_message = (char*) simengine_errors[seresult->status];

    // Copy the final time from simulation
    for(modelid=0; modelid<models_per_batch; modelid++){
      seresult->final_time[models_executed + modelid] = props->time[modelid]; // Time from the first solver
    }

    // Free all internal simulation memory and make sure that model_states has the final state values
    free_solver_props(props, model_states);

    // Copy state values back to state initial value structure
    for(modelid=0; modelid<models_per_batch; modelid++){
      for(stateid=0;stateid<seint.num_states;stateid++){
	seresult->final_states[AS_IDX(seint.num_states, num_models, stateid, models_executed + modelid)] = model_states[TARGET_IDX(seint.num_states, PARALLEL_MODELS, stateid, modelid)];
      }
    }
  }

  close_progress_file(progress, progress_fd, num_models);
  clean_up_output_buffers(output_fd);

  return seresult;
}
コード例 #7
0
ファイル: main_m0.c プロジェクト: DapperFactory/pixy
int main(void)
{
	//CTIMER_DECLARE();
#if 0
	uint32_t memory = SRAM1_LOC;
	uint32_t lut = SRAM1_LOC;

	//while(1);
	memset((void *)QQ_LOC, 0x01, 0x3000);
	g_qqueue->writeIndex = 0;
	g_qqueue->produced = 0;
	g_qqueue->consumed = 0;

 	while(1)
 		getRLSFrame(&memory, &lut); 
#endif
#if 0
	int i = 0x12345678;
	foo(&i);
	printf("%d\n", i);
	while(1);
#endif
#if 0
	int i;
	uint32_t lut = SRAM1_LOC;
 	uint32_t memory = SRAM1_LOC+0x1000;
	uint8_t *plut = (uint8_t *)lut;
	for (i=0; i<0x4000; i++)
		plut[i] = i%5==0 ? 1 : 0;
	
 	while(1)
 		getRLSFrame(&memory, &lut); 

#endif
#if 1
	printf("M0 start\n");

	chirpOpen();
	exec_init();
	frame_init();
	rls_init();

	//printf("M0 ready\n");
	exec_loop();
#endif
#if 0
	while(1)
	{
		CTIMER_START();
		syncM1((uint32_t *)&LPC_GPIO_PORT->PIN[1], 0x2000);
		CTIMER_STOP();
		
		printf("%d\n", CTIMER_GET());
	}	
#endif
#if 0
{
	uint32_t i;
	uint8_t *lut = (uint8_t *)SRAM1_LOC + 0x10000;
	uint32_t memory = SRAM1_LOC;
	uint32_t size = SRAM1_SIZE/2;
	for (i=0; i<0x10000; i++)
		lut[i] = 0;
	lut[0xb400] = 0;
	lut[0xb401] = 1;
	lut[0xb402] = 1;
	lut[0xb403] = 1;
	lut[0xb404] = 0;
	lut[0xb405] = 1;
	lut[0xb406] = 1;
	lut[0xb407] = 0;
	lut[0xb408] = 0;
	lut[0xb409] = 0;

	while(1)
 		getRLSFrame(&memory, &size); //, (uint32_t *)&lut);
}
#endif
}
コード例 #8
0
ファイル: simengine_api.c プロジェクト: joshuaecook/simengine
// simEngine API: simengine_runmodel()
//
//    executes the model for the given parameters, states and simulation time
EXTERN_C
simengine_result *simengine_runmodel(double start_time, double stop_time, unsigned int num_models, double *inputs, double *states, simengine_alloc *alloc){
  CDATAFORMAT model_states[PARALLEL_MODELS * NUM_STATES];
  CDATAFORMAT parameters[PARALLEL_MODELS * NUM_INPUTS];
  unsigned int stateid;
  unsigned int modelid;
  unsigned int inputid;
  unsigned int outputid;

  int models_executed;
  int models_per_batch;


  // Seed the entropy source
  seed_entropy_with_time();

	     
  // Set up allocation functions
  if(alloc){
    se_alloc.malloc = alloc->malloc;
    se_alloc.realloc = alloc->realloc;
    se_alloc.free = alloc->free;
  }
	     
  // Create result structure
  simengine_result *seresult = (simengine_result*)se_alloc.malloc(sizeof(simengine_result));
	     
  // Couldn't allocate return structure, return NULL
  if(!seresult) return NULL;
	     
  // Allocate return structures
  if(seint.num_outputs){
    seresult->outputs = (simengine_output*)se_alloc.malloc(num_models * seint.num_outputs * sizeof(simengine_output));
  }
  else{
    seresult->outputs = NULL;
  }
  if(seint.num_states){
    seresult->final_states = (double*)se_alloc.malloc(num_models * seint.num_states * sizeof(double));
  }
  else{
    seresult->final_states = NULL;
  }
  seresult->final_time = (double*)se_alloc.malloc(num_models * sizeof(double));
  if((seint.num_outputs && !seresult->outputs) || (seint.num_states && !seresult->final_states) ||!seresult->final_time){
    seresult->status = ERRMEM;
    seresult->status_message = (char*) simengine_errors[ERRMEM];
    seresult->outputs = NULL;
    seresult->final_states = NULL;
    seresult->final_time = NULL;
    return seresult;
  }

  // Run the parallel simulation repeatedly until all requested models have been executed
  for(models_executed = 0 ; models_executed < num_models; models_executed += PARALLEL_MODELS){
    models_per_batch = MIN(num_models - models_executed, PARALLEL_MODELS);
    
    // Copy inputs and state initial values to internal representation
    for(modelid=0; modelid<models_per_batch; modelid++){
      for(stateid=0;stateid<seint.num_states;stateid++){
	model_states[TARGET_IDX(seint.num_states, PARALLEL_MODELS, stateid, modelid)] = states[AS_IDX(seint.num_states, num_models, stateid, models_executed + modelid)];
      }
      for(inputid=0;inputid<seint.num_inputs;inputid++){
	parameters[TARGET_IDX(seint.num_inputs, PARALLEL_MODELS, inputid, modelid)] = inputs[AS_IDX(seint.num_inputs, num_models, inputid, models_executed + modelid)];
      }
    }
	     
    // Initialization of output structures
    for (modelid = 0; modelid < models_per_batch; ++modelid) {
      for (outputid = 0; outputid < seint.num_outputs; ++outputid) {
	seresult->outputs[AS_IDX(seint.num_outputs, num_models, outputid, models_executed + modelid)].alloc = START_SIZE;
	seresult->outputs[AS_IDX(seint.num_outputs, num_models, outputid, models_executed + modelid)].num_quantities = seint.output_num_quantities[outputid];
	seresult->outputs[AS_IDX(seint.num_outputs, num_models, outputid, models_executed + modelid)].num_samples = 0;
	seresult->outputs[AS_IDX(seint.num_outputs, num_models, outputid, models_executed + modelid)].data = (double*)se_alloc.malloc(START_SIZE*seint.output_num_quantities[outputid]*sizeof(double));
      }
    }

    // Initialize the solver properties and internal simulation memory structures
    solver_props *props = init_solver_props(start_time, stop_time, models_per_batch, parameters, model_states, &seresult->outputs[AS_IDX(seint.num_outputs, num_models, 0, models_executed)]);
    // Run the model
    seresult->status = exec_loop(props);
    seresult->status_message = (char*) simengine_errors[seresult->status];
	     
    // Copy the final time from simulation
    for(modelid=0; modelid<models_per_batch; modelid++){
      seresult->final_time[models_executed + modelid] = props->time[modelid]; // Time from the first solver
    }

    // Free all internal simulation memory and make sure that model_states has the final state values
    free_solver_props(props, model_states);

    // Copy state values back to state initial value structure
    for(modelid=0; modelid<models_per_batch; modelid++){
      for(stateid=0;stateid<seint.num_states;stateid++){
	seresult->final_states[AS_IDX(seint.num_states, num_models, stateid, models_executed + modelid)] = model_states[TARGET_IDX(seint.num_states, PARALLEL_MODELS, stateid, modelid)];
      }
    }
  }

  return seresult;
}
コード例 #9
0
ファイル: main_m4.cpp プロジェクト: jaycle/pixy
int main(void)
{
	uint16_t major, minor, build;
	char *type;
	int i, res, count, count2;
	volatile uint32_t d;

	// insert a small delay so power supply can stabilize
	for (d=0; d<2500000; d++);

#ifdef KEIL
 	pixyInit(SRAM3_LOC, &LR0[0], sizeof(LR0));
#else
	pixyInit();
#endif

#if 0
	i = 0;
	char *foo;
	while(1)
	{
		foo = new (std::nothrow) char[128];
		if (foo==NULL)
		{
			_DBG("full\n");
			break;
		}
		else
		{
			_DBH32((int)foo); _DBG(" "); _DBH32(i); _DBG("\n");
		}
		i++;
	}
	while(1);
#endif
	// main init of hardware plus a version-dependent number for the parameters that will
	// force a format of parameter between version numbers.  

#ifndef LEGO
	rcs_init();
#endif
	cc_init(g_chirpUsb);
	ser_init();
	exec_init(g_chirpUsb);

#if 0
    exec_addProg(&g_progBlobs);
    ptLoadParams();
    exec_addProg(&g_progPt);
    exec_addProg(&g_progVideo, true);
#if 0
    cam_setMode(CAM_MODE1);
    while(1)
    	periodic();
#endif
#endif

#if 1
	// load programs
	exec_addProg(&g_progBlobs);
#ifndef LEGO
	// need to call this to get the pan/tilt parameters to display.  
	// We can make some properties modal, meaning they are only diaplayed when the program is running.
	// We might want to do this here, but this is good for now.  
	ptLoadParams();	 
	exec_addProg(&g_progPt);
#endif
#if 0
	chaseLoadParams();
	exec_addProg(&g_progChase);
#endif
	exec_addProg(&g_progVideo, true);

#if 1 
	// this code formats if the version has changed
	for (i=0, count=0, count2=0; i<25; i++)
	{
		res = prm_get("fwver", &major, &minor, &build, END);
		if (res>=0 && major==FW_MAJOR_VER && minor==FW_MINOR_VER && build==FW_BUILD_VER)
			count++;
		res = prm_get("fwtype", &type, END);
		if (res>=0 && strcmp(type, FW_TYPE)==0)
			count2++;
	}
	if (count==0 || count2==0)
		prm_format();
#endif

   	// check version
	prm_add("fwver", PRM_FLAG_INTERNAL, "", UINT16(FW_MAJOR_VER), UINT16(FW_MINOR_VER), UINT16(FW_BUILD_VER), END);
	prm_add("fwtype", PRM_FLAG_INTERNAL, "", STRING(FW_TYPE), END);

	exec_loop();
#endif
#if 0
	#define DELAY 1000000
	rcs_setFreq(100);
	rcs_setLimits(0, -200, 200);
	rcs_setLimits(1, -200, 200);
	while(1)
	{
		rcs_setPos(0, 0);
		delayus(DELAY);
		rcs_setPos(0, 500);
		delayus(DELAY);
		rcs_setPos(0, 1000);
		delayus(DELAY);
		rcs_setPos(1, 0);
		delayus(DELAY);
		rcs_setPos(1, 500);
		delayus(DELAY);
		rcs_setPos(1, 1000);
		delayus(DELAY);
	}

#endif
#if 0
	while(1)
	{
		g_chirpUsb->service();
		handleButton();
	}
#endif
}