程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站
点击跳转“创龙科技服务通”

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 8741|回复: 0
打印 上一主题 下一主题

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
) r7 d* p; r& o* c, x% d9 F#include <linux/init.h>2 m/ i3 b0 W% v7 P' e/ a
#include <linux/module.h>
; u, ~3 |0 @3 L# }9 o, j#include <linux/kernel.h># B' x' H9 t1 o" s! q, c& f
#include <linux/types.h>' s, z2 o8 ]' B  \
#include <linux/gpio.h>7 T' [7 T3 l0 B+ w- G
#include <linux/leds.h>
! Z/ P8 M. |7 @#include <linux/platform_device.h># v5 O6 p* g+ H- Z. [4 C

) _! Z: f: r0 g2 I. g# K#include <asm/mach-types.h>
/ ?. @& p; {+ q#include <asm/mach/arch.h>
. T, o+ A% X; ~7 N" u- h) s2 i- i#include <mach/da8xx.h>$ z; C. [7 ?& `9 U4 \0 U. t
#include <mach/mux.h>  C$ w+ y* ~' g

0 `$ [& X( a, t% h' R7 I# d! \#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
3 D+ H* j3 D1 I1 L4 v! I/ F8 q#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
% X: Y  v( Q% A5 m% o' N% q$ ]#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
9 l, e+ s7 Z  r8 ]( C) H4 ?) }" |#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)/ c1 `9 m" t! b7 O7 N; `
2 Z1 `/ L) m, }. C& {
/* assign the tl som board LED-GPIOs*/
/ {& e. A: o" F+ J( j5 b( @7 jstatic const short da850_evm_tl_user_led_pins[] = {# T, w2 [; w' c. D
        /* These pins are definition at <mach/mux.h> file *// }% F& e; Y, ]; f& r4 d
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 a/ j$ b) b( [6 y. T
        -1$ f& ?1 o; K, ^5 Q" G
};8 {; m9 N! f/ n4 l+ _+ u

$ f3 I8 N( g% _static struct gpio_led da850_evm_tl_leds[] = {" n0 y" g8 i5 P) x2 n/ c- t
        {
! G' @4 e1 J7 x! m( y; E/ h                .active_low = 0,: I7 z( P& O5 `. d4 C
                .gpio = DA850_USER_LED0,; }6 f/ h6 k. o  [: x7 b
                .name = "user_led0",& w& }8 \+ x5 @5 }& y+ f. U# J
                .default_trigger = "default-on",
