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

📄 camera2.c

📁 ucosii在codefire系列的5222x上的移植
💻 C
字号:
#include "mcf5xxx.h"
#include "mcf5222x.h"
#include "m5222x_evb.h"
#include "mwerks.h"
#include "INCLUDES.H"
#include "uart.h"

OS_STK	AppTaskCameraStk[256];	

const INT8U shoot_photo[9] =
{
	0x7E,0x00,0x00,0x00,0x13,0x00,0x13,0x7E               //???????
};
static INT8U shoot_photo_back[10] = 
{
	0x00                                                  //??????????????????
};
static INT8U read_photo[9] = 
{
	0x7E,0x00,0x02,0x00,0x00,0x00,0x02,0x7E               //??????
};

static INT8U read_photo25[10] = 
{
	0x7E,0x00,0x02,0x00,0x19,0x00,0x1B,0x00,0x7E               //??????
};

static INT8U read_photo27[9] = 
{
	0x7E,0x00,0x02,0x00,0x1B,0x00,0x00,0x1D,0x7E               //??????
};

static INT8U read_photo_back[520] = 
{
	0x00                                                  //??????????????  
};
const INT8U resume_camera[9] = 
{
	0x7E,0x00,0x09,0x00,0x00,0x00,0x09,0x7E                //??????
};
 
static INT8U camera_buf[540] =
{
	0x00
};

