#ifndef __BSP_h
#define __BSP_h

#include <stdlib.h>
#include "type.h"
#include "sys.h"
#include "data.h"
//#include "levetop.h"
#include "LT768_Lib.h"
#include "ft5216.h"
#include "SinCosTable.h"
#include "Winbond.h"
#include "pit.h"
#include "keyboard.h"
#include "tjpgd.h"

#define SPI_X       1   // 选择LT768的SPI
#define CLK_DIV     0   // SPI的分频系数

#define SCREEN_5inch     0   // SPI的分频系数
#define SCREEN_7inch     1   // SPI的分频系数

#if SCREEN_5inch
	#define FT_TOUCH   1
	#define GT_TOUCH   0

	#define Default_BUFF   0x80000000
	#define MAIN_BUFF   (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*1)
	#define LAY_BUFF1 	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*2)
	#define LAY_BUFF2 	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*3)
	#define LAY_BUFF3 	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*4)
	#define LAY_BUFF4 	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*5)
	#define LAY_BUFF5 	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*6)				//83指令缓存区
	#define LAY_BUFF6 	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*7)

	#define ROLL_BUFF1	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*11)	// D9指令上下方向的缓存区/B4指令 
	#define ROLL_BUFF2	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*13)	// D9指令左右方向的缓存区/9B指令
	#define SLID_BUFF	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*19)	// 94指令缓存

	#define QR_BUFF   	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*9)
	#define Clock_BUFF  (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*9)
	#define Camera_BUFF  (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*9)

	#define TEMP_BUFF   (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*10)		//8E指令开辟的缓存区

	#define CircleTouch_BUFF   (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*8)		// 96指令缓存

	#define Password_BUFF1   (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*17)		// A4指令缓存
	#define Password_BUFF2   (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*18)
#endif

#if SCREEN_7inch
	#define FT_TOUCH   0
	#define GT_TOUCH   1

	#define Default_BUFF   0x80000000
	#define MAIN_BUFF   (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*1)
	#define LAY_BUFF1 	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*2)
	#define LAY_BUFF2 	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*3)
	#define LAY_BUFF3 	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*4)
	#define LAY_BUFF4 	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*5)
	#define LAY_BUFF5 	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*6)				//83指令缓存区
	#define LAY_BUFF6 	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*7)

	#define ROLL_BUFF1	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*8)	// D9指令上下方向的缓存区/B4指令 
	#define ROLL_BUFF2	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*9)	// D9指令左右方向的缓存区/9B指令
	#define SLID_BUFF	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*10)	// 94指令缓存

	#define QR_BUFF   	(0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*9)
	#define Clock_BUFF  (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*9)
	#define Camera_BUFF  (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*9)

	#define TEMP_BUFF   (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*8)		//8E指令开辟的缓存区

	#define CircleTouch_BUFF   (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*8)		// 96指令缓存

	#define Password_BUFF1   (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*11)		// A4指令缓存
	#define Password_BUFF2   (0x80000000+LCD_XSIZE_TFT*LCD_YSIZE_TFT*2*12)
#endif


extern u8 R_angle;
extern u8 ENDBYTE_Buf[];
extern u8 FF_Update_Flag;

u16 Rx_CRC_CCITT(u8 *puchMsg, u16 usDataLen);
void LT_ReadFlash(u8* pBuffer,u32 ReadAddr,u16 NumByteToRead);				//必须有该函数，封装的库函数用到
void LT_ReceiveCmd(u8 *buf);






#endif

