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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。- \9 I  H& Z% {1 U+ Q
#include <linux/init.h>
/ |* x" F6 E, d1 Y) B#include <linux/module.h>  t: `( j9 {& m$ L* t9 c2 D
#include <linux/kernel.h>) s1 f( x, H3 \6 [8 O8 C
#include <linux/types.h>
& K. a6 u/ B9 r, Q# {  \#include <linux/gpio.h># |9 U0 H: ?" M% I: `; o
#include <linux/leds.h>
* h% H2 }7 t1 Y  H6 {/ H6 s/ y#include <linux/platform_device.h># {% f% [' T. `0 B$ @& h8 _6 o# m

' Z1 j* B& m2 D% A6 f# L#include <asm/mach-types.h>
$ o; }! |" z& k( Q. G$ d#include <asm/mach/arch.h>
, _- n) s' q: |7 ]6 v#include <mach/da8xx.h>5 G. Q. P: {% R
#include <mach/mux.h># ^2 n8 m, n* h

* v4 e8 W& ^( v4 \. o#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)/ L0 q4 u' J6 p$ U( l
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
/ M9 B* A5 ?5 K; _#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
4 R. d$ g. N- T4 E4 j1 I+ F$ B9 b7 m#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)1 p8 d7 e4 a% W; Y  m) b: n5 d- n
. i0 \& X( T# R" t' K6 q
/* assign the tl som board LED-GPIOs*/9 ]$ Q; j* w, Z4 w6 \, k; b
static const short da850_evm_tl_user_led_pins[] = {
+ Y7 q; q/ O0 j) ~. L% n        /* These pins are definition at <mach/mux.h> file */0 Y2 O/ M$ C5 e3 g* i% V8 b- e& g
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 Q5 w- _3 x! f8 F        -18 t7 m6 f& I. G$ o+ Q: M# f1 J8 r0 w
};
; M2 H# E/ c# x* Z( F7 f/ w& \5 R! e
static struct gpio_led da850_evm_tl_leds[] = {  g8 Z0 M  A0 ~' t" H8 Q  u9 W  M  O
        {
# f8 V8 c" X6 A0 H+ a8 z3 C                .active_low = 0,& F9 [' P6 Y) P+ V
                .gpio = DA850_USER_LED0,
9 H4 `+ `( ^- @, G( c                .name = "user_led0",
! P2 h4 W% }5 ?                .default_trigger = "default-on",
0 R# L& i) z! P1 [: L/ @! z; g# w  a        },
1 A( ^% B5 s, S! R        {
. x* l  y  f3 l% N                .active_low = 0,
2 S! t$ _3 Y  d1 g; S                .gpio = DA850_USER_LED1,) x0 i9 Y# Y8 H; p5 a; y7 K6 {% |
                .name = "user_led1",( _* x9 O- {& d# A3 u% [9 x/ e, z
                .default_trigger = "default-on",* w( d' O$ k' F0 y+ ?
        },% V- ?$ _; r( |( b
        {
  |& K+ ~* |) s& a( p5 u/ l                .active_low = 0,& [( B! h/ A+ R
                .gpio = DA850_USER_LED2,
  o$ Y! ]/ s4 j% m3 A                .name = "user_led2",  t- e( E* I& f. D7 U- O( R
                .default_trigger = "default-on",
* h2 p: n1 m& D  w        },! ^7 Y+ R% g# q
        {( Z6 @. s, j: ]$ N# n7 x
                .active_low = 0,3 y# }. W% @" V
                .gpio = DA850_USER_LED3,
0 h1 [% L4 k1 r+ y8 y$ t, Y                .name = "user_led3",
7 Z- m/ s0 v9 T1 r                .default_trigger = "default-on",* H  u. u/ @) |" V: E" j
        },9 t1 z- T( H4 Y' m$ d; m4 z; E
};
* I- F! F6 y5 F3 e# m. v/ `
+ u" {$ V& B( V3 d1 \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 q& \4 s: |2 e$ V3 M/ q
        .leds = da850_evm_tl_leds,
( n% o* a% R6 K4 N. S        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ U$ C% C2 V$ F8 J
};; m1 J- S3 y/ w! D% f. R- y
- u* l/ I/ e2 t4 X
static void led_dev_release(struct device *dev)
! r9 J: m4 W9 [0 l! B+ G{* D1 O+ \4 \# L- Z
};
& w7 p0 [7 }$ o0 s, u9 b. M6 @$ L; N; m: r
static struct platform_device da850_evm_tl_leds_device = {
8 H; [' Y% q+ \; [3 ^) p/ G, L        .name                = "leds-gpio",, P, C# |& Z; ?6 {
        .id                = 1,' r2 Y* t/ `# ~+ f$ c
        .dev = {
: j, Y" B5 Q  ]2 W                .platform_data = &da850_evm_tl_leds_pdata,
3 l; j2 v) O3 B% h( D  w                .release = led_dev_release,
2 ~+ n' i1 g4 r        }; X+ u; y& M$ L" c! u9 S
};
2 n2 v/ [9 ?2 o/ a! T% V' n& c- o( C; K( A4 P3 r$ x3 B) C& b: R, f
static int __init led_platform_init(void)5 c) q! O  u; j+ [
{
" D. `0 ^$ |8 ^# |+ O        int ret;
. e9 r/ }% P$ _  O; |#if 0
3 Y4 U4 C" }1 i        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ j5 \% b$ l" D$ p        if (ret)0 @* \$ ^+ F! V. `9 D' }6 X' @  z, \
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ g( \4 ~, j" }( s' O- v: i; h" t- B                                "%d\n", ret);# V+ [2 W$ l# w5 T2 H6 n4 F% Z
#endif
  l. k' j: C8 F        ret = platform_device_register(&da850_evm_tl_leds_device);8 J2 b3 s# h" Y- b% `4 e
        if (ret)6 n/ i# Q# t1 ~/ O, ]9 E0 N
                pr_warning("Could not register som GPIO expander LEDS");; d& b& ?# z% `, R* m
        else- N6 S8 e- \$ @: Z2 t3 E
                printk(KERN_INFO "LED register sucessful!\n");
9 _  H, ], Z6 T, P' S6 I  e( ~0 ^  e* m% \5 P5 A
        return ret;8 o. i5 g( _& J- C) i+ t
}
# }5 q' Z) [" }1 U% r% r- ~. [0 n& E2 |# C6 i0 T
static void __exit led_platform_exit(void)
# U, ?  y9 S2 _9 C9 D, a{& ~8 a* n; E1 _( w; o9 I! o+ Q8 `
        platform_device_unregister(&da850_evm_tl_leds_device);, b, }2 J1 D9 z7 v+ s) s9 ]
7 \/ W8 |3 {2 \2 J
        printk(KERN_INFO "LED unregister!\n");
* A- ^) C  V+ r: s' N1 ~; z! m! D}: u3 ]. e8 P& l2 L; m. R
4 {( Y9 O4 W3 G, ?% ^+ g
module_init(led_platform_init);( I- w9 }6 H: p
module_exit(led_platform_exit);1 c" n0 m; o+ E0 ?& \$ s8 t
9 G5 u+ y7 L' L4 s3 X
MODULE_DESCRIPTION("Led platform driver");
$ I1 y6 a5 G* q+ F& XMODULE_AUTHOR("Tronlong");
$ {+ ?! b( a1 Z! C$ CMODULE_LICENSE("GPL");
- k( V& p! G) ^0 K. {; h1 ]3 C8 P& Y1 i) ~( v) `
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-28 19:39 , Processed in 0.045542 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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