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

📄 app_3a.c

📁 dz3000_51.0.0.4.rar
💻 C
字号:
/********************************************************************************
  Copyright (c) 2001 Sunplus Technology Co., Ltd.
  Module Name:  l1.c
  Function   :  This level-1 API is written for HP's Rocky project
  Environment:  Keil C51 Compiler
  Creation   :  2001/10/25 Max Hsu          
***********************************************************************************/
#include "general.h"
#include "main.h"
//patch4.2@richie@0516
#include "initio.h"


//patch4.4@yichang@snapping in subsample mode begin
extern void L2_SnapFrontSubSample(UCHAR SnapNum);
//patch4.4@yichang@snapping in subsample mode end

//-----------------------------------------------------------------------------
//L1_AppSnapRaw
//-----------------------------------------------------------------------------
void L1_AppSnapRaw() USING_0
{ 
//  ULONG size,tmbsize;
//  ULONG i;
  
  //PRINT_APP ("    L1_AppSnapRaw: Enter\n");

  L2_TurnOnOffDisplay(0);  //turn off the display device 

  XBYTE[0X20D0]  = XBYTE[0X20D0] & 0xDF;  //Turn off VD interrupt 
  /////// RAW DATA CAPTURE /////////////////////////////////////////////////////

  L2_SetCDSPScale(G_Hsize,G_Hsize); //TurnOff the CDSP H-scale function
  L2_SetImageType(0);               //Set raw dta type
  L2_SetDisplayMode(0,0);           //disable  frame rate conversion
  //patch5.0@richie@sdram mapping begin
  L2_SetRFBAddr(K_SDRAM_ImageCaptureBufAddr+G_Hsize*6);  //captured raw data will be stored in the buffer
  L2_SetAFBAddr(K_SDRAM_ImageCaptureBufAddr+G_Hsize*6); 
  //patch5.0@richie@sdram mapping end
  L2_SetAFBSize(G_Hsize,G_Vsize);
  L2_SetRFBSize(G_Hsize,G_Vsize);      //pointed by the Raw buffer pointer
 
  
  L2_SetRCDSPWidth(G_Hsize);
  L2_SetACDSPWidth(G_Hsize);    
  
  L2_SetCamMode(0); //prepare to receiver data fomr the sensor 
  L2_SetCamMode(2);

  L2_WaitVD(0,1);   //wait for the falling edge of VD for one time                          // Set to DSC mode 
  L2_SnapFront(1);  //Trigger the  CMOS sensor into the full-frame mode

  while((L2_CheckDRAMStatus()&0X02)!=0X02);

//#ifdef RJ23P3AA
//    XBYTE[0x2924] = 0x10;         //Set 3 Field DISable, fieldsel
//#endif  

//#ifdef SONY432
//    XBYTE[0x2924] = 0x90;         //Set 3 Field DISable, fieldsel
//#endif      

//PRINT_APP ("    L1_AppSnapRaw: 1.Raw data captured.\n"); 
  
  //PRINT_APP ("    L1_AppSnapRaw: Exit\n");

 
}         



//patch4.4@yichang@badpixel begin
//-----------------------------------------------------------------------------
//L1_AppSnapRawSub
//-----------------------------------------------------------------------------
void L1_AppSnapRawSub() USING_0
{ 
  USHORT captureSubWidth, captureSubHeight;
        
  printf("snap subsample\n");      
 
  captureSubWidth = G_MHSize;
  captureSubHeight = G_MVSize-13;
  printf("captureSubWidth=%d\n",captureSubWidth);
  printf("captureSubHeight=%d\n",captureSubHeight);

  L2_TurnOnOffDisplay(0);  //turn off the display device 

  XBYTE[0X20D0]  = XBYTE[0X20D0] & 0xDF;  //Turn off VD interrupt 
  /////// RAW DATA CAPTURE /////////////////////////////////////////////////////
  L2_SetCDSPScale(captureSubWidth, captureSubWidth);       //TurnOff the CDSP H-scale function
  L2_SetImageType(0);                     //Set raw dta type
  L2_SetDisplayMode(0,0);                 //disable  frame rate conversion
  
  L2_SetRFBAddr(G_RawImageBufAddr+captureSubWidth*6);     //captured raw data will be stored in the buffer
  L2_SetAFBAddr(G_RawImageBufAddr+captureSubWidth*6); 
  
  L2_SetAFBSize(captureSubWidth, captureSubHeight);
  L2_SetRFBSize(captureSubWidth, captureSubHeight);         //pointed by the Raw buffer pointer
   
  L2_SetRCDSPWidth(captureSubWidth);
  L2_SetACDSPWidth(captureSubWidth);      
  L2_SetCamMode(0); //prepare to receiver data fomr the sensor 
  L2_SetCamMode(2);

  L2_WaitVD(0,1);           //wait for the falling edge of VD for one time                          // Set to DSC mode 
  L2_SnapFrontSubSample(1);   //Trigger the  CMOS sensor into the full-frame mode

  while((L2_CheckDRAMStatus()&0X02)!=0X02);
 
}         

//patch4.4@yichang@badpixel end


//-----------------------------------------------------------------------------
//L1_AppSnapOne
//-----------------------------------------------------------------------------


