pvx521.c

来自「video to VGA 源码」· C语言 代码 · 共 83 行

C
83
字号
/*===================================
PVX521.c
===================================*/
#include"g2300.h"
#include"twi.h"
#include"pvx521.h"

#define PVX521  0x2e
extern unsigned char fvideo;
extern unsigned char standard;
extern unsigned char resolution;

/*=============================
=============================*/
unsigned char PVX521write(unsigned char chSub,unsigned char chData)
{
  iic_start();
  iic_wait();
  if(iic_state()!=0x08)  {    iic_ee();    return 0;  }
  iic_send(PVX521);
  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();
  return 1;
}
/*=============================
=============================*/
unsigned char PVX521read(unsigned char chSub)
{
  unsigned char tmp;
  iic_start();
  iic_wait();
  if(iic_state()!=0x08)  {    iic_ee();    return 0;  }
  iic_send(PVX521);
  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(PVX521|0x01);
  iic_wait();
  if(iic_state()!=0x40)  {    iic_ee();    return 0;  }
  iic_noack();
  iic_wait();
  tmp=iic_receive();
  iic_stop();
  return tmp;
}
/*=============================
=============================*/
void SetPvx521(void)
{
  unsigned char j;
  unsigned char blue_overlay[6][2]=
  {0xdc,0x01,0xdd,0xfc,0xdf,0x02,0xe0,0xbc,0xe1,0x9d,0xe2,0x03};

  if(fvideo)
  {
    for(j=0;j<227;j++)
      PVX521write(pvx521[standard][j][0],pvx521[standard][j][1]);
  }
  else
  {
    for(j=0;j<6;j++)
      PVX521write(blue_overlay[j][0],blue_overlay[j][1]);
  }
  WDR();
}


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

⌨️ 快捷键说明

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