//----------------------------------------------------------------------
//EASTRISING TECHNOLOGY CO,.LTD.//
// Module    : ER-TFTM0784-1  7.84 INCH TFT LCD  1280*400
// Lanuage   : C51 Code
// Create    : JAVEN LIU
// Date      : 2018-12-23
// Drive IC  : RA8876     FLASH:W25Q128FV  128M BIT   FONT CHIP: 30L24T3Y   CTP:GT911
// INTERFACE : 4SPI   	 CTP:IIC	SSD2828: 3SPI 
// MCU 		 : STC12LE5C60S2     1T MCU	    
// MCU VDD	 : 3.3V
// MODULE VDD : 5V OR 3.3V 
//----------------------------------------------------------------------

//===========================================================
#include <STC12C5A.H>
#include <math.h>
#include <stdio.h>
#include<stdlib.h>
#include <intrins.h>
#include"RA8876.h" 
#include"8876demo.h" 
#include"SD.h"  
#include"TP.h" 
#include"2828.h"   


//=============================================================


#define uchar      unsigned char
#define uint       unsigned int
#define ulong      unsigned long



/////////////////////main////////////////////
void main(void)
{  
	P0=0xff;
	P1=0xff;
	P2=0xff;
	P3=0xff;	   
//	BL_ON=0;  //Backlight on when external signal control

 //  	delay_ms(1000);//delay for  power on


   	SSD2828_Reset();	  
	SSD2828_initial();

    RA8876_HW_Reset();
	 while(LCD_StatusRead()&0x02);	 //Initial_Display_test	and  set SW2 pin2 = 1

 	RA8876_initial();
	 Display_ON();
	 delay_ms(20);
  


   	Foreground_color_65k(White);
	Line_Start_XY(0,0);
	Line_End_XY(399,1279);
	Start_Square_Fill();

 while(1) 
 	{
 ///////////////////////////////////////////////// BackLight  Brightness control test  whit RA8876's PWM0
   	Enable_PWM0_Interrupt();
	Clear_PWM0_Interrupt_Flag();
 	Mask_PWM0_Interrupt_Flag();
	Select_PWM0_Clock_Divided_By_2();
 	Select_PWM0();
 	Enable_PWM0_Dead_Zone();
	Auto_Reload_PWM0();
	 Start_PWM0();
 	Set_Timer0_Compare_Buffer(0xffff);

/* 	 delay_ms(2000);
 	Set_Timer0_Compare_Buffer(0x0000);
 	 delay_ms(2000);
 	Set_Timer0_Compare_Buffer(0x0ff0);
 	 delay_ms(2000);
	  	Set_Timer0_Compare_Buffer(0xffff);
 	 delay_ms(2000);
   					 */
 ///////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////	
	 
  	TPTEST();
 // 	Geometric();
	Text_Demo();
 	mono_Demo();	   
	gray();


	Display_JPG_SDCARD();
	delay_ms(3000);
	DMA_Demo();

	BTE_Pattern_Fill();
  	BTE_Color_Expansion();

 	 PIP_Demo();
	 App_Demo_Waveform();
	 App_Demo_Scrolling_Text();

	 App_Demo_slide_frame_buffer();
	 App_Demo_multi_frame_buffer();


	}


}




	
