示例#1
0
uint32_t fpga_upp_test(void)
{


	 // ADC_CFG 设置为4.是连续采集, 设置为0是按照帧数采集(参照下面采集帧数)

	fpga_write_reg(ADC_CFG,0x4);

	///  RUN_FR_CNT1  采集帧数,
	fpga_write_reg(RUN_FR_CNT1,0x1);
	fpga_write_reg(RUN_FR_CNT2,0x0);

	///  SELECT_CCD ==0 冰松的S12443_CCD       SELECT_CCD ==1   东芝的 TCD1254GFG
	fpga_write_reg(SELECT_CCD,0x0);



	 //CCD_TINT 积分时间   S12443_CCD ,设置范围50-5000 .积分实际单位为0.11us  .  东芝的 TCD1254GFG  设置范围为1-128   积分实际单位为10us.
	fpga_write_reg(CCD_TINT,100);


    //// uppp 的fifo 读取点。   设置范围100-1000 .   S12443_CCD :参考值 1000, TCD1254GFG :参考值 1000
	fpga_write_reg(FIFO_RD_ST,2000);
	/// CCD_ST 采集开始。
	fpga_write_reg(CCD_ST,0);
	dsp_delay(100);
	fpga_write_reg(CCD_ST,1);
    return 0;
}
示例#2
0
static inline void dsp_wait_hrdy(void)
{
	int i;

	i = 0;
#if defined(CONFIG_NETTA_6412)
	while (i < 1000 && (dsp_read_hpic_word(DSP_HPIC) & 0x08) == 0) {
#else
	while (i < 1000 && (dsp_read_hpic() & 0x08) == 0) {
#endif
		dsp_delay();
		i++;
	}
}

static inline void dsp_write_hpic_word(u32 addr, u32 val)
{
	volatile u16 *p;
#if defined(CONFIG_NETTA_6412)
	p = (volatile u16 *)((volatile u8 *)DSP_BASE + addr);
	p[0] = bit_invert((u16)(val >> 16));
	/* dsp_delay(); */

	p[1] = bit_invert((u16)val);
	/* dsp_delay(); */
#else
	p = (volatile u16 *)((volatile u8 *)DSP_BASE + addr);
	p[0] = (u16)(val >> 16);
	dsp_delay();

	p[1] = (u16)val;
	dsp_delay();
#endif
}

static inline void dsp_write_hpic_hi_hword(u32 addr, u16 val_h)
{
#if defined(CONFIG_NETTA_6412)
	*(volatile u16 *)((volatile u8 *)DSP_BASE + addr) = bit_invert(val_h);
#else

	*(volatile u16 *)((volatile u8 *)DSP_BASE + addr) = val_h;
#endif
}
示例#3
0
static inline u32 dsp_read_hpic_word(u32 addr)
{
	u32 val;
	volatile u16 *p;
#if defined(CONFIG_NETTA_6412)
	p = (volatile u16 *)((volatile u8 *)DSP_BASE + addr);

	val = ((u32) bit_invert(p[0]) << 16);
	/* dsp_delay(); */

	val |= bit_invert(p[1]);
	/* dsp_delay(); */
#else
	p = (volatile u16 *)((volatile u8 *)DSP_BASE + addr);

	val = ((u32) p[0] << 16);
	dsp_delay();

	val |= p[1];
	dsp_delay();
#endif
	return val;
}
示例#4
0
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]);


	 }

}