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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。  [4 c( T& n$ b" e! a& a
#include <linux/init.h>9 W8 y, ^3 m/ P
#include <linux/module.h>5 ~+ \7 B3 z/ q4 w
#include <linux/kernel.h>. Q  \' e7 H! X
#include <linux/types.h>! R9 D* S& S) B) P0 d  W+ I
#include <linux/gpio.h>/ x6 \3 V8 u" r2 s' X. Y; o
#include <linux/leds.h>
; n; |+ c- S% n3 D4 r3 v. ~* `#include <linux/platform_device.h>3 E0 i1 o. E/ g" r7 }. V7 r0 `
$ K3 y- ~7 H$ e- g" S- L
#include <asm/mach-types.h>
3 l& J% l( S6 I3 |#include <asm/mach/arch.h>  V: d, m3 ^4 A; ]
#include <mach/da8xx.h>7 r" a- G5 u# a% a3 ~% w5 u
#include <mach/mux.h># c1 u" Y, C1 f7 \/ w7 x3 m0 L

( a4 y2 U/ k/ k$ |. d$ L#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
# U4 L) T' d" Y6 g  d' B1 K#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)" A+ ?* S6 K+ \* g! V) B2 a
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)& X- |, |4 C' n. f4 o( `
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# N- |& _- v4 Y1 j7 c

1 P" Y" |: A/ _7 n+ g/* assign the tl som board LED-GPIOs*/2 f6 l% G( u; D, _
static const short da850_evm_tl_user_led_pins[] = {
% z3 o+ C. B4 U* P        /* These pins are definition at <mach/mux.h> file *// S, {. g0 g) _5 w" o- W
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% q3 J1 c/ o! N1 l- W
        -15 p# N5 V$ t  v8 Q
};
7 h2 T9 F) n7 R* w: D  u2 C* Z& O" q) `
static struct gpio_led da850_evm_tl_leds[] = {
( v' N) J' z; l, c/ o        {/ w" j( @  ^. O0 H% O2 Y
                .active_low = 0,
) G/ g+ G  d7 n" L5 F( M2 e5 z; S                .gpio = DA850_USER_LED0,7 m. |1 ~& I3 ~1 T! o
                .name = "user_led0",
8 Z1 D" |0 _9 V$ @                .default_trigger = "default-on",( N4 T- p9 |2 G6 l, A
        },
' ]7 G" z. {/ V$ P        {* r* a+ h# s+ E/ b! y
                .active_low = 0,
( l; C$ F3 q! y) F& s- H                .gpio = DA850_USER_LED1,
/ n; y! e- R1 O% V' _4 B8 r                .name = "user_led1",
4 }7 d/ r. _: l; o. g7 Z; V+ S1 k7 x                .default_trigger = "default-on",
3 ~( L5 ^/ f$ X6 g        },
2 u6 S, `3 M; ~- c        {$ ?/ f, l5 Y3 s! R- J# J3 `
                .active_low = 0,
( `9 b! [+ K3 Q7 W( I8 m! |                .gpio = DA850_USER_LED2,9 G4 v3 \* Q/ m* H, M
                .name = "user_led2",5 h2 g6 u8 |4 p; |
                .default_trigger = "default-on",/ z( t9 I: w% Z; ^
        },  N% Y/ q' o9 W# ]- A
        {
! a" A: N4 t; O% `# b                .active_low = 0,; `0 _1 q9 Q' ~( _* ]. @3 w0 M
                .gpio = DA850_USER_LED3,
4 D% I7 ~% d1 \) Z& r                .name = "user_led3",
9 v/ b5 |  Y5 S- w# v0 k) M                .default_trigger = "default-on",
) Z- V8 e, P! l6 q1 ]        },
5 C* {& m' \7 X};0 W& A/ `# w6 k9 j( c( u

9 n1 f* _6 S+ _; y# Y( c. A3 cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' R' \' O7 a/ _- S: H7 F. g
        .leds = da850_evm_tl_leds,7 N6 T. S7 J4 E: Y
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 {/ M* [. M$ W4 |8 {% S% w
};; d4 G* P" l! l
% F' Q! `- S$ P5 f) `
static void led_dev_release(struct device *dev), d1 q8 F& S* S* w  Y
{2 K" ]& H' A' y
};
3 G+ R& j' K4 k  @
+ u7 j% @& H7 |  U- Y- lstatic struct platform_device da850_evm_tl_leds_device = {& N- f+ c/ F/ t
        .name                = "leds-gpio",8 |# D8 Y5 y  a5 n. J' k
        .id                = 1,4 |5 I+ I/ T9 O  F' E
        .dev = {7 ~* O1 [5 l* `5 a6 v+ d# T
                .platform_data = &da850_evm_tl_leds_pdata,/ G' `3 N* g. O! M
                .release = led_dev_release,. K- y& s" c' J8 f$ `/ _% p
        }
. w, c6 \: {$ J4 Y. f};
% D0 d+ g. H+ U
: S. x1 ^/ M. mstatic int __init led_platform_init(void), _5 v- C- g2 d
{8 j2 ?# e# T9 ^* z6 g9 W! ?) I; u
        int ret;$ ?( ^, u( }- i) R6 B: {
#if 04 U% N5 r/ I1 S& R7 z
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ J; N% H, l6 Y, k8 f* ^        if (ret)3 R/ A  q/ q2 @9 h, L; }
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& g2 G% v: w/ s- D2 B
                                "%d\n", ret);
9 D4 }# S; E" h1 l6 H#endif/ R  E3 h' h& A( x1 r2 c& T4 Z5 O
        ret = platform_device_register(&da850_evm_tl_leds_device);
+ y3 h2 h3 A5 _4 N) t( |; B        if (ret)3 z; E1 f5 G. x2 k; }" @+ U
                pr_warning("Could not register som GPIO expander LEDS");
6 z; y* Z) Y- q& x        else  |7 e! h/ \$ `& O  U# O5 _
                printk(KERN_INFO "LED register sucessful!\n");& f4 A/ S' l- K, K3 e/ B; T3 L

6 G% g, [/ `  g5 H6 K6 G        return ret;
" N0 [- [" x* K" S# [# F}- G' e3 m9 [& \7 f3 }. [

. Y) z+ H. S: p8 H) istatic void __exit led_platform_exit(void)
9 e7 Q! F% s: R1 u- x: P( \# y{* V* o7 T: Z1 d* A+ V! }
        platform_device_unregister(&da850_evm_tl_leds_device);
: N* p' W' o) H2 H+ V& \3 W
' G' }, g* q; M* Q        printk(KERN_INFO "LED unregister!\n");5 @0 S5 M7 l( X! ~# D& R# }
}# U9 M+ r4 [, x2 ~( v% c1 {
" Q! ?1 K+ U6 y9 j! F2 m1 v
module_init(led_platform_init);
& M# N1 B- ~& `3 ]module_exit(led_platform_exit);5 E0 X/ l+ L  V# b
* V( L1 D: y0 m7 a6 E
MODULE_DESCRIPTION("Led platform driver");
# g9 `' ~0 a2 j) f) `1 rMODULE_AUTHOR("Tronlong");5 e8 G" t; o# V. q0 n$ W1 q
MODULE_LICENSE("GPL");
( _7 P9 q% E/ ^$ B2 L1 U( G5 Z: s! X9 ~
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-29 01:28 , Processed in 0.049322 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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