程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ A& ~  D) z$ K1 U  c#include <linux/init.h>8 e- u* h' _5 m
#include <linux/module.h>! ~4 j2 D' E1 E) n2 E  n
#include <linux/kernel.h>
0 K) Z. L* \& ^; s& k! x# P- p#include <linux/types.h>
# w9 h4 l* d  L' {#include <linux/gpio.h>. Q' `# ?- y% ^( U
#include <linux/leds.h>- c/ _. }" O4 q
#include <linux/platform_device.h>. k: C/ V! P2 E

) b9 ~7 S  G& E; B#include <asm/mach-types.h>. j& g# l- x/ ~% G! ?
#include <asm/mach/arch.h>
5 e# \4 A8 M, N9 |& M, |& [#include <mach/da8xx.h>
6 j3 g8 W. I* t$ r#include <mach/mux.h>
6 c6 x1 s7 @, B" z
2 [: K  v: e$ e8 I- ~8 w2 f3 }4 J( R. W7 a#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
/ M1 |6 P  H7 m. `#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
6 y4 }% G, \; ?" }" k. C#define DA850_USER_LED2        GPIO_TO_PIN(0, 1): O- H1 |! A% C# {% \2 ^
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
4 [% |! E# V- ^0 U* @
8 f1 U2 c' x7 T+ }/* assign the tl som board LED-GPIOs*/( Y0 r  q7 N4 n4 P
static const short da850_evm_tl_user_led_pins[] = {
# J" m; r* O$ _& ]% P        /* These pins are definition at <mach/mux.h> file */* i! [/ f: `" ~: o
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,  G/ w$ D+ u! A; K
        -15 J) y9 r3 }: ^. y
};
. F9 Z: Z8 l4 H0 h4 x3 m- c7 o
' E  P. C; p3 J6 ~) `3 Qstatic struct gpio_led da850_evm_tl_leds[] = {
9 q5 B! m9 N/ h( `0 _  o        {" V6 n0 f. L8 u) I7 s' z
                .active_low = 0," w8 K$ F3 b% P1 r; C3 s/ w
                .gpio = DA850_USER_LED0,
' y0 p5 n; h9 F) p  c& u1 I" g1 s& m                .name = "user_led0",
$ I+ S% K) U1 V: |2 a. g                .default_trigger = "default-on",& M. t+ N0 V  F& p. T/ ^# d
        },
( l) J6 E4 n6 Y' [5 d        {" L$ ~' e; j. B
                .active_low = 0,7 ?& R9 D& R) C) [2 {. g1 X
                .gpio = DA850_USER_LED1,; f- f5 Y, Y1 }9 m  _  s
                .name = "user_led1",
1 Z! H3 d! i" \; X2 n& C9 c; V                .default_trigger = "default-on",  x# I" o9 F8 I% }
        },
2 P* t3 w" @( Z* \, C        {/ \0 Y6 c: A0 `# u* e0 I
                .active_low = 0,
6 B9 }7 I# Y6 o8 ]                .gpio = DA850_USER_LED2,
) T$ h2 W0 U. V# D                .name = "user_led2",: @2 F  r5 y5 [) t- k
                .default_trigger = "default-on",
: A* c, T" J" t5 m1 n+ O, j        },7 {+ p8 ~! z9 z4 Y* T  D; z9 u+ P0 Y
        {
2 O) K% i. g6 [$ ?4 ~                .active_low = 0,7 H6 S: {- R& r9 S; k4 B6 i" o' J
                .gpio = DA850_USER_LED3,3 m; h3 ^0 J! }
                .name = "user_led3",
4 t* J* ]% G- e4 l( W                .default_trigger = "default-on",- F, w# h4 l! F, A/ E: Q) F
        },
' G( F# f) }' k};
( Z- A2 }9 v- w0 Z# s' X
4 }- o$ W7 A1 J  W  h  I1 N; w' j$ Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 E! t3 Y; S5 M9 J- k        .leds = da850_evm_tl_leds,1 z$ a1 ]2 U* J8 B! L# K/ ~2 e
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, i) t  G. K8 G. @( Z3 h6 c
};% `# M. [! ~/ R$ v9 e

$ }2 D( E3 w( v. W+ Q! Q& l/ bstatic void led_dev_release(struct device *dev)
5 g) c) G, F: x- Y{2 L' K& L. }' ?+ J
};
4 b" n, H7 O/ g3 O. u
: t: p; V7 q" K( Qstatic struct platform_device da850_evm_tl_leds_device = {( H% a+ I7 e* l0 S- C* z- J
        .name                = "leds-gpio",
. e5 {) N5 G* c& Y9 x        .id                = 1," a- g) J5 [- ~& M( \, M4 i
        .dev = {
$ u9 n0 u+ b8 q& |                .platform_data = &da850_evm_tl_leds_pdata,- t, H, M6 n: U* L5 S
                .release = led_dev_release,
8 q2 {8 E" q, Y        }
; r5 s! `! }% {7 ?! I& v6 y};; V/ i1 [/ \" ~) G7 V% r7 b$ L
6 n- Z  h9 L0 s+ y) i4 Q$ j
static int __init led_platform_init(void)
7 J* x% a9 s2 g2 v- W# M% _( O8 M{* G; y/ X2 P2 k' e! U
        int ret;
0 X# L3 \6 H' U) }# b0 X. J" O, e#if 0' t2 {/ c: B; x- O+ \! s: @0 d7 {5 u9 J
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- C6 p; p2 y) X$ E# m5 {1 _' v. }4 I        if (ret)! G+ r0 ^( Q" P6 U/ q* E0 j
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% J& V5 ?7 ?6 q3 i. i                                "%d\n", ret);
* o6 x/ f" b  m: H* M#endif0 D: Y! E8 [+ m8 O) f% {
        ret = platform_device_register(&da850_evm_tl_leds_device);+ m2 q( F% V1 n/ I* ~
        if (ret). F1 H' X- _& M9 ]  E2 n
                pr_warning("Could not register som GPIO expander LEDS");
, A& _% F" f2 |# V        else
. i& j$ @' g: X; {0 ~6 k* ]                printk(KERN_INFO "LED register sucessful!\n");( O; }9 }* G7 U

. v$ ]) N, s3 e  s6 X' N        return ret;8 K* I2 E5 W) g* x4 o, b
}1 ^& B- ~$ w( ^! c! a( d! Y3 s
. @; T0 @- h' D5 [( @
static void __exit led_platform_exit(void)2 y, @) r5 d6 }. @  O- j5 T
{
, `5 X8 P3 [$ v8 o! e4 R7 R        platform_device_unregister(&da850_evm_tl_leds_device);, I. M6 N8 {9 R4 E; _

9 @3 A4 V' r, H% I        printk(KERN_INFO "LED unregister!\n");- O! j0 m) y* v. {
}
& F0 o4 V) |3 _, K0 c8 G
  P3 k3 g! [6 z: a' \module_init(led_platform_init);
5 w* A: U; a2 Y# ~% @" Qmodule_exit(led_platform_exit);
1 i0 R# I: ^& o7 v- R2 C3 Q0 I" ], a. U" ~7 k
MODULE_DESCRIPTION("Led platform driver");
6 m5 r4 N' S1 `/ e. SMODULE_AUTHOR("Tronlong");7 f7 t6 X3 k! P/ e
MODULE_LICENSE("GPL");/ T* T$ p+ c7 e' o

& y  ^# h. T; ^5 b& I& u
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-26 02:35 , Processed in 0.037415 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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