You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.1 KiB

#ifndef __Lcd_Driver_H
#define __Lcd_Driver_H
#define RED 0xf800
#define GREEN 0x07e0
#define BLUE 0x001f
#define WHITE 0xffff
#define BLACK 0x0000
#define YELLOW 0xFFE0
#define GRAY0 0xEF7D //<EFBFBD><EFBFBD>ɫ0 3165 00110 001011 00101
#define GRAY1 0x8410 //<EFBFBD><EFBFBD>ɫ1 00000 000000 00000
#define GRAY2 0x4208 //<EFBFBD><EFBFBD>ɫ2 1111111111011111
#define LCD_CTRL GPIOB //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>TFT<EFBFBD><EFBFBD><EFBFBD>ݶ˿<EFBFBD>
//#define LCD_LED GPIO_Pin_9 //MCU_PB9--->>TFT --BL
#define LCD_RS GPIO_Pin_1 //PB11--->>TFT --RS/DC
#define LCD_CS GPIO_Pin_12 //MCU_PB11--->>TFT --CS/CE
//#define LCD_RST GPIO_Pin_12 //PB10--->>TFT --RST
#define LCD_SCL GPIO_Pin_13 //PB13--->>TFT --SCL/SCK
#define LCD_SDA GPIO_Pin_15 //PB15 MOSI--->>TFT --SDA/DIN
//#define LCD_CS_SET(x) LCD_CTRL->ODR=(LCD_CTRL->ODR&~LCD_CS)|(x ? LCD_CS:0)
//Һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define LCD_CS_SET LCD_CTRL->BSRR=LCD_CS
#define LCD_RS_SET LCD_CTRL->BSRR=LCD_RS
#define LCD_SDA_SET LCD_CTRL->BSRR=LCD_SDA
#define LCD_SCL_SET LCD_CTRL->BSRR=LCD_SCL
#define LCD_RST_SET LCD_CTRL->BSRR=LCD_RST
#define LCD_LED_SET LCD_CTRL->BSRR=LCD_LED
//Һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define LCD_CS_CLR LCD_CTRL->BRR=LCD_CS
#define LCD_RS_CLR LCD_CTRL->BRR=LCD_RS
#define LCD_SDA_CLR LCD_CTRL->BRR=LCD_SDA
#define LCD_SCL_CLR LCD_CTRL->BRR=LCD_SCL
//#define LCD_RST_CLR LCD_CTRL->BRR=LCD_RST
#define LCD_LED_CLR LCD_CTRL->BRR=LCD_LED
#define LCD_DATAOUT(x) LCD_DATA->ODR=x; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define LCD_DATAIN LCD_DATA->IDR; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define LCD_WR_DATA(data){\
LCD_RS_SET;\
LCD_CS_CLR;\
LCD_DATAOUT(data);\
LCD_WR_CLR;\
LCD_WR_SET;\
LCD_CS_SET;\
}
void LCD_GPIO_Init(void);
void Lcd_WriteIndex(u8 Index);
void Lcd_WriteData(u8 Data);
void Lcd_WriteReg(u8 Index,u8 Data);
u16 Lcd_ReadReg(u8 LCD_Reg);
void Lcd_Reset(void);
void Lcd_Init(void);
void Lcd_Clear(u16 Color);
void Lcd_SetXY(u16 x,u16 y);
void Gui_DrawPoint(u16 x,u16 y,u16 Data);
unsigned int Lcd_ReadPoint(u16 x,u16 y);
void Lcd_SetRegion(u16 x_start,u16 y_start,u16 x_end,u16 y_end);
void LCD_WriteData_16Bit(u16 Data);
#endif