⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sensor.c

📁 arm嵌入式开发实例
💻 C
字号:
/**************************************************************************************************
                                                                         
 * FILENAME
 *     timer.c
 *
 * VERSION
 *     1.0
 *
 * DESCRIPTION
 *     This file contains the timer initial routine and timer ISR.
 *
 * DATA STRUCTURES
 *     None
 *
 * FUNCTIONS
 *     1. Fun_TimerX_ISR()
 *     2. Fun_TimerInitialize()
 *
 * HISTORY
 *     10/28/2003		 Ver 1.0 Created by Hank Ji
 *
 * REMARK
 *     None
 *     
 *************************************************************************************************/
#include <stdio.h>
#include "740defs.h"

#include "ist.h"

void Fun_delay_1us(void)
{
  uint8 i;
  for(i=0;i<50;i++)
  {
      nops;
  }

}

bool Fun_Sensor_init(void)
{ 
//  uint16 r_i;
  uint32 xendsh;
  uint32 xsed;

//  Bmf_reset_lo;		// bmf reset
  Fun_delay_1ms(10);
  Bmf_reset_hi;		// bmf reset
	
	// initialization bmf 
  Bmf_Address = Bmf_LDS_1;
  Fun_delay_1us();
  
  Bmf_Address = Bmf_DCI_1;
  Fun_delay_1ms(10);			 // delay 100us; initialize BCT-100
     
  Bmf_Address = Bmf_DCI_0;

	//waiting for end_sh = 1;     
  Fun_TimerInitialize(0,100);
  while(Flag_timer)
  {
    xendsh = Bmf_endsh;
    if(xendsh == 1)
    {	
      Disable_Int(TIMERINT0);	// initliation success
		
      Bmf_Address = Bmf_Parallel;
	  nops;
 	  nops;
 	  nops;
 	  
      Fun_TimerInitialize(0,100);
	  xsed = 0;
	  while(xsed == 0)
	  {
        xsed = Bmf_sed;
    	if(!Flag_timer)
  		{
  		  return False;
 		}    
	  }
      Disable_Int(TIMERINT0);

      Bmf_Address = Bmf_PLDS_1;
	  return True;
	}
  }
	//failure reset
  Bmf_reset_lo;
  nops;
  nops;
  nops;
  Bmf_reset_hi;
  return False;
}


bool Fun_Get_BmfImage(uint8 *pImage)
{ 	 
    uint8 x;
	uint16 r_i,r_j;
    uint32 xsed = 0;

   	Bmf_Address = Bmf_PLDS_1;
		//start to read image
	for(r_i = 0; r_i <384; r_i++)
	{	
    				   
	    Fun_TimerInitialize(0,100);
	    xsed = 1;
		while(xsed == 1)
		{
	        xsed = Bmf_sed;
	        
    		if(!Flag_timer) return False;
		}
		Disable_Int(TIMERINT0);

		Bmf_dsc_lo;  
			//Bmf_Address 由输出变成输入		
		for(r_j = 0;r_j<256;r_j++)
	    {		
			Bmf_dsc_hi;
			x = Bmf_Address;
			pImage[r_i*256 + r_j] = ~x;
//			pImage[r_i*256 + r_j] = x;
			Bmf_dsc_lo;	
		}	
		
	    Fun_TimerInitialize(0,100);
	    xsed = 0;
		while(xsed == 0)
		{
	        xsed = Bmf_sed;
    		
    		if(!Flag_timer) return False;
		}
		Disable_Int(TIMERINT0);

    	Bmf_Address = Bmf_PLDS_1;
	}

	return True;
}



bool Fun_capture_image(uint8 *pImage)
{
	uint8 press_t;
	
	Led_greenon;
//	if(Fun_Sensor_init())return False;
	
	Fun_TimerInitialize(0,500);			//setup timeout of 5s
	while(Flag_timer)
	{
 		press_t = WAKE;
 		
 		if(press_t == 0)				//identify branch
		{
			Disable_Int(TIMERINT0);
			if(Fun_Get_BmfImage(pImage))return False;
			Led_greenoff;
			return True;
		}
	}
	Led_greenoff;
	return False;
}

bool Fun_read_image(uint8 *pImage)
{
//	if(Fun_Sensor_init())return False;
	
	Fun_TimerInitialize(0,500);			//setup timeout of 5s
	while(Flag_timer)
	{
		Disable_Int(TIMERINT0);
		if(Fun_Get_BmfImage(pImage))return False;
		Led_greenoff;
		return True;
	}
	Led_greenoff;
	return False;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -