📄 ap_tw2835.c
字号:
}
else { //-- Right
for(_t1_ = 0 ; _t1_ < 4 ; _t1_++) {
ReadAsicByte(DVC_PG2,_md_+(0x02*_t1_),(unsigned char *)&_rw_value_);
if(FLAG == TRUE){_rw_value_ &= 0x07;}
else {_rw_value_ |= 0xf8;}
WriteAsicByte(DVC_PG2,_md_+(0x02*_t1_),_rw_value_);
}
}
return TRUE;
}
//------------------------------------------------------------------------------------------------
BOOL Ap_getTriggerchannel(char* flag)
{
unsigned char _read_value_=0;
ReadAsicByte(DVC_PG1,0x79,(unsigned char *)&_read_value_);
_read_value_ &= 0x0f;
*flag = _read_value_;
return TRUE;
}
//------------------------------------------------------------------------------------------------
BOOL Ap_Draw_Index(char channel, BOOL FLAG)
{
unsigned char _t1_,_t2_,_t3_;
unsigned char _pos_st_x,_pos_end_x,_pos_st_y,_pos_end_y;
if(channel > 36)
return FALSE;//FAIL;
_t1_ = (channel-1) * 5;
_pos_st_x = _Ap_channel_[_t1_];// Ap_channel_[_t1_]
_pos_end_x = _Ap_channel_[_t1_+1]; // Ap_channel_[_t1_+1]
_pos_st_y = _Ap_channel_[_t1_+2]; // Ap_channel_[_t1_+2]
_pos_end_y = _Ap_channel_[_t1_+3]; // Ap_channel_[_t1_+3]
if(FLAG == TRUE) {
WriteAsicByteOSD(0x00,OSD_MIX|OSD_COL_GRN);
WriteAsicByteOSD(0x01,OSD_MIX|OSD_COL_GRN);
WriteAsicByteOSD(0x02,OSD_MIX|OSD_COL_GRN);
WriteAsicByteOSD(0x03,OSD_MIX|OSD_COL_GRN);
}
else {
WriteAsicByteOSD(0x00,OSD_MIX|OSD_CLR);
WriteAsicByteOSD(0x01,OSD_MIX|OSD_CLR);
WriteAsicByteOSD(0x02,OSD_MIX|OSD_CLR);
WriteAsicByteOSD(0x03,OSD_MIX|OSD_CLR);
}
WriteAsicByteOSD(0x04,0x80);
WriteAsicByteOSD(0x07,_pos_st_y);
WriteAsicByteOSD(0x08,_pos_end_y);
WriteAsicByteOSD(0x09,0x00);
//----------------------------------------------------------------------
_t2_ = (_pos_end_x - _pos_st_x) >> 4;
_t3_ = (_pos_end_x - _pos_st_x) & 0xff;
if (_t2_ != 0) {
WriteAsicByteOSD(0x05,_pos_st_x);
WriteAsicByteOSD(0x06,_pos_st_x+(_t2_<<4));
WriteAsicByteOSD(0x0a,0xc0);
while(ReadAsicOSDMemWr()&BIT7){}
}
if (_t3_ != 0){
WriteAsicByteOSD(0x05,_pos_st_x+(_t2_<<4));
WriteAsicByteOSD(0x06,_pos_end_x);
WriteAsicByteOSD(0x0a,0xc0);
while(ReadAsicOSDMemWr()&BIT7){}
}
return TRUE;
}
#if 1
///main flow part ///modify
//-------------------------- NTSC ------------------------------//
//=================================================================================
unsigned char tbl_ntsc_pg0_cmn[] = {
// CH1 CH2 CH3 CH4
0x00,0xc8,0x18,0xd0, //... 0x00~0x03 0x10~0x13 0x20~0x23 0x30~0x33
0x06,0xf0,0x08,0x80, //... 0x04~0x07 0x14~0x17 0x24~0x27 0x34~0x37
0x80,0x80,0x80,0x02, //... 0x08~0x0b 0x18~0x1b 0x28~0x2b 0x38~0x3b
0x06,0x00,0x11 //... 0x0c~0x0e 0x1c~0x1e 0x2c~0x2e 0x3c~0x3e
};
unsigned char tbl_ntsc_pg0_sfr1[] = { //... other decoder part
0x00,0x77,0x77,0x45, //... 0x40~0x43 //... update:060626
0xa0,0xd0,0x2f,0x64, //... 0x44~0x47
0x80,0x80,0x82,0x82, //... 0x48~0x4b
0x00,0x0f,0x05,0x00, //... 0x4c~0x4f
0x00,0x80,0x06,0x00, //... 0x50~0x53
0x00 //... 0x54
};
unsigned char tbl_ntsc_pg0_sfr2[] = { //... audio part
0x88,0x88,0x00,0x00, //... 0x60~0x63
0x10,0x32,0x54,0x76, //... 0x64~0x67
0x98,0xba,0xdc,0xfe, //... 0x68~0x6b
0x00,0x00,0x88,0x88, //... 0x6c~0x6f
0x88,0x54,0x00,0x00, //... 0x70~0x73
0x00 //... 0x74
};
unsigned char tbl_ntsc_pg0_scl[] = {
// CH1 CH2 CH3 CH4
0x01,0x7f,0xff,0x7f, //... 0x80~0x83 0x90~0x93 0xa0~0xa3 0xb0~0xb3
0xff,0x00,0xff,0xff, //... 0x84~0x87 0x94~0x97 0xa4~0xa7 0xb4~0xb7
0xff,0xff,0x31,0x00, //... 0x88~0x8b 0x98~0x9b 0xa8~0xab 0xb8~0xbb
0xd0,0x00,0xf0,0x08 //... 0x8c~0x8e 0x9c~0x9e 0xac~0xae 0xbc~0xbe
};
unsigned char tbl_ntsc_pg0_sfr3[] = { //...
// 0x00,0x00,0x00,0x07, //... 0xc0~0xc3 //... AUTOBGNDxx on
0x00,0x00,0x00,0x00, //... 0xc0~0xc3 //... AUTOBGNDxx off
0x00,0x00,0xf0,0xff, //... 0xc4~0xc7
0x00,0x3c,0x4f //... 0xc8~0xca //... update:060315
};
//==================================================================================
// Page1 initialize table description
//==================================================================================
unsigned char tbl_pg1_x_cmn[] = {
// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0x02,0x00,0x00,0x00,0x84,0x00,0x00, 0x00,0x00,0x00,0xd7,0x23,0x2d,0x1e,0xa7, //... 0x01
0x80,0x02,0x00,0x00,0x02,0x00,0x10,0x00, 0x81,0x02,0x00,0x01,0x02,0x00,0x11,0x00, //... 0x10 //... normal quad
0x82,0x02,0x00,0x02,0x02,0x00,0x12,0x00, 0x83,0x02,0x00,0x03,0x02,0x00,0x13,0x00, //... 0x20
};
unsigned char tbl_ntsc_pg1_pic_qd[] = {
// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0x00,0x5a,0x00,0x3c,0x5a,0xb4,0x00,0x3c, 0x00,0x5a,0x3c,0x78,0x5a,0xb4,0x3c,0x78 //...
};
unsigned char tbl_ntsc_pg1_pic_9_rb[] = {
// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0x78,0xb4,0x28,0x50,0x00,0x3c,0x50,0x78, 0x3c,0x78,0x50,0x78,0x78,0xb4,0x50,0x78 //...
};
unsigned char tbl_pg1_y_cmn[] = {
// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
// 0x28,0x00,0x10,0xa0,0x00,0x00,0x00,/*0x03*/0x00, /*0x00*/0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xa7, //... 1x50
// 0x80,0x02,0x00,0x81,0x02,0x00,0x82,0x02, 0x00,0x83,0x02,0x00,0x00,0xe4,0x00,0x00, //... 1x60 //... normal quad
// 0x00,0x03,0x00,0x00,0x00,0x00,0x02,0x00, 0xff,0xff,0xff,0xff,0xf0,0x00,0x89,0x84, //... 1x70
// 0xdf,0x00,0x91,0x07,0xeb,0x10,0xa8,0x00, 0x91,0xe7,0x80,0x00,0x00,0x00,0x00,0x00, //... 1x80 //... update:060715
// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //... 1x90
0x28,0x00,0x10,0xa0,0x00,0x00,0x00,0x03, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa7, //... 1x50
0x80,0x02,0x00,0x81,0x02,0x00,0x82,0x02, 0x00,0x83,0x02,0x00,0x00,0xe4,0x00,0x00, //... 1x60 //... normal quad
0x00,0x03,0x00,0x00,0x00,0x00,0x02,0x00, 0xff,0xff,0xff,0xff,0xf0,0x00,0x89,0x84, //... 1x70
0xdf,0x00,0x91,0x07,0xeb,0x10,0xa8,0x00, 0x91,0xe7,0x80,0x00,0x00,0x00,0x00,0x00, //... 1x80 //... update:060715
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //... 1x90
};
//-------------------------- NTSC ------------------------------//
unsigned char tbl_ntsc_pg1_pic_16_0[] = {
// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0x00,0x2d,0x00,0x1e,0x2d,0x5a,0x00,0x1e, 0x5a,0x87,0x00,0x1e,0x87,0xb4,0x00,0x1e //...
};
unsigned char tbl_ntsc_pg1_enc[] = {
// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
// 0x77,0x23,0xd7/*0x90*/,0x01,0x80,0x20,0x00,0x0c, 0x20,/*0x09*/0x00,0xaa,0x00,0x40,0x40,0x00,0x00 //... 1xa0
0x77,0x23,0x90,0x01,0x80,0x20,0x00,0x0c, 0x20,0x09,0xaa,0x00,0x40,0x40,0x00,0x00
};
unsigned char tbl_pg2_mse_box[] = { // 80 EA
// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
//... mouse & LUT
0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //... 0x10
//... single box
0x00,0xb0,0x00,0x00,0x00,0x00,0x40,0x00, 0x00,0x00,0x00,0x00,0x00,0xb0,0x00,0x00, //... 0x20
0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //... 0x30
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //... 0x40
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x40,0x40,0x40,0x42,0xff //... 0x50
};
unsigned char tbl_ntsc_pg2_2dbox[] = { // 32 EA
//... 2d array box
//... quad position
0x88,0x00,0x01,0x0a,0x00,0x09,0xfb,0x00, 0x89,0x00,0x5b,0x0a,0x00,0x09,0xfb,0x00, //... 0x60
0x8a,0x00,0x01,0x0a,0x3c,0x09,0xfb,0x00, 0x8b,0x00,0x5b,0x0a,0x3c,0x09,0xfb,0x00 //... 0x70
};
unsigned char tbl_ntsc_pg2_mtn1[] = { // 32 EA
//... sensitivity & mask info
0x17,0x73,0x88,0x4a,0x07,0x24,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, //... 0x80
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff //... 0x90
};
unsigned char tbl_ntsc_pg2_mtn2[] = { // 32 EA
//... sensitivity & mask info
0x17,0x73,0x88,0x4a,0x07,0x24,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //... 0x80
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //... 0x90
};
//======================================================================================
//======================================================================================
unsigned int _timer_delay = 0;
unsigned int _timer_delay2 = 0;
unsigned char _timer_osd_sel = 0;
unsigned char _md_byte_1 = 0xff;
unsigned char _md_byte_2 = 0xff;
unsigned char _md_byte_3 = 0xff;
unsigned char _md_byte_4 = 0xff;
unsigned char _md_byte_5 = 0xff;
//==================================================================================
void SetOSDCol(unsigned char _pth, unsigned char _col_num, unsigned char _y, unsigned char _cb, unsigned char _cr)
{
WriteAsicByte(DVC_PG2,0x0b,_y); //... Y
WriteAsicByte(DVC_PG2,0x0c,_cb); //... Cb
WriteAsicByte(DVC_PG2,0x0d,_cr); //... Cr
if(BitSet(_pth,PTH_X))
WriteAsicByte(DVC_PG2,0x0e,BIT7|_col_num); //... address
else
WriteAsicByte(DVC_PG2,0x0e,BIT7|BIT6|_col_num); //... address
}
//==================================================================================
void InitOSDCol(void)
{
SetOSDCol(PTH_Y,OSD_COL_BLK,0x00,0x80,0x80);
SetOSDCol(PTH_Y,OSD_COL_50WHT,0x7f,0x80,0x80);//???
SetOSDCol(PTH_Y,OSD_COL_75WHT,0xc0,0x80,0x80);
SetOSDCol(PTH_X,OSD_COL_BLK,0x00,0x80,0x80);
SetOSDCol(PTH_X,OSD_COL_50WHT,0x7f,0x80,0x80);
SetOSDCol(PTH_X,OSD_COL_75WHT,0xc0,0x80,0x80);
SetOSDCol(PTH_X,OSD_COL_25WHT,0x3f,0x80,0x80);
SetOSDCol(PTH_X,OSD_COL_100WHT,0xf0,0x80,0x80);
SetOSDCol(PTH_X,OSD_COL_BLU,0x1d,0xff,0x6b);
SetOSDCol(PTH_X,OSD_COL_RED,0x4c,0x54,0xff);
SetOSDCol(PTH_X,OSD_COL_ORNG,0x95,0x4f,0xb5);
SetOSDCol(PTH_X,OSD_COL_CYN,0xb2,0xaa,0x00);
SetOSDCol(PTH_X,OSD_COL_MGN,0x69,0xd4,0xea);
SetOSDCol(PTH_X,OSD_COL_GRN,0x4b,0x55,0x4a);
SetOSDCol(PTH_X,OSD_COL_OCN,0x61,0xb5,0x3a);
SetOSDCol(PTH_X,OSD_COL_YLW,0xe1,0x00,0x94);
}
//=============================================================
// Interrupt_Program
//=============================================================
//void timer_int(void) interrupt 5 //interrupt timer count
//{
// TH2 = (65536 - 50000)/256;
// TL2 = (65536 - 50000)%256;
// _timer_delay++;
// if(_timer_delay == 50000){_timer_delay2++;}
// if(_timer_delay == 50000){_timer_osd_sel++;}
//}
//------------------------------------------------------------------------------------------------
unsigned char _t1_,_t2_,_t3_,_t4_,_channel,_sel_channel,_osd_md_flag=0;
char* _channel_set;
BOOL _osd_flag=FALSE;//0;
unsigned short _dly_;
void main_111(void)
{
// unsigned char _t1_,_t2_,_t3_,_t4_,_channel,_sel_channel,_osd_md_flag=0;
// char* _channel_set;
// BOOL _osd_flag=FALSE;//0;
// unsigned short _dly_;
I2cInitial();
#if 0 ///8051 part
P0 = 0xff;
P1 = 0xff;
P2 = 0xff;
P3 = 0xff;
TH1 = 0xfd; // SMOD = 0 SMOD = 1
TL1 = 0xfd; // 0ffh :57600 bps
// 0fdh : 9600 bps 0fdh :19200 bps
// 0fah : 4800 bps
// 0f4h : 2400 bps
// 0e8h : 1200 bps
TMOD = 0x22; // 0010 0010 timer 0 - 8 bit auto reload
// timer 1 - baud rate generator
TCON = 0x55; // 0101 0101 timer 0,1 run
// int 0, edge triggered
// int 1, edge triggered
// TF1 TR1 TF0 TR0 EI1 IT1 EI0 IT0
T2CON = 0x04; // 0101 0101 timer 0,1 run
// int 0, edge triggered
// int 1, edge triggered
// TF2 EXF2 RCLK TCLK EXEN2 TR2 C/T CP/RL2
SCON = 0x50; // 0101 0000 mode 1 - 8 bit UART
// Enable serial reception
PCON = 0x00; // 0000 0000 SMOD(double baud rate bit) = 1
IP = 0x00; // 0000 0000 interrupt priority
// - - PT2 PS PT1 PX1 PT0 PX0
IE = 0xa0; // 1011 0000 interrupt enable:
// EA - ET2 ES ET1 EX1 ET0 EX0
TH0 = TL0 = 64;
TH2 = (65536 - 50000)/256;
TL2 = (65536 - 50000)%256;
TR0 = 1; // Timer0 Enable
TR1 = 1; // Timer1 Enable
TR2 = 1; // Timer2 Enable
/*Reset TW2835*/
DLY_FOR(5000);
RSTn = 0;
DLY_FOR(10000);
RSTn = 1;
DLY_FOR(10000);
/*define i2c address pin*/
HSPB = 1;
HALE = 1;
HRDB = 0;
HWRB = 0;
HCSB0 = 0;
HCSB1 = 0;
P0 = 0xc2;
#endif
//------------------------------------------------------------------------------------------------
/*initPG0*/
//------------------------------------------------------------------------------------------------
for(_t1_=0;_t1_<4;_t1_++){
WriteAsicTable(DVC_PG0,0x00+0x10*_t1_,tbl_ntsc_pg0_cmn,15);
WriteAsicByte(DVC_PG0,0x0c+0x10*_t1_,(_t1_<<6)|0x06); //... x path ANA_CH mux
WriteAsicTable(DVC_PG0,0x80+0x10*_t1_,tbl_ntsc_pg0_scl,16);
WriteAsicByte(DVC_PG0,0x80+0x10*_t1_,(_t1_<<6)|0x01); //... x path scale filter : quad
WriteAsicByte(DVC_PG0,0x8a+0x10*_t1_,(_t1_<<6)|0x31); //... y path scale filter : quad
//ReadAsicByte(DVC_PG0,0x00+(0x10*(_channel-1)));
}
WriteAsicTable(DVC_PG0,0x40,tbl_ntsc_pg0_sfr1,21);
WriteAsicTable(DVC_PG0,0x60,tbl_ntsc_pg0_sfr2,21);
WriteAsicTable(DVC_PG0,0xc0,tbl_ntsc_pg0_sfr3,11);
//------------------------------------------------------------------------------------------------
/*initPG1*/
//------------------------------------------------------------------------------------------------
//DEV_TW2835_Init();
#if 1
WriteAsicTable(DVC_PG1,0x01,tbl_pg1_x_cmn,47);
WriteAsicTable(DVC_PG1,0x50,tbl_pg1_y_cmn,80);
WriteAsicTable(DVC_PG1,0x30,tbl_ntsc_pg1_pic_qd,16); //... normal quad
WriteAsicTable(DVC_PG1,0x40,tbl_ntsc_pg1_pic_9_rb,16);
WriteAsicTable(DVC_PG1,0xa0,tbl_ntsc_pg1_enc,16);
WriteAsicByte(DVC_PG1,0x00,0x00);
for(_t1_=0;_t1_<4;_t1_++){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -