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

📄 tvp5150.c

📁 video to VGA 源码
💻 C
字号:
/*===================================
tvp5150.c
===================================*/
#include"G2300.h"
#include"twi.h"
#include"tvp5150.h"

#define TVP5150  0xba

extern unsigned char standard  ;
extern unsigned char fvideo    ;
/*=============================
=============================*/
unsigned char TVP5150write(unsigned char chSub,unsigned char chData)
{
  unsigned char j;
  iic_start();
  iic_wait();
  if(iic_state()!=0x08)  {    iic_ee();    return 0;  }
  iic_send(TVP5150);
  iic_wait();
  if(iic_state()!=0x18)  {    iic_ee();    return 0;  }
  iic_send(chSub);
  iic_wait();
  if(iic_state()!=0x28)  {    iic_ee();    return 0;  }
  iic_send(chData);
  iic_wait();
  if(iic_state()!=0x28)  {    iic_ee();    return 0;  }
  iic_stop();
  for(j=200;j;j--);
  return 1;
}
/*=============================
=============================*/
unsigned char TVP5150read(unsigned char chSub)
{
  unsigned char tmp;
  iic_start();
  iic_wait();
  if(iic_state()!=0x08)  {    iic_ee();    return 0;  }
  iic_send(TVP5150);
  iic_wait();
  if(iic_state()!=0x18)  {    iic_ee();    return 0;  }
  iic_send(chSub);
  iic_wait();
  if(iic_state()!=0x28)  {    iic_ee();    return 0;  }
  iic_start();   //restart
  iic_wait();
  if(iic_state()!=0x10)  {    iic_ee();    return 0;  }
  iic_send(TVP5150|0x01);
  iic_wait();
  if(iic_state()!=0x40)  {    iic_ee();    return 0;  }
  iic_noack();
  iic_wait();
  tmp=iic_receive();
  iic_stop();
  return tmp;
}
/*=============================
=============================*/
void SetTvp5150(void)
{
  unsigned char j;
  unsigned char static fauto=0;
  if(!fauto)
  {
    tvp5150[TVP5150_28][1]=0x04;
    fauto=1;
  }
  else
  {
    tvp5150[TVP5150_28][1]=0x00;
  }
  if(fvideo)
  {
    tvp5150[TVP5150_09][1]=0x70;
    tvp5150[TVP5150_0a][1]=0x80;
    tvp5150[TVP5150_0b][1]=0x00;
    tvp5150[TVP5150_0c][1]=0x50;
  }
  else
  {
    tvp5150[TVP5150_09][1]=0x00;
    tvp5150[TVP5150_0a][1]=0x00;
    tvp5150[TVP5150_0b][1]=0x00;
    tvp5150[TVP5150_0c][1]=0x00;
  }
  if(PINB&0x20)   //S_video
  {
    tvp5150[TVP5150_00][1]=0x01;
  }
  else      //composite
  {
    tvp5150[TVP5150_00][1]=0x00;
  }
  for(j=0;j<24;j++)
  {
    TVP5150write(tvp5150[j][0],tvp5150[j][1]);
  }
  WDR();
}


/*===================================
END
===================================*/

⌨️ 快捷键说明

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