This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TLC6946: TLC6946: Basic example for text scrolling on LED matrix

Part Number: TLC6946

Dear TI,

<<Keep this message as private>>

We are developing Monochrome 16X32 Led matrix 4 panels in series for Text scrolling for Indian Railways.

From forums it was suggested to use FPGA.

Our requirement is,

1. Ghost removal

2. Fluid text scroll

3. Flicker free

4. Caterpiller effect removal ... etc

Q1. Please let me  is it possible to use cortex M4 for driving TLC6946 to achieve smooth text scroll with out flickering? or we need to use FPGA?

Q2. You are very good in providing sample code and application notes. But for TLC6946, i am unlucky.  Please provide demo code for Text scrolling.

Competitions are giving basic text scrolling functionality with 8051 like low end micro-controllers and got approvals.

With TLC6946 we want to provide quality product but not too much cost deviation.Is it possible?

Please suggest cost effective solution.

Regards,

Kishore

  • Hi Kishore,

    Sorry for the late reply.

    Yes, you can use MCU GPIOs to drive TLC6946, but the speed will be limited by GPIO. Currently, we have no sample code with MCU to fit multiplexing, if you are interested, we have one device which will be released soon, this device can use SPI to drive and one device can drive 16*48 LED matrix.

    could you contact TI sales/FAE, we can share you the material through that channel.

    Regards,

    Shawn.

  • In need support for 16X32 monochrome led display. But suggested solution seems 16X48 RGB LED matrix.

    Ours is startup company and We dont have FAE or TI Sales, Dont know how to proceed further.

    We need portable c/c++ library for driving TLC6946. we want to use it for LED text scrolling for Indian Railways.

    Though it adds cost to our product, I am trying to add this product to improve over all product quality,

    But without drivers and alternative solutions it will be difficult for us to do test TLC6946,

    I am still not clear How much GPIO speed is required to get complete performance of TLC696.

  • OK, got it.  here I attach theTLC6946 code with multiplexing function for your reference.

    0564.main.c
    #include "TLC6946_Line.h"
    void GPIOInit(void);
    #define SYSTICK_RELOAD_VAL 160000UL
    void flash_test(void);
    
    int main(void)
    {
    // system configuration, depends on different MCU
    	SystemInit();
    	{
    		Flashc_MainWriteEnable();
    		Flashc_WorkWriteEnable();
    	}
    
    	WDT_Init();
    	WDT_Enable();
    	/* Place your initialization/startup code here (e.g. MyInst_Start()) */
    	SysTick_Init(SYSTICK_CLOCK_SOURCE_CLK_CPU, SYSTICK_RELOAD_VAL);
    	SysTick_SetCallback(0, time_interval);
    	SysTick_Enable();
    
    	GPIOInit();
    	(void)Appl_EcuStartup();
    	(void)Appl_FlStartup();
    	__enable_irq();/* Enable global interrupts. */
    	
     // initialization/startup
    	TLC6946_PinsInit(void);
    	FC1_Write( FC1_Value);// send the value of FC registers
    	FC2_Write( FC2_Value);
    	FC3_Write( FC3_Value);
    	FC4_Write( FC4_Value);
    
    	
    	for(;;)
    	{ 
    		WDT_ClearWatchdog();
    
    		Frame_process();
    	}
    }
    /* [] END OF FILE */
    
    TLC6946_Line.c
    /*****************************************************************************************
    **	Include Files
    *****************************************************************************************/
    #include "TLC5958_D7258.h"
    
    #if (isway1 == 0)
    /*****************************************************************************************
    **	variable define
    *****************************************************************************************/
    //D7258
    uint8 D7258_config_line_num = 0;//7258���õ��к�
    uint8 D7258_active_line_complete_flag = 0;//7258����һ����ɱ�־,��1��ɣ���0δ���
    //GS
    uint8 GS_line_num = 0;//GS����д����к�
    uint8 GS_unit_num = 0;//GS����д��ĵ�Ԫ��
    uint8 GS_chip_num = 0;//GS����д���оƬ��
    uint8 GS_write_complete_flag = 0;//д��������ɣ�1��δ��ɣ�0
    uint8 Send_Vsync_Com_complete_flag = 1;
    //GCLK
    uint8 GCLK_line_cnt = 0;//����GCLK���
    uint16 GCLK_pulse_cnt = 0;//����GCLK���������ÿ�������ڹ���256*N��NΪ��������GCLK
    uint16 GCLK_subperiod_cnt = 0;//����GCLK�����ڼ���(8+8ģʽ��256��������)
    uint8 GCLK_send_complete_flag = 0;//����GCLK��ɣ�1��δ��ɣ�0
    
    uint8 FC2DATA[48] =
    {
    	0,1,1,0,	//0110�FC2
    	0,0,		//Reverse_V_R
    	0,0,		//Interference_R
    	0,0,		//Reverse_V_G
    	0,0,		//Interference_G
    	0,0,		//Reverse_V_B
    	0,0,		//Interference_B
    	0,0,0,0,	//lgse1-r
    	0,0,0,0,	//lgse1-g
    	0,0,0,0,	//lgse1-b
    	1,
    	0,0,
    	0,1,
    	0,0,0,0,
    	0,0,0,		//��Ҫ�Ķ�
    	0,			//Ԥ���ģʽѡ��
    	0,			//GLCK �������ã��˴�0����ֻ���������½�OUTn������
    	0,			//ʡ��ģʽ���˴�0����ر�
    	1,0,1,1,1	//���ñȣ��˴�����24��
    };
    
    //16��48λ��ȵĴ洢��Ԫ, ÿ����Ԫ����һ��ͨ����R/G/B�Ҷȣ�GS������
    uint64 GS_Data[16] =
    {
    /*	//B   G   R
    	0x00000000FFFF,//0
    	0x0000FFFF0000,
    	0xFFFF00000000,
    	0x0000FFFFFFFF,
    	0xFFFF0000FFFF,
    	0xFFFFFFFF0000,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF//15*/
    
    	0xFFFFFFFFFFFF,//0
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF//15
    };
    
    /*****************************************************************************************
    **	function define
    *****************************************************************************************/
    //SCLK/GCLK/LAT/SDI�ܽų�ʼ��
    void TLC5958_PinsInit(void)
    {
    	//todo:����SCLK/GCLK/LAT/SDI��4 ���ܽ�Ϊ�������
    }
    
    //ʹ��д��FC
    void FCWRTEN(void)
    {
    	SDI_L;SCLK_L;LAT_L;
    	SCLK_H;SCLK_L;
    
    	//LAT����ʱ15��ʱ���źŴ���д�뵽FC
    	LAT_H;
    	SCLK_H;SCLK_L;//1
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;//15
    
    	LAT_L;SCLK_L;
    }
    
    //WriteDataToSDI����д�����ݡ�CMD:0 ������ 1��ҪWRTGS����
    void WriteDataToSDI(uint16 data, uint8 size, uint8 cmd)
    {
    	uint8 cnt;
    	for(cnt=size; cnt>0; cnt--)
    	{
    		if((cmd == 1) && (cnt == 1))
    		{
    			LAT_H;
    			SCLK_L;
    			SDI_V(data >> (cnt - 1));SCLK_H;SCLK_L;
    			LAT_L;
    			SCLK_L;
    		}
    		else
    		{
    			SDI_V(data >> (cnt - 1));SCLK_H;SCLK_L;
    		}
    	}
    }
    
    void FC1_Write(uint8 BC, uint16 CCR, uint16 CCG, uint16 CCB)
    {
    	uint8_t i;
    	FCWRTEN();
    	//write FC1
    	for(i=CHIPS_NUM; i>0; i--)
    	{
    		//44-47����FC1����FC2 FC1: 1001 FC2:0110
    		SDI_H;SCLK_H;SCLK_L;//head
    		SDI_L;SCLK_H;SCLK_L;
    		SDI_L;SCLK_H;SCLK_L;
    		SDI_H;SCLK_H;SCLK_L;
    		//41-43 BC��
    		SDI_V(BC>>2);SCLK_H;SCLK_L;//BC
    		SDI_V(BC>>1);SCLK_H;SCLK_L;
    		SDI_V(BC);SCLK_H;SCLK_L;
    		//32-40 CCR
    		WriteDataToSDI(CCR, 9, 0);
    		//23-31 CCG
    		WriteDataToSDI(CCG, 9, 0);
    		//14-22 CCR
    		WriteDataToSDI(CCB, 9, 0);
    
    		SDI_L;SCLK_H;SCLK_L;//CUE
    		SDI_L;SCLK_H;SCLK_L;//RSV
    		SDI_L;SCLK_H;SCLK_L;
    		SDI_L;SCLK_H;SCLK_L;
    		SDI_L;SCLK_H;SCLK_L;//PREC_MODE3
    		SDI_H;SCLK_H;SCLK_L;//PREC_EN
    		SDI_L;SCLK_H;SCLK_L;//RSV
    		SDI_L;SCLK_H;SCLK_L;
    		SDI_L;SCLK_H;SCLK_L;
    		//LAT����Ȼ��5��ʱ��д�����
    		if(i == 1)
    		{
    			LAT_H;
    		}
    		SDI_H;SCLK_H;SCLK_L;//LOD
    
    		SDI_L;SCLK_H;SCLK_L;
    		SDI_H;SCLK_H;SCLK_L;//TD0
    
    		SDI_L;SCLK_H;SCLK_L;
    		SDI_H;SCLK_H;SCLK_L;//LODVTH
    
    		LAT_L;SCLK_L;
    	}
    }
    void FC2_Write(uint8 * data)//FC2 is set to default value, only used in multiplexing application
    {
    	uint8 i, j;
    	FCWRTEN();
    	//�FC2
    	for(j=CHIPS_NUM; j>0; j--)
    	{
    		for(i=0; i<48; i++)//��д��48λ
    		{
    			if(i <= 42)
    			{
    				SDI_V(data[i]);SCLK_H;SCLK_L;
    			}
    			else if((i == 43) && (j == 1))//���һ��оƬ�������λҪ��LAT���ߣ�ʹ������д��FC2
    			{
    				LAT_H;
    				SDI_V(data[i]);SCLK_H;SCLK_L;
    			}
    			else//ֻ�ڵ�43λ��������һ�Σ�֮�����ظ�����
    			{
    				SDI_V(data[i]);SCLK_H;SCLK_L;
    			}
    		}
    	}
    	LAT_L;SCLK_L;
    }
    
    
    void WriteDataToSDI(uint64 **data, uint8 size, uint8 cmd)
    {
    	uint8 cnt;
    	for(cnt=size; cnt>0; cnt--)
    	{
    		if((cmd == 1) && (cnt == 1))
    		{
    			LAT_H;
    			SCLK_L;
    			SDI_V(data >> (cnt - 1));SCLK_H;SCLK_L;
    			LAT_L;
    			SCLK_L;
    		}
    		else
    		{
    			SDI_V(data >> (cnt - 1));SCLK_H;SCLK_L;
    		}
    	}
    }
    
    
    
    
    //-------------------------------------------------------------------------------------------
    //������
    //-------------------------------------------------------------------------------------------
    
    void GS_DataInit(uint64 data[24][256])//���ݳ�ʼ��
    {
    	uint8 i, j;
    	for(i=0;i<24;i++)
    	{
    		for(j=0;j<256;j++)
    		{
    			if(j<80)
    			{
    				data[i][j]=0x00000000FFFF;
    			}
    			else if(j<160)
    			{
    				data[i][j]=0x0000FFFF0000;
    			}
    			else
    			{
    				data[i][j]=0xFFFF00000000;
    			}
    		}
    	}
    }
    
    
    void GS_DataWrite(uint64 data[24][256], uint8 chip_num)//һ֡���ݷ���
    {
    	uint64 GSdata;
    	uint8 chip_index, column, line,send_bit;
    	for(line=0;line<TOTAL_LINE_NUM;line++)
    	{
    		for(column=0;column<16;column++)//дijһ�����е�
    		{
    			for(chip_index=0;chip_index < chip_num,chip_index++)//�N ����
    			{
    				send_bit=48;
    				while(send_bit>1)
    				{										
    					SDI_V(data[line][chip_index*16+column] >> (send_bit - 1));SCLK_H;SCLK_L;
    					send_bit--;
    				}
    				if(chip_index==chip_num-1)
    				{
    					LAT_H;
    					SCLK_L;
    				}
    
    				SDI_V(data[line][chip_index*16+column] >> (send_bit - 1));SCLK_H;SCLK_L;
    				LAT_L;
    			}
    		}
    	}	
    }
    
    void TIMER0_IRQHandler()//�ö�ʱ���ж�����֡�ʣ�����������60Hz, 16.67ms
    {
    	frame_rate_flag=1;
    }
    
    //�ȴ�д��������ٷ���Vsync���֪ͨ����BANK
    void SendVsyncCommand()
    {
    	SCLK_L;LAT_L;//Ϊ��ֹ�����������������ܽ����ߣ��Ƚ��������ܽ����ͣ�����һ��
    	LAT_H;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	LAT_L;SCLK_L;
    }
    
    
    void Line_select(uint8 line_index)//��ѡ��
    {
    	uint8 line_num;
    	if(line_index < 8)
    	{
    		C1_ENL_L;C2_ENL_H;C3_ENL_H;
    		line_num = line_index;
    	}
    	else if(line_index >= 8 && line_index < 16)
    	{
    		C1_ENL_H;C2_ENL_L;C3_ENL_H;
    		line_num = line_index - 8;
    	}
    	else if(line_index >= 16 && line_index < 24)
    	{
    		C1_ENL_H;C2_ENL_H;C3_ENL_L;
    		line_num = line_index - 16;
    	}
    	else
    	{
    		//do nothing
    	}
    	
    	switch(line_num)
    	{
    		case 0:
    			D7258_A_L;D7258_B_L;D7258_C_L;
    		break;
    		case 1:
    			D7258_A_L;D7258_B_L;D7258_C_H;
    		break;
    		case 2:
    			D7258_A_L;D7258_B_H;D7258_C_L;
    		break;
    		case 3:
    			D7258_A_L;D7258_B_H;D7258_C_H;
    		break;
    		case 4:
    			D7258_A_H;D7258_B_L;D7258_C_L;
    		break;
    		case 5:
    			D7258_A_H;D7258_B_L;D7258_C_H;
    		break;
    		case 6:
    			D7258_A_H;D7258_B_H;D7258_C_L;
    		break;
    		case 7:
    			D7258_A_H;D7258_B_H;D7258_C_H;
    		break;
    		default:
    		break;
    	}
    }
    void SendGCLK()//total 257 GCLK, ��Ҫ��ѭ����䣬����ʡ��ѭ���жϵ�ʱ��
    {
    	GCLK_L3;
    	GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;//10 x GCLK�ź�
    	GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;//10 x GCLK�ź�
    	GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK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x GCLK�ź�		
    }
    
    uint8 subperiod=2;//����PWM bit ��������ˢ����
    void Frame_process()//�˳����ִ��ʱ��һ��ҪС��16.67ms,��С��һ֡��ʱ�䡣��main() ����ֱ�ӵ�����������Ϳ����ˡ�
    {
    	uint8 line_index;
    	uint8 subperiod_index;
    	uint64 photo[24][256];
    	GS_DataInit(photo);
    	if(frame_rate_flag==1)
    	{
    		GS_DataWrite(photo,CHIPS_NUM);//дһ֡����
    		SendVsyncCommand();//��VSYNC����
    		subperiod_index=0;//��һ֡��GCLK�ͻ����ź�
    		while(subperiod_index<subperiod)
    		{
    			for(line_index=0;line_index<TOTAL_LINE_NUM;line_index++)
    			{
    				Line_select(line_index);
    				SendGCLK()//��GCLKʱ��
    			}
    			subperiod_index++;
    		}
    		frame_rate_flag=0;
    	}
    }
    
    //--------------------------------------------------------------------------------------------------------
    //һά����
    //--------------------------------------------------------------------------------------------------------
    void GS_DataInit(uint64 data[6144])//���ݳ�ʼ��
    {
    	uint8 i, j;
    	for(i=0;i<24;i++)
    	{
    		for(j=0;j<256;j++)
    		{
    			if(j<80)
    			{
    				data[(i+1)*j]=0x00000000FFFF;
    			}
    			else if(j<160)
    			{
    				data[(i+1)*j]=0x0000FFFF0000;
    			}
    			else
    			{
    				data[(i+1)*j]=0xFFFF00000000;
    			}
    		}
    	}
    }
    
    
    void GS_DataWrite(uint64 data[6144], uint8 chip_num)//һ֡���ݷ���
    {
    	uint64 GSdata;
    	uint8 chip_index, column, line,send_bit;
    	for(line=0;line<TOTAL_LINE_NUM;line++)
    	{
    		for(column=0;column<16;column++)//дijһ�����е�
    		{
    			for(chip_index=0;chip_index < chip_num,chip_index++)//�N ����
    			{
    				send_bit=48;
    				while(send_bit>1)
    				{										
    					SDI_V(data[(line+1)*(chip_index*16+column)] >> (send_bit - 1));SCLK_H;SCLK_L;
    					send_bit--;
    				}
    				if(chip_index==chip_num-1)
    				{
    					LAT_H;
    					SCLK_L;
    				}
    
    				SDI_V(data[(line+1)*(chip_index*16+column)] >> (send_bit - 1));SCLK_H;SCLK_L;
    				LAT_L;
    			}
    		}
    	}	
    }
    
    void TIMER0_IRQHandler()//�ö�ʱ���ж�����֡�ʣ�����������60Hz, 16.67ms
    {
    	frame_rate_flag=1;
    }
    
    //�ȴ�д��������ٷ���Vsync���֪ͨ����BANK
    void SendVsyncCommand()
    {
    	SCLK_L;LAT_L;//Ϊ��ֹ�����������������ܽ����ߣ��Ƚ��������ܽ����ͣ�����һ��
    	LAT_H;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	SCLK_H;SCLK_L;
    	LAT_L;SCLK_L;
    }
    
    
    void Line_select(uint8 line_index)//��ѡ��
    {
    	uint8 line_num;
    	if(line_index < 8)
    	{
    		C1_ENL_L;C2_ENL_H;C3_ENL_H;
    		line_num = line_index;
    	}
    	else if(line_index >= 8 && line_index < 16)
    	{
    		C1_ENL_H;C2_ENL_L;C3_ENL_H;
    		line_num = line_index - 8;
    	}
    	else if(line_index >= 16 && line_index < 24)
    	{
    		C1_ENL_H;C2_ENL_H;C3_ENL_L;
    		line_num = line_index - 16;
    	}
    	else
    	{
    		//do nothing
    	}
    	
    	switch(line_num)
    	{
    		case 0:
    			D7258_A_L;D7258_B_L;D7258_C_L;
    		break;
    		case 1:
    			D7258_A_L;D7258_B_L;D7258_C_H;
    		break;
    		case 2:
    			D7258_A_L;D7258_B_H;D7258_C_L;
    		break;
    		case 3:
    			D7258_A_L;D7258_B_H;D7258_C_H;
    		break;
    		case 4:
    			D7258_A_H;D7258_B_L;D7258_C_L;
    		break;
    		case 5:
    			D7258_A_H;D7258_B_L;D7258_C_H;
    		break;
    		case 6:
    			D7258_A_H;D7258_B_H;D7258_C_L;
    		break;
    		case 7:
    			D7258_A_H;D7258_B_H;D7258_C_H;
    		break;
    		default:
    		break;
    	}
    }
    void SendGCLK()//total 257 GCLK, ��Ҫ��ѭ����䣬����ʡ��ѭ���жϵ�ʱ��
    {
    	GCLK_L3;
    	GCLK_H3;GCLK_L3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3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;//10 x GCLK�ź�
    	GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;//10 x GCLK�ź�
    	GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;GCLK_H3;GCLK_L3;//7 x GCLK�ź�		
    }
    
    uint8 subperiod=2;//����PWM bit ��������ˢ����
    void Frame_process()//�˳����ִ��ʱ��һ��ҪС��16.67ms,��С��һ֡��ʱ�䡣��main() ����ֱ�ӵ�����������Ϳ����ˡ�
    {
    	uint8 line_index;
    	uint8 subperiod_index;
    	uint64 photo[6144];
    	GS_DataInit(photo);
    	if(frame_rate_flag==1)
    	{
    		GS_DataWrite(photo,CHIPS_NUM);//дһ֡����
    		SendVsyncCommand();//��VSYNC����
    		subperiod_index=0;//��һ֡��GCLK�ͻ����ź�
    		while(subperiod_index<subperiod)
    		{
    			for(line_index=0;line_index<TOTAL_LINE_NUM;line_index++)
    			{
    				Line_select(line_index);
    				SendGCLK()//��GCLKʱ��
    			}
    			subperiod_index++;
    		}
    		frame_rate_flag=0;
    	}
    }
    
    
    
    
    
    //--------------------------------------------------------------------------------------------------------
    //--------------------------------------------------------------------------------------------------------
    
    #endif
    
    #if (isway1 == 1)
    /*****************************************************************************************
    **	variable define
    *****************************************************************************************/
    uint8 D7258_config_line_num = 0;//7258���õ��к�
    //uint8 D7258_active_line_complete_flag = 0;//7258����һ����ɱ�־,��1��ɣ���0δ���
    //D7258_1
    //uint8 D7258_config_line_num_1 = 0;//7258���õ��к�
    uint8 D7258_active_line_complete_flag_1 = 0;//7258����һ����ɱ�־,��1��ɣ���0δ���
    //D7258_2
    //uint8 D7258_config_line_num_2 = 0;//7258���õ��к�
    uint8 D7258_active_line_complete_flag_2 = 0;//7258����һ����ɱ�־,��1��ɣ���0δ���
    //D7258_3
    //uint8 D7258_config_line_num_3 = 0;//7258���õ��к�
    uint8 D7258_active_line_complete_flag_3 = 0;//7258����һ����ɱ�־,��1��ɣ���0δ��?
    //GS1
    uint8 GS_line_num_1 = 0;//GS����д����к�
    uint8 GS_unit_num_1 = 0;//GS����д��ĵ�Ԫ��
    uint8 GS_chip_num_1 = 0;//GS����д���оƬ��
    uint8 GS_write_complete_flag_1 = 0;//д��������ɣ�1��δ��ɣ�0
    uint8 Send_Vsync_Com_complete_flag1 = 1;
    //GS2
    uint8 GS_line_num_2 = 0;//GS����д����к�
    uint8 GS_unit_num_2 = 0;//GS����д��ĵ�Ԫ��
    uint8 GS_chip_num_2 = 0;//GS����д���оƬ��
    uint8 GS_write_complete_flag_2 = 0;//д��������ɣ�1��δ��ɣ�0
    uint8 Send_Vsync_Com_complete_flag2 = 1;
    //GS3
    uint8 GS_line_num_3 = 0;//GS����д����к�
    uint8 GS_unit_num_3 = 0;//GS����д��ĵ�Ԫ��
    uint8 GS_chip_num_3 = 0;//GS����д���оƬ��
    uint8 GS_write_complete_flag_3 = 0;//д��������ɣ�1��δ��ɣ�0
    uint8 Send_Vsync_Com_complete_flag3 = 1;
    //GCLK1
    uint8 GCLK_line_cnt_1 = 0;//����GCLK���
    uint16 GCLK_pulse_cnt_1 = 0;//����GCLK���������ÿ�������ڹ���256*N��NΪ��������GCLK
    uint16 GCLK_subperiod_cnt_1 = 0;//����GCLK�����ڼ���(8+8ģʽ��256��������)
    uint8 GCLK_send_complete_flag_1 = 0;//����GCLK��ɣ�1��δ��ɣ�0
    //GCLK2
    uint8 GCLK_line_cnt_2 = 0;//����GCLK���
    uint16 GCLK_pulse_cnt_2 = 0;//����GCLK���������ÿ�������ڹ���256*N��NΪ��������GCLK
    uint16 GCLK_subperiod_cnt_2 = 0;//����GCLK�����ڼ���(8+8ģʽ��256��������)
    uint8 GCLK_send_complete_flag_2 = 0;//����GCLK��ɣ�1��δ��ɣ�0
    //GCLK3
    uint8 GCLK_line_cnt_3 = 0;//����GCLK���
    uint16 GCLK_pulse_cnt_3 = 0;//����GCLK���������ÿ�������ڹ���256*N��NΪ��������GCLK
    uint16 GCLK_subperiod_cnt_3 = 0;//����GCLK�����ڼ���(8+8ģʽ��256��������)
    uint8 GCLK_send_complete_flag_3 = 0;//����GCLK��ɣ�1��δ��ɣ�0
    
    
    //A	��
    uint8 M2_A_FC2DATA[48] =
    {
    	0,1,1,0,	//0110�FC2
    	0,0,		//Reverse_V_R
    	0,0,		//Interference_R
    	0,0,		//Reverse_V_G
    	0,0,		//Interference_G
    	0,0,		//Reverse_V_B
    	0,0,		//Interference_B
    	0,0,0,0,	//lgse1-r
    	0,0,0,0,	//lgse1-g
    	0,0,0,0,	//lgse1-b
    	1,
    	0,0,
    	0,1,
    	0,0,0,0,
    	0,0,0,		//��Ҫ�Ķ�
    	0,			//Ԥ���ģʽѡ��
    	0,			//GLCK �������ã��˴�0����ֻ���������½�OUTn������
    	0,			//ʡ��ģʽ���˴�0����ر�
    	1,0,1,1,1	//���ñȣ��˴�����24��
    };
    //B��
    uint8 M2_B_FC2DATA[48] =
    {
    	0,1,1,0,	//0110�FC2
    	0,0,		//Reverse_V_R
    	0,0,		//Interference_R
    	0,0,		//Reverse_V_G
    	0,0,		//Interference_G
    	0,0,		//Reverse_V_B
    	0,0,		//Interference_B
    	0,0,0,0,	//lgse1-r
    	0,0,0,0,	//lgse1-g
    	0,0,0,0,	//lgse1-b
    	1,
    	0,0,
    	0,1,
    	0,0,0,0,
    	0,0,0,		//��Ҫ�Ķ�
    	0,			//Ԥ���ģʽѡ��
    	0,			//GLCK �������ã��˴�0����ֻ���������½�OUTn������
    	0,			//ʡ��ģʽ���˴�0����ر�
    	1,0,1,1,1	//���ñȣ��˴�����24��
    };
    //C��
    uint8 M2_C_FC2DATA[48] =
    {
    	0,1,1,0,	//0110�FC2
    	0,0,		//Reverse_V_R
    	0,0,		//Interference_R
    	0,0,		//Reverse_V_G
    	0,0,		//Interference_G
    	0,0,		//Reverse_V_B
    	0,0,		//Interference_B
    	0,0,0,0,	//lgse1-r
    	0,0,0,0,	//lgse1-g
    	0,0,0,0,	//lgse1-b
    	1,
    	0,0,
    	0,1,
    	0,0,0,0,
    	0,0,0,		//��Ҫ�Ķ�
    	0,			//Ԥ���ģʽѡ��
    	0,			//GLCK �������ã��˴�0����ֻ���������½�OUTn������
    	0,			//ʡ��ģʽ���˴�0����ر�
    	1,0,1,1,1	//���ñȣ��˴�����24��
    };
    
    //16��48λ��ȵĴ洢��Ԫ, ÿ����Ԫ����һ��ͨ����R/G/B�Ҷȣ�GS������
    /*
    uint64 GS_Data[16] =
    {   //B   G   R
    	0x00000000FFFF,//0
    	0x0000FFFF0000,
    	0xFFFF00000000,
    	0x0000FFFFFFFF,
    	0xFFFF0000FFFF,
    	0xFFFFFFFF0000,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF//15
    };
    */
    uint64 GS_Data[GS_DATA_LEN] =//һ����Ԫ������
    {     //B   G   R
    	0xFFFFFFFFFFFF,//0
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,
    	0xFFFFFFFFFFFF,//15
    };
    
    /*****************************************************************************************
    **	function define
    *****************************************************************************************/
    void M2_A_FCWRTEN(void)
    {
    	SDI_L1;SCLK_L1;LAT_L1;
    	SCLK_H1;SCLK_L1;
    
    	//LAT����ʱ15��ʱ���źŴ���д�뵽FC
    	LAT_H1;
    	SCLK_H1;SCLK_L1;//1
    	SCLK_H1;SCLK_L1;
    	SCLK_H1;SCLK_L1;
    	SCLK_H1;SCLK_L1;
    	SCLK_H1;SCLK_L1;
    	SCLK_H1;SCLK_L1;
    	SCLK_H1;SCLK_L1;
    	SCLK_H1;SCLK_L1;
    	SCLK_H1;SCLK_L1;
    	SCLK_H1;SCLK_L1;
    	SCLK_H1;SCLK_L1;
    	SCLK_H1;SCLK_L1;
    	SCLK_H1;SCLK_L1;
    	SCLK_H1;SCLK_L1;
    	SCLK_H1;SCLK_L1;//15
    
    	LAT_L1;SCLK_L1;
    }
    void M2_B_FCWRTEN(void)
    {
    	SDI_L2;SCLK_L2;LAT_L2;
    	SCLK_H2;SCLK_L2;
    
    	//LAT����ʱ25��ʱ���źŴ���д�뵽FC
    	LAT_H2;
    	SCLK_H2;SCLK_L2;//1
    	SCLK_H2;SCLK_L2;
    	SCLK_H2;SCLK_L2;
    	SCLK_H2;SCLK_L2;
    	SCLK_H2;SCLK_L2;
    	SCLK_H2;SCLK_L2;
    	SCLK_H2;SCLK_L2;
    	SCLK_H2;SCLK_L2;
    	SCLK_H2;SCLK_L2;
    	SCLK_H2;SCLK_L2;
    	SCLK_H2;SCLK_L2;
    	SCLK_H2;SCLK_L2;
    	SCLK_H2;SCLK_L2;
    	SCLK_H2;SCLK_L2;
    	SCLK_H2;SCLK_L2;//15
    
    	LAT_L2;SCLK_L2;
    }
    void M2_C_FCWRTEN(void)
    {
    	SDI_L3;SCLK_L3;LAT_L3;
    	SCLK_H3;SCLK_L3;
    
    	//LAT����ʱ35��ʱ���źŴ���д�뵽FC
    	LAT_H3;
    	SCLK_H3;SCLK_L3;//1
    	SCLK_H3;SCLK_L3;
    	SCLK_H3;SCLK_L3;
    	SCLK_H3;SCLK_L3;
    	SCLK_H3;SCLK_L3;
    	SCLK_H3;SCLK_L3;
    	SCLK_H3;SCLK_L3;
    	SCLK_H3;SCLK_L3;
    	SCLK_H3;SCLK_L3;
    	SCLK_H3;SCLK_L3;
    	SCLK_H3;SCLK_L3;
    	SCLK_H3;SCLK_L3;
    	SCLK_H3;SCLK_L3;
    	SCLK_H3;SCLK_L3;
    	SCLK_H3;SCLK_L3;//15
    
    	LAT_L3;SCLK_L3;
    }
    void M2_A_WriteDataToSDI(uint16 data, uint8 size, uint8 cmd)
    {
    	uint8 cnt;
    	for(cnt=size; cnt>0; cnt--)
    	{
    		if((cmd == 1) && (cnt == 1))
    		{
    			LAT_H1;
    			SCLK_L1;
    			SDI_V1(data >> (cnt - 1));SCLK_H1;SCLK_L1;
    			LAT_L1;
    			SCLK_L1;
    		}
    		else
    		{
    			SDI_V1(data >> (cnt - 1));SCLK_H1;SCLK_L1;
    		}
    	}
    }
    void M2_B_WriteDataToSDI(uint16 data, uint8 size, uint8 cmd)
    {
    	uint8 cnt;
    	for(cnt=size; cnt>0; cnt--)
    	{
    		if((cmd == 1) && (cnt == 1))
    		{
    			LAT_H2;
    			SCLK_L2;
    			SDI_V2(data >> (cnt - 1));SCLK_H2;SCLK_L2;
    			LAT_L2;
    			SCLK_L2;
    		}
    		else
    		{
    			SDI_V2(data >> (cnt - 1));SCLK_H2;SCLK_L2;
    		}
    	}
    }
    void M2_C_WriteDataToSDI(uint16 data, uint8 size, uint8 cmd)
    {
    	uint8 cnt;
    	for(cnt=size; cnt>0; cnt--)
    	{
    		if((cmd == 1) && (cnt == 1))
    		{
    			LAT_H3;
    			SCLK_L3;
    			SDI_V3(data >> (cnt - 1));SCLK_H3;SCLK_L3;
    			LAT_L3;
    			SCLK_L3;
    		}
    		else
    		{
    			SDI_V3(data >> (cnt - 1));SCLK_H3;SCLK_L3;
    		}
    	}
    }
    void M2_A_FC1_Write(uint8 BC, uint16 CCR, uint16 CCG, uint16 CCB)
    {
    	uint8_t i;
    	M2_A_FCWRTEN();
    	//write FC1
    	for(i=CHIPS_NUM_A; i>0; i--)
    	{
    		//44-47����FC1����FC2 FC1: 1001 FC2:0110
    		SDI_H1;SCLK_H1;SCLK_L1;//head
    		SDI_L1;SCLK_H1;SCLK_L1;
    		SDI_L1;SCLK_H1;SCLK_L1;
    		SDI_H1;SCLK_H1;SCLK_L1;
    		//41-43 BC��
    		SDI_V1(BC>>2);SCLK_H1;SCLK_L1;//BC
    		SDI_V1(BC>>1);SCLK_H1;SCLK_L1;
    		SDI_V1(BC);SCLK_H1;SCLK_L1;
    		//32-40 CCR
    		M2_A_WriteDataToSDI(CCR, 9, 0);
    		//23-31 CCG
    		M2_A_WriteDataToSDI(CCG, 9, 0);
    		//14-22 CCR
    		M2_A_WriteDataToSDI(CCB, 9, 0);
    
    		SDI_L1;SCLK_H1;SCLK_L1;//CUE
    		SDI_L1;SCLK_H1;SCLK_L1;//RSV
    		SDI_L1;SCLK_H1;SCLK_L1;
    		SDI_L1;SCLK_H1;SCLK_L1;
    		SDI_L1;SCLK_H1;SCLK_L1;//PREC_MODE3
    		SDI_H1;SCLK_H1;SCLK_L1;//PREC_EN
    		SDI_L1;SCLK_H1;SCLK_L1;//RSV
    		SDI_L1;SCLK_H1;SCLK_L1;
    		SDI_L1;SCLK_H1;SCLK_L1;
    		//LAT����Ȼ��5��ʱ��д�����
    		if(i == 1)
    		{
    			LAT_H1;
    		}
    		SDI_H1;SCLK_H1;SCLK_L1;//LOD
    
    		SDI_L1;SCLK_H1;SCLK_L1;
    		SDI_H1;SCLK_H1;SCLK_L1;//TD0
    
    		SDI_L1;SCLK_H1;SCLK_L1;
    		SDI_H1;SCLK_H1;SCLK_L1;//LODVTH
    
    		LAT_L1;SCLK_L1;
    	}
    }
    void M2_B_FC1_Write(uint8 BC, uint16 CCR, uint16 CCG, uint16 CCB)
    {
    	uint8_t i;
    	M2_B_FCWRTEN();
    	//write FC1
    	for(i=CHIPS_NUM_B; i>0; i--)
    	{
    		//44-47����FC1����FC2 FC1: 1001 FC2:0110
    		SDI_H2;SCLK_H2;SCLK_L2;//head
    		SDI_L2;SCLK_H2;SCLK_L2;
    		SDI_L2;SCLK_H2;SCLK_L2;
    		SDI_H2;SCLK_H2;SCLK_L2;
    		//41-43 BC��
    		SDI_V2(BC>>2);SCLK_H2;SCLK_L2;//BC
    		SDI_V2(BC>>1);SCLK_H2;SCLK_L2;
    		SDI_V2(BC);SCLK_H2;SCLK_L2;
    		//32-40 CCR
    		M2_B_WriteDataToSDI(CCR, 9, 0);
    		//23-31 CCG
    		M2_B_WriteDataToSDI(CCG, 9, 0);
    		//14-22 CCR
    		M2_B_WriteDataToSDI(CCB, 9, 0);
    
    		SDI_L2;SCLK_H2;SCLK_L2;//CUE
    		SDI_L2;SCLK_H2;SCLK_L2;//RSV
    		SDI_L2;SCLK_H2;SCLK_L2;
    		SDI_L2;SCLK_H2;SCLK_L2;
    		SDI_L2;SCLK_H2;SCLK_L2;//PREC_MODE3
    		SDI_H2;SCLK_H2;SCLK_L2;//PREC_EN
    		SDI_L2;SCLK_H2;SCLK_L2;//RSV
    		SDI_L2;SCLK_H2;SCLK_L2;
    		SDI_L2;SCLK_H2;SCLK_L2;
    		//LAT����Ȼ��5��ʱ��д�����
    		if(i == 1)
    		{
    			LAT_H2;
    		}
    		SDI_H2;SCLK_H2;SCLK_L2;//LOD
    
    		SDI_L2;SCLK_H2;SCLK_L2;
    		SDI_H2;SCLK_H2;SCLK_L2;//TD0
    
    		SDI_L2;SCLK_H2;SCLK_L2;
    		SDI_H2;SCLK_H2;SCLK_L2;//LODVTH
    
    		LAT_L2;SCLK_L2;
    	}
    }
    void M2_C_FC1_Write(uint8 BC, uint16 CCR, uint16 CCG, uint16 CCB)
    {
    	uint8_t i;
    	M2_C_FCWRTEN();
    	//write FC1
    	for(i=CHIPS_NUM_C; i>0; i--)
    	{
    		//44-47����FC1����FC2 FC1: 1001 FC2:0110
    		SDI_H3;SCLK_H3;SCLK_L3;//head
    		SDI_L3;SCLK_H3;SCLK_L3;
    		SDI_L3;SCLK_H3;SCLK_L3;
    		SDI_H3;SCLK_H3;SCLK_L3;
    		//41-43 BC��
    		SDI_V3(BC>>2);SCLK_H3;SCLK_L3;//BC
    		SDI_V3(BC>>1);SCLK_H3;SCLK_L3;
    		SDI_V3(BC);SCLK_H3;SCLK_L3;
    		//32-40 CCR
    		M2_C_WriteDataToSDI(CCR, 9, 0);
    		//23-31 CCG
    		M2_C_WriteDataToSDI(CCG, 9, 0);
    		//14-22 CCR
    		M2_C_WriteDataToSDI(CCB, 9, 0);
    
    		SDI_L3;SCLK_H3;SCLK_L3;//CUE
    		SDI_L3;SCLK_H3;SCLK_L3;//RSV
    		SDI_L3;SCLK_H3;SCLK_L3;
    		SDI_L3;SCLK_H3;SCLK_L3;
    		SDI_L3;SCLK_H3;SCLK_L3;//PREC_MODE3
    		SDI_H3;SCLK_H3;SCLK_L3;//PREC_EN
    		SDI_L3;SCLK_H3;SCLK_L3;//RSV
    		SDI_L3;SCLK_H3;SCLK_L3;
    		SDI_L3;SCLK_H3;SCLK_L3;
    		//LAT����Ȼ��5��ʱ��д�����
    		if(i == 1)
    		{
    			LAT_H3;
    		}
    		SDI_H3;SCLK_H3;SCLK_L3;//LOD
    
    		SDI_L3;SCLK_H3;SCLK_L3;
    		SDI_H3;SCLK_H3;SCLK_L3;//TD0
    
    		SDI_L3;SCLK_H3;SCLK_L3;
    		SDI_H3;SCLK_H3;SCLK_L3;//LODVTH
    
    		LAT_L3;SCLK_L3;
    	}
    }
    void  M2_A_FC2_Write(uint8 * data)//FC2 is set to default value, only used in multiplexing application
    {
    	uint8 i, j;
    	M2_A_FCWRTEN();
    	//�FC2
    	for(j=CHIPS_NUM_A; j>0; j--)
    	{
    		for(i=0; i<48; i++)//��д��48λ
    		{
    			if(i <= 42)
    			{
    				SDI_V1(data[i]);SCLK_H1;SCLK_L1;
    			}
    			else if((i == 43) && (j == 1))//���һ��оƬ�������λҪ��LAT���ߣ�ʹ������д��FC2
    			{
    				LAT_H1;
    				SDI_V1(data[i]);SCLK_H1;SCLK_L1;
    			}
    			else//ֻ�ڵ�43λ��������һ�Σ�֮�����ظ�����
    			{
    				SDI_V1(data[i]);SCLK_H1;SCLK_L1;
    			}
    		}
    	}
    	LAT_L1;SCLK_L1;
    }
    void M2_B_FC2_Write(uint8 * data)//FC2 is set to default value, only used in multiplexing application
    {
    	uint8 i, j;
    	M2_B_FCWRTEN();
    	//�FC2
    	for(j=CHIPS_NUM_B; j>0; j--)
    	{
    		for(i=0; i<48; i++)//��д��48λ
    		{
    			if(i <= 42)
    			{
    				SDI_V2(data[i]);SCLK_H2;SCLK_L2;
    			}
    			else if((i == 43) && (j == 1))//���һ��оƬ�������λҪ��LAT���ߣ�ʹ������д��FC2
    			{
    				LAT_H2;
    				SDI_V2(data[i]);SCLK_H2;SCLK_L2;
    			}
    			else//ֻ�ڵ�43λ��������һ�Σ�֮�����ظ�����
    			{
    				SDI_V2(data[i]);SCLK_H2;SCLK_L2;
    			}
    		}
    	}
    	LAT_L2;SCLK_L2;
    }
    void M2_C_FC2_Write(uint8 * data)//FC2 is set to default value, only used in multiplexing application
    {
    	uint8 i, j;
    	M2_C_FCWRTEN();
    	//�FC2
    	for(j=CHIPS_NUM_C; j>0; j--)
    	{
    		for(i=0; i<48; i++)//��д��48λ
    		{
    			if(i <= 42)
    			{
    				SDI_V3(data[i]);SCLK_H3;SCLK_L3;
    			}
    			else if((i == 43) && (j == 1))//���һ��оƬ�������λҪ��LAT���ߣ�ʹ������д��FC2
    			{
    				LAT_H3;
    				SDI_V3(data[i]);SCLK_H3;SCLK_L3;
    			}
    			else//ֻ�ڵ�43λ��������һ�Σ�֮�����ظ�����
    			{
    				SDI_V3(data[i]);SCLK_H3;SCLK_L3;
    			}
    		}
    	}
    	LAT_L3;SCLK_L3;
    }
    void M2_A_GS_DataWrite(uint64 * data, uint8 pattern)//47-32 Blue, 31-16 Green, 15-0 Red
    {
    	uint16 dataR = 0, dataB = 0, dataG = 0;
    
    	if(Send_Vsync_Com_complete_flag1 == 1)
    	{
    		Send_Vsync_Com_complete_flag1 = 0;
    		if(GS_chip_num_1 < CHIPS_NUM_A)//����оƬд��һ����Ԫ���ݣ�д��һ��оƬ��оƬ������1��д�����һ��оƬʱ����д������
    		{
    			dataR = data[GS_unit_num_1];
    			dataG = data[GS_unit_num_1] >> 16;
    			dataB = data[GS_unit_num_1] >> 32;
    			dataB = dataB && 0xFFFF;
    
    			switch(pattern)
    			{
    				case 0://pattern=0; only red LED light
    					dataG = 0;
    					dataB = 0;
    				break;
    				case 1://pattern=1; only green LED light
    					dataR = 0;
    					dataB = 0;
    				break;
    				case 2://pattern=2; only blue LED light
    					dataR = 0;
    					dataG = 0;
    				break;
    				case 3://pattern=3; RG
    					dataB = 0;
    				break;
    				case 4://pattern=4; RB
    					dataG = 0;
    				break;
    				case 5://pattern=5; GB
    					dataR = 0;
    				break;
    				case 6://pattern=6; RGB
    				break;
    				default:
    				break;
    			}
    			M2_A_WriteDataToSDI(dataB, 16, 0);//data blue
    			M2_A_WriteDataToSDI(dataG, 16, 0);//data green
    			if(GS_chip_num_1 == (CHIPS_NUM_A - 1))//data red
    			{
    				M2_A_WriteDataToSDI(dataR, 16, 1);//���һ��д�������
    			}
    			else
    			{
    				M2_A_WriteDataToSDI(dataR, 16, 0);
    			}
    			GS_chip_num_1++;
    			if(GS_chip_num_1 >= CHIPS_NUM_A)//����оƬ��д��һ����Ԫ����оƬ������0����Ԫ����1��׼��д����һ����Ԫ
    			{
    				GS_chip_num_1 = 0;
    				GS_unit_num_1++;
    				if(GS_unit_num_1 >= 16)//д��16����Ԫ������1����Ԫ����0��׼��д��һ��
    				{
    					GS_unit_num_1 = 0;
    					GS_line_num_1++;
    					if(GS_line_num_1 >= TOTAL_LINE_NUM)//�����ж�д�꣬��������0��д����ɱ�־��1
    					{
    						GS_line_num_1 = 0;
    						GS_write_complete_flag_1 = 1;
    					}
    				}
    			}
    		}
    	}
    }
    void M2_B_GS_DataWrite(uint64 * data, uint8 pattern)//47-32 Blue, 31-16 Green, 15-0 Red
    {
    	uint16 dataR = 0, dataB = 0, dataG = 0;
    
    	if(Send_Vsync_Com_complete_flag2 == 1)
    	{
    		Send_Vsync_Com_complete_flag2 = 0;
    		if(GS_chip_num_2 < CHIPS_NUM_B)//����оƬд��һ����Ԫ���ݣ�д��һ��оƬ��оƬ������1��д�����һ��оƬʱ����д������
    		{
    			dataR = data[GS_unit_num_2];
    			dataG = data[GS_unit_num_2] >> 16;
    			dataB = data[GS_unit_num_2] >> 32;
    			dataB = dataB && 0xFFFF;
    
    			switch(pattern)
    			{
    				case 0://pattern=0; only red LED light
    					dataG = 0;
    					dataB = 0;
    				break;
    				case 1://pattern=1; only green LED light
    					dataR = 0;
    					dataB = 0;
    				break;
    				case 2://pattern=2; only blue LED light
    					dataR = 0;
    					dataG = 0;
    				break;
    				case 3://pattern=3; RG
    					dataB = 0;
    				break;
    				case 4://pattern=4; RB
    					dataG = 0;
    				break;
    				case 5://pattern=5; GB
    					dataR = 0;
    				break;
    				case 6://pattern=6; RGB
    				break;
    				default:
    				break;
    			}
    			M2_B_WriteDataToSDI(dataB, 16, 0);//data blue
    			M2_B_WriteDataToSDI(dataG, 16, 0);//data green
    			if(GS_chip_num_2 == (CHIPS_NUM_B - 1))//data red
    			{
    				M2_B_WriteDataToSDI(dataR, 16, 1);//���һ��д�������
    			}
    			else
    			{
    				M2_B_WriteDataToSDI(dataR, 16, 0);
    			}
    			GS_chip_num_2++;
    			if(GS_chip_num_2 >= CHIPS_NUM_B)//����оƬ��д��һ����Ԫ����оƬ������0����Ԫ����1��׼��д����һ����Ԫ
    			{
    				GS_chip_num_2 = 0;
    				GS_unit_num_2++;
    				if(GS_unit_num_2 >= 16)//д��16����Ԫ������1����Ԫ����0��׼��д��һ��
    				{
    					GS_unit_num_2 = 0;
    					GS_line_num_2++;
    					if(GS_line_num_2 >= TOTAL_LINE_NUM)//�����ж�д�꣬��������0��д����ɱ�־��1
    					{
    						GS_line_num_2 = 0;
    						GS_write_complete_flag_2 = 1;
    					}
    				}
    			}
    		}
    	}
    }
    void M2_C_GS_DataWrite(uint64 * data, uint8 pattern)//47-32 Blue, 31-16 Green, 15-0 Red
    {
    	uint16 dataR = 0, dataB = 0, dataG = 0;
    
    	if(Send_Vsync_Com_complete_flag3 == 1)
    	{
    		Send_Vsync_Com_complete_flag3 = 0;
    		if(GS_chip_num_3 < CHIPS_NUM_C)//����оƬд��һ����Ԫ���ݣ�д��һ��оƬ��оƬ������1��д�����һ��оƬʱ����д������
    		{
    			dataR = data[GS_unit_num_3];
    			dataG = data[GS_unit_num_3] >> 16;
    			dataB = data[GS_unit_num_3] >> 32;
    			dataB = dataB && 0xFFFF;
    
    			switch(pattern)
    			{
    				case 0://pattern=0; only red LED light
    					dataG = 0;
    					dataB = 0;
    				break;
    				case 1://pattern=1; only green LED light
    					dataR = 0;
    					dataB = 0;
    				break;
    				case 2://pattern=2; only blue LED light
    					dataR = 0;
    					dataG = 0;
    				break;
    				case 3://pattern=3; RG
    					dataB = 0;
    				break;
    				case 4://pattern=4; RB
    					dataG = 0;
    				break;
    				case 5://pattern=5; GB
    					dataR = 0;
    				break;
    				case 6://pattern=6; RGB
    				break;
    				default:
    				break;
    			}
    			M2_C_WriteDataToSDI(dataB, 16, 0);//data blue
    			M2_C_WriteDataToSDI(dataG, 16, 0);//data green
    			if(GS_chip_num_3 == (CHIPS_NUM_C - 1))//data red
    			{
    				M2_C_WriteDataToSDI(dataR, 16, 1);//���һ��д�������
    			}
    			else
    			{
    				M2_C_WriteDataToSDI(dataR, 16, 0);
    			}
    			GS_chip_num_3++;
    			if(GS_chip_num_3 >= CHIPS_NUM_C)//����оƬ��д��һ����Ԫ����оƬ������0����Ԫ����1��׼��д����һ����Ԫ
    			{
    				GS_chip_num_3 = 0;
    				GS_unit_num_3++;
    				if(GS_unit_num_3 >= 16)//д��16����Ԫ������1����Ԫ����0��׼��д��һ��
    				{
    					GS_unit_num_3 = 0;
    					GS_line_num_3++;
    					if(GS_line_num_3 >= TOTAL_LINE_NUM)//�����ж�д�꣬��������0��д����ɱ�־��1
    					{
    						GS_line_num_3 = 0;
    						GS_write_complete_flag_3 = 1;
    					}
    				}
    			}
    		}
    	}
    }
    
    void M2_A_SendVsyncCommand(void)
    {
    	if(GS_write_complete_flag_1 == 1)
    	{
    		GS_write_complete_flag_1 = 0;
    		SCLK_L1;LAT_L1;//Ϊ��ֹ�����������������ܽ����ߣ��Ƚ��������ܽ����ͣ�����һ��
    		SCLK_H1;SCLK_L1;
    		LAT_H1;
    		SCLK_H1;SCLK_L1;
    		SCLK_H1;SCLK_L1;
    		SCLK_H1;SCLK_L1;
    		LAT_L1;SCLK_L1;
    		Send_Vsync_Com_complete_flag1 = 1;
    	}
    }
    void M2_B_SendVsyncCommand(void)
    {
    	if(GS_write_complete_flag_2 == 1)
    	{
    		GS_write_complete_flag_2 = 0;
    		SCLK_L2;LAT_L2;//Ϊ��ֹ�����������������ܽ����ߣ��Ƚ��������ܽ����ͣ�����һ��
    		SCLK_H2;SCLK_L2;
    		LAT_H2;
    		SCLK_H2;SCLK_L2;
    		SCLK_H2;SCLK_L2;
    		SCLK_H2;SCLK_L2;
    		LAT_L2;SCLK_L2;
    		Send_Vsync_Com_complete_flag2 = 1;
    	}
    }
    void M2_C_SendVsyncCommand(void)
    {
    	if(GS_write_complete_flag_3 == 1)
    	{
    		GS_write_complete_flag_3 = 0;
    		SCLK_L3;LAT_L3;//Ϊ��ֹ�����������������ܽ����ߣ��Ƚ��������ܽ����ͣ�����һ��
    		SCLK_H3;SCLK_L3;
    		LAT_H3;
    		SCLK_H3;SCLK_L3;
    		SCLK_H3;SCLK_L3;
    		SCLK_H3;SCLK_L3;
    		LAT_L3;SCLK_L3;
    		Send_Vsync_Com_complete_flag3 = 1;
    	}
    }
    
    void M2_A_SendGCLK(void)
    {
    	if(D7258_active_line_complete_flag_1 == 1)
    	{
    		if(GCLK_pulse_cnt_1 < GCLK_PULSE_TOTAL)//����257������
    		{
    			GCLK_H1;//GCLK�ź�
    			GCLK_L1;
    			GCLK_pulse_cnt_1++;
    		}
    		else
    		{
    			GCLK_pulse_cnt_1 = 0;//256��GCLK������0�����¼���
    			D7258_active_line_complete_flag_1 = 0;//GCLK�������256��GCLK���壬D7258Ҫ����һ�������ϵ�
    
    			/*D7258_config_line_num++;//D7258���õĵ�ǰ������1
    			if(D7258_config_line_num >= TOTAL_LINE_NUM)//���D7258�����кŴ���������������к���0�ٴӵ�1�п�ʼ����
    			{
    				D7258_config_line_num = 0;
    			}
    			
    			GCLK_line_cnt_1++;//GCLK����������1
    			if(GCLK_line_cnt_1 >= TOTAL_LINE_NUM)//һ�������ڷ�����ϣ�����GCLK������0�������ڼ�����1
    			{
    				GCLK_line_cnt_1 = 0;
    				GCLK_subperiod_cnt_1++;
    				if(GCLK_subperiod_cnt_1 >= GCLK_SUBPERIOD_TOTAL)//�Ѿ�����256�������ڣ�������������0������֪ͨ���������
    				{
    					GCLK_subperiod_cnt_1 = 0;//����������0
    					GCLK_send_complete_flag_1 = 1;
    				}
    			}*/
    		}
    	}
    }
    void M2_B_SendGCLK(void)
    {
    	if(D7258_active_line_complete_flag_2 == 1)
    	{
    		if(GCLK_pulse_cnt_2 < GCLK_PULSE_TOTAL)//����257������
    		{
    			GCLK_H2;//GCLK�ź�
    			GCLK_L2;
    			GCLK_pulse_cnt_2++;
    		}
    		else
    		{
    			GCLK_pulse_cnt_2 = 0;//256��GCLK������0�����¼���
    			D7258_active_line_complete_flag_2 = 0;//GCLK�������256��GCLK���壬D7258Ҫ����һ�������ϵ�
    
    			/*D7258_config_line_num++;//D7258���õĵ�ǰ������1
    			if(D7258_config_line_num >= TOTAL_LINE_NUM)//���D7258�����кŴ���������������к���0�ٴӵ�1�п�ʼ����
    			{
    				D7258_config_line_num = 0;
    			}
    			
    			GCLK_line_cnt_2++;//GCLK����������1
    			if(GCLK_line_cnt_2 >= TOTAL_LINE_NUM)//һ�������ڷ�����ϣ�����GCLK������0�������ڼ�����1
    			{
    				GCLK_line_cnt_2 = 0;
    				GCLK_subperiod_cnt_2++;
    				if(GCLK_subperiod_cnt_2 >= GCLK_SUBPERIOD_TOTAL)//�Ѿ�����256�������ڣ�������������0������֪ͨ���������
    				{
    					GCLK_subperiod_cnt_2 = 0;//����������0
    					GCLK_send_complete_flag_2 = 1;
    				}
    			}*/
    		}
    	}
    }
    void M2_C_SendGCLK(void)
    {
    	if(D7258_active_line_complete_flag_3 == 1)
    	{
    		if(GCLK_pulse_cnt_3 < GCLK_PULSE_TOTAL)//����257������
    		{
    			GCLK_H3;//GCLK�ź�
    			GCLK_L3;
    			GCLK_pulse_cnt_3++;
    		}
    		else
    		{
    			GCLK_pulse_cnt_3 = 0;//256��GCLK������0�����¼���
    			D7258_active_line_complete_flag_3 = 0;//GCLK�������256��GCLK���壬D7258Ҫ����һ�������ϵ�
    
    			D7258_config_line_num++;//D7258���õĵ�ǰ������1
    			if(D7258_config_line_num >= TOTAL_LINE_NUM)//���D7258�����кŴ���������������к���0�ٴӵ�1�п�ʼ����
    			{
    				D7258_config_line_num = 0;
    			}
    			
    			/*GCLK_line_cnt_3++;//GCLK����������1
    			if(GCLK_line_cnt_3 >= TOTAL_LINE_NUM)//һ�������ڷ�����ϣ�����GCLK������0�������ڼ�����1
    			{
    				GCLK_line_cnt_3 = 0;
    				GCLK_subperiod_cnt_3++;
    				if(GCLK_subperiod_cnt_3 >= GCLK_SUBPERIOD_TOTAL)//�Ѿ�����256�������ڣ�������������0������֪ͨ���������
    				{
    					GCLK_subperiod_cnt_3 = 0;//����������0
    					GCLK_send_complete_flag_3 = 1;
    				}
    			}*/
    		}
    	}
    }
    
    void TLC5958_Control(void)
    {
    	M2_A_GS_DataWrite(GS_Data, 6);//д��GS���ݣ���ɺ���������Vsync�����л�BANK
    	M2_B_GS_DataWrite(GS_Data, 6);//д��GS���ݣ���ɺ���������Vsync�����л�BANK
    	M2_C_GS_DataWrite(GS_Data, 6);//д��GS���ݣ���ɺ���������Vsync�����л�BANK
    	M2_A_SendVsyncCommand();//����Vsync�����л�BANK����ɺ������д��GS����
    	M2_B_SendVsyncCommand();//����Vsync�����л�BANK����ɺ������д��GS����
    	M2_C_SendVsyncCommand();//����Vsync�����л�BANK����ɺ������д��GS����
    	M2_A_SendGCLK();//����GCLK��ʼ��ʾһ֡��ͼ��д��GS����������GCLKҪͬ������
    	M2_B_SendGCLK();//����GCLK��ʼ��ʾһ֡��ͼ��д��GS����������GCLKҪͬ������
    	M2_C_SendGCLK();//����GCLK��ʼ��ʾһ֡��ͼ��д��GS����������GCLKҪͬ������
    }
    
    void D7258_Control(void)
    {
    	uint8 line_num = 0;
    
    	if((D7258_active_line_complete_flag_1 == 1)
    	||(D7258_active_line_complete_flag_2 == 1)
    	||(D7258_active_line_complete_flag_3 == 1))
    	{
    		return;
    	}
    	
    	if(D7258_config_line_num < 8)
    	{
    		C1_ENL_L;C2_ENL_H;C3_ENL_H;
    		line_num = D7258_config_line_num;
    	}
    	else if(D7258_config_line_num >= 8 && D7258_config_line_num < 16)
    	{
    		C1_ENL_H;C2_ENL_L;C3_ENL_H;
    		line_num = D7258_config_line_num - 8;
    	}
    	else if(D7258_config_line_num >= 16 && D7258_config_line_num < 24)
    	{
    		C1_ENL_H;C2_ENL_H;C3_ENL_L;
    		line_num = D7258_config_line_num - 16;
    	}
    	else
    	{
    		//do nothing
    	}
    	
    	switch(line_num)
    	{
    		case 0:
    			D7258_A_L;D7258_B_L;D7258_C_L;
    		break;
    		case 1:
    			D7258_A_L;D7258_B_L;D7258_C_H;
    		break;
    		case 2:
    			D7258_A_L;D7258_B_H;D7258_C_L;
    		break;
    		case 3:
    			D7258_A_L;D7258_B_H;D7258_C_H;
    		break;
    		case 4:
    			D7258_A_H;D7258_B_L;D7258_C_L;
    		break;
    		case 5:
    			D7258_A_H;D7258_B_L;D7258_C_H;
    		break;
    		case 6:
    			D7258_A_H;D7258_B_H;D7258_C_L;
    		break;
    		case 7:
    			D7258_A_H;D7258_B_H;D7258_C_H;
    		break;
    		default:
    		break;
    	}
    	D7258_active_line_complete_flag_1 = 1;
    	D7258_active_line_complete_flag_2 = 1;
    	D7258_active_line_complete_flag_3 = 1;
    }
    #endif
    
    TLC6946_Line.h