Exemple #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);
        }
Exemple #2
0
        public bool MipiWrite(byte[] Data)
        {
            byte[] WhiskyValue = Data;
            int    DataNum = WhiskyValue.Length - 1;
            byte   HD = 0, M_HD = 0, M_LD = 0, LD = 0, ConfRegH = 0, ConfRegL = 0;

            //General Packet
            if (WhiskyValue[0] == 0x29)
            {
                ConfRegH = 0x06; ConfRegL = 0x10;
            }
            if (WhiskyValue[0] == 0x03)
            {
                ConfRegH = 0x02; ConfRegL = 0x10;
            }
            if (WhiskyValue[0] == 0x13)
            {
                ConfRegH = 0x02; ConfRegL = 0x10;
            }
            if (WhiskyValue[0] == 0x23)
            {
                ConfRegH = 0x02; ConfRegL = 0x10;
            }
            //DCS
            if (WhiskyValue[0] == 0x39)
            {
                ConfRegH = 0x06; ConfRegL = 0x50;
            }
            if (WhiskyValue[0] == 0x05)
            {
                ConfRegH = 0x02; ConfRegL = 0x50;
            }
            if (WhiskyValue[0] == 0x15)
            {
                ConfRegH = 0x02; ConfRegL = 0x50;
            }

            LD   = (byte)(DataNum & 0xff);
            M_LD = (byte)((DataNum >> 8) & 0xff);
            M_HD = (byte)((DataNum >> 16) & 0xff);
            HD   = (byte)((DataNum >> 24) & 0xff);

            SL_Comm_Base.SPI_WriteReg(0xb7, ConfRegH, ConfRegL);
            SL_Comm_Base.SPI_WriteReg(0xbd, HD, M_HD);
            SL_Comm_Base.SPI_WriteReg(0xbc, M_LD, LD);

            SL_Comm_Base.BdgeSel(true);
            SL_Comm_Base.SL_CommBase_WriteReg(0x8b, 0xbf);
            SL_Comm_Base.SL_AddrWrite(0x8c);
            for (int i = 1; i < WhiskyValue.Length; i++)
            {
                SL_Comm_Base.SL_DataWrite(WhiskyValue[i]);
            }

            SL_Comm_Base.UnBgeSel();

            return(true);
        }
Exemple #3
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);
        }
Exemple #4
0
        public bool MipiHSRead(byte Addr, byte RdNum, ref string RdStr)
        {
            byte RdNumH = 0, RdNumeL = 0, C2_1 = 0, C2_2 = 0, C6_1 = 0, C6_2 = 0, Ready = 0;
            int  i = 0, k = 0, l = 0;
            uint Value = 0;

            SL_Comm_Base.SPI_WriteReg(0xb8, 0x00, 0x00);
            SL_Comm_Base.SPI_WriteReg(0xb7, 0x02, 0x89);
            SL_Comm_Base.SPI_WriteReg(0xbd, 0x00, 0x00);
            SL_Comm_Base.SPI_WriteReg(0xbc, 0x00, 0x01);

            RdNumH  = (byte)(RdNum >> 8);
            RdNumeL = (byte)(RdNum & 0xff);

            SL_Comm_Base.SPI_WriteReg(0xc1, RdNumH, RdNumeL);

            SL_Comm_Base.SPI_AddrWr(0xbf);
            SL_Comm_Base.SPI_DataWr(Addr);

            Thread.Sleep(20);

            SL_Comm_Base.SL_CommBase_WriteReg(0xb3, SL_Comm_Base.ChipSel());
            SL_Comm_Base.SPI_AddrWrNoCs(0xc2);
            SL_Comm_Base.SPI_AddrWrNoCs(0xfa);
            SL_Comm_Base.SL_AddrWrite(SL_Comm_Base.DATARDMODE_2828);
            C2_1 = SL_Comm_Base.SL_DataDummyRd();
            C2_2 = SL_Comm_Base.SL_DataDummyRd();
            SL_Comm_Base.UnBgeSel();

            Thread.Sleep(10);

            SL_Comm_Base.SL_CommBase_WriteReg(0xb3, SL_Comm_Base.ChipSel());
            SL_Comm_Base.SPI_AddrWrNoCs(0xc6);
            SL_Comm_Base.SPI_AddrWrNoCs(0xfa);
            SL_Comm_Base.SL_AddrWrite(SL_Comm_Base.DATARDMODE_2828);
            C6_1 = SL_Comm_Base.SL_DataDummyRd();
            C6_2 = SL_Comm_Base.SL_DataDummyRd();
            SL_Comm_Base.UnBgeSel();

            Thread.Sleep(10);

            Ready = (byte)(C6_1 & 0x01);
            if (Ready == 1)
            {
                SL_Comm_Base.SL_CommBase_WriteReg(0xb3, SL_Comm_Base.ChipSel());

                i = ((C2_2 * 256) + C2_1);

                SL_Comm_Base.SPI_AddrWrNoCs(0xff);

                l = 16 * (1 + i / 16);

                for (k = 0; k < l; k++)
                {
                    if (k == 0)
                    {
                        SL_Comm_Base.SPI_AddrWrNoCs(0xFA);
                        SL_Comm_Base.SL_AddrWrite(SL_Comm_Base.DATARDMODE_2828);
                    }
                    Value = SL_Comm_Base.SL_DataDummyRd();
                    if (k < i)
                    {
                        RdStr += "Rd[" + k + "]= 0x" + Convert.ToString(Value, 16) + " ";
                    }
                }

                SL_Comm_Base.UnBgeSel();
            }
            return(true);
        }
