oscilloscope/User/lcd/bsp_ili9341_lcd.h

217 lines
9.6 KiB
C
Raw Normal View History

2020-10-25 22:59:45 +08:00
#ifndef __BSP_ILI9341_LCD_H
#define __BSP_ILI9341_LCD_H
#include "stm32f10x.h"
#include "./font/fonts.h"
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
extern uint16_t Wave_Centor_X;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
extern uint16_t Wave_Centor_Y;
extern uint16_t Wave_Height; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ڳߴ<DAB3>
extern uint16_t Wave_Width;
2020-10-25 22:59:45 +08:00
/***************************************************************************************
2^26 =0X0400 0000 = 64MB,ÿ<EFBFBD><EFBFBD> BANK <EFBFBD><EFBFBD>4*64MB = 256MB
64MB:FSMC_Bank1_NORSRAM1:0X6000 0000 ~ 0X63FF FFFF
64MB:FSMC_Bank1_NORSRAM2:0X6400 0000 ~ 0X67FF FFFF
64MB:FSMC_Bank1_NORSRAM3:0X6800 0000 ~ 0X6BFF FFFF
64MB:FSMC_Bank1_NORSRAM4:0X6C00 0000 ~ 0X6FFF FFFF
ѡ<EFBFBD><EFBFBD>BANK1-BORSRAM1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD> TFT<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>ΧΪ0X6000 0000 ~ 0X63FF FFFF
FSMC_A16 <EFBFBD><EFBFBD>LCD<EFBFBD><EFBFBD>DC(<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>)<EFBFBD><EFBFBD>
<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ = 0X60000000
RAM<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ = 0X60020000 = 0X60000000+2^16*2 = 0X60000000 + 0X20000 = 0X60020000
<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַҪ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD>
****************************************************************************************/
/******************************* ILI9341 <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> FSMC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ***************************/
//FSMC_Bank1_NORSRAM<41><4D><EFBFBD><EFBFBD>LCD<43><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ
#define FSMC_Addr_ILI9341_CMD ( ( uint32_t ) 0x60000000 )
//FSMC_Bank1_NORSRAM<41><4D><EFBFBD><EFBFBD>LCD<43><44><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ
#define FSMC_Addr_ILI9341_DATA ( ( uint32_t ) 0x60020000 )
//<2F><>Ƭѡ<C6AC><D1A1><EFBFBD>ž<EFBFBD><C5BE><EFBFBD><EFBFBD><EFBFBD>NOR/SRAM<41><4D>
#define FSMC_Bank1_NORSRAMx FSMC_Bank1_NORSRAM1
/******************************* ILI9341 <20><>ʾ<EFBFBD><CABE>8080ͨѶ<CDA8><D1B6><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD> ***************************/
/******<2A><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><C5BA><EFBFBD>******/
//Ƭѡ<C6AC><D1A1>ѡ<EFBFBD><D1A1>NOR/SRAM<41><4D>
#define ILI9341_CS_CLK RCC_APB2Periph_GPIOD
#define ILI9341_CS_PORT GPIOD
#define ILI9341_CS_PIN GPIO_Pin_7
//DC<44><43><EFBFBD>ţ<EFBFBD>ʹ<EFBFBD><CAB9>FSMC<4D>ĵ<EFBFBD>ַ<EFBFBD>źſ<C5BA><C5BF>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ž<EFBFBD><C5BE><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD>LCDʱʹ<CAB1>õĵ<C3B5>ַ
//PD11ΪFSMC_A16
#define ILI9341_DC_CLK RCC_APB2Periph_GPIOD
#define ILI9341_DC_PORT GPIOD
#define ILI9341_DC_PIN GPIO_Pin_11
//дʹ<D0B4><CAB9>
#define ILI9341_WR_CLK RCC_APB2Periph_GPIOD
#define ILI9341_WR_PORT GPIOD
#define ILI9341_WR_PIN GPIO_Pin_5
//<2F><>ʹ<EFBFBD><CAB9>
#define ILI9341_RD_CLK RCC_APB2Periph_GPIOD
#define ILI9341_RD_PORT GPIOD
#define ILI9341_RD_PIN GPIO_Pin_4
//<2F><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
#define ILI9341_RST_CLK RCC_APB2Periph_GPIOE
#define ILI9341_RST_PORT GPIOE
#define ILI9341_RST_PIN GPIO_Pin_1
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define ILI9341_BK_CLK RCC_APB2Periph_GPIOD
#define ILI9341_BK_PORT GPIOD
#define ILI9341_BK_PIN GPIO_Pin_12
/********<2A><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><C5BA><EFBFBD>***************/
#define ILI9341_D0_CLK RCC_APB2Periph_GPIOD
#define ILI9341_D0_PORT GPIOD
#define ILI9341_D0_PIN GPIO_Pin_14
#define ILI9341_D1_CLK RCC_APB2Periph_GPIOD
#define ILI9341_D1_PORT GPIOD
#define ILI9341_D1_PIN GPIO_Pin_15
#define ILI9341_D2_CLK RCC_APB2Periph_GPIOD
#define ILI9341_D2_PORT GPIOD
#define ILI9341_D2_PIN GPIO_Pin_0
#define ILI9341_D3_CLK RCC_APB2Periph_GPIOD
#define ILI9341_D3_PORT GPIOD
#define ILI9341_D3_PIN GPIO_Pin_1
#define ILI9341_D4_CLK RCC_APB2Periph_GPIOE
#define ILI9341_D4_PORT GPIOE
#define ILI9341_D4_PIN GPIO_Pin_7
#define ILI9341_D5_CLK RCC_APB2Periph_GPIOE
#define ILI9341_D5_PORT GPIOE
#define ILI9341_D5_PIN GPIO_Pin_8
#define ILI9341_D6_CLK RCC_APB2Periph_GPIOE
#define ILI9341_D6_PORT GPIOE
#define ILI9341_D6_PIN GPIO_Pin_9
#define ILI9341_D7_CLK RCC_APB2Periph_GPIOE
#define ILI9341_D7_PORT GPIOE
#define ILI9341_D7_PIN GPIO_Pin_10
#define ILI9341_D8_CLK RCC_APB2Periph_GPIOE
#define ILI9341_D8_PORT GPIOE
#define ILI9341_D8_PIN GPIO_Pin_11
#define ILI9341_D9_CLK RCC_APB2Periph_GPIOE
#define ILI9341_D9_PORT GPIOE
#define ILI9341_D9_PIN GPIO_Pin_12
#define ILI9341_D10_CLK RCC_APB2Periph_GPIOE
#define ILI9341_D10_PORT GPIOE
#define ILI9341_D10_PIN GPIO_Pin_13
#define ILI9341_D11_CLK RCC_APB2Periph_GPIOE
#define ILI9341_D11_PORT GPIOE
#define ILI9341_D11_PIN GPIO_Pin_14
#define ILI9341_D12_CLK RCC_APB2Periph_GPIOE
#define ILI9341_D12_PORT GPIOE
#define ILI9341_D12_PIN GPIO_Pin_15
#define ILI9341_D13_CLK RCC_APB2Periph_GPIOD
#define ILI9341_D13_PORT GPIOD
#define ILI9341_D13_PIN GPIO_Pin_8
#define ILI9341_D14_CLK RCC_APB2Periph_GPIOD
#define ILI9341_D14_PORT GPIOD
#define ILI9341_D14_PIN GPIO_Pin_9
#define ILI9341_D15_CLK RCC_APB2Periph_GPIOD
#define ILI9341_D15_PORT GPIOD
#define ILI9341_D15_PIN GPIO_Pin_10
/*************************************** <20><><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4> ******************************************/
#define DEBUG_DELAY()
/***************************** ILI934 <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ***************************/
#define ILI9341_DispWindow_X_Star 0 //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD>
#define ILI9341_DispWindow_Y_Star 0 //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>Y<EFBFBD><59><EFBFBD><EFBFBD>
#define ILI9341_LESS_PIXEL 240 //Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD>϶̷<CFB6><CCB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD>
#define ILI9341_MORE_PIXEL 320 //Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD>ϳ<EFBFBD><CFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD>
//<2F><><EFBFBD><EFBFBD>Һ<EFBFBD><D2BA>ɨ<EFBFBD><EFBFBD><E8B7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4BBAF>XY<58><59><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD>
//<2F><><EFBFBD><EFBFBD>ILI9341_GramScan<61><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
extern uint16_t LCD_X_LENGTH,LCD_Y_LENGTH;
//Һ<><D2BA><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8>ģʽ
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡֵΪ0-7
extern uint8_t LCD_SCAN_MODE;
/******************************* <20><><EFBFBD><EFBFBD> ILI934 <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ ********************************/
#define BACKGROUND BLACK //Ĭ<>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD>ɫ
#define WHITE 0xFFFF //<2F><>ɫ
#define BLACK 0x0000 //<2F><>ɫ
#define GREY 0xF7DE //<2F><>ɫ
#define BLUE 0x001F //<2F><>ɫ
#define BLUE2 0x051F //dz<><C7B3>ɫ
#define RED 0xF800 //<2F><>ɫ
#define MAGENTA 0xF81F //<2F><><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
#define GREEN 0x07E0 //<2F><>ɫ
#define CYAN 0x7FFF //<2F><><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ɫ
#define YELLOW 0xFFE0 //<2F><>ɫ
#define BRED 0xF81F
#define GRED 0xFFE0
#define GBLUE 0x07FF
/******************************* <20><><EFBFBD><EFBFBD> ILI934 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ********************************/
#define CMD_SetCoordinateX 0x2A //<2F><><EFBFBD><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD>
#define CMD_SetCoordinateY 0x2B //<2F><><EFBFBD><EFBFBD>Y<EFBFBD><59><EFBFBD><EFBFBD>
#define CMD_SetPixel 0x2C //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/********************************** <20><><EFBFBD><EFBFBD> ILI934 <20><><EFBFBD><EFBFBD> ***************************************/
void ILI9341_Init ( void );
void ILI9341_Rst ( void );
void ILI9341_BackLed_Control ( FunctionalState enumState );
void ILI9341_GramScan ( uint8_t ucOtion );
void ILI9341_OpenWindow ( uint16_t usX, uint16_t usY, uint16_t usWidth, uint16_t usHeight );
void ILI9341_Clear ( uint16_t usX, uint16_t usY, uint16_t usWidth, uint16_t usHeight );
void ILI9341_SetPointPixel ( uint16_t usX, uint16_t usY );
uint16_t ILI9341_GetPointPixel ( uint16_t usX , uint16_t usY );
void ILI9341_DrawLine ( uint16_t usX1, uint16_t usY1, uint16_t usX2, uint16_t usY2 );
void ILI9341_DrawDottedLine ( uint16_t usX1, uint16_t usY1, uint16_t usX2, uint16_t usY2 , uint8_t space);
2020-10-25 22:59:45 +08:00
void ILI9341_DrawRectangle ( uint16_t usX_Start, uint16_t usY_Start, uint16_t usWidth, uint16_t usHeight,uint8_t ucFilled );
void ILI9341_DrawCircle ( uint16_t usX_Center, uint16_t usY_Center, uint16_t usRadius, uint8_t ucFilled );
void ILI9341_DispChar_EN ( uint16_t usX, uint16_t usY, const char cChar );
void ILI9341_DispStringLine_EN ( uint16_t line, char * pStr );
void ILI9341_DispString_EN ( uint16_t usX, uint16_t usY, char * pStr );
void ILI9341_DispString_EN_YDir ( uint16_t usX,uint16_t usY , char * pStr );
void LCD_SetFont (sFONT *fonts);
sFONT *LCD_GetFont (void);
void LCD_ClearLine (uint16_t Line);
void LCD_SetBackColor (uint16_t Color);
void LCD_SetTextColor (uint16_t Color) ;
void LCD_SetColors (uint16_t TextColor, uint16_t BackColor);
void LCD_GetColors (uint16_t *TextColor, uint16_t *BackColor);
/********************************** <20><><EFBFBD><EFBFBD> ILI934 <20><><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD> ***************************************/
void LCD_Test(void);
#endif /* __BSP_ILI9341_ILI9341_H */