//============================================================================// void WriteScalar_SILO(DBfile *dbfile, char *vname, char *mesh_name, float *var, int *dims) { // This function writes the data in var to the .silo database file int silodims[ndims] = {dims[0],dims[1],dims[2]+2*Nghost+1}; float *silovar; if(halfcyl){ AddFinalZone_Var(var,silovar,dims); }else{ // Add the SILO ghost zones to the data: AddGhostZones_Var(var,silovar,dims); } // Remove nonzero elements below a threshold (e.g. 1e-10): Set_Zeros(silovar,silodims[0]*silodims[1]*silodims[2]); // Write the data to the .silo file: DBPutQuadvar1(dbfile, vname, mesh_name, silovar, silodims, ndims, NULL, 0, DB_FLOAT, DB_NODECENT, NULL); delete [] silovar; }
int main(void) { uint32_t REVID_reg=HWREG(SYSCONFIG_REG_BASE); if(REVID_reg!=0x4E840102) { printf("fail to read revid ,error debug "); SW_BREAKPOINT ; return 1; } dsp_delay(200); EMIF_init(); UPP_PINMUX(); test_fpga_reg(); // uint32_t bcnt= Loadfromfile(ptr); // int j=0; memset(recv_adc_buffer,0,UPP_RX_BCNT); TEST_uart(); // load_fpga(ptr,bcnt); init_9822(); fpga_upp_test(); config_upp(); int frcnt = 0; int cc=0; static int calc_cnt = 0; while(1) { config_upp(); calc_cnt++; recv_adc_buffer[2531]=1; upp_receive_fifo(recv_adc_buffer,UPP_RX_LNCNT,UPP_DMA_BCNT); cc=0; char show_str[50]; //送的数据速度太快,导致程序移植timeout, //好像和buffer一直没有被取出会导致overflow相关。如果程序不运行需要大量时间的函数就不会出现问题 while(1) { if(recv_adc_buffer[2531]!=1 ) { if (calc_cnt %loop_num ==1) { point_notclear = point_nclear_return_maxValue(recv_adc_buffer, 20, &MaxValue); leftpoint = bi_side_search_withMaxValue(recv_adc_buffer, point_notclear, 0, ratio, 5, MaxValue); rightpoint = bi_side_search_withMaxValue(recv_adc_buffer, point_notclear, 1, ratio, 5, MaxValue); Set_Zeros(buffer_int_data, leftpoint - 5, rightpoint + 5); Sum_To_Int(recv_adc_buffer, buffer_int_data, leftpoint - 5, rightpoint + 5); } else if(calc_cnt %loop_num != 0) { Sum_To_Int(recv_adc_buffer, buffer_int_data, leftpoint - 5, rightpoint + 5); //sprintf(show_str, "location = %d\t\t",frcnt); //str2com(show_str); } else { Sum_To_Int(recv_adc_buffer, buffer_int_data, leftpoint - 5, rightpoint + 5); //dsp_delay(500000); //Data_Average_Int(buffer_int_data, buffer_tmp , 4, 790, 850); region_gauss_filter(buffer_int_data, leftpoint - 5, rightpoint + 5,buffer_float_data); //point_notclear = point_nclear_return_maxValue(recv_adc_buffer, 20, &MaxValue); leftpoint = bi_side_search_float(buffer_float_data, point_notclear, 0 , ratio, 5, MaxValue*4); rightpoint = bi_side_search_float(buffer_float_data, point_notclear, 1 , ratio, 5, MaxValue*4); mylocation = zhixin_upward(buffer_float_data, leftpoint, rightpoint, ratio ,MaxValue); kalman_result = kalman_realtime(mylocation, &kalman_preData, &kalman_p); kalman_loop_num++; //kalman_result1 = kalman_realtime(kalman_result, &kalman_preData1, &kalman_p1); //kalman_result2 = kalman_realtime(kalman_result1, &kalman_preData2, &kalman_p2); //mylocation = 0.235; //sprintf(show_str, "location = %f\t\t",kalman_result2); //str2com(show_str); // Set_Zeros(buffer_int_data,745,865); // memset(buffer_int_data,0,sizeof(uint16_t) * 900); } // frcnt++; if(frcnt%2000 ==0) { uint16_t r0= fpga_read_reg(UPP_CNT); sprintf(show_str, " A %d %d %d ",frcnt,r0,cc); str2com(show_str); } break; } cc++; if(cc>80000) { uint16_t r0= fpga_read_reg(UPP_CNT); sprintf(show_str, "B %d %d %d ",calc_cnt,r0,cc); str2com(show_str); break; } } //str2com(show_str); continue; // SW_BREAKPOINT ; // printf("end of ccd \n"); // printf("over windows %d %d %d %d \n",light[24],light[25],light[2028],light[2029]); } }