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

📄 bit1601.c

📁 dvr
💻 C
字号:
 /*
********************************************************************************
*
* (c) Copyright 2002, Vineyard Technologies, Inc.
*
* Filename : bit1601.c
* Programmer(s): Steve KyeongHyeon Lee
* Created : 2003/02/05
* Modified :
*
* Description :
********************************************************************************
*/
#include "types.h"

#ifndef TW2804

#include "i2c.h"
#include "bit1601.h"
#include "gio.h"

code u8 bit1601_ids[NUM_CAM] = {0x88,0x8a,0x8c,0x8e};
xdata u8 video_active=0;

// ++++++++++++++++++++++++++++++++++++++++++
// Added by JC 11:32AM  2004/09/17

/* ------------------------------------
    Header Files
   ------------------------------------ */
#include "8052reg.h"

/* ------------------------------------
    Type Definitions
   ------------------------------------ */
typedef unsigned char       UB8;        /* 8-bit data */
typedef unsigned short int  UW16;       /*16-bit data */
typedef unsigned long       UW32;       /*32-bit data */

/* ------------------------------------
    Variables Definitions/Declarations
   ------------------------------------ */

#define VD_RST_ON   { P1_6 = 0;    }
#define VD_RST_OFF  { P1_6 = 1;    }

/* ------------------------------------
    Function Prototypes
   ------------------------------------ */
static void YUV_HardwareReset(void);
static void YUV_Init(UB8 bPAL);
// ++++++++++++++++++++++++++++++++++++++++++

//===============================================================================
//
//===============================================================================
void bit1601_init(u8 ntsc_pal)
{
    // ------------------------------------------
    // Removed by JC 11:11AM  2004/10/13
    #ifdef NOT_JUNK

    xdata u8 ch=0;
    xdata u8 devid=0;

    for(ch=0; ch < NUM_CAM; ch++)
    {
        devid = bit1601_read(ch,0x00);

        bit1601_write(ch,0x06,0x60);
        bit1601_write(ch,0x02,0x40);
        bit1601_write(ch,0x20,0x20);
        bit1601_write(ch,0x28,0x0c);
        bit1601_write(ch,0x2e,0x5d);
        bit1601_write(ch,0x2f,0xe6);// force blueback

        if(ntsc_pal) // PAL CASE
        {
            bit1601_write(ch,0x03,0x92);
            bit1601_write(ch,0x07,0x12);// VACTIVE
            bit1601_write(ch,0x08,0x16);// VDELAY
            bit1601_write(ch,0x09,0x20);// VACTIVE
            bit1601_write(ch,0x0c,0x8c);// comb filer soft
            bit1601_write(ch,0x12,0x0f);// sharpness soft
            bit1601_write(ch,0x1c,0x01);//PAL
            bit1601_write(ch,0x1d,0x7f);

        }
        else        // NTSC CASE
        {
           bit1601_write(ch,0x03,0xA2);
           bit1601_write(ch,0x07,0x02);// VACTIVE
           bit1601_write(ch,0x08,0x15);// VDELAY
           bit1601_write(ch,0x09,0xF0);// VACTIVE
           bit1601_write(ch,0x0C,0x9c);//7.5IRE
           bit1601_write(ch,0x12,0x01);// sharpness soft
           bit1601_write(ch,0x1c,0x00);//NTSC
           bit1601_write(ch,0x1d,0x00);
        }   
        if(devid==0x18) bit1601_write(ch,0x06,0xe0); //bit1601A
        else{
                        bit1601_write(ch,0x06,0xc0); //bit1601B   
                        bit1601_write(ch,0x3b,0x00); //bit1601B   
        }
        #ifdef MAKE_VDELAY
        if(ntsc_pal)    bit1601_write(ch,0x08,0x1b-0x0b);    // To make horizontal upper line
        else            bit1601_write(ch,0x08,0x15-0x0b);    // To make horizontal upper line
        #endif

    }
    #endif
    // ------------------------------------------

    // ++++++++++++++++++++++++++++++++++++++++++
    // Added by JC 11:12AM  2004/10/13
    YUV_Init(ntsc_pal);
    // ++++++++++++++++++++++++++++++++++++++++++

}

// ------------------------------------------
// Removed by JC 11:11AM  2004/10/13
#ifdef NOT_JUNK
// ------------------------------------------
//===============================================================================
//
//===============================================================================
u8 bit1601_write(u8 ch, u8 idx, u8 val)
{
   i2c_pkt_write(bit1601_ids[ch],idx,val);
   return 0;
}

//===============================================================================
//
//===============================================================================
u8 bit1601_read(u8 ch, u8 idx)
{
    return i2c_pkt_read(bit1601_ids[ch],idx);
}
#endif
// ------------------------------------------

/*
//===============================================================================
//
//===============================================================================
u8 bit1601_read_video_active(void)
{
    u8 ch=0;
    u8 pre_video_active;
    
    pre_video_active = video_active;

    for(ch = 0; ch < NUM_CAM; ch++ )
    {
        if(0x80 & bit1601_read(ch,0x01))
            video_active &= ~(1 << (NUM_CAM-(ch+1)));
        else
            video_active |= (1 << (NUM_CAM-(ch+1)));
    }

    if(pre_video_active != video_active)
        return 1;
    else
        return 0;
}
*/

#endif // TW2804

// ++++++++++++++++++++++++++++++++++++++++++
// Added by JC 11:13AM  2004/10/13


/* ::::::::::::::::::::::::::::::::::::
    Video Decoder Register Definition
   :::::::::::::::::::::::::::::::::::: */

#define YUV_MAD_1                   0x40
#define YUV_MAD_2                   0x42
#define YUV_MAD_3                   0x48
#define YUV_MAD_4                   0x4A

// MAD: 0x40
static UB8 code ab01_74_1[] = {
    0x67,       //  02  01
    0xFF,       //  04  02
    0xFC,       //  06  03
    0xE8,//20051104 david modify 0xF8,       //  08  04
    0xE0,       //  0A  05
    0xFF,       //  0C  06
    0x66,       //C0  0E  07
    0x60,       //55  10  08
    0x24,       //33  12  09
    0x00,       //  14  0A
    0x55,       //  16  0B
    0x45,       //  18  0C
    0x49,       //  1A  0D
    0x8C,       //  1C  0E
    0x00,       //  1E  0F
    0x00,       //14  20  10 
    0x40,       //  22  11
    0x7F,       //  24  12
    0x7F,       //  26  13 
    0x1F,       //  28  14 
    0x1F,       //  2A  15
    0xA0,       //  2C  16 //0x20=color kill function on   (礚癟腹块

⌨️ 快捷键说明

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