"Guide: use the riotboard development board, design the LCD driver circuit by yourself, and configure the LCD with riotboard. This paper mainly introduces the LCD interface of riotboard development board and modifying the driver code to realize the display of 7-inch LCD.
Using hardware
Riotboard development board, self-developed 7-inch LCD driver board, HDMI cable.
Using software
Embedded Linux development environment + ad10 PCB design software.
Firstly, the main processor of riotboard is the imx6 solo chip of Freescale, which has powerful data processing and image processing functions.
After getting the board, first get familiar with the board interface according to the document
As can be seen from the figure, there are LVDS interface and HDMI interface related to LCD. If we make our own LCD driver for 7-inch screen, we will use LVDS interface first
Then analyze the pin definition of LVDS interface on the development board,
It can be seen that the LVDS interface in the schematic diagram is four pairs, a pair of clocks, three pairs of data lines, plus the I2C interface of the touch screen and touch interrupt, which can just connect the LCD with touch. So I started to work on LCD driver + touch panel. Considering the high price of capacitive screen, I chose resistive touch and used resistive touch chip with I2C interface. The main planning of the whole LCD driver panel is as follows:
1) LCD power planning:
LCD requires power supply with backlight, including VGH, VGL, dvdd and VCOM
Power on sequence: dvdd - > VGL - > VGH - > Data - > b / L
Power down sequence: B / L - > Data - > VGH - > VGL - > dvdd
Data includes RGB signal, U / D, L / R, DCLK, HS, VE and de.
B / L is backlight.
The above power supply is basically determined.
2) LVDS to RGB
Since the demo board uses LVDS signal output and LCD receives RGB signal, to complete the conversion from LVDS signal to RGB signal, select a conversion chip that does not need programming for simple operation.
3) Touch screen
The touch uses a resistive touch screen. Since there is only I2C and touch interrupt in the LVDS interface signal, the resistive touch screen chip using I2C interface is specifically arranged.
After two days of schematic drawing confirmation and PCB Printing, the long-awaited LCD driver board has finally been released. Let's see the picture below:
When the board arrives, I will study the code to see how to modify and support my LCD.
According to the official manual, LVDS output is suitable for 9.7-inch LCD. If we want to replace the LCD, we must learn to read the driver source code and configuration parameters by ourselves. Before looking at the driver, we should first understand the display principle of LCD:
This is simple and easy to say. It's not easy to explain the trouble in a sentence or two. It's not so relevant to our topic. We won't elaborate here, but we must take a look at the abstraction of LCD hardware by Linux system (see: documentation \ FB \ framebuffer.txt for details. The documents under doucumentation in the source code are good documents, It can solve many confused problems. Sometimes when you are at a loss, you may see the relevant documents in this folder.)
There are seven important parameters in the figure. Let me take a look at the data structure parameters and definitions related to this abstraction:
The structure in the source code of the riotboard board is as follows:
struct fb_ videomode {
constchar *name; /* optional */
u32refresh; /* optional */
u32xres;
u32yres;
u32pixclock;
u32left_ margin;
u32right_ margin;
u32upper_ margin;
u32lower_ margin;
u32hsync_ len;
u32vsync_ len;
u32sync;
u32vmode;
u32flag;
};
Specific meaning:
name
significance
remarks
const char *name
LCD name, which can be defined by yourself
u32 refresh
Refresh rate, generally defined as 60
u32 xres
Row pixel
u32 yres
Column pixel
u32 pixclock
Pixel clock
u32 left_ margin
The number of pixel clock cycles to be inserted at the beginning of the output of pixel data in each row or column
u32 right_ margin
The pixels in each row or column end up on the LCD The number of pixel clocks between line clock output pulses
u32 upper_ margin
The number of invalid lines at the beginning of the frame after the vertical synchronization cycle
u32 lower_ margin
The number of invalid lines from the end of the data output of this frame to the beginning of the vertical synchronization cycle of the next frame
u32 hsync_ len
Row synchronization pulse width
u32 vsync_ len
Field synchronous pulse width
u32 sync
Synchronous polarity setting
It can be set according to the situation
u32 vmode
It is generally configured as interlaced scanning
u32 flag
not used
Let's look at filling these parameters according to our actual LCD specification. First, let's look at the timing sequence in the LCD specification:
The above is the list of main parameters about LCD.
Let's take a look at the configuration parameters according to our own LCD specifications.
Const char * Name: This is the name of the corresponding LCD parameter. You can name it yourself, but it should be the same as the parameter name passed to the kernel later.
Refresh: This is the refresh rate we are familiar with. We will not discuss the refresh rate of LCD and CRT. Here, just select the default 60.
Xres and yres are resolution parameters, that is, the number of pixels in rows and columns. Our LCD is 800 * 480. Just fill in 800 and 480 directly
Pixclock: pixel clock. The calculation formula is given in the Linux document: pixclock = 1000000 / DCF
Let's take a look at the calculation of the following 6 parameters. First, take a look at the timing parameter in the LCD specification:
You can see that the LCD clock is 33.3m, so pixclock = 1000000 / 33.3 = 30030
The line synchronization pulse width is a clock cycle, so Hsync_ len=1
The width of the field synchronization pulse is one line period, so Vsync_ len = 1
Then look at the sequence diagram of a frame of images:
According to up_ Margin definition: the number of invalid lines at the beginning of the frame after the vertical synchronization cycle, that is, TVB tvpw in the figure, that is, 23-1 = 22.
According to lower_ Margin definition: the number of invalid lines from the end of the data output of this frame to the beginning of the vertical synchronization cycle of the next frame
Lower_ margin=tv-tvd-up_ Margin, 525-480-22 = 23
Then look at the sequence diagram in one line:
This picture is a little fuzzy, according to left_ margin Definition: the number of pixel clock cycles to be inserted when the pixel data of each row or column begins to be output, left_ Margin = THB, i.e. 46
According to U32 right_ Margin definition: the end of pixels in each row or column to LCD Number of pixel clocks between line clock output pulses.right_ Margin = th thd THB, i.e. 1056-800-46 = 210
In this way, we have set the main parameters relative to the LCD.
Modify the LCD configuration file of riotboard according to the above contents to make the LCD resolution and other parameters suitable for our 7-inch LCD.
First, let's look at the configuration steps of using lvds0 channel output:
one Open the LDB. C file and find static struct FB_ videomode ldb_ Modedb [] structure definition:
In the structure definition, the LCD configuration parameters are modified to the configuration parameters suitable for our LCD. The specific configuration method is analyzed above. Please refer to it by yourself. The red font is modified according to the above calculation:
staticstruct fb_ videomode ldb_ modedb[] = {
{
"" LDB-WXGA"", 60, 1280, 800, 14065,
40, 40,
10, 3,
80, 10,
0
FB_ VMODE_ NONINTERLACED,
FB_ MODE_ IS_ DETAILED,},
{
"" LDB-XGA"", 60, 800, 480, 30030,
210, 46,
22, 23,
1, 1,
0
FB_ VMODE_ NONINTERLACED,
FB_ MODE_ IS_ DETAILED,},
{
"" LDB-1080P60"", 60, 1920, 1080, 7692,
100, 40,
30, 3,
10, 2,
0
FB_ VMODE_ NONINTERLACED,
FB_ MODE_ IS_ DETAILED,},
};
two Adjust the BSP file, find the board-mx6q-riot. C file, and find the static struct FSL_ mxc_ ldb_ platform_ data ldb_ Data structure definition:
staticstruct fsl_ mxc_ ldb_ platform_ data ldb_ data = {
.ipu_ id = 0,
.disp_ id = 0,
.ext_ ref = 1,
.mode = LDB_ Sep0, / / set LVDS output channel and LDB in this place_ Sep0 is lvds0 channel output.
.sec_ ipu_ id = 0,
.sec_ disp_ id = 1,
};
This LVDS output channel also uses lvds0 by default on riotboard, so we don't need to modify it.
Now mainly modify these two parameters, then recompile the kernel, download and run, and you can see the perfect display of our Ubuntu on the 7-inch screen. Next is the I2C driver for touch,
Originally, I thought I2C was a relatively simple linux driver, but after looking at the I2C driver framework under Linux, it is really not a general trouble. Here, I briefly describe the I2C communication problem using the I2C interface on riotboard.
Firstly, the experimental environment is to use the i2c3 interface of riotboard, that is, the I2C interface on minihdmi, to connect the touch screen chip tsc207 (I2C interface) of 7-inch LCD
Simple steps of communication debugging:
1. Configure the menuconfig option and select the tsc2007 driver. Now think about how lucky the touch screen chip was to select the tsc207 chip. The driver file of this chip is used in the source code, which saves a lot of work.
2. The driver file is tsc2007. C. now it is the problem of configuring the I2C communication interface of riotboard.
We make the following modifications in the source code:
Add I2C platform_ data:
struct tsc2007_ platform_ data tsc2007_ data = {
.model = 2007,
.x_ plate_ ohms = 180,
.fuzzx = 0,
.fuzzy = 0,
.fuzzz = 0,
.init_ platform_ hw = tsc2007_ init_ hw,
.exit_ platform_ hw = tsc2007_ exit_ hw,
.get_ pendown_ state = tsc2007_ state_ hw,
.irq_ pin = RIOT_ Touch_ Int,};
Add I2C board_ info:
static struct i2c_ board_ info mxc_ i2c2_ board_ info[] __ initdata = {
{ I2C_ BOARD_ INFO(""tsc2007"", (0x90>>1)),
.platform_ data = &tsc2007_ data, }, }; // tsc2007 i2c client
The I2C address of tsc2007 is configured as 0x90.
Next, we will implement the three hardware functions of tsc2007
.init_ platform_ hw = tsc2007_ init_ hw,
.exit_ platform_ hw = tsc2007_ exit_ hw,
.get_ pendown_ state = tsc2007_ state_ hw,
Specific implementation, we can according to their own needs, to specific implementation.
Add print information for reading touch coordinates in tsc2007. C file:
/* Prepare for next touch reading - power down ADC, enable P
Our other product: