int main(int argc, char* argv[]) { const char* title = "\nam18x library for ecap!\n"; int i; arm_intr_enable(); systick_start(); printk(title); printk("tary, compiled date : %s %s\n", __DATE__, __TIME__); psc_state_transition(PSC_GPIO, PSC_STATE_ENABLE); psc_state_transition(PSC_ECAP, PSC_STATE_ENABLE); gpio_set_mux(LCDC_BL_PWR, GPIO_DIR_OUTPUT); gpio_set_output1(LCDC_BL_PWR, GPIO_HIGH); #if 0 gpio_set_mux(LCDC_BL_PWM, GPIO_DIR_OUTPUT); gpio_set_output1(LCDC_BL_PWM, GPIO_HIGH); #else syscfg_pinmux(LCDC_BL_PWM_PINMUX); #endif ecap_init(ECAP_HW); for (i = 0;; i += 5) { if (i > 100) { i = 0; } ecap_conf->duty = i; ecap_set_conf(ECAP_HW, ecap_conf); systick_sleep(1000); } return 0; }
//void main_function(cyg_addrword_t data) { void * main_function(void * data) { int tmp = 1; region_information = (int *) malloc (4 * sizeof(int)); // create particles create_particle_filter(100, 10); /*slots = (int *) malloc (6 * sizeof(int)); slots[0] = 0; slots[1] = 1; slots[2] = 2; slots[3] = 3; slots[4] = 4; slots[5] = 5; set_importance_hw_static(1, &slots[0]);*/ /*rthread_attr_init(&hwthread_sorter_attr); rthread_attr_setslotnum(&hwthread_sorter_attr, 0); rthread_attr_setresources(&hwthread_sorter_attr, hwthread_sorter_resources, 3); reconos_hwthread_create( 15, // priority &hwthread_sorter_attr, // hardware thread attributes 0, // entry data (not needed) "MT_HW_SORT", // thread name hwthread_sorter_stack, // stack STACK_SIZE, // stack size &hwthread_sorter_handle, // thread handle &hwthread_sorter // thread object ); cyg_thread_resume( hwthread_sorter_handle );*/ //cyg_thread_delay(50); #ifndef NO_ETHERNET init_all_network_interfaces(); if(!eth0_up){ printf("failed to initialize eth0\naborting\n"); return NULL; } else{ printf(" eth0 up\n"); } diag_printf( "initializing ECAP interface..." ); ecap_init(); diag_printf( "done\n" ); // establish connection while (tmp == 1){ tmp = establish_connection(6666, region_information); } #endif // start read_new_frame cyg_semaphore_post(sem_read_new_frame_start); srand(1); // set region information for equal time measurements #define VIDEO 1 printf("\n#################################################"); printf("\n#################################################"); #ifdef VIDEO #if VIDEO==1 printf("\n########## S O C C E R V I D E O ############"); region_information[0] = 286; region_information[1] = 247; region_information[2] = 117; region_information[3] = 171; #else #if VIDEO==2 printf("\n######## F O O T B A L L V I D E O ##########"); region_information[0] = 255; region_information[1] = 252; region_information[2] = 23; region_information[3] = 41; #else #if VIDEO==3 printf("\n########## H O C K E Y V I D E O ############"); region_information[0] = 152; region_information[1] = 95; region_information[2] = 19; region_information[3] = 39; #else #if VIDEO==4 printf("\n########## H O C K E Y V I D E O (FULL PICTURE) ############"); region_information[0] = 159; region_information[1] = 119; region_information[2] = 320; region_information[3] = 240; #endif #endif #endif #endif #else printf("\n###### N O V I D E O D E F I N E D ########"); #endif printf("\n#################################################"); printf("\n#################################################\n"); // init particles init_particles(region_information, 4); // Output Object Region printf("\n\nx0 = %d\ny0 = %d\nwidth = %d\nheight = %d\n\n", region_information[0], region_information[1], region_information[2], region_information[3]); particle p; p.x = region_information[0]*PF_GRANULARITY; p.y = region_information[1]*PF_GRANULARITY; p.x0 = p.x; p.y0 = p.y; p.xp = p.x; p.yp = p.y; p.s = PF_GRANULARITY; p.sp = p.s; p.width = region_information[2]; p.height = region_information[3]; // get reference data get_reference_data(&p, &reference_data); init_reference_data (&reference_data); print_histogram(&reference_data); //print_histogram2(&reference_data); #ifdef STORE_VIDEO int i; printf("\n\nThe first %d Frames will be stored into Main Memory. Again this will take some time.\n", (int)MAX_FRAMES); // load first frames for(i=0; i<MAX_FRAMES-1; i++){ //switch_framebuffer(); read_frame(); } printf("\nFinished: The first %d Frames are stored in the Main Memory.\n", (int)MAX_FRAMES); #endif parameter_s = (int *) malloc (5 * sizeof(int)); parameter_s[0] = SIZE_X; parameter_s[1] = SIZE_Y; parameter_s[2] = 16384; // GRANULARITY / TRANS_STD_X parameter_s[3] = 8192; // GRANULARITY / TRANS_STD_Y parameter_s[4] = 16; // GRANULARITY / TRANS_STD_S parameter_o = (int *) malloc (2 * sizeof(int)); parameter_o[0] = SIZE_X; parameter_o[1] = SIZE_Y; slots = (int *) malloc (6 * sizeof(int)); slots[0] = 0; slots[1] = 1; slots[2] = 2; slots[3] = 3; slots[4] = 4; slots[5] = 5; // create sampling, importance, resampling thread printf("\n#################################################"); printf("\n#################################################"); #ifdef PARTITIONING #if PARTITIONING==1 printf("\n###### P A R T I T I O N I N G S W #######"); set_sample_sw(1); set_observe_sw(1); set_importance_sw(1); set_resample_sw(1); #else #if PARTITIONING==2 printf("\n#### P A R T I T I O N I N G H W I #####"); set_sample_sw(1); set_observe_sw(1); set_importance_sw(1); set_importance_hw_static(1, &slots[2]); set_resample_sw(1); #else #if PARTITIONING==3 printf("\n#### P A R T I T I O N I N G H W II #####"); set_sample_sw(1); set_observe_sw(1); set_importance_sw(1); set_importance_hw_static(2, &slots[2]); set_resample_sw(1); #else #if PARTITIONING==4 printf("\n#### P A R T I T I O N I N G H W O #####"); set_sample_sw(1); set_observe_sw(1); set_observe_hw_static(1, &slots[0], parameter_o, 2); set_importance_sw(1); set_resample_sw(1); #else #if PARTITIONING==5 printf("\n#### P A R T I T I O N I N G H W OO #####"); set_sample_sw(1); set_observe_sw(1); set_observe_hw_static(1, &slots[0], parameter_o, 2); set_importance_sw(1); set_resample_sw(1); #else #if PARTITIONING==6 printf("\n#### P A R T I T I O N I N G H W IO #####"); set_sample_sw(1); set_observe_sw(1); set_observe_hw_static(1, &slots[0], parameter_o, 2); set_importance_sw(1); set_importance_hw_static(1, &slots[2]); set_resample_sw(1); #else #if PARTITIONING==7 printf("\n#### P A R T I T I O N I N G H W IIO #####"); set_sample_sw(1); set_observe_sw(1); set_observe_hw_static(2, &slots[0], parameter_o, 2); set_importance_sw(1); set_importance_hw_static(1, &slots[2]); set_resample_sw(1); #else #if PARTITIONING==8 printf("\n#### P A R T I T I O N I N G H W IOO #####"); set_sample_sw(1); set_observe_sw(1); set_observe_hw_static(1, &slots[0], parameter_o, 2); set_importance_sw(1); set_importance_hw_static(2, &slots[2]); set_resample_sw(1); #else #if PARTITIONING==9 printf("\n#### P A R T I T I O N I N G H W IIOO #####"); set_sample_sw(1); set_observe_sw(1); set_observe_hw_static(2, &slots[0], parameter_o, 2); set_importance_sw(1); set_importance_hw_static(2, &slots[2]); set_resample_sw(1); #endif #endif #endif #endif #endif #endif #endif #endif #endif #else //printf("\n# N O P A R T I T I O N I N G D E F I N E D #"); printf("\n#### P A R T I T I O N I N G S W O #####"); reconf_mode_observation_on = TRUE; reconf_mode_observation_last_slot_on = FALSE; // I. SAMPLING //////////////////////////////////////// set_sample_sw(1); //set_sample_hw_dynamic(1, &hw_thread_s_circuit, parameter_s, 5); // II. OBSERVATION //////////////////////////////////// //set_observe_sw(1); set_observe_hw_dynamic(2, &hw_thread_o_circuit, parameter_o, 2); //set_observe_hw_dynamic(2, &hw_thread_o_circuit, parameter_o, 2); //set_observe_hw_static(1, &slots[2], parameter_o, 2); // III. IMPORTANCE //////////////////////////////////// set_importance_sw(1); //set_importance_hw_dynamic(1, &hw_thread_i_circuit); //set_importance_hw_dynamic(2, &hw_thread_i_circuit); set_importance_hw_static(1, &slots[2]); //[2] // IV. RESAMPLING ///////////////////////////////////// set_resample_sw(1); #endif printf("\n#################################################"); printf("\n#################################################\n"); /* // create and start sorting thread init_all_network_interfaces(); if(!eth0_up){ printf("failed to initialize eth0\naborting\n"); return NULL; } else{ printf(" eth0 up\n"); } diag_printf( "initializing ECAP interface..." ); ecap_init(); diag_printf( "done\n" );*/ //create_particle_filter(100, 10); //set_observe_hw_dynamic(2, &hw_thread_o_circuit, 0, 0); //sw_test_thread = (cyg_thread *) malloc (sizeof(cyg_thread)); //sw_test_thread_stack = (char *) malloc (sizeof(char) * STACK_SIZE); //sw_test_thread_handle = (cyg_handle_t *) malloc(sizeof(cyg_handle_t)); /*cyg_thread_create(PRIO, // scheduling info (eg pri) test_thread, // entry point function 0, // entry data "TEST", // optional thread name //sw_test_thread_stack, // stack base sw_measurement_thread_4_stack, // stack base STACK_SIZE, // stack size, //sw_test_thread_handle, // returned thread handle &sw_measurement_thread_4_handle, // returned thread handle //sw_test_thread // put thread here &sw_measurement_thread_4 // put thread here ); // resume thread cyg_thread_resume(sw_measurement_thread_4_handle);*/ //cyg_thread_resume(*sw_test_thread_handle); /*cyg_thread_create(PRIO, // scheduling info (eg pri) test_thread, // entry point function 0, // entry data "READ_MEASUREMENTS_4", // optional thread name sw_measurement_thread_4_stack, // stack base STACK_SIZE, // stack size, &sw_measurement_thread_4_handle, // returned thread handle &sw_measurement_thread_4 // put thread here ); // resume thread cyg_thread_resume(sw_measurement_thread_4_handle);*/ //cyg_thread_delay(1000); //diag_printf( "Reconfigure!\n" ); /*old_number_of_sortings = 0; start_sorting(); set_sort8k_hw_dynamicB(2); set_sort8k_hw_dynamic(2); cyg_thread_delay(1000);*/ start_particle_filter(); printf("\nstart particle filter"); return NULL; }