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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。  E8 b; [( w6 z$ \
#include <linux/init.h>
2 u6 q; J* Z9 w% M% i- {' s#include <linux/module.h>
, ^) G+ c5 `) J" Q( p3 e' V#include <linux/kernel.h>
4 ~+ s& `1 W% ?7 b* Q! ~! r4 G#include <linux/types.h>
7 ]9 e, ?& k" e#include <linux/gpio.h>
# {, `! ]; s& \#include <linux/leds.h>
& `) k. W/ Q  N' h#include <linux/platform_device.h>
7 D/ `) j! w5 O  \5 f6 b* Q9 C. @; s1 y3 j5 s; J7 x
#include <asm/mach-types.h>( ~% \/ G; t) Z, A
#include <asm/mach/arch.h>
- Q' R9 b8 T  x/ Y# D#include <mach/da8xx.h>
( O: H. v1 j" c#include <mach/mux.h>/ B6 a5 V3 k, v* `2 U( U
. ~- @  G$ d! k3 b- P4 Z( M  I
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
" j" d, ~2 @9 k- j7 l' N#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)/ y* e6 B  m* Q* }0 o( n- g, r
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
! o; R' P! P1 @#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ B1 N. }* A" {/ D
) i" g+ z) a! y# q/ K: g( j# c
/* assign the tl som board LED-GPIOs*/
) K- F, G. Y2 S! o6 S5 Y; a  Astatic const short da850_evm_tl_user_led_pins[] = {
0 D% z3 e/ w% w7 q& R0 t. Y2 J  [        /* These pins are definition at <mach/mux.h> file */
; M/ w( H( V& K# h2 V" p9 L4 X        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 v1 O9 N) z( t( c        -1
2 D5 m, w0 O. m2 N3 \};0 o: z) j  l+ s

& U+ w" @1 t: C% y& E: \4 h: istatic struct gpio_led da850_evm_tl_leds[] = {6 |" W: j* I5 [# X' s9 }( K
        {
. s$ n+ g& H; x. G) I7 O4 J                .active_low = 0,
! Y8 E$ S5 p" r2 v" i; W7 ]                .gpio = DA850_USER_LED0,/ R: ?0 K3 t" ?3 D- e( J4 P
                .name = "user_led0",  K) J, \  Q) L1 V* o2 _
                .default_trigger = "default-on",/ i5 ~* h7 ]6 _2 _
        },
. k) m: i) U- O: }1 T8 T. a        {
. V4 x! h: b( Z( ]; I+ S! E- A                .active_low = 0,- O/ Q9 l9 J3 l
                .gpio = DA850_USER_LED1,: L9 p& X" \) D+ R
                .name = "user_led1",
: r' t5 U) ]7 m                .default_trigger = "default-on",
9 U8 H: f. I: q% k# e        },
* a! M/ y- ?( J" P2 {; L3 z7 s        {% h0 K+ ~- ~3 E( H, d
                .active_low = 0,# n1 s4 Z3 C7 D7 e1 [+ g9 J0 F
                .gpio = DA850_USER_LED2,& j, H, q1 `( ]5 q5 t% c. o* l& K
                .name = "user_led2",
; E8 y! T0 c% H* v9 ~5 M                .default_trigger = "default-on",$ X# P8 x' W1 c. m! r1 b
        },
6 P' T! [( }4 p2 _        {9 \+ F  v4 n) K  u* L
                .active_low = 0,
* M# y! @5 F% g5 |/ a& B% h                .gpio = DA850_USER_LED3,
& o# i, \. @' h9 l2 ^% Y                .name = "user_led3",
, Y3 b% B$ Z& I; P- P! Y5 z& s                .default_trigger = "default-on",
& J' m/ H( A$ N. g1 O        },
6 U1 `* O) _! I};' B: h" `! H5 A4 Y0 X- [4 V
; J' C& _% U. I8 A! ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 M' Z1 d" w" @# Q        .leds = da850_evm_tl_leds,3 l! v2 w2 z6 d8 s
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; ?- f$ z* h, f$ D* W, l, ?};. {4 {% E# r1 X2 P5 [, o5 Z

8 L! T0 h9 n; P; F  J9 vstatic void led_dev_release(struct device *dev)* r8 }: R" w+ U0 ^) c3 ?
{* C; G5 l4 J% Y/ E2 W9 R7 u
};. M7 M+ |+ ~: a$ ?+ q
9 D* V% U1 C) i6 [- j
static struct platform_device da850_evm_tl_leds_device = {  N/ P: V9 ~2 b  A2 E  X% E9 R3 b
        .name                = "leds-gpio",5 w. z1 _" z! g  P
        .id                = 1,
3 b( ^, w. E9 m5 l2 s: O        .dev = {, z5 V: @& _8 q7 |% }7 R
                .platform_data = &da850_evm_tl_leds_pdata,
; t8 {8 S1 Y! `8 g                .release = led_dev_release,
9 V+ i) U+ K6 H        }
) I, B: A6 P; Q, a; m, d% f" x};
) {$ t$ G3 j( I' {
. O- u* w, P, y% ~2 Sstatic int __init led_platform_init(void)" Y# G( g9 p. N3 q$ g: n! X
{" Q2 U2 z2 K* A$ z, Y
        int ret;
- T  W. e$ E" Y8 a! T8 C+ [6 P* d#if 0& K6 }5 ~/ J% G* Y: ~2 F3 u
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ P4 n: I7 o4 `% Q( }/ t        if (ret)( a* N7 ?& P" U* L) ^$ u
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 o% K/ |# c8 M# J9 o                                "%d\n", ret);# r% x$ ?  Z1 b" J
#endif6 I6 j& f) V' ^" A$ l# R
        ret = platform_device_register(&da850_evm_tl_leds_device);1 I. I. y& @2 F- H2 m( p, B
        if (ret)
4 b8 V% U) V+ S: a9 _! G                pr_warning("Could not register som GPIO expander LEDS");
( n1 L# I" ~3 M0 w1 O  T        else4 O4 B1 P  d" h& t6 G3 N
                printk(KERN_INFO "LED register sucessful!\n");
$ h- I3 P8 P- K! C0 x+ ~
9 h2 ?% |( ?, d        return ret;$ N5 [. A' Y. n  @3 ?6 f9 N
}! n! I, Y+ U% I# t' Z

% _  `: _3 z4 estatic void __exit led_platform_exit(void)+ M8 e; o  r( \- J) v8 ?
{
' x: V+ E* H; u9 c8 W, r7 M        platform_device_unregister(&da850_evm_tl_leds_device);1 p" d1 Q: ^  v
3 N' k8 \2 I% C* u0 Y: R. y9 D3 q
        printk(KERN_INFO "LED unregister!\n");
# H% M2 F. [$ L7 N3 }! k- m( H7 y}& D5 L1 o3 P4 K) W% y

, K% ^5 ^0 @! b: B- P+ _module_init(led_platform_init);
% I7 V2 M1 Z' R/ J: C7 T9 U6 |module_exit(led_platform_exit);9 N" K* n8 p! _5 }; L8 V! g

) S1 \: c. n. Q7 ^2 e3 LMODULE_DESCRIPTION("Led platform driver");) _' ?: ]! R1 ^8 j/ d) R
MODULE_AUTHOR("Tronlong");
7 d6 ]' q/ K3 n0 AMODULE_LICENSE("GPL");7 Z5 a, n' m: m
" |( E: B9 ]0 t! _* U
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-12 02:10 , Processed in 0.159692 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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