Programming - abstract important structure

According to the blog post in the framework need to write these files:

First look at the led.h in everything?

. 1  #ifndef _LCD_H
 2  #define _LCD_H
 . 3  
. 4  
. 5  enum {
 . 6      the NORMAL = 0 ,
 . 7      INVERT = . 1 ,
 . 8  };
 . 9  
10  / * the NORMAL: normal polarity
 . 11  * INVERT: reversed polarity
 12 is   * / 
13 is typedef struct pins_polarity {
 14      int VCLK;   / * Normal: acquiring data on the falling edge * / 
15      int RGB;    / * Normal: high indicates. 1 * / 
16      int HSYNC;/ * Normal: high pulse * / 
. 17      int VSYNC; / * Normal: high pulse * / 
18 is } pins_polarity, * p_pins_polarity;
 . 19  
20 is typedef struct time_sequence {
 21 is      / * vertical * / 
22 is      int TVP; / * vysnc pulse width * / 
23 is      int TVB; / * top black box, the Back Porch Vertical * / 
24      int TVF; / * lower black box, Vertical Front Porch * / 
25  
26 is      / * horizontal * / 
27      intTHP; / * HSYNC pulse width * / 
28      int THB; / * left black box, the Back Porch Horizontal * / 
29      int THF; / * to the right of the black box, Horizontal Front Porch * / 
30  
31 is      int VCLK;
 32 } time_sequence, * p_time_sequence ;
 33 is  
34 is  
35 typedef struct lcd_params {
 36      / * pin polarity * / 
37 [      pins_polarity pins_pol;
 38 is      
39      / * timing * / 
40      time_sequence time_seq;
 41 is      
42 is     / * Resolution, BPP * / 
43 is      int XRES;
 44 is      int yres;
 45      int BPP;
 46 is      
47      / * the framebuffer address * / 
48      unsigned int fb_base;
 49 } lcd_params, * p_lcd_params;
 50  
51 is  
52 is  #endif / * * _LCD_H /

2)lcd_4.3.c

lcd_params lcd_4_3_params = {...};

3)lcd_controller.h

 1 #ifndef _LCD_CONTROLLER_H
 2 #define _LCD_CONTROLLER_H
 3 
 4 #include "lcd.h"
 5 
 6 typedef struct lcd_controller {
 7     void (*init)(p_lcd_params plcdparams);
 8     void (*enable)(void);
 9     void (*disable)(void);
10 }lcd_controller, *p_lcd_controller;
11 
12 #endif /* _LCD_CONTROLLER_H */

4)lcd_controller.c

1 /* 向上: 接收不同LCD的参数
2  * 向下: 使用这些参数设置对应的LCD控制器
3  */
4 
5 void lcd_controller_init(p_lcd_params plcdparams)
6 {
7     /* 调用2440的LCD控制器的初始化函数 */
8     lcd_controller.init(plcdparams);
9 }

5)s3c2440_lcd_controller.c

1 struct lcd_controller s3c2440_lcd_controller = {
2     .init    = xxx;
3     .enalbe  = xxx;
4     .disable = xxx;
5 };

 

Guess you like

Origin www.cnblogs.com/-glb/p/11334459.html