; `( b7 N2 w( T6 S        },
. ~! @9 ^9 `. r: p) e0 w        {
6 S$ f7 q9 Z8 N+ F! ^1 N                .active_low = 0,2 G3 L" _% x1 w% {1 [9 I
                .gpio = DA850_USER_LED1,/ s4 z  L+ n. K& V% P3 M4 i# Z& Y
                .name = "user_led1",
/ F7 z6 ^3 E. r, v                .default_trigger = "default-on",& J. A5 w5 ]+ ?2 Z
        },8 P3 H) }8 T+ K5 d
        {
+ a8 G8 I. ^4 O# x9 `9 ?                .active_low = 0,
: ]* T) e9 @2 u. ?$ u                .gpio = DA850_USER_LED2,
0 r5 R; |6 T  ?$ A8 F% m                .name = "user_led2",
5 }6 J1 {2 k+ W+ _& e                .default_trigger = "default-on",
: M8 S. l$ V. K  ?        }," q. K, B4 k& x- s4 j4 I; z
        {
1 r- F! I& f; w, F4 q                .active_low = 0,
9 @; N4 {% j- ^1 O/ {8 c( n                .gpio = DA850_USER_LED3,
, N" Q3 E, o% p! X4 ~* U                .name = "user_led3",
# y% ]) {" X9 |3 W: T# _$ c9 \                .default_trigger = "default-on",
* x1 \, N* U  ]5 O5 F# R        },& s1 j  S% y1 k) g$ H
};
, F& D& `( [! C* n- l4 O7 T; q1 p1 j; U
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 |/ b' F1 a* K) t7 }& o) O        .leds = da850_evm_tl_leds,
; x7 _& b$ Z( \2 A4 F* }6 B        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ E; w; A/ r" ]$ z) J& K
};) ?9 O; z' h# e6 |  D. J7 m
  m$ b) j6 {" o
static void led_dev_release(struct device *dev)
. s8 ~( l6 x; h+ [) M) ^{3 J7 P" B$ r/ X& n! u! }
};
. p* d! L& S1 o3 k8 d) J- U
" `' o1 c3 R& @* g4 y# a# i2 d$ e- pstatic struct platform_device da850_evm_tl_leds_device = {
; N6 ^3 p) G  w4 c  b        .name                = "leds-gpio",
# S6 d. b. ^$ ~8 C4 B3 g" w  ]        .id                = 1,
! N$ q4 c( C6 W$ H; L; p5 F. k        .dev = {
2 k! i/ E$ q! @% k- O                .platform_data = &da850_evm_tl_leds_pdata,# W$ P" R2 B$ ?5 L
                .release = led_dev_release,' u6 V6 y$ P& |8 j# f
        }1 [2 L0 I& V- {% t
};
" l/ q, \* d# A) w' T0 O8 v+ m) @9 J* S0 }- M
static int __init led_platform_init(void)
5 u" ?+ C' w0 z* z. H; r5 c{! x9 Q( T; e; M* q, B  Q
        int ret;; u, k7 x+ N/ |+ M$ G9 C# ^/ e# l
#if 0; k! ]) B! `, _3 Q+ V
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);  V2 Z$ }8 s; T3 e, j
        if (ret)
8 |5 G* u- k# Q                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" b: t  [: c7 P) X                                "%d\n", ret);# g/ L! }% F( w( W& }
#endif
0 M) F( r, K, y- b        ret = platform_device_register(&da850_evm_tl_leds_device);
+ }* G: r3 x7 g9 I$ `  z        if (ret)
: n& G; y! b3 ~" c                pr_warning("Could not register som GPIO expander LEDS");3 l/ J+ S6 |9 N% ^2 u+ ^8 W7 k( y
        else7 l) L3 E: F- o) z  u
                printk(KERN_INFO "LED register sucessful!\n");" J& ?2 E3 D, H* U/ G7 _0 g
6 M& E4 I: Z! }. r7 }" L
        return ret;
+ M- r3 e9 ~& [: h1 y}
* M: S+ t) G: _7 w
. b1 R& Z" N# a5 `6 u; }3 ~7 {static void __exit led_platform_exit(void)
& B8 S0 a2 u3 v{  m' v& n8 ~$ K/ G
        platform_device_unregister(&da850_evm_tl_leds_device);. C, j5 N+ e4 r$ T# j" w
) ]' L& z  H, V) u* ?- ^6 \  \( _
        printk(KERN_INFO "LED unregister!\n");+ Q; w. r5 r- D; J
}
& S8 R: C1 }8 ~4 [3 h# P) A6 y. \8 t& j  w* o$ D
module_init(led_platform_init);7 e1 A* ^7 y+ v% g6 r7 L. c% h
module_exit(led_platform_exit);
: q1 }/ T" B8 C4 s5 O' T, t4 P
& g* ]8 h2 o2 H9 K: jMODULE_DESCRIPTION("Led platform driver");
1 g( r$ p0 M) q) N2 d+ d. xMODULE_AUTHOR("Tronlong");
8 X7 P9 U, {% A# [2 ~MODULE_LICENSE("GPL");
4 d5 @: P9 k1 h& h- b
% h. ?/ P/ _2 K- l* F& Q3 @! I
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

点击跳转“创龙科技服务通”

QQ|手机版|小黑屋|嵌入式开发者社区 ( 粤ICP备15055271号

GMT+8, 2026-2-2 02:08 , Processed in 0.044206 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

快速回复 返回顶部 返回列表