zoukankan      html  css  js  c++  java
  • 编程——抽象出重要的结构体

    根据上篇博客中的框架,需要编写这些文件:

    首先看一下led.h中,都有什么?

     1 #ifndef _LCD_H
     2 #define _LCD_H
     3 
     4 
     5 enum {
     6     NORMAL = 0,
     7     INVERT = 1,
     8 };
     9 
    10 /* NORMAL : 正常极性
    11  * INVERT : 反转极性
    12  */
    13 typedef struct pins_polarity {
    14     int vclk;  /* normal: 在下降沿获取数据 */
    15     int rgb;   /* normal: 高电平表示1 */
    16     int hsync; /* normal: 高脉冲 */
    17     int vsync; /* normal: 高脉冲 */
    18 }pins_polarity, *p_pins_polarity;
    19 
    20 typedef struct time_sequence {
    21     /* 垂直方向 */
    22     int tvp; /* vysnc脉冲宽度 */
    23     int tvb; /* 上边黑框, Vertical Back porch */
    24     int tvf; /* 下边黑框, Vertical Front porch */
    25 
    26     /* 水平方向 */
    27     int thp; /* hsync脉冲宽度 */
    28     int thb; /* 左边黑框, Horizontal Back porch */
    29     int thf; /* 右边黑框, Horizontal Front porch */
    30 
    31     int vclk;
    32 }time_sequence, *p_time_sequence;
    33 
    34 
    35 typedef struct lcd_params {
    36     /* 引脚极性 */
    37     pins_polarity pins_pol;
    38     
    39     /* 时序 */
    40     time_sequence time_seq;
    41     
    42     /* 分辨率, bpp */
    43     int xres;
    44     int yres;
    45     int bpp;
    46     
    47     /* framebuffer的地址 */
    48     unsigned int fb_base;
    49 }lcd_params, *p_lcd_params;
    50 
    51 
    52 #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 };
  • 相关阅读:
    DedeCMS的arclist循环中判断第一个元素并添加class样式
    PC 浏览器伪装移动(微信)User-Agent
    DedeCMS后台无法保存中文字符
    java spring boot 定时器
    java spring boot 部署redis
    java spring boot 打包方法
    java spring boot返回json的写法
    关于java idea 创建spring boot没有下载依赖的解决方案
    java和golang并发测试
    php转java 系列2 Spring boo 链接数据库jdbc
  • 原文地址:https://www.cnblogs.com/-glb/p/11334459.html
Copyright © 2011-2022 走看看