Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views11 pages

Instruction

This document provides a detailed guide for using a TFT LCD display with an SPI interface, including driver installation and configuration steps. It outlines the functionalities of the driver, such as controlling display orientation, drawing pixels, and writing strings, along with the necessary kernel module files. Additionally, it describes various IOCTL commands for interacting with the display, including setting GPIO pins and configuring display windows.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views11 pages

Instruction

This document provides a detailed guide for using a TFT LCD display with an SPI interface, including driver installation and configuration steps. It outlines the functionalities of the driver, such as controlling display orientation, drawing pixels, and writing strings, along with the necessary kernel module files. Additionally, it describes various IOCTL commands for interacting with the display, including setting GPIO pins and configuring display windows.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

TFT LCD with SPI Interface

General Information
Dear customers,
Thank you very much for choosing our product.
In following, we will introduce you to what to observe while starting up and using
this product.
Should you encounter any unexpected problem during use, please do not hesitate to
contact us.
TABLE OF CONTENTS
I. INTRODUCTION............................................................................................ 1
1.1. About Driver ............................................................................................. 1
1.2. Funtion Description ................................................................................... 1
II. KERNEL CONFIGULATION ..................................................................... 1
Step 1: Install the Device Tree Overlay ............................................................ 1
III. INTERFACE DESCRIPTION ...................................................................... 2
3.1. Interface Definition: .................................................................................. 2
3.2. IOCTL Command Description: ................................................................. 3
❖ TFT_IOCTL_SET_GPIO: ......................................................................... 3
❖ TFT_SET_WINDOW: .............................................................................. 4
❖ TFT_SET_ORIENTATION_PORTRAIT: ................................................ 5
❖ TFT_SET_ORIENTATION_LANDSCAPE: ............................................ 6
❖ TFT_Clear: ................................................................................................ 6
❖ TFT_DRAW_PIXEL:................................................................................ 7
❖ TFT_WRITE_STRING: ............................................................................ 8
I. INTRODUCTION
This code is a Linux kernel module that provides a driver for controlling a TFT display using the SPI

interface. The driver is designed to interface with a TFT display module, managing its initialization,

configuration, and rendering operations. The main functionalities include controlling the display

orientation, drawing pixels, clearing the screen, and writing strings.

1.1. About Driver

The driver includes the following 3 files:

• Kernel Object File: tft_driver.ko

• Kernel Header File: tft_driver.h

• Device Tree File: testoverlay_2.dtb

1.2. Funtion Description

• Support SPI0 interfaces, Chip Select 0(CE0), Max Speed 30MHz.

• Support selection GPIO for Back Light and A0 Pin of ST7735.

• Provide Ioctl Interface with Character Driver.

• Provide API for interface with Driver to config TFT LCD Parameter.

II. KERNEL CONFIGULATION

Step 1: Install the Device Tree Overlay


• Copy the testoverlay_2.dtb file to the /boot/overlays/ directory on your Raspberry Pi:

• Open the /boot/config.txt file for editing:

1
• Add the following line to the end of the file to activate the overlay:

• Save the file and reboot your Raspberry Pi.

Step 2: Load the Kernel Module


• After the system reboots, copy the tft_driver.ko file to an appropriate directory, such as
/lib/modules/$(uname -r)/kernel/drivers/:

• Load kernel module:

III. INTERFACE DESCRIPTION

3.1.Interface Definition:

❖ The definition is stored in file tft_driver.h, following some define:

• Constants for Color: Defined constants represent various colors in 16-bit RGB format.

• Font Definition: The header defines a font structure (FontDef) which includes the width,

height, and data for a specific font (Font7x10). This font is represented as a 2D array of

16-bit values.

• IOCTL Commands:

➢ Commands for resetting the display, setting display intensity, configuring GPIO

pins, setting display orientation, clearing the display, writing a byte to the display,

drawing a pixel, writing a string, and writing a character.

2
➢ Each command is associated with a unique IOCTL number and may include

additional parameters.

3.2.IOCTL Command Description:


❖ TFT_IOCTL_SET_GPIO:

• Description: Select GPIO Pin for Back Light LED and A0 PIN of ST7735.

• Commad Parameter: struct tft_gpio_config.

➢ gpio_led: December Number of GPIO PIN to config Back Light LED pin of ST7735.

➢ gpio_led_value: logic output value ( 0 or 1).

➢ gpio_ao: December Number of GPIO PIN to config A0 pin of ST7735.

➢ gpio_ao_value: logic output value ( 0 or 1).

Example in User Code:

3
❖ TFT_SET_WINDOW:

• Description: set window display for TFT CLD.

• Command Parameter: s typedef struct following window parameter.

➢ uint8_t x: Represents the x-coordinate (horizontal position) of the window.

➢ uint8_t y: Represents the y-coordinate (vertical position) of the window.

➢ uint8_t w: Represents the width of the window.

➢ uint8_t h: Represents the height of the window.

Example in user code

4
❖ TFT_SET_ORIENTATION_PORTRAIT:

• Description: Select display orientation (Portrait).

• Commad Parameter: None

Example in user code:

5
❖ TFT_SET_ORIENTATION_LANDSCAPE:

• Description: Select display orientation (Lascape).

• Commad Parameter: None.

Example in user code:

❖ TFT_Clear:

• Description: Clear all display to black backgroud.

• Commad Parameter: None

Example in user code:

6
❖ TFT_DRAW_PIXEL:

• Description: Draw a pixel to display TFT LCD (Lascape).

• Commad Parameter: typedef struct defines a structure named pixel, which represents a

single pixel on a display.

➢ uint8_t x: Represents the x-coordinate (horizontal position) of the pixel.

➢ uint8_t y: Represents the y-coordinate (vertical position) of the pixel.

➢ uint16_t color: Represents the color of the pixel. The color is typically encoded as a 16-bit value,

allowing a wide range of colors to be represented.

• Color value: 16 bit value mode RGB565

7
Example in user code:

❖ TFT_WRITE_STRING:

• Description: Display a string on TFT LCD.

• Commad Parameter: typedef struct defines a structure named tft_write_string_params,

used to specify parameters for writing a string of characters to a display.

➢ uint16_t x: Represents the x-coordinate (horizontal position) where the string will be written.

➢ uint16_t y: Represents the y-coordinate (vertical position) where the string will be written.

➢ uint16_t color: Represents the color of the characters in the string. The color is typically encoded

8
as a 16-bit value, allowing a wide range of colors to be represented.

• Color value: 16 bit value mode RGB565

➢ uint16_t bgcolor: Represents the background color behind the characters. The color is
typically encoded as a 16-bit value, allowing a wide range of colors to be represented.

➢ char* str: A pointer of string to be displayed.

Example in user code:

You might also like