static INT16U camera_bag[43] = 
{
    0xA5,0xC3,0x00,0x00,0x00,0x00,'h','f','u','t','h','f','u','t','A','0','0','0','0','0','1','I','M','A','G','E',0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
const INT8U last_bag[4] = 
{
    '#',0xA5,0x99
};


extern OS_EVENT *sem_gps;
extern OS_EVENT *sem_cam;
extern OS_EVENT *sem_lost;
INT8U total_module=0;       //??? 

INT8U image_num = 0;        //????

INT8U module = 0;           //????

INT8U length1 = 0;          //????
INT8U length2 = 0;

INT16U j = 0;
INT8U sl = 0;


INT8U er;
INT8U lost_len = 0;
extern char lost_buffer[20];           //?????????
extern INT8U flag;
extern INT8U flag_coutin;

extern void FD810_Send(INT8U *Buffer,int size);

void cdma_send(INT8U buffer[], int num);

void  AppTaskCamera (void * pdata)
{
    int i = 0;
    int k = 0;
    int total_length = 0;
    int last_frame_count = 0;                                           //???????????pdata = pdata; ????
    INT8U err;
    pdata = pdata;                          
    
    MCF_GPIO_PTAPAR = MCF_GPIO_PTAPAR_ICOC3_GPIO;
    MCF_GPIO_DDRTA = MCF_GPIO_DDRTA_DDRTA3;

	while(1)
	{
         OSSemPend (sem_cam, 0, &err);
         flag = 1;
         flag_coutin = 0;
         
         for(i=0;i<10000;i++)                           //must delay 
		 ;

         MCF_GPIO_PORTTA = 0x08;
		 for(i=0;i<8;i++)
		 uart_putchar(2,shoot_photo[i]);
		 
		 for(i=0;i<50000;i++)                           //must delay ,else no data receive 
		 ;

         MCF_GPIO_PORTTA = 0x00;
		 for(i=0;i<10;i++)
         	shoot_photo_back[i] = uart_getchar(2);

         total_length = shoot_photo_back[5]*256+shoot_photo_back[6];
         total_module = total_length/512;
         last_frame_count = total_length%512;
         
         if(last_frame_count != 0)
         	total_module = total_module+1;
         
         for(i=0;i<1500;i++)                           //must delay at lest 3ms
         ;
         
		 for(i=0;i<total_module;i++)
		 {
		 	
		 	module = i;
		 	k = 0;
            sl = 0;
            read_photo[4] = i;
            for(j=1;j<5;j++)
            sl = sl+read_photo[j]; 
            read_photo[6] = sl; 
           
            MCF_GPIO_PORTTA = 0x08;
		    if(i == 25)
		    {
		    	for(j=0;j<9;j++)
		    	uart_putchar(2,read_photo25[j]);
		    }
		    else if(i == 27)
		    {
		    	for(j=0;j<9;j++)
		    	uart_putchar(2,read_photo27[j]);
		    }
		    else
		    {
		        for(j=0;j<8;j++)
		        uart_putchar(2,read_photo[j]);
		    }
            
            for(j=0;j<3000;j++)                               //must delay at lest 3ms 
		    ;

   		 	MCF_GPIO_PORTTA = 0x00;
   	 		camera_buf[k] = uart_getchar(2);
   		 	camera_buf[k] = uart_getchar(2);
		 	do
		 	{
		 		k++;
		 		camera_buf[k] = uart_getchar(2);
		 	}while(camera_buf[k] != 0x7E);
		 	
		 	length1 = (k+1)/256;
		 	length2 = (k+1)%256;

		    cdma_send(camera_buf,k+1);
		 }
		 
		 FD810_Send((INT8U *)"hfutE\\r\n END OF IMG\r\n",strlen("hfutE\\r\n END OF IMG\r\n"));//NEW 
         /*
	     OSSemPend (sem_lost, 0, &er);
	     
	     while(flag == 1)
	     {
	        flag_coutin = 0;
	        
	        lost_len = strlen ((const char *)lost_buffer);
	        
	        for(i=0;i<lost_len;i++)
	        {
	           k = 0;
               sl = 0;

	           module = lost_buffer[i];
            
               read_photo[4] = lost_buffer[i];
               for(j=1;j<5;j++)
               sl = sl+read_photo[j]; 
               read_photo[6] = sl; 
           
               MCF_GPIO_PORTTA = 0x08;
		       if(module == 25)
		       {
		    	  for(j=0;j<9;j++)
		    	  uart_putchar(2,read_photo25[j]);
		       }
		       else if(module == 27)
		       {
		      	  for(j=0;j<9;j++)
		    	  uart_putchar(2,read_photo27[j]);
		       }
		       else
		       {
		          for(j=0;j<8;j++)
		          uart_putchar(2,read_photo[j]);
		       }
            
               for(j=0;j<3500;j++)                               //????????????5??????????????
		       ;

   		 	   MCF_GPIO_PORTTA = 0x00;
   	 		   camera_buf[k] = uart_getchar(2);
   		 	   camera_buf[k] = uart_getchar(2);
		 	   do
		 	   {
		 		  k++;
		 		  camera_buf[k] = uart_getchar(2);
		 	   }while(camera_buf[k] != 0x7E);
		 	
		 	   length1 = (k+1)/256;
		 	   length2 = (k+1)%256;

		       cdma_send(camera_buf,k+1);
	        }
	       
	       OSSemPend (sem_lost, 0, &er);
	     }
	     */		 		 
		// image_num++;
		 
		 OSTimeDly(100);///去掉
    }
}

  

void cdma_send(INT8U buffer[], int num)
{
	int f;
	int n1;
	int n2;
	int tota;
	tota = num+45;
	n1 = tota/256;
	n2 = tota%256;

    camera_bag[3] = n1;                  //???
    camera_bag[4] = n2;
	camera_bag[28] = shoot_photo_back[5];        //?????
	camera_bag[29] = shoot_photo_back[6];
	camera_bag[33] = total_module;      //???
	camera_bag[35] = image_num;         //????
	camera_bag[37] = module;             //????
	camera_bag[40] = length1;
	camera_bag[41] = length2;            //????
    
    for(f=0;f<42;f++)
    uart_putchar(1,camera_bag[f]);
    
    for(f=0;f<num;f++)
    uart_putchar(1,buffer[f]);	
    
    for(f=0;f<3;f++)
    uart_putchar(1,last_bag[f]);
}

⌨️ 快捷键说明

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