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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。" o' I& T3 F+ F7 w
#include <linux/init.h>- P* ~+ r& e  p# r5 H5 f) y# w
#include <linux/module.h>7 C" n; `, U: |6 a3 e7 j
#include <linux/kernel.h>
4 B: S$ G5 B- ?3 j# b#include <linux/types.h>
9 x8 U: G1 @6 n/ b7 R#include <linux/gpio.h>
3 |2 O8 _  m4 U' a, G( S# |#include <linux/leds.h>7 k" ~1 u- D% D; W! m# d* n8 a/ N6 x
#include <linux/platform_device.h>" {( S6 u2 ?" B) @, X% t

- Q0 D. J$ Y( g5 A#include <asm/mach-types.h>, M7 O7 B" w3 {9 A$ e; a4 W
#include <asm/mach/arch.h>
# T8 X% ~3 H  f* p+ c#include <mach/da8xx.h>
) }9 H1 t* c& S#include <mach/mux.h>
  K" \" F$ k. S$ W' B; y% g8 O; L' b5 h/ s3 B) _+ ~1 ?7 q& f
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0). z9 t! w  U, y" i' P4 l/ j6 S
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
! H8 ^! P3 \0 _1 r, `* @5 k) a: J#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
0 x; }6 W, S% K0 ]#define DA850_USER_LED3        GPIO_TO_PIN(0, 2); y. ]1 J0 \2 e9 ]

( ~! }4 Y; F* q4 I3 u/* assign the tl som board LED-GPIOs*/: p% R5 R0 z* m" |
static const short da850_evm_tl_user_led_pins[] = {6 o; t  b; a. T/ O( h% I/ i
        /* These pins are definition at <mach/mux.h> file */. Y) _; _/ q6 f+ k
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 }" r/ C9 r/ `' [        -1
/ r( u. z4 [5 @. h- N};! ?" l( [: z- M4 Z: }
' O+ Z) n4 r& Q: x( f8 V
static struct gpio_led da850_evm_tl_leds[] = {8 W. M# S% e7 c
        {$ [) X8 x$ s" `# g* K4 j4 |
                .active_low = 0,: A( J: n4 S$ E2 c7 x# R
                .gpio = DA850_USER_LED0,
3 s" ?$ D1 N, v1 b7 }8 _* W                .name = "user_led0",
5 X# R2 v9 t% l- B" p                .default_trigger = "default-on",
6 K7 }  ]6 _: l7 V7 ?/ ]        },6 k8 h% F' ?" E0 B7 M
        {
4 H, {( S' D6 Y2 X2 t4 a                .active_low = 0,$ n0 c+ h- V- d( E2 \! j
                .gpio = DA850_USER_LED1,6 m  I* O( e/ n# e% Q% A+ u$ s
                .name = "user_led1",
8 ?) l0 F% e- H                .default_trigger = "default-on",8 B, V5 V3 [$ K% s
        },7 B4 p: _  [5 r, z3 ?" D
        {4 Y- x. M( r# Z8 f# d1 `! H
                .active_low = 0,
2 Y: \  l+ d" z6 [( Y4 N5 a                .gpio = DA850_USER_LED2,* |# V- ~1 [6 S+ I8 B
                .name = "user_led2",
8 m2 a" c( P( g7 N  b( S9 j                .default_trigger = "default-on",
) g4 [4 m/ P8 b# f6 n( N        },
! J* u; c: t2 M# \        {6 @6 R$ N8 N7 `
                .active_low = 0,
$ p8 D! ]  g! U                .gpio = DA850_USER_LED3,, _% e& x3 g( U) d  h  S/ _
                .name = "user_led3",6 x) h: \) H0 M  I  Y
                .default_trigger = "default-on",2 @" n1 z+ K2 ~- ?% ?- R
        },3 {& ]' Q3 O4 H% Y3 @
};
( U4 O' Y% i# V) m' x" G/ b/ `) _) D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* X* H# e% p* C! x8 u/ d* F/ c
        .leds = da850_evm_tl_leds,
; N+ V5 d* u7 f+ b* ~        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# \. R, A* }7 ?, W, P) s8 S2 b* j$ \};' H$ d' \+ u6 z" d& c- z3 j
- J8 ]5 L0 ^. v: y! _( O8 V
static void led_dev_release(struct device *dev)2 U/ V" c" z; W; b4 k1 b
{" v% r# E# w$ W- H' r2 U  @! n
};
6 E9 [7 m* o) q/ O: Q8 h& c/ p& v  L! J" h9 Z: f0 z" m
static struct platform_device da850_evm_tl_leds_device = {
& \( X$ e& [. m9 n- T  N0 d        .name                = "leds-gpio",8 S8 P' B+ M0 y! f/ z
        .id                = 1,  N7 \+ s7 c4 t
        .dev = {' V$ G  ~' g% p# W' S
                .platform_data = &da850_evm_tl_leds_pdata,
3 _# _6 y% ?5 @/ ^                .release = led_dev_release,
# B% z: ?9 b0 f6 l1 D' z        }3 A+ S' T1 [1 G9 `5 `$ p' [
};2 m# v# N& }1 w, B% `% X5 d' O
2 K) U8 W9 O- w) Y5 v3 b1 T
static int __init led_platform_init(void)
$ z: w# Q$ M& d; x; v6 R{) I' E) R0 T) `4 ]" E8 G+ ?
        int ret;
( N( ~$ c  x+ F6 F% ^9 V#if 06 [# N" r3 w( s! @
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ F$ T7 k3 A$ x/ n6 I2 T        if (ret)' _" D* ~6 i" a
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 h9 O7 A" {$ t( Z6 z                                "%d\n", ret);
' L) U8 x$ `% |. R& q#endif5 Y9 {4 [1 Y/ D) c
        ret = platform_device_register(&da850_evm_tl_leds_device);
. K' }3 |. }1 @9 `" K: Q        if (ret)9 m6 j+ ]) b# L: W$ r/ R
                pr_warning("Could not register som GPIO expander LEDS");; ]8 g9 b  _% ^2 G
        else# C% _' i, p6 n: G% e, p& z8 Z1 L
                printk(KERN_INFO "LED register sucessful!\n");
: @) R. v+ m: c) w% Y: S! h1 O/ F  w/ R( r. H, \* {
        return ret;  ?% w& P  C* _7 G; O+ I
}5 L/ \- b2 Y- y, L' M

7 |7 Z. W4 j" j1 T) D; Cstatic void __exit led_platform_exit(void)( e* A- V# Z" `1 w' o* C
{+ U% N) @7 S) b
        platform_device_unregister(&da850_evm_tl_leds_device);2 y+ T2 S% C+ {8 A; d. w9 t/ g
% r/ C* \* d) s
        printk(KERN_INFO "LED unregister!\n");
* z$ y% Q; X3 t}
7 z8 C9 Q! _# J: e2 m
0 _( S# t: v! U! ~6 v+ c! Y- tmodule_init(led_platform_init);
5 j' p! N  {7 c" [' i6 n" `module_exit(led_platform_exit);
; D3 `2 G- H. W3 d+ s) F. J! p3 w/ s; w( J* B( i: F
MODULE_DESCRIPTION("Led platform driver");; c% Q( l" N" I" \
MODULE_AUTHOR("Tronlong");
  ?1 N. `, t6 K9 k. M3 k2 h9 }MODULE_LICENSE("GPL");
0 Y. P3 L( S3 @
; P+ j" n0 |, e6 s
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-3 17:49 , Processed in 0.042483 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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