Ejemplo n.º 1
0
        public bool i2cRead(byte i2c_W_Addr, byte ICAddr, byte Rdnum, ref string RdStr)
        {
            byte outPort    = 0;
            byte i2c_R_Addr = (byte)(i2c_W_Addr + 1);

            SL_Comm_Base.SL_CommBase_ReadReg(0xa0, ref outPort);
            SL_Comm_Base.SL_CommBase_WriteReg(0xa0, 0x20);              //i2c output
            SL_Comm_Base.SL_CommBase_WriteReg(0x9c, 0x32, 0x32);        //i2c 400k
            SL_Comm_Base.SL_CommBase_WriteReg(0x9d, 0x00, 0x00, Rdnum); //i2c read count
            SL_Comm_Base.SL_CommBase_WriteReg(0x9b, 0x02);              //i2c Start
            SL_Comm_Base.SL_CommBase_WriteReg(0x80, i2c_W_Addr);
            SL_Comm_Base.SL_CommBase_WriteReg(0x80, ICAddr);
            SL_Comm_Base.SL_CommBase_WriteReg(0x9b, 0x01); //i2c stop

            SL_Comm_Base.SL_CommBase_WriteReg(0x9b, 0x02); //i2c Start
            SL_Comm_Base.SL_CommBase_WriteReg(0x80, i2c_R_Addr);
            SL_Comm_Base.SL_AddrWrite(0x83);
            for (int i = 0; i < Rdnum; i++)
            {
                RdStr += "0x" + Convert.ToString(SL_Comm_Base.SL_DataDummyRd(), 16);
            }
            SL_Comm_Base.SL_CommBase_WriteReg(0x9b, 0x01);//i2c stop
            SL_Comm_Base.SL_CommBase_WriteReg(0xa0, outPort);
            return(true);
        }
Ejemplo n.º 2
0
        public bool FpgaRead(byte Addr, int RdNum, ref string RdStr)
        {
            uint Val = 0;
            int  Ret = SL_Comm_Base.SL_CommBase_ReadReg(Addr, ref Val, RdNum);

            RdStr = "0x" + Convert.ToString(Val, 16);
            return((Ret == 0) ? true : false);
        }
Ejemplo n.º 3
0
        public bool SetMipiVideo(int vLanes, int hPixels, byte framerate, byte vbp, byte vfp, byte hbp, byte hfp, byte vsa, byte hsa)
        {
            byte HT_H = 0, HT_L = 0, VT_H = 0, VT_L = 0;
            int  Value = 0;
            uint Val   = 0;


            Value = hPixels + hsa + hbp + hfp;

            HT_H = (byte)(Value >> 8);
            HT_L = (byte)(Value & 0xff);

            HD_H = (byte)(hPixels >> 8);
            HD_L = (byte)(hPixels & 0xff);

            Value = vLanes + vsa + vbp + vfp;
            VT_H  = (byte)(Value >> 8);
            VT_L  = (byte)(Value & 0xff);

            VD_H = (byte)(vLanes >> 8);
            VD_L = (byte)(vLanes & 0xff);

            VBP = (byte)(vbp & 0xff);
            VFP = (byte)(vfp & 0xff);
            HBP = (byte)(hbp & 0xff);
            HFP = (byte)(hfp & 0xff);
            VSA = (byte)(vsa & 0xff);
            HSA = (byte)(hsa & 0xff);

            SL_Comm_Base.SL_CommBase_WriteReg(0xb4, HT_H, HT_L, HT_H, HT_L);    //TH
            SL_Comm_Base.SL_CommBase_WriteReg(0xb6, HD_H, HD_L, HD_H, HD_L);    //TH
            SL_Comm_Base.SL_CommBase_WriteReg(0xb8, 0x00, HBP, 0x00, HBP);
            SL_Comm_Base.SL_CommBase_WriteReg(0xba, HSA, HSA);
            SL_Comm_Base.SL_CommBase_WriteReg(0xb5, VT_H, VT_L, VT_H, VT_L);
            SL_Comm_Base.SL_CommBase_WriteReg(0xb7, VD_H, VD_L, VD_H, VD_L);
            SL_Comm_Base.SL_CommBase_WriteReg(0xb9, 0x00, VBP, 0x00, VBP);
            SL_Comm_Base.SL_CommBase_WriteReg(0xbb, VSA, VSA);
            SL_Comm_Base.SL_CommBase_WriteReg(0xad, 0x00, 0x00, 0x00);//Normal Data

            /*2828 Setting*/
            SL_Comm_Base.SPI_WriteReg(0xb1, VSA, HSA);
            SL_Comm_Base.SPI_WriteReg(0xb2, VBP, HBP);
            SL_Comm_Base.SPI_WriteReg(0xb3, VFP, HFP);
            SL_Comm_Base.SPI_WriteReg(0xb4, VD_H, VD_L);
            SL_Comm_Base.SPI_WriteReg(0xb5, HD_H, HD_L);

#if (DEBUG)
            SL_Comm_Base.SL_CommBase_ReadReg(0xb4, ref Val, 2);
            SL_Comm_Base.SL_CommBase_ReadReg(0xb5, ref Val, 2);
            SL_Comm_Base.SL_CommBase_ReadReg(0xb6, ref Val, 2);
            SL_Comm_Base.SL_CommBase_ReadReg(0xb7, ref Val, 2);
            SL_Comm_Base.SL_CommBase_ReadReg(0xb8, ref Val, 2);
            SL_Comm_Base.SL_CommBase_ReadReg(0xb9, ref Val, 2);
            SL_Comm_Base.SL_CommBase_ReadReg(0xba, ref Val, 2);
            SL_Comm_Base.SL_CommBase_ReadReg(0xbb, ref Val, 2);
#endif
            return(true);
        }