Exemple #5
0
        public bool MipiRead(byte Addr, byte RdNum, ref byte[] RdVal)
        {
            byte RdNumH = 0, RdNumeL = 0, C2_1 = 0, C2_2 = 0, C6_1 = 0, C6_2 = 0, Ready = 0;
            int  i = 0, k = 0, l = 0, j = 2;
            uint Value = 0;
            bool ret   = true;

            if (RdVal.Length != RdNum)
            {
                return(false);
            }

            SL_Comm_Base.SPI_WriteReg(0xb8, 0x00, 0x00);
            SL_Comm_Base.SPI_WriteReg(0xb7, 0x02, 0x80);
            SL_Comm_Base.SPI_WriteReg(0xbd, 0x00, 0x00);
            SL_Comm_Base.SPI_WriteReg(0xbc, 0x00, 0x01);

            RdNumH  = (byte)(RdNum >> 8);
            RdNumeL = (byte)(RdNum & 0xff);

            SL_Comm_Base.SPI_WriteReg(0xc1, RdNumH, RdNumeL);

            SL_Comm_Base.SPI_AddrWr(0xbf);
            SL_Comm_Base.SPI_DataWr(Addr);
            Thread.Sleep(20);

            SL_Comm_Base.SL_CommBase_WriteReg(0xb3, SL_Comm_Base.ChipSel());
            SL_Comm_Base.SPI_AddrWrNoCs(0xc2);
            SL_Comm_Base.SPI_AddrWrNoCs(0xfa);
            SL_Comm_Base.SL_AddrWrite(SL_Comm_Base.DATARDMODE_2828);
            C2_1 = SL_Comm_Base.SL_DataDummyRd();
            C2_2 = SL_Comm_Base.SL_DataDummyRd();
            SL_Comm_Base.UnBgeSel();

            Thread.Sleep(20);

            SL_Comm_Base.SL_CommBase_WriteReg(0xb3, SL_Comm_Base.ChipSel());
            SL_Comm_Base.SPI_AddrWrNoCs(0xc6);
            SL_Comm_Base.SPI_AddrWrNoCs(0xfa);
            SL_Comm_Base.SL_AddrWrite(SL_Comm_Base.DATARDMODE_2828);
            C6_1 = SL_Comm_Base.SL_DataDummyRd();
            C6_2 = SL_Comm_Base.SL_DataDummyRd();
            SL_Comm_Base.UnBgeSel();

            Thread.Sleep(10);

            Ready = (byte)(C6_1 & 0x01);
            if (Ready == 1)
            {
                SL_Comm_Base.SL_CommBase_WriteReg(0xb3, SL_Comm_Base.ChipSel());

                i = ((C2_2 * 256) + C2_1);

                SL_Comm_Base.SPI_AddrWrNoCs(0xff);

                l = 16 * (1 + i / 16);

                for (k = 0; k < l; k++)
                {
                    if (j == 2)
                    {
                        SL_Comm_Base.SPI_AddrWrNoCs(0xFA);
                        SL_Comm_Base.SL_AddrWrite(SL_Comm_Base.DATARDMODE_2828);
                        j = 0;
                    }
                    Value = SL_Comm_Base.SL_DataDummyRd();
                    if (k < i)
                    {
                        RdVal[k] = (byte)Value;
                    }
                    j++;
                }

                SL_Comm_Base.UnBgeSel();
                ret = true;
            }
            else
            {
                ret = false;
            }
            return(ret);
        }
        public bool MipiHSRead(byte Addr, byte RdNum, ref string RdStr)
        {
            byte RdNumH = 0, RdNumeL = 0, C2_1 = 0, C2_2 = 0, C6_1 = 0, C6_2 = 0, Ready = 0, BTAR = 0, LPTO = 0, DST = 0, CST = 0;
            int  i = 0, k = 0, l = 0, j = 2;
            uint Value = 0;
            bool ret   = true;

            RdStr = null;

            SL_Comm_Base.SPI_WriteReg(0xb8, 0x00, 0x00);
            SL_Comm_Base.SPI_WriteReg(0xb7, 0x02, 0x89);
            SL_Comm_Base.SPI_WriteReg(0xbd, 0x00, 0x00);
            SL_Comm_Base.SPI_WriteReg(0xbc, 0x00, 0x01);

            RdNumH  = (byte)(RdNum >> 8);
            RdNumeL = (byte)(RdNum & 0xff);


            SL_Comm_Base.SPI_WriteReg(0xc1, RdNumH, RdNumeL);

            SL_Comm_Base.SPI_AddrWr(0xbf);
            SL_Comm_Base.SPI_DataWr(Addr);
            Thread.Sleep(20);

            SL_Comm_Base.SL_CommBase_WriteReg(0xb3, SL_Comm_Base.ChipSel());
            SL_Comm_Base.SPI_AddrWrNoCs(0xc2);
            Thread.Sleep(1);
            SL_Comm_Base.SPI_AddrWrNoCs(0xfa);
            SL_Comm_Base.SL_AddrWrite(SL_Comm_Base.DATARDMODE_2828);
            C2_1 = SL_Comm_Base.SL_DataDummyRd();
            C2_2 = SL_Comm_Base.SL_DataDummyRd();
            SL_Comm_Base.UnBgeSel();

            Thread.Sleep(20);

            SL_Comm_Base.SL_CommBase_WriteReg(0xb3, SL_Comm_Base.ChipSel());
            SL_Comm_Base.SPI_AddrWrNoCs(0xc6);
            Thread.Sleep(1);
            SL_Comm_Base.SPI_AddrWrNoCs(0xfa);
            SL_Comm_Base.SL_AddrWrite(SL_Comm_Base.DATARDMODE_2828);
            C6_1 = SL_Comm_Base.SL_DataDummyRd();
            C6_2 = SL_Comm_Base.SL_DataDummyRd();
            SL_Comm_Base.UnBgeSel();

            Thread.Sleep(20);


            CST   = (byte)((C6_2 & 0x8) >> 3);
            DST   = (byte)((C6_2 & 0x4) >> 2);
            LPTO  = (byte)((C6_1 & 0x40) >> 6);
            BTAR  = (byte)((C6_1 & 0x04) >> 2);
            Ready = (byte)(C6_1 & 0x01);

            if (LPTO == 1)
            {
                SL_Comm_Base.SPI_WriteReg(0xc0, 0x00, 0x01); Thread.Sleep(50);
            }

            Thread.Sleep(10);

            if (Ready == 1)
            {
                SL_Comm_Base.SL_CommBase_WriteReg(0xb3, SL_Comm_Base.ChipSel());

                i = ((C2_2 * 256) + C2_1);

                SL_Comm_Base.SPI_AddrWrNoCs(0xff);

                l = 16 * (1 + i / 16);

                for (k = 0; k < l; k++)
                {
                    if (j == 2)
                    {
                        SL_Comm_Base.SPI_AddrWrNoCs(0xFA);
                        SL_Comm_Base.SL_AddrWrite(SL_Comm_Base.DATARDMODE_2828);
                        j = 0;
                    }

                    Value = SL_Comm_Base.SL_DataDummyRd();

                    if (k < i)
                    {
                        RdStr += "Rd[" + k + "]= 0x" + Convert.ToString(Value, 16) + " ";
                    }
                    j++;
                }

                SL_Comm_Base.UnBgeSel();
                ret = true;
            }
            else
            {
                ret   = false;
                RdStr = "Mipi Read Not Ready";
            }
            return(ret);
        }