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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。+ z' P/ x: J9 l6 B
#include <linux/init.h>* ~* X/ P6 s7 i- w% _
#include <linux/module.h>
( z  E. D6 w/ D9 I) X#include <linux/kernel.h>3 a4 F5 X$ d& q3 z
#include <linux/types.h>4 u2 m- O1 r" D+ b
#include <linux/gpio.h>7 M& O) T- [1 |( `" t+ N6 }
#include <linux/leds.h>" y1 f# r& A- l0 ~
#include <linux/platform_device.h>$ n9 h; T3 }9 d# E& A( N% H
& s* Q2 `8 j# \3 d' b; `! U$ Q
#include <asm/mach-types.h>; J$ _  X& G& k6 e4 _, i" w. j
#include <asm/mach/arch.h># W" w; \8 [. V
#include <mach/da8xx.h>
  W4 y# B4 L! Q. {4 m0 q#include <mach/mux.h># x; N0 q; U& Z. T! j; ]

3 b& C/ L9 A& I2 F#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
) Z+ U- o" }; D! k1 @9 c5 S' S#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- }  ]$ {( v- Z! Z- L$ M2 c6 m#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)* X# ^1 Z% s. U7 U' V2 `
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2): c/ L, W  `5 Q+ H
' r/ G& s6 G/ T
/* assign the tl som board LED-GPIOs*/( D( s6 v4 h3 I: j
static const short da850_evm_tl_user_led_pins[] = {! M5 p! x+ K6 S6 S" n
        /* These pins are definition at <mach/mux.h> file */" h& p8 w1 Z7 x# w3 Q
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ N* A/ H, _$ h- O* y        -17 a9 d: e' [) i8 C% ^" P
};3 h  u, {2 b) M6 Y  c8 T* L2 S

0 `" x! ], y3 p2 K) M, @- astatic struct gpio_led da850_evm_tl_leds[] = {
; f' V* W6 s- @* ~        {8 d1 U- e/ g0 b- d. G: e/ f
                .active_low = 0,: A1 p: L/ Z* [( P& F: r3 ?
                .gpio = DA850_USER_LED0,7 }3 Z4 f3 |; q
                .name = "user_led0",
% G1 l, x9 f+ ^4 C9 ~                .default_trigger = "default-on",( V4 H3 g8 l3 g3 k6 [& Q1 c. G
        },
) B+ y6 x/ t# P. C/ y0 ?        {
9 I) ^. C9 B, m$ o" M& k& W; ~9 Q1 g                .active_low = 0,
( y: d; @$ ]' N& d                .gpio = DA850_USER_LED1,
3 D) w9 D! q7 p                .name = "user_led1",, j4 R3 G4 I% M- |0 p  Y; ~1 E
                .default_trigger = "default-on",' I1 {8 n2 L- q+ s. R
        },7 ^' _  S) f) f( ^7 u9 `" t- }
        {; g+ r" X. J# R. J1 t2 s
                .active_low = 0,
  ~1 s+ G0 m6 k" l# ^: Y                .gpio = DA850_USER_LED2,
% r6 W" D" p; ?' n                .name = "user_led2",: D7 g' B: i4 ^/ E/ |9 C, e
                .default_trigger = "default-on"," i7 H* Q1 D8 b1 s3 I
        },& X  v* g5 W6 y
        {2 I5 j4 m! p( w( _
                .active_low = 0,( B2 q$ T  h; K; _5 ~3 T/ d
                .gpio = DA850_USER_LED3,
4 h5 }' t+ J$ i/ D& ~                .name = "user_led3",
# y$ l$ K/ J$ H( T                .default_trigger = "default-on",
2 c0 L; A; A# u( a. }        },
. Z4 r+ G4 u8 D  ~; P};# n: m# |7 _- ?: E$ ?! d
& K' I1 x# V4 U
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 P- d% o$ ^6 _+ q  j' Y        .leds = da850_evm_tl_leds,
) J$ I+ j$ @( N+ Y' I        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 t- W& k% [/ }- ^) V+ Z5 R1 C# L};/ S$ Q' B; ^  C8 Z; q, u) h: w! }( ~

4 K7 d/ u! _+ J1 A% \* E3 T+ E4 ^* zstatic void led_dev_release(struct device *dev)
3 M: g- y+ ~9 L6 K{& y4 N) l. E# |, [% a! T
};( [, S9 A/ m1 l' m

, T* K' V( a/ k* k0 X3 Ostatic struct platform_device da850_evm_tl_leds_device = {$ c8 z4 ?! N$ j, f
        .name                = "leds-gpio",! k+ d+ C. C5 g& B& N$ z
        .id                = 1,1 g  \7 Z4 l! u/ o% ]8 i, \
        .dev = {- n! K4 ^# J. M4 J5 B% U* v3 B
                .platform_data = &da850_evm_tl_leds_pdata,
" }! E+ H$ m8 q" [/ C# S                .release = led_dev_release,6 h5 y3 V1 V* v8 Q0 Y  ~8 L
        }
1 ]6 Y! i" w" r$ A" ]/ t6 n% C};
$ h1 V" d6 w5 O. I% |. T! |7 f3 R. B* {8 ~6 r- k: s1 z# m
static int __init led_platform_init(void)" C! t& e9 _9 m+ p6 F/ G2 a
{. z% U& p8 M) j% K+ Y5 P7 K
        int ret;
& M$ b) M7 C9 A5 S: d#if 07 J4 V+ i. ?1 Q) B
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! t# B9 D% k" e        if (ret)
4 ~9 `& Y3 ]2 Y                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ }- i( x& A. B                                "%d\n", ret);9 P( P) z8 \% j6 d# L& K- |6 |+ w
#endif" [3 _* ~! S: ^! Z; D  n
        ret = platform_device_register(&da850_evm_tl_leds_device);
7 s# v  g9 v: X! c        if (ret)7 h% K3 d+ J; G2 u3 [4 f
                pr_warning("Could not register som GPIO expander LEDS");
- E1 a3 c$ `# E/ X, r( l        else. `$ w2 b. I' A7 t# d" C2 N) j: I
                printk(KERN_INFO "LED register sucessful!\n");: I9 a6 g9 d) M  D: j; J) H
/ s( ], K. H1 G& X7 q
        return ret;; c" E: _( h; u( Z! P
}
1 r8 |1 f0 S8 ?) |! r; }; Q
7 H3 _$ {9 X4 E6 c; kstatic void __exit led_platform_exit(void)- G; _% o  w; I
{- r2 d! h) m% ]4 G9 e: J
        platform_device_unregister(&da850_evm_tl_leds_device);; ]7 o! o1 f5 k$ }3 _

. K* @1 p5 g' E! |* n        printk(KERN_INFO "LED unregister!\n");
* j6 c* \6 b$ y8 t! c* W* _}: d, c& u- r0 W- r2 |/ F
1 a% v4 h$ P' c8 D- o4 C! z" C, p% Y
module_init(led_platform_init);
9 _$ l) B9 O. {& Kmodule_exit(led_platform_exit);0 H# f. M# v* K% V$ f/ x9 y

. W+ I( U# k5 `& ~5 @MODULE_DESCRIPTION("Led platform driver");4 Q7 c* a. P( q* {: i
MODULE_AUTHOR("Tronlong");: L' l! U8 B. p) g) c
MODULE_LICENSE("GPL");
" x+ c$ Q! z! L% V1 f" ^# @
, G% S# I: c9 z3 K" |3 {( C: r& q. Y$ L
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-2 15:40 , Processed in 0.036218 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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