void L1_AppSnapOne() USING_0
{ 
  ULONG size,tmbsize;
  ULONG i;


  //PRINT_APP ("    L1_AppSnapOne: Enter\n");

  L2_TurnOnOffDisplay(0);  //turn off the display device 

  /////// RAW DATA CAPTURE /////////////////////////////////////////////////////

  L2_SetCDSPScale(G_Hsize,G_Hsize); //TurnOff the CDSP H-scale function
  L2_SetImageType(0);               //Set raw dta type
  L2_SetDisplayMode(0,0);           //disable  frame rate conversion
  //patch5.0@richie@sdram mapping begin
  L2_SetRFBAddr(K_SDRAM_ImageCaptureBufAddr+G_Hsize*6);  //captured raw data will be stored in the buffer
  L2_SetAFBAddr(K_SDRAM_ImageCaptureBufAddr+G_Hsize*6); 
  //patch5.0@richie@sdram mapping end
  L2_SetAFBSize(G_Hsize,G_Vsize);
  L2_SetRFBSize(G_Hsize,G_Vsize);      //pointed by the Raw buffer pointer
 
  
  L2_SetRCDSPWidth(G_Hsize);
  L2_SetACDSPWidth(G_Hsize);    
  
  L2_SetCamMode(0); //prepare to receiver data fomr the sensor 
  L2_SetCamMode(2);

  L2_WaitVD(0,1);   //wait for the falling edge of VD for one time                          // Set to DSC mode 
  L2_SnapFront(1);  //Trigger the  CMOS sensor into the full-frame mode

  while((L2_CheckDRAMStatus()&0X02)!=0X02);

  //PRINT_APP ("    L1_AppSnapOne: 1.Raw data captured.\n"); 

  //patch5.0@richie@sdram mapping begin
  ///////// VERTICAL LINE EXTENSION ////////////////////////////////////////////
  //Extend the vertical image size by 12 lines (mirror) for CDSP
  //The horizontal extending pixels are mirrored by the CDSP automatically
   for(i=1;i<7;i++) //top mirror
          L2_DoDRAMDMA(K_SDRAM_ImageCaptureBufAddr*2+(ULONG)G_Hsize*6*2+(ULONG)G_Hsize*i*2, 
                       K_SDRAM_ImageCaptureBufAddr*2+(ULONG)G_Hsize*6*2-(ULONG)G_Hsize*i*2,
                       G_Hsize*2);
     
   for(i=1;i<7;i++) //bottom mirror
          L2_DoDRAMDMA(K_SDRAM_ImageCaptureBufAddr*2+(ULONG)G_Hsize*6*2-(ULONG)G_Hsize*i*2+(ULONG)G_Hsize*(G_Vsize - 1)*2,
                       K_SDRAM_ImageCaptureBufAddr*2+(ULONG)G_Hsize*6*2+(ULONG)G_Hsize*i*2+(ULONG)G_Hsize*(G_Vsize - 1)*2, 
                       G_Hsize*2);                                   

   //PRINT_APP ("    L1_AppSnapOne: 2.Vertical extention completed.\n"); 


   ////// COLOR PROCESSING /////////////////////////////////////////// 
   L2_DoCDSP2(K_SDRAM_ImageCaptureBufAddr,G_Hsize,G_Vsize+12,
              K_SDRAM_ImageCaptureBufAddr,G_Hsize,G_Vsize,
              0,0,K_SDRAM_ImageCaptureGeneralBufAddr); //this function should extend the horizontal 16-pixels 
                               //After this function is done, YUV data is in AFB   
   //PRINT_APP ("    L1_AppSnapOne: 3.Color processing completed\n");

   /////// 2X Digital Zoom ///////////////////////////////////////////
   /*
   if(G_PVZFactor==20)
   {  L2_CopyImage(K_SDRAM_FrameBufAAddr,G_Hsize,G_Vsize,              //source address and size
                   G_Hsize >> 2, G_Vsize >> 2,             //source offset 
                   G_Hsize >> 1, G_Vsize >> 1,             //size to be copied 
                   K_SDRAM_GeneralBufAddr, G_Hsize >> 1, G_Vsize >> 1,  //destination address and size
                   0,0);                                   //destination offset
       
      L2_ScaleUpImage(K_SDRAM_GeneralBufAddr, G_Hsize >> 1 , G_Vsize >> 1,  //source
                      K_SDRAM_FrameBufAAddr, G_Hsize, G_Vsize,             //destination
                      K_SDRAM_TemporaryBufAddr);                             //temp buffer

    //PRINT_APP("    L1_AppSnapOne:  2X digital zoom completed\n");
   }
   */

//////// COMPRESSION //////////////////////////////////////////////
    L2_SetCamMode(0);                    //must switch back to idle before compression    
    L2_SetJPEGVscale(G_Vsize, G_Vsize);  //turn off JPEG Vertical scaling function
        
   //use option 0x30 instead of 0x20 in the final version
   //since our AP can only deal with the non-JFIF format, so use 0x20 here 
    L2_Compress(2,K_SDRAM_ImageCaptureBufAddr,G_Hsize,G_Vsize,  //source
                K_SDRAM_ImageCaptureGeneralBufAddr,                   //destination
                K_SDRAM_DcTermBufAddr,                 //DC-teram location
                0x30);                        //Mode: JFIF, generate DC term
    //patch5.0@richie@sdram mapping end

    L2_ReadCompSize(&size);
        
    //PRINT_APP("    L1_AppSnapOne: 4.Compression done\n");
    //PRINT_APP("    L1_AppSnapOne:   VLC data length = %lX\n",size);

    //PRINT_APP ("    L1_AppSnapOne: Exit\n"); 
//#ifdef RJ23P3AA
//    XBYTE[0x2924] = 0x10;         //Set 3 Field DISable, fieldsel
//#endif  

//#ifdef SONY432
//    XBYTE[0x2924] = 0x90;         //Set 3 Field DISable, fieldsel
//#endif     
} 


⌨️ 快捷键说明

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