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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% a/ J9 x8 q; J4 C9 j7 {2 M
#include <linux/init.h>
5 d. K: d" V7 X, `3 O, P#include <linux/module.h>
0 ^& c9 @% v) _. _3 w7 ]#include <linux/kernel.h>
/ z+ r% @+ d& G#include <linux/types.h>
; B" B: J8 L4 }1 j#include <linux/gpio.h>, n( r( H# F7 @! u9 V) v
#include <linux/leds.h>+ ^6 `2 F, O* m
#include <linux/platform_device.h>; Y1 h; g1 E8 a6 m
9 y/ Z; Q7 Z( X4 h
#include <asm/mach-types.h>$ x# j1 M9 I# f- \
#include <asm/mach/arch.h>
# V4 i6 Z; h, {2 U#include <mach/da8xx.h>
1 G$ z( E6 h2 m$ x* a#include <mach/mux.h>
5 w0 _% A1 R) W/ r4 R' o
# q/ [) [: h, g1 B#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)4 e; `; o0 C3 Z; `
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5); g$ e# c' q4 j
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
0 M% }9 F( \# ^7 b* s6 e. i#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
$ H8 `9 T+ y! f) J1 v& U  f9 X( s# N( O$ `. e
/* assign the tl som board LED-GPIOs*/
, U' s$ ^9 {9 l9 u) }static const short da850_evm_tl_user_led_pins[] = {: a6 p( Y" ^1 B3 a" k' c
        /* These pins are definition at <mach/mux.h> file */
* Z* l$ s! o+ C' e" y        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, f& S1 }9 U) V3 V6 J  H
        -1& ~" \, o2 |- }  Z
};
+ [# q  B  a2 z% i# n$ z& m7 o% J, z8 k$ m- c
static struct gpio_led da850_evm_tl_leds[] = {1 I, _$ |2 M0 @' N* X) }- L5 h
        {
) @; ^9 _2 x5 e& W: L. @# g9 R                .active_low = 0,1 s, R% `: D- T; R/ W1 |
                .gpio = DA850_USER_LED0,
, E- Y& y' e! _! U4 s* Z3 W                .name = "user_led0",( b) H  G" q1 ^
                .default_trigger = "default-on",
5 q% }9 E4 J0 m: g        },
1 [$ f; A, E# a! E: S3 e        {# [% y6 _; c3 V& d, L
                .active_low = 0,) h2 E8 l" v; b0 ^( F# i
                .gpio = DA850_USER_LED1,
- [+ n4 s; D- |, W; F                .name = "user_led1",% ]7 |) n  A" i/ Y$ q0 U
                .default_trigger = "default-on",
3 c3 Z; o6 U" a# ]& b        },3 B: |) u4 e: n$ i
        {
6 s( j' ]4 E. E* j3 J                .active_low = 0,$ @7 c7 F: B5 c- h1 t
                .gpio = DA850_USER_LED2,. H+ b; ?1 i& D
                .name = "user_led2",
+ @1 r. p& n6 d/ p1 z# m+ |                .default_trigger = "default-on",
6 C0 ^% [8 E- D/ Q. u5 m        },
) B8 x5 K: t: o3 K/ j) _  z        {
0 `( l# I) {' j- ?7 H                .active_low = 0,' A  \3 @- C5 h1 W1 w' ?1 N* `8 q1 ^- C
                .gpio = DA850_USER_LED3,( ?0 j6 l; F9 u2 j" H' p2 g, M
                .name = "user_led3",8 Y& E4 A9 d' ^/ x1 k/ \
                .default_trigger = "default-on"," k3 `# I" V0 d+ L8 _4 Z. b5 G+ }
        },+ t# I! J" Z. A% c- O. J; {  t! W
};3 O3 _# J0 u5 {  r7 }

3 P* i9 e* W: ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) z9 _. c, ^) Z% v* f9 P( c
        .leds = da850_evm_tl_leds,
# t3 s/ o! [4 J9 M  `+ R7 M9 S        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ K. ~: I/ f. @1 \1 b" N
};
2 h( r3 n: N8 p+ Q' ~- ?
' q/ n9 w. O% w! `static void led_dev_release(struct device *dev)
. D  ]9 j) _! }: S$ o{
" A# r3 e+ u# O/ b2 W- F};
# C2 \4 h$ o2 f) x. v/ @
3 J* y* p* e: V3 lstatic struct platform_device da850_evm_tl_leds_device = {1 h3 g8 Z0 a% v) Y$ g
        .name                = "leds-gpio",% @3 E# O' ]# Q  W
        .id                = 1,, P, P; o4 k! z4 r+ n: D
        .dev = {% ^+ s9 ]2 r+ A6 e4 `( g
                .platform_data = &da850_evm_tl_leds_pdata,+ Z0 j- n9 d4 M0 m, o
                .release = led_dev_release,
/ y# E5 b, w7 H# D" t" i4 d        }8 f! J+ u8 b! s/ M* e
};
7 J6 r# i8 k% _* X
, |( a% l1 g0 T8 Dstatic int __init led_platform_init(void)
# C, E3 i2 k3 J- p{+ y0 H) a  N% _& I1 q& I; T* Q# w
        int ret;
* l$ W( z; D( W; K) b1 M) b9 j#if 0
0 O. p+ {* H& i" r- ?        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: Z" e" p! {1 H- U6 L/ {) s        if (ret)
# b3 b1 }& B/ s8 \8 M( f+ j" H                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 Q+ \$ j; |0 o# T  P
                                "%d\n", ret);5 `- |/ P* T3 h) Y" Q, X+ U% n" t7 e8 h
#endif
8 J" P* X7 J( o9 o* S2 g        ret = platform_device_register(&da850_evm_tl_leds_device);
- U! z; T- R# j5 T6 L* d( F        if (ret)
: z) {/ }- V$ @# L1 d0 L! v2 Y                pr_warning("Could not register som GPIO expander LEDS");# T& ?! b" C3 P1 k; w: {% J5 h& I: T
        else+ g8 r( D$ F' w. d% d: l* o; d
                printk(KERN_INFO "LED register sucessful!\n");. k+ `. n1 n# M3 ~2 I
8 P9 f; q  e% L' n" B
        return ret;6 J. w6 }" D( ]: A
}
6 V, |- ^% }1 P5 I+ t
" |. l  B4 x0 lstatic void __exit led_platform_exit(void)2 q# r% d$ Y: G  a$ P
{
* h" n) I* Q, p& [* G! Y! e        platform_device_unregister(&da850_evm_tl_leds_device);9 U  s. ?' Y8 Y# h
8 {/ X3 F* e. |+ ~3 m
        printk(KERN_INFO "LED unregister!\n");
6 B4 S4 |. @7 \" |}7 K8 I; V) J$ X! \

" V# w& j' b$ p, Q, W7 E, ~module_init(led_platform_init);
- `* W' K: o5 n3 W5 ]4 Ymodule_exit(led_platform_exit);8 R( j7 O3 k: K7 z
! [2 S" B8 D. [- B
MODULE_DESCRIPTION("Led platform driver");  O- t/ c% K) e% ]2 W8 l8 m
MODULE_AUTHOR("Tronlong");
. c. D& M3 D: y/ v2 ]MODULE_LICENSE("GPL");
$ G2 o& w6 ?2 `6 \0 ?0 E9 l1 c" V. g; s* Z
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-4 08:40 , Processed in 0.051358 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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