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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。5 O1 ^0 T" d9 E- t+ s
#include <linux/init.h>
& _! e8 R- H) ]' v6 d& M0 l#include <linux/module.h>
5 B( `0 \6 P4 N# t) r" N( E* _, f#include <linux/kernel.h>. E- v; U0 d% K4 q5 T  h% ~
#include <linux/types.h>
# \" t. Z. R, l* I#include <linux/gpio.h>% \6 C$ K4 j" `% t1 v
#include <linux/leds.h>
: a# k" z# v; n. u' P#include <linux/platform_device.h>
, Y  B/ f4 L% M) X7 u1 N
& e% @5 e* Q' i+ D$ l- D: A7 [9 i5 p#include <asm/mach-types.h>% V. W5 f/ J/ C
#include <asm/mach/arch.h>
7 }5 F! r- Q2 A! z#include <mach/da8xx.h>
9 z% F1 R2 [  e  M: K& m#include <mach/mux.h>
) h' E6 D8 P  a' \$ ?+ S" w9 K) z
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)+ y9 u2 P. v, i+ l: c/ D9 ~/ ~
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
+ W( |5 `! _4 v( S0 u0 ]5 D% f* J#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)% U% \7 K0 j+ T, {, S+ t7 X* k. Z1 s4 y
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)" E" U4 G7 f6 X2 q/ s

0 i$ s6 t% ^. G6 H5 v+ ~$ L/* assign the tl som board LED-GPIOs*/1 F; I5 C) Y2 W. W  ?% F
static const short da850_evm_tl_user_led_pins[] = {& U9 y7 {0 [; J5 i( r5 x
        /* These pins are definition at <mach/mux.h> file */
7 m9 V# N5 j& u, D9 ]        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 c# K7 G! J8 b! \        -1
) Q. R+ d: v. r7 r};
4 E9 \& ^# }/ z! ~$ s$ a, Z& s% i$ @% K8 I# K
static struct gpio_led da850_evm_tl_leds[] = {+ J0 f& M$ a/ n7 k) F# ?6 a6 N6 B
        {
% {2 O) V% c  p2 v* g                .active_low = 0,
$ `7 E& A8 N- S9 B                .gpio = DA850_USER_LED0,2 g1 x9 v  ^. P9 k+ M' K
                .name = "user_led0",5 R- ]* i4 P! n1 W
                .default_trigger = "default-on",, ~4 Q$ n1 ^! P6 P& Y* E
        },
0 r4 w3 H9 {* @2 p  B        {4 P7 `3 ?0 h5 X* P7 ?+ ?7 G
                .active_low = 0,( ], _0 L6 `9 n9 }' y! m1 A
                .gpio = DA850_USER_LED1,5 R( B* j. S6 i' Z* k9 f7 X. a
                .name = "user_led1",) U4 X2 c5 K+ n9 ^0 E+ Y4 l
                .default_trigger = "default-on",& I0 y: }/ p" K- Z1 F8 r. J, o
        },
* c; o; K6 }* C# `' V7 H% c        {2 M5 C- M4 m( b" K( C
                .active_low = 0,* X4 q9 d0 E, \& m0 l* ^
                .gpio = DA850_USER_LED2,
* o. k' b6 z: z                .name = "user_led2",
* u! J' K+ d0 U' s, X- I9 W5 O                .default_trigger = "default-on",& @2 ~5 C; W, {' a1 `" h% e
        },( k- |" ~4 K8 ^3 D# u% G8 y
        {
. l8 z2 k& Q; z  K/ k% d                .active_low = 0,2 J, z1 w9 m& p; T0 z+ F$ ^
                .gpio = DA850_USER_LED3,
1 e0 w; t/ h9 |) x$ E3 Y, T                .name = "user_led3",
  x9 E, {+ {4 s: J5 p- h                .default_trigger = "default-on",( S$ Z* {! P  {
        },' r8 C/ m& h8 c& V$ i- e2 C! G* B
};2 Y( @. M- h9 L

; X8 \1 h6 g+ kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 _. F! ?* p# J4 }# y" j: L: X6 \* l
        .leds = da850_evm_tl_leds,
& ]! G& j. W! k5 B6 K  w        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: z. a% i& V$ v) A" Q};
+ H" \$ a, U4 y1 s) |, s1 d# t9 |! Z0 |6 c
static void led_dev_release(struct device *dev)
! B0 J- @6 E' O* D{9 Z: k% d( B7 |. Y" E5 O* e
};3 ^2 c" `4 A& F! o+ u" u

7 n# ^4 m) Z' Jstatic struct platform_device da850_evm_tl_leds_device = {
+ \2 H  j+ P/ `# K2 T9 Y9 E  f        .name                = "leds-gpio",  B% \, `' x1 N  ~
        .id                = 1,5 {0 V( X% O1 F( c. }9 w
        .dev = {
$ u* ^3 l1 M0 t; a                .platform_data = &da850_evm_tl_leds_pdata," W/ D( P! x2 f, c
                .release = led_dev_release,
$ E5 _, L9 g) O, o        }
% y* N8 P. S7 H9 d! E! k# z2 U};
$ v4 [' Q2 B2 p3 _3 a
2 w4 h) K8 L7 m. F$ J. Cstatic int __init led_platform_init(void)
. `! J% M2 d) J9 y  a7 I! [{, \/ D: c1 J  B- h
        int ret;
. [, g# c; l. w% Z- ~+ A3 l#if 0
  H- [& }( r  z$ g3 w        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( N8 \; C( J# ^% D0 Y/ v/ [5 u6 a% B        if (ret)/ q! d+ N5 s- X2 C
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& O, j% o$ Y0 A  |/ @% c/ X                                "%d\n", ret);# v# n* P0 j( T" P
#endif
  ?! }- R5 m" h* c: w7 @! y        ret = platform_device_register(&da850_evm_tl_leds_device);1 D/ n% N$ ]  V4 q$ Q3 b: y! R
        if (ret), p, ]# D2 H* }8 H1 z
                pr_warning("Could not register som GPIO expander LEDS");
- \/ T. B; l; ]/ N  v0 K        else! y' z" r  E: k/ }7 Q/ _, {
                printk(KERN_INFO "LED register sucessful!\n");; }' S( ~6 j+ u4 f
; B8 x5 D5 W9 j- K+ p. [) ^# ~
        return ret;# ], x) x+ `" n# B3 ?& E) D# ?# P
}
8 ^# S. ~% T# Z- _' G4 h, p+ I4 _, k1 i7 _: l7 l$ q
static void __exit led_platform_exit(void)
2 v( q3 G; L7 V- ^2 ?. T7 x5 ^{+ a& R! T4 W: y$ ]! v9 s
        platform_device_unregister(&da850_evm_tl_leds_device);' ~5 @4 ]# q4 T: [. D
0 z! m0 w, E; r% m3 G7 R( j
        printk(KERN_INFO "LED unregister!\n");
3 J2 n: d8 Z: g. w' j4 }}8 U2 {# t1 x9 p. Y& L. `2 r% E
/ T2 r" x9 v, }9 Q0 B& o+ R$ M
module_init(led_platform_init);
' T! e# |; i6 b3 K6 H, j8 Hmodule_exit(led_platform_exit);
" I; V3 Y1 Z: X, ^- a* C2 E  t( R3 c
MODULE_DESCRIPTION("Led platform driver");3 u# L* s3 f, t, M
MODULE_AUTHOR("Tronlong");; ~1 S; G7 P# g! G# w7 l+ K; s
MODULE_LICENSE("GPL");
+ c+ r1 R/ M4 O) `! }% B6 b( Z$ s0 H/ ^& I9 m
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-5 14:19 , Processed in 0.040391 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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