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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
) S& V1 Y; \& s$ z; M" u#include <linux/init.h>
6 `% _! l; f# |+ P#include <linux/module.h># n1 v8 c7 ]3 W6 v) W. A+ Q2 \
#include <linux/kernel.h>
! }3 H0 `( o/ O7 g7 V$ \( `#include <linux/types.h>
! h( r5 O. D. V* F#include <linux/gpio.h>
3 o( t+ x, J0 g) Z#include <linux/leds.h>
4 `. |1 c3 m3 T9 d  M, a#include <linux/platform_device.h>
+ z- q; }0 t2 l) r! s7 `5 U# V3 E+ {
6 d. ?. ^% w9 ?- {) I, z, R5 ]#include <asm/mach-types.h>1 @( [' S. }. j3 |( |# F- f
#include <asm/mach/arch.h>
  @( E/ e4 h0 V* ^+ K# F4 P#include <mach/da8xx.h>
% z8 i5 b/ M7 W7 e#include <mach/mux.h>4 y6 Q: n! b3 U* L6 d  d5 q0 @
6 T1 B0 K, K! |' x% }; Z! j2 C
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0): A/ j) Z1 k+ S+ u
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)5 q% a) C# d; h4 h  ~
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)4 I8 j+ T" E: W7 M5 ^! H
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
% N' w3 @" e# v; J
7 @6 ]4 V9 `+ g/ F* J/* assign the tl som board LED-GPIOs*/
) i8 J& y# j2 Dstatic const short da850_evm_tl_user_led_pins[] = {3 s; o  c. \- v! h" d6 F1 L
        /* These pins are definition at <mach/mux.h> file *// c% Q' J+ T' R) Y$ f- C5 U
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. q4 b. j* p3 N. f
        -1
3 k( s3 K) b5 k};
. Y) [0 @; {" X/ j4 p1 o: ~0 D3 l* N% U' G' y+ Q4 l
static struct gpio_led da850_evm_tl_leds[] = {
4 S9 c2 O+ S0 s        {5 U4 |7 m( F' N% P7 M9 U+ W
                .active_low = 0,
) T1 h8 ^6 N: a7 k8 p3 R4 z) P" l                .gpio = DA850_USER_LED0,
& w) c: R9 H) w$ h( k1 ^: |                .name = "user_led0",1 G8 V8 _8 i2 B% o' M2 X- l
                .default_trigger = "default-on",
7 I% e: k4 g. `# x& l6 ?6 W( }        },
  ^3 M" P& m$ j: Q- R        {
) d9 M4 t7 x1 @0 k6 x                .active_low = 0,. c: N7 P- e- r9 n. x
                .gpio = DA850_USER_LED1,4 l7 B1 I2 j/ t4 q& B  ~9 q5 K
                .name = "user_led1",; Z* i$ o2 [% `8 {# w
                .default_trigger = "default-on",
+ T! |, s. l5 ^  z, N( I) \9 W        },/ Q: R- w! y" R
        {
6 A* {6 Y9 }5 F! l! x                .active_low = 0,
! f2 O" X3 a0 J7 \+ m2 ?                .gpio = DA850_USER_LED2,
3 f) ]3 k: U% l  E5 a: C                .name = "user_led2",6 c, a+ ?' G6 ~$ {7 v9 V& X$ V
                .default_trigger = "default-on",7 I+ |0 c+ {6 @, `* N% Y4 F
        },1 F8 P5 i1 C4 ]/ c5 P+ m
        {2 A0 `  v3 R% {2 \
                .active_low = 0,- @; o7 \) ^. }2 a; S% Y" j5 P6 ?
                .gpio = DA850_USER_LED3,
# g* e: L6 l* t5 H( @0 c* @# l                .name = "user_led3",3 M- K! G8 ], H
                .default_trigger = "default-on",- t/ q2 V" S" g& b/ ~
        },
( |) F7 \3 o) @; |2 P- f};* Z3 d# e0 [$ n4 T0 B8 R

) N1 Y! U' W- O% k# X% s% j4 Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; [" o& v7 `0 L        .leds = da850_evm_tl_leds,3 i- ~* U2 D) W  V# ]' Y
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 r0 B4 f. }/ T1 R4 v+ W$ s; h1 g: @};: v7 \9 y* B; ?' u9 M

8 s& d& q7 ?: N" ^- j# A5 Xstatic void led_dev_release(struct device *dev)
1 w8 i2 i( f7 o  ~& u0 g{; A& b* {* ]" U9 \
};! T$ b) [/ H9 x( [$ o, L

: {0 a% ~" }5 g+ ?% wstatic struct platform_device da850_evm_tl_leds_device = {
5 H1 W* J7 V. a+ ]0 l' r        .name                = "leds-gpio",- P9 q$ l8 U. {$ m4 Z$ ?
        .id                = 1,& \) M6 [6 P" \) a
        .dev = {4 @2 L" \5 v3 m" a
                .platform_data = &da850_evm_tl_leds_pdata,
) n  _% R( |! m  T                .release = led_dev_release,- e8 z0 ~% Z3 s# K
        }- Q" H4 O7 y, Y8 B4 Z& q
};
1 ?; k; d( D! m  Q
) o9 B) S2 t) }& b4 qstatic int __init led_platform_init(void)6 T$ d: s: m0 G* s* x4 N
{+ |, C9 L0 \: t4 g
        int ret;8 e+ U1 V2 \$ [7 D" I0 D9 S
#if 01 g7 \  P2 m( U0 c- k
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ v$ U9 k& v1 T% k$ q8 v0 P; E        if (ret)+ T$ K. S9 B1 |; U6 N
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ g3 f1 w* K, V- ^4 [
                                "%d\n", ret);
: X4 o7 a  N/ S2 u, k0 P#endif% |4 T$ K# B8 q! M
        ret = platform_device_register(&da850_evm_tl_leds_device);
! `' f- u- U- q4 l# [        if (ret)# z& g' Z0 I' O! i" m+ J7 p
                pr_warning("Could not register som GPIO expander LEDS");
) }/ g5 i* m' o$ @8 _$ _$ L* h        else7 O; |4 F# n. N  E4 L2 X; J! h# ^
                printk(KERN_INFO "LED register sucessful!\n");
' L  N" E  e% a# Z, _2 K7 h$ q* [* ^, Z! q& y
        return ret;
( {6 ], k$ j+ s3 R}
7 k. C+ c# Y) |3 m
  D3 L* X* c$ o6 S5 g0 j+ fstatic void __exit led_platform_exit(void)
1 M5 N1 [4 l  ?{6 E* z9 _9 F: c8 f" l: u, E9 _
        platform_device_unregister(&da850_evm_tl_leds_device);: f. e; T. |3 P7 X

& v5 \8 J( h( k3 |7 e/ B: [7 n        printk(KERN_INFO "LED unregister!\n");
& l: \2 {1 i4 C7 }. B. Q}5 v  i. C* L# X4 X

9 C* ^7 b4 @' p4 f5 j9 _module_init(led_platform_init);
$ N- p; l! L8 F3 H: Y  _0 lmodule_exit(led_platform_exit);5 C- J% n3 X8 u; I+ M1 l- [& d
9 a* o) ~7 U5 Z
MODULE_DESCRIPTION("Led platform driver");
3 [0 J8 e8 _9 p4 g9 g/ }) cMODULE_AUTHOR("Tronlong");
: R4 a2 {' R$ N% Q+ M) {2 DMODULE_LICENSE("GPL");
: B* J+ X4 h6 M8 J, T; T: ]: R! O
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-6 20:57 , Processed in 0.042495 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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