• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef LCD_HARDWARE_INIT_H_
17 #define LCD_HARDWARE_INIT_H_
18 
19 #include "gd32f4xx.h"
20 
21 #define LCD_CS_PIN GPIO_PIN_11
22 #define LCD_CS_GPIO_PORT GPIOD
23 #define LCD_CS_GPIO_CLK RCU_GPIOD
24 
25 #define LCD_RS_PIN GPIO_PIN_3
26 #define LCD_RS_GPIO_PORT GPIOE
27 #define LCD_RS_GPIO_CLK RCU_GPIOE
28 
29 #define LCD_SPI_SCK_PIN GPIO_PIN_13
30 #define LCD_SPI_SCK_GPIO_PORT GPIOG
31 #define LCD_SPI_SCK_GPIO_CLK RCU_GPIOG
32 
33 #define LCD_SPI_MOSI_PIN GPIO_PIN_14
34 #define LCD_SPI_MOSI_GPIO_PORT GPIOG
35 #define LCD_SPI_MOSI_GPIO_CLK RCU_GPIOG
36 
37 #define LCD_SPI SPI5
38 #define LCD_SPI_CLK RCU_SPI5
39 
40 #define LCD_PIXEL_WIDTH ((uint16_t)320)
41 #define LCD_PIXEL_HEIGHT ((uint16_t)480)
42 
43 /* choose only one of them based on the version of LCD */
44 // #define USE_LCD_VERSION_1_1                /* LCD V1.1 or earlier */
45 // #define USE_LCD_VERSION_1_2                /* LCD V1.2 */
46 // #define USE_LCD_VERSION_1_3                /* LCD V1.3 (TK035F3296) */
47 #define USE_LCD_VERSION_1_4 /* LCD V1.4 (3LINE SPI + RGB) */
48 
49 /* enable the LCD */
50 void lcdEnable(void);
51 /* disable the LCD */
52 void lcdDisable(void);
53 /* configure the LCD control line */
54 void lcdCtrlGpioConfig(void);
55 /* set the LCD control line */
56 void lcdCtrlLineSet(uint32_t gpiox, uint16_t gpiopin);
57 /* reset the LCD control line */
58 void lcdCtrlLineReset(uint32_t gpiox, uint16_t gpiopin);
59 /* configure the LCD SPI and it's GPIOs */
60 void InitLcdSpiGpio(void);
61 /* write command to select LCD register */
62 void lcdCommandWrite(uint8_t lcd_register);
63 /* write data to select LCD register */
64 void lcdDateWrite(uint8_t value);
65 /* configure the LCD based on the power on sequence 3(for V1.4 LCD, inanbo) */
66 void InitLcdRegister(void);
67 
68 #endif /* _LCD_CONFIG_H_ */
69