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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
# L5 R1 p! l0 Q#include <linux/init.h>
4 V. i# W, R: f. d7 L" r#include <linux/module.h>% E7 @2 O$ l# G) R# C1 C/ v
#include <linux/kernel.h>
5 @* J& p. Y7 v% Z0 u8 G1 E#include <linux/types.h>
# |& t- N2 T8 k+ h#include <linux/gpio.h>
. M9 R, K' z. ^* f/ ~* C9 w+ n: n#include <linux/leds.h>7 Y; n( G. ~% i- F! k3 r
#include <linux/platform_device.h>: W1 x! z5 ^( g4 y( d7 o5 B& R; D
. f" p+ O, I; `, h7 n" E7 j
#include <asm/mach-types.h>( C- k% b/ ~3 d3 o
#include <asm/mach/arch.h>
9 e8 J) b, c% _$ |1 G: @  J#include <mach/da8xx.h>& H( t7 B6 ]! e
#include <mach/mux.h>
* W- ~/ `- ^/ l) L# S7 @3 O+ k4 J8 O' T0 q$ n( T1 k- k
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
3 d3 w1 s0 W! M# N3 v4 _#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
! W3 ]7 C$ t- c2 M0 n#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
7 Y$ E2 f7 o$ x- d$ O; f#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# o- S! f0 b8 C: b3 F0 \

) t" t. q/ C4 F. Z5 L" a9 o/* assign the tl som board LED-GPIOs*/
5 @, R; b. H0 x. F, dstatic const short da850_evm_tl_user_led_pins[] = {& F) s" K7 ]3 o$ \3 i! L; g/ w/ i& U
        /* These pins are definition at <mach/mux.h> file */
% _. R$ s3 o' D        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 Y% _* j, j+ r% F, j, l, e        -1
+ F! q  ^2 Q7 E7 O' @" t};
1 X- r  J9 }& `  @9 d, C
/ N! K" a) A# |static struct gpio_led da850_evm_tl_leds[] = {
, [- a* v2 G$ d7 ~& E7 y        {
1 |+ \+ A* _7 L( }* X1 K                .active_low = 0,
& E" Y$ r% {9 L; i) Z                .gpio = DA850_USER_LED0,
0 T4 e* D6 W; j3 w& P$ ?                .name = "user_led0",
% _; V( R) D- c) f7 K3 k                .default_trigger = "default-on",
# h/ i- Q# W& X) i1 s; I        },
; M) E- G# \! A        {
, F+ ]- d) M- n# j' d1 P4 ]: d- I& s) P                .active_low = 0,8 C+ ?' U' Q0 L4 i0 l
                .gpio = DA850_USER_LED1,- y# J6 M% e  O) i
                .name = "user_led1",0 I$ l& m% C! L6 \( @
                .default_trigger = "default-on",
- c5 i- G0 H  c( M0 }- H# D        },
- ^6 x) ?) C% u# G: P4 u        {6 e. P; {/ w2 P0 J! a* R8 @
                .active_low = 0,
1 L1 `/ R0 }3 k: N1 W, c0 x                .gpio = DA850_USER_LED2,
) n/ h: Z' ~( N7 p+ `/ a' c3 Z  ?4 ~                .name = "user_led2",4 ^, V' Z6 N+ O$ G( Q7 |2 r
                .default_trigger = "default-on",
! O. L# E9 n0 Q7 S        },4 u, v: z1 r0 g8 p) o; V* U! b
        {" ~7 V' b" X. ?9 ^5 S
                .active_low = 0,
' @' \3 ~' U. Q1 W  ]$ r7 P. V  ^+ m                .gpio = DA850_USER_LED3,
3 w  X$ {, K! W( R                .name = "user_led3",; Q6 o- c: x& U0 V1 b8 b1 b
                .default_trigger = "default-on",
7 |: A. v* V( `0 _' E2 @! j        },6 X" C4 u) B- G0 k+ |
};
: j8 t. n+ k# a+ k) ?( x. N: _$ X8 |, r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ r# h$ B0 U, L5 e2 s8 W
        .leds = da850_evm_tl_leds,5 y  e& M8 @, Z# H1 S
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, j, l, z9 a! }+ d; _$ m9 U8 Z6 ^};
) J0 G8 \% q  M2 ^* F& u1 h3 J" G6 C0 q8 H; D2 `
static void led_dev_release(struct device *dev)
- g  ~# M/ N! [2 Q( ]9 P4 P( }7 r{
% X! M  ]/ I5 b! c& M; h};8 i; C  Y# ^1 K. u# ^- F
- x' r3 J5 g% v7 P
static struct platform_device da850_evm_tl_leds_device = {
) [6 d- i5 _; M        .name                = "leds-gpio",6 b" z% l  ]* ?; O: |
        .id                = 1,# B& k' {* G5 }
        .dev = {
8 B) Z+ C4 _7 F                .platform_data = &da850_evm_tl_leds_pdata,
! w4 T8 {: E- m: j$ {1 T1 V+ Z                .release = led_dev_release,
7 d+ T0 |0 e2 E6 ^4 O        }( F; |* F2 j( |: ?  U7 n
};
' b# {4 W0 i% s1 @! h& F$ c7 t5 |
static int __init led_platform_init(void). F: v& J; Q4 V* `; ^2 r
{0 e+ v% P, V: z5 p; y$ }: |* x
        int ret;% O; L- w. Q: O* p
#if 0( l' u+ N! H' W/ D( I/ R: ?
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% \! Q# G% d; l8 I
        if (ret)
6 x$ X% l0 m3 A7 j# a3 V' Q0 D! ^                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 r. L0 Y! r/ {* C                                "%d\n", ret);4 D" |1 X) g# {% b* {
#endif
9 `" d% o; J1 L) W6 r* H+ Z& Y& C        ret = platform_device_register(&da850_evm_tl_leds_device);5 @% G$ L* ^' q6 u
        if (ret)- Q  n( O1 Z8 a6 m9 f. ~  b" R
                pr_warning("Could not register som GPIO expander LEDS");
, `9 }* `  c! Y5 F        else
7 m: e" ]. }1 r. |% F1 p                printk(KERN_INFO "LED register sucessful!\n");% r. I' Z! P; d% u& n

/ |- E+ G- C% @& _/ j4 U        return ret;
! F, R/ v/ s  q% O- ^}
" p# l4 D8 p( W" o7 |  i1 l- p0 N* X' Y5 }
static void __exit led_platform_exit(void)
8 {9 N, o2 ]: M* d7 s* E9 ~8 L3 P{
$ t5 S5 u9 A$ l! J* t        platform_device_unregister(&da850_evm_tl_leds_device);. }6 A2 F8 b; s: M
- k4 x/ h2 |1 o; a0 h& p% ?) q
        printk(KERN_INFO "LED unregister!\n");$ _# p3 G& g& e) h
}. O2 r; D3 a: g' Q! ]/ A0 q
8 N; |: _, A8 G, f
module_init(led_platform_init);1 |" {1 _( S; j. F
module_exit(led_platform_exit);
2 O9 `* p, B& S+ ~; Z7 ?6 N8 T4 @8 ^) r
MODULE_DESCRIPTION("Led platform driver");
) M% z4 X1 u+ u3 E' _MODULE_AUTHOR("Tronlong");
$ R% n( y  y% E+ l' r1 D+ AMODULE_LICENSE("GPL");
! A- Z* r. J9 N4 F) ^
) x2 Z2 S5 O7 t) Y$ D/ z) B
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-1 09:48 , Processed in 0.040535 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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