📄 tw2835.c
字号:
#include <REG_MPC82G516.h>//"C:\Keil\C51\INC\Megawin\REG_MPC82G516.h" //REG_MPC82G516.h //reg82xx.h
//#include <intrins.h>
#include <Tw2835.h>
/****************************************************************************/
/* Const, Macro, type definition */
/****************************************************************************/
#define DEV_I2C_SET_DEV_ADDR(devAddr, dir) ( ( (devAddr) << 1 ) | ( (dir) & 0x1 ) )
/****************************************************************************/
/* External Functions */
/****************************************************************************/
extern void I2cStart(void);
extern BOOL I2cSentByte(Byte bytedata);
extern void I2cStop(void);
extern void delay1ms(unsigned char);
extern Byte I2cReceiveByte(void);
extern void SendAcknowledge(BOOL ack);
/****************************************************************************/
/* External Variables */
/****************************************************************************/
/****************************************************************************/
/* Global Functions */
/****************************************************************************/
/****************************************************************************/
/* Local Functions declaration */
/****************************************************************************/
/****************************************************************************/
/* Global Variables */
/****************************************************************************/
/****************************************************************************/
/* Local Variables declartaion */
/****************************************************************************/
/****************************************************************************/
/* Brief : cmd = 0 */
/* Return : */
/* Description : */
/****************************************************************************/
//extern U8 ReadAsicByte(U8 _pg, U8 _addr);
STATUS ReadAsicByte(unsigned char page, unsigned char adr , unsigned char *dat )
{
STATUS Status = E_PASS;
Byte bytedata;
I2cStart();
Status = I2cSentByte( DEV_I2C_SET_DEV_ADDR((TW2835_I2C_ID>>1), I2C_WRITE) );
Status = I2cSentByte(page);//page
Status = I2cSentByte(adr);//_addr
I2cStop( );
I2cStart();
Status = I2cSentByte( DEV_I2C_SET_DEV_ADDR((TW2835_I2C_ID>>1), I2C_READ) );
bytedata=I2cReceiveByte( );
SendAcknowledge(1);
I2cStop( );
*dat = bytedata;
return Status;
}
/****************************************************************************/
/* Brief : cmd = 0 */
/* Return : */
/* Description : */
/****************************************************************************/
//void WriteAsicByte(U8 _pg, U8 _addr, U8 _wdat)
STATUS WriteAsicByte( unsigned char _pg, unsigned char _addr, unsigned char _wdat )
{
STATUS Status = E_PASS;
I2cStart();
Status = I2cSentByte( DEV_I2C_SET_DEV_ADDR((TW2835_I2C_ID>>1), I2C_WRITE) );
Status = I2cSentByte(_pg);//page
Status = I2cSentByte(_addr);//_addr
Status = I2cSentByte(_wdat);//_wdat
I2cStop( );
delay1ms(1);
return( Status );
}
//==================================================================================
STATUS WriteAsicTable(unsigned char _pg, unsigned char _addr, unsigned char *_tbl_ptr, unsigned char _tbl_cnt)
{
unsigned char _t1_,adrr;
STATUS Status = E_PASS;
adrr = _addr;
for(_t1_=0;_t1_<_tbl_cnt;_t1_++){
WriteAsicByte( _pg, adrr, *_tbl_ptr );
//SetAsicI2CP2S(*_tbl_ptr);
_tbl_ptr++;
adrr++;
}
return Status;
}
STATUS WriteAsicByteOSD(unsigned char _addr, unsigned char _wdat)
{
STATUS Status = E_PASS;
I2cStart();
Status = I2cSentByte( DEV_I2C_SET_DEV_ADDR((TW2835_I2C_ID>>1), I2C_WRITE) );
Status = I2cSentByte(0x02);//page
Status = I2cSentByte(_addr);//_addr
Status = I2cSentByte(_wdat);//_wdat
I2cStop( );
delay1ms(1);
return( Status );
}
unsigned char ReadAsicOSDMemWr()
{
unsigned char _rdat_;
STATUS Status;
I2cStart();
Status = I2cSentByte( DEV_I2C_SET_DEV_ADDR((TW2835_I2C_ID>>1), I2C_WRITE) );
Status = I2cSentByte(0x02);//page
Status = I2cSentByte(0x0a);//_addr
I2cStart();
Status = I2cSentByte( DEV_I2C_SET_DEV_ADDR((TW2835_I2C_ID>>1), I2C_READ) );
_rdat_=I2cReceiveByte( );
SendAcknowledge(1);
I2cStop( );
return _rdat_;
}
#if 0
/* */
/* test for one change input */
STATUS DEV_TW2835_Init( void )
{
STATUS Status = E_PASS;
///MUST ADD RESET PLUSE TO TW2835
/*initPG1*/
//0x28,0x00,0x10,0xa0,0x00,0x00,0x00,0x03, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa7, //... 0x50
//WriteAsicTable(DVC_PG1,0x50,tbl_pg1_y_cmn,80);
Status = WriteAsicByte(DVC_PG1 ,0x50,0x28);
Status = WriteAsicByte(DVC_PG1 ,0x51,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x52,0x10);
Status = WriteAsicByte(DVC_PG1 ,0x53,0xa0);
Status = WriteAsicByte(DVC_PG1 ,0x54,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x55,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x56,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x57,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x58,0x03);
Status = WriteAsicByte(DVC_PG1 ,0x59,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x5a,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x5b,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x5c,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x5d,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x5e,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x5f,0xa7);
//0x80,0x02,0x00,0x81,0x02,0x00,0x82,0x02, 0x00,0x83,0x02,0x00,0x00,0xe4,0x00,0x00, //... 0x60 //... normal quad
Status = WriteAsicByte(DVC_PG1 ,0x60,0x80);
Status = WriteAsicByte(DVC_PG1 ,0x61,0x02);
Status = WriteAsicByte(DVC_PG1 ,0x62,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x63,0x81);
Status = WriteAsicByte(DVC_PG1 ,0x64,0x02);
Status = WriteAsicByte(DVC_PG1 ,0x65,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x66,0x82);
Status = WriteAsicByte(DVC_PG1 ,0x67,0x02);
Status = WriteAsicByte(DVC_PG1 ,0x68,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x69,0x83);
Status = WriteAsicByte(DVC_PG1 ,0x6a,0x02);
Status = WriteAsicByte(DVC_PG1 ,0x6b,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x6c,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x6d,0xE4);
Status = WriteAsicByte(DVC_PG1 ,0x6e,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x6f,0x00);
//0x00,0x03,0x00,0x00,0x00,0x00,0x02,0x00, 0xff,0xff,0xff,0xff,0xf0,0x00,0x89,0x84, //... 0x70
Status = WriteAsicByte(DVC_PG1 ,0x70,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x71,0x03);
Status = WriteAsicByte(DVC_PG1 ,0x72,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x73,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x74,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x75,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x76,0x02);
Status = WriteAsicByte(DVC_PG1 ,0x77,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x78,0xff);
Status = WriteAsicByte(DVC_PG1 ,0x79,0xff);
Status = WriteAsicByte(DVC_PG1 ,0x7a,0xff);
Status = WriteAsicByte(DVC_PG1 ,0x7b,0xff);
Status = WriteAsicByte(DVC_PG1 ,0x7c,0xf0);
Status = WriteAsicByte(DVC_PG1 ,0x7d,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x7e,0x89);
Status = WriteAsicByte(DVC_PG1 ,0x7f,0x84);
Status = WriteAsicByte(DVC_PG1 ,0x80,0xdf);
Status = WriteAsicByte(DVC_PG1 ,0x81,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x82,0x91);
Status = WriteAsicByte(DVC_PG1 ,0x83,0x07);
Status = WriteAsicByte(DVC_PG1 ,0x84,0xeb);
Status = WriteAsicByte(DVC_PG1 ,0x85,0x10);
Status = WriteAsicByte(DVC_PG1 ,0x86,0xa8);
Status = WriteAsicByte(DVC_PG1 ,0x87,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x88,0x91);
Status = WriteAsicByte(DVC_PG1 ,0x89,0xe7);
Status = WriteAsicByte(DVC_PG1 ,0x8a,0x80);
Status = WriteAsicByte(DVC_PG1 ,0x8b,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x8c,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x8d,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x8e,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x8f,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x90,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x91,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x92,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x93,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x94,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x95,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x96,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x97,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x98,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x99,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x9a,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x9b,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x9c,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x9d,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x9e,0x00);
Status = WriteAsicByte(DVC_PG1 ,0x9f,0x00);
Status = WriteAsicByte(DVC_PG1 ,0xa0,0x77);
Status = WriteAsicByte(DVC_PG1 ,0xa1,0x23);
Status = WriteAsicByte(DVC_PG1 ,0xa2,0xd7);
Status = WriteAsicByte(DVC_PG1 ,0xa3,0x01);
Status = WriteAsicByte(DVC_PG1 ,0xa4,0x80);
Status = WriteAsicByte(DVC_PG1 ,0xa5,0x20);
Status = WriteAsicByte(DVC_PG1 ,0xa6,0x00);
Status = WriteAsicByte(DVC_PG1 ,0xa7,0x0c);
Status = WriteAsicByte(DVC_PG1 ,0xa8,0x20);
Status = WriteAsicByte(DVC_PG1 ,0xa9,0x00);
Status = WriteAsicByte(DVC_PG1 ,0xaa,0xaa);
Status = WriteAsicByte(DVC_PG1 ,0xab,0x00);
Status = WriteAsicByte(DVC_PG1 ,0xac,0x40);
Status = WriteAsicByte(DVC_PG1 ,0xad,0x40);
Status = WriteAsicByte(DVC_PG1 ,0xae,0x00);
Status = WriteAsicByte(DVC_PG1 ,0xaf,0x00);
return Status;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -