#ifndef __SN32F780_EBI8080_LCD_H
#define __SN32F780_EBI8080_LCD_H

/*_____ I N C L U D E S ____________________________________________________*/
#include <stdint.h>

/*_____ D E F I N I T I O N S ______________________________________________*/

#define _LCD_SET_RST_OUTPUT_LOW  	SN_GPIO2->MODE_b.MODE12 = 1; _LCD_SET_RST_LOW
#define _LCD_SET_RST_LOW  				SN_GPIO2->DATA_b.DATA12 = 0;
#define _LCD_SET_RST_HIGH  				SN_GPIO2->DATA_b.DATA12 = 1;

//LCD register&command setting
#define	CMD_NOP				0X00
#define	CMD_RESET			0x01
#define	CMD_RDDID			0x04
#define	CMD_RDDST			0x09
#define	CMD_RDDPM			0X0A
#define	CMD_RDDMADCTL	0X0B
#define	CMD_RDDCOLMOD	0X0C
#define	CMD_RDDIM			0X0D
#define	CMD_RDDSM			0X0E
#define	CMD_RDDSDR		0X0F
#define	CMD_SLPIN			0X10
#define	CMD_SLPOUT		0X11
#define	CMD_PTLON			0X12
#define	CMD_NORON			0X13
#define	CMD_INVOFF		0X20
#define	CMD_INVON			0X21
#define	CMD_GAMSET		0X26
#define	CMD_DISPOFF		0X28
#define	CMD_DISPON		0X29
#define	CMD_CASET			0X2A
#define	CMD_RASET			0X2B
#define	CMD_RAMWR			0X2C
#define	CMD_GRBSET		0X2D
#define	CMD_RAMRD			0X2E
#define	CMD_PTLAR			0X30
#define	CMD_VSCRDEF		0X33
#define	CMD_TEOFF			0X34
#define	CMD_TEON			0X35
#define	CMD_MADCTL		0X36
#define	CMD_VSCSAD		0X37
#define	CMD_IDMOFF		0X38
#define	CMD_IDMON			0X39
#define	CMD_COLMOD		0X3A
#define	CMD_WRMEMC		0X3C
#define	CMD_RDMEMC		0X3E
#define	CMD_STE				0X44
#define	CMD_GSCAN			0X45
#define	CMD_WRDISBV		0X51
#define	CMD_RDDISBV		0X52
#define	CMD_WRCTRLD		0X53
#define	CMD_RDCTRLD		0X54
#define	CMD_WRCACE		0X55
#define	CMD_RDCABC		0X56
#define	CMD_WRCABCMB	0X5E
#define	CMD_RDCABCMB	0X5F
#define	CMD_RDID1			0XDA
#define	CMD_RDID2			0XDB
#define	CMD_RDID3			0XDC
#define	CMD_RAMCTRL		0XB0
#define	CMD_RGBCTRL		0XB1
#define	CMD_PORCTRL		0XB2
#define	CMD_FRCTRL1		0XB3
#define	CMD_GCTRL			0XB7
#define	CMD_DGMEN			0XBA
#define	CMD_VCOMS			0XBB
#define	CMD_LCMCTRL		0XC0
#define	CMD_IDSET			0XC1
#define	CMD_VDVVRHEN	0XC2
#define	CMD_VRHS			0XC3
#define	CMD_VDVS			0XC4
#define	CMD_VCMOFSET	0XC5
#define	CMD_FRCTRL2		0XC6
#define	CMD_CABCCTRL	0XC7
#define	CMD_REGSEL1		0XC8
#define	CMD_REGSEL2		0XCA
#define	CMD_PWCTRL1		0XD0
#define	CMD_PVGAMCTRL	0XE0
#define	CMD_NVGAMCTRL	0XE1
#define	CMD_DGMLUTR		0XE2
#define	CMD_DGMLUTB		0XE3
#define	CMD_GATECTRL	0XE4
#define	CMD_PWCTRL2		0XE8
#define	CMD_EQCTRL		0XE9
#define	CMD_PROMCTRL	0XEC
#define	CMD_PROMEN		0XFA
#define	CMD_NVMSET		0XFC
#define	CMD_PROMACT		0XFE

#define	LCD_X_SIZE_H		320
#define	LCD_Y_SIZE_H		240

#define	LCD_YAXIS_MAX_H		(LCD_Y_SIZE_H-1)
#define	LCD_XAXIS_MAX_H		(LCD_X_SIZE_H-1)	

#define	LCD_X_SIZE_V		240
#define	LCD_Y_SIZE_V		320

#define	LCD_YAXIS_MAX_V		(LCD_Y_SIZE_V-1)
#define	LCD_XAXIS_MAX_V		(LCD_X_SIZE_V-1)	

//Color
#define WHITE      0xFFFF
#define BLACK      0x0000	  
#define BLUE       0x001F  
#define BRED       0XF81F
#define GRED 			 0XFFE0
#define GBLUE			 0X07FF
#define RED      	 0xF800
#define GREEN      0x07E0
#define YELLOW     0xFFE0

/*_____ D E C L A R A T I O N S ____________________________________________*/
void LCD_Init(uint8_t bHorizontal, uint8_t bVertical, uint8_t bBank);
void EBI_8080LCD_Init_ST7789(uint8_t bHorizontal, uint8_t bVertical);
void LCD_Clear(uint16_t hwColor);

#endif	/*__SN32F780_EBI8080_LCD_H*/