Ejemplo n.º 4
0
        private bool SetBoardTiming(byte BankEn, byte BankWrRd, byte Interface, byte RgbMode, byte DcmMul, byte DcmDiv)
        {
            uint Val = 0;

            SL_Comm_Base.SL_CommBase_WriteReg(0x92, 0x20); //Default(CPU/SPI From EPP, RGB from SRAM) , In_Data_Source
            SL_Comm_Base.SL_CommBase_WriteReg(0xa0, Interface);
            SL_Comm_Base.SL_CommBase_WriteReg(0xa1, RgbMode);

            SL_Comm_Base.SL_CommBase_WriteReg(0x95, 0xaa); //SPI Setting
            SL_Comm_Base.SL_CommBase_WriteReg(0x96, 0xaa); //SPI Setting

            SL_Comm_Base.SL_CommBase_WriteReg(0xf3, 0x11); //Reset
            SL_Comm_Base.SL_CommBase_WriteReg(0xf3, 0x10);
            SL_Comm_Base.SL_CommBase_WriteReg(0xf3, 0x11);

            Thread.Sleep(10);

            SL_Comm_Base.SL_CommBase_WriteReg(0xb0, BankEn);
            SL_Comm_Base.SL_CommBase_WriteReg(0xb2, BankWrRd);
            SL_Comm_Base.SL_CommBase_WriteReg(0xb3, 0x11);
            Thread.Sleep(2);

            //DCM Reset
            SL_Comm_Base.SL_CommBase_WriteReg(0xf0, 0x11);
            Thread.Sleep(2);
            SL_Comm_Base.SL_CommBase_WriteReg(0xf0, 0x10);
            Thread.Sleep(2);
            if (DcmMul < 2)
            {
                DcmMul = 2;
            }
            if (DcmDiv < 1)
            {
                DcmDiv = 1;
            }
            SL_Comm_Base.SL_CommBase_WriteReg(0xf1, DcmMul);
            SL_Comm_Base.SL_CommBase_WriteReg(0xf2, DcmDiv);
            SL_Comm_Base.SL_AddrWrite(0x8a); //Reload

#if (DEBUG)
            SL_Comm_Base.SL_CommBase_ReadReg(0x92, ref Val, 1); //0x20
            SL_Comm_Base.SL_CommBase_ReadReg(0x95, ref Val, 1); //0xaa
            SL_Comm_Base.SL_CommBase_ReadReg(0x96, ref Val, 1); //0xaa

            SL_Comm_Base.SL_CommBase_ReadReg(0xb0, ref Val, 1); //WhiskyValue[0]
            SL_Comm_Base.SL_CommBase_ReadReg(0xb2, ref Val, 1); //WhiskyValue[1]
            SL_Comm_Base.SL_CommBase_ReadReg(0xb3, ref Val, 1); //0x11

            SL_Comm_Base.SL_CommBase_ReadReg(0xa0, ref Val, 1); //WhiskyValue[2]
            SL_Comm_Base.SL_CommBase_ReadReg(0xa1, ref Val, 1); //WhiskyValue[3]

            SL_Comm_Base.SL_CommBase_ReadReg(0xf1, ref Val, 1); // WhiskyValue[4]
            SL_Comm_Base.SL_CommBase_ReadReg(0xf2, ref Val, 1); // WhiskyValue[5]
#endif
            return(true);
        }
Ejemplo n.º 5
0
        public bool i2cWrite(byte i2cAddr, byte[] i2cData)
        {
            byte outPort = 0;

            SL_Comm_Base.SL_CommBase_ReadReg(0xa0, ref outPort);
            SL_Comm_Base.SL_CommBase_WriteReg(0xa0, 0x20);             //i2c output
            SL_Comm_Base.SL_CommBase_WriteReg(0x9c, 0x32, 0x32);       //i2c 400k
            SL_Comm_Base.SL_CommBase_WriteReg(0x9d, 0x00, 0x00, 0x01); //i2c read count
            SL_Comm_Base.SL_CommBase_WriteReg(0x9b, 0x02);             //i2c Start
            SL_Comm_Base.SL_CommBase_WriteReg(0x80, i2cAddr);
            foreach (byte Data in i2cData)
            {
                SL_Comm_Base.SL_CommBase_WriteReg(0x81, Data);
            }
            SL_Comm_Base.SL_CommBase_WriteReg(0x9b, 0x01);//i2c Start
            SL_Comm_Base.SL_CommBase_WriteReg(0xa0, outPort);
            return(true);
        }