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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
: e) @! [, m# Z#include <linux/init.h>5 u2 p  h2 x7 T3 ?. C1 W% L' m
#include <linux/module.h>. d5 e0 k5 t5 W, y/ n
#include <linux/kernel.h>! J) u  p/ r) W
#include <linux/types.h>1 ]- }* x# y, ?" g6 j7 \3 U
#include <linux/gpio.h>
- L  i. ^! G8 p4 U9 H#include <linux/leds.h>
3 I9 Y8 O& x' _6 @: j#include <linux/platform_device.h>7 f3 P$ M  H! R
5 s7 R- m0 R5 n. V' i" \" N3 `
#include <asm/mach-types.h>
+ y7 m+ W: ?) Z8 {/ J4 C( L1 ^% _#include <asm/mach/arch.h>* B' C- B$ b+ e3 y- W( s' M
#include <mach/da8xx.h>
: t8 @2 R0 |5 S7 \#include <mach/mux.h>
# }" Y. Q3 e* X9 H& K7 n% F' h3 i4 t" v* k; w+ k
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)0 U- U; d. M& o/ [6 H% h2 _# |
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
9 K% @! _0 Y3 R& m! ^#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)' G" }5 W; d" [0 m) ^# F
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)$ r% w% r2 i3 x# A: A# U0 K

( W- j; @0 c) U! ^/* assign the tl som board LED-GPIOs*/
: W; O7 ]6 H- `5 F- C7 X$ G; A/ Ystatic const short da850_evm_tl_user_led_pins[] = {
/ {/ D3 Y/ P+ Z        /* These pins are definition at <mach/mux.h> file */
( K$ h* [* a5 }) F# V1 y: k        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, x* @+ i: o' _* k+ Y
        -1
8 _2 m( E3 a2 W8 N! h};
3 `. m* W) \2 |) Q( |+ N: r! i: @$ }' I% `& Q- k  s
static struct gpio_led da850_evm_tl_leds[] = {
( o  g% @0 \+ z+ ?. h        {
- R! l' ]4 ^5 K: @6 ?                .active_low = 0,' C+ e1 q2 Y) n3 K
                .gpio = DA850_USER_LED0,
. m5 m5 y- r( U% R3 x6 @! O. a- G                .name = "user_led0",, B6 D1 _7 r4 P; }4 c# C" n% O
                .default_trigger = "default-on",$ u; m. s& s9 ~' e' }$ K
        },
! D( Q& a; k. F        {6 ?% |' b% b  U4 v# X' N
                .active_low = 0,. S# q( I6 N2 ~+ x" K9 t: F
                .gpio = DA850_USER_LED1,
9 A9 Q/ h1 _2 N: l- y: z                .name = "user_led1",. Z1 H& _- F3 X9 c) G% ]
                .default_trigger = "default-on",$ s) ?/ i$ B* Y8 p7 _
        },
6 G" I1 b- P- b        {& N; l' R9 _: F; F6 }* z& k% a
                .active_low = 0,
% o5 q; g) ^  ~) }  S' t" r                .gpio = DA850_USER_LED2,4 l! A" X$ C# B6 p2 r
                .name = "user_led2",
5 P  `8 @# d: `' U( }5 r# E                .default_trigger = "default-on",
0 ]% b- c, u, s1 s( K7 g' J. T* w        },
& |  g3 r4 ]# N  U+ X$ g. z* I        {% z, B. b2 x9 _! D4 }
                .active_low = 0,
6 t# q6 ?: L+ `! X: \                .gpio = DA850_USER_LED3,8 ]4 ^. e& b. M. b4 y. j
                .name = "user_led3",
1 o) \# O$ {! ?7 Q/ l                .default_trigger = "default-on",
: V& U% r2 v5 }9 p6 B# r- y1 I        },
5 g( h, Y8 d" f};
0 V  W+ B" I/ I( k
: G8 J' Y# m( G  Z0 T4 h9 V. j; gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 k# I$ S& s7 y1 C* ?        .leds = da850_evm_tl_leds,
  V  m& T% }( `; V2 l- ^) u8 r        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 P& A' K4 _* j* w. A3 @" I" ^};
0 c  ?! D( g! c7 R* i8 ~8 V  Q  S! Z$ x; q4 R$ f- P" a
static void led_dev_release(struct device *dev)2 U/ w9 N. V0 K( V$ m
{1 s) _9 P/ c% \3 c0 v- k: m+ f
};
3 O0 t8 I4 U* G/ N9 ?  G' n4 G% r; O- U& E
static struct platform_device da850_evm_tl_leds_device = {/ X; T+ g, a; [* h9 x2 S* E/ b, U
        .name                = "leds-gpio",+ A5 g! g7 u1 y8 L8 R! [
        .id                = 1,
4 v7 }/ [' a$ A7 q        .dev = {
1 b% _% [7 r4 a6 I6 l5 R  S1 f! b, h                .platform_data = &da850_evm_tl_leds_pdata,
8 @8 v# r# \5 e                .release = led_dev_release,
& d+ w6 P- I1 q9 C# p        }! ?" \2 B' R1 F- W- ~
};
- k3 ~: @$ A% g0 q: q1 V8 D
2 f' z: i0 k) D9 Rstatic int __init led_platform_init(void)
) f  z6 V' w0 r# B2 d{9 m$ N# }9 Q- ]; a
        int ret;
3 C) c! |7 t4 e! }2 _#if 0
5 W: S' O& r/ x7 K$ x. y8 S        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% L7 v" m2 v; o9 X
        if (ret)- u5 i7 q' A; m6 ]$ ^+ Y5 O; k. g
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 Z1 i3 R+ U( H& f5 E* ?
                                "%d\n", ret);4 k" p4 H& o5 t9 V$ {
#endif5 [# N8 |" m* ?! B* j, F& t# f
        ret = platform_device_register(&da850_evm_tl_leds_device);! T# M% A* J* Q4 t0 u" ~
        if (ret)) _, g/ j' r5 D1 ^: B/ G# X
                pr_warning("Could not register som GPIO expander LEDS");6 h% s% B1 r/ S
        else4 t  k( a/ G2 ]8 }* r
                printk(KERN_INFO "LED register sucessful!\n");
) T8 e' u1 r; c" E0 a( C# P% l0 l1 V  Y2 O6 \
        return ret;6 t- _0 S. q# i0 w
}
, D' J0 S: I# @$ T/ `: j3 k  G/ F9 u2 f6 D  c& T8 z& \6 O
static void __exit led_platform_exit(void)- J5 Q+ }2 l) f8 s1 D
{0 ?0 b2 f, V8 u$ G' A* v6 J
        platform_device_unregister(&da850_evm_tl_leds_device);$ @' g* c  k# d4 _1 G7 K& M7 Z& |
! T/ Y# C; J) u
        printk(KERN_INFO "LED unregister!\n");# T3 P! y: H$ L
}
! S; B2 k, f* g. x" Q( ^7 X( H! A) U) ^: d
module_init(led_platform_init);
. T, c' {1 r  A# Y4 T. Z' [% zmodule_exit(led_platform_exit);
/ \" H5 l; C# |7 {, f9 \5 e; J& _9 }0 V$ M
MODULE_DESCRIPTION("Led platform driver");
- g6 Y; |, F( Y7 W; f- {5 wMODULE_AUTHOR("Tronlong");/ N/ o) v* v0 z6 f
MODULE_LICENSE("GPL");4 h0 M6 x6 ~7 I% ?- e8 U

8 f3 v- z9 H( e% ]6 y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-19 16:03 , Processed in 0.038536 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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