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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ y" c8 m5 |% v0 Q' ]6 e4 b#include <linux/init.h>
, T- ^7 i: y# b) i2 o9 V0 x- ]& J#include <linux/module.h>
+ ~, s6 n( T& e6 r" S) o, ^3 ?#include <linux/kernel.h>
% U$ Y$ w* R+ c, F8 _#include <linux/types.h>5 x6 t8 J- ^+ Z0 ], y, h
#include <linux/gpio.h>
( W0 \/ ?$ _% q- F! a- T#include <linux/leds.h>( T. X) K9 E0 n
#include <linux/platform_device.h>- ~$ x& A2 Q* V

" t8 A- ]* e$ G9 q#include <asm/mach-types.h>
+ L9 X9 e# p; E* V#include <asm/mach/arch.h>
7 ^' t  t8 l* [5 C8 m" W#include <mach/da8xx.h>+ u$ F. R2 h% o2 h0 t, f
#include <mach/mux.h>
: r0 r, p5 t5 E4 s* v& a6 Q
2 S/ u! G1 f, ?#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)" L+ p) F& V, Q% {) ?+ R
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
  W) k; \3 Z( o. t4 V& A#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
- V* j8 b% }; d9 w$ h% C6 w#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
9 X# I6 E, U0 R: O- c5 p
3 H' m& n  Z7 }% |6 Y* n5 Q/* assign the tl som board LED-GPIOs*/
) F) ~5 k9 t- t6 U: W/ \9 rstatic const short da850_evm_tl_user_led_pins[] = {# B0 y/ x3 c! J2 z9 e& f
        /* These pins are definition at <mach/mux.h> file */
9 ?; |/ I, n9 R; {  W! T        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: h. w8 c! A$ I        -1
9 d7 x& i1 f, X; L};, O8 m1 d5 s2 Y9 N2 b, u

5 S" x7 v7 `' N* Dstatic struct gpio_led da850_evm_tl_leds[] = {/ |: f2 e  e% u# P1 z% w( |( z0 b
        {" k4 v' c: F6 ?6 b
                .active_low = 0,
+ e9 E5 Z- O3 P6 W( I: a* @( z                .gpio = DA850_USER_LED0,
8 J: A4 X# N2 ~% h" _' \* \                .name = "user_led0",
8 F% V8 ^) N) \0 J3 C/ Z0 c                .default_trigger = "default-on",7 f+ e$ M- X* O) E$ U2 l; _
        },3 @0 R# M* G: N2 r! P) d  C
        {
/ [" I+ x- F" D; c/ H                .active_low = 0,+ v' p4 C0 J7 a( y" {: F
                .gpio = DA850_USER_LED1,& k- w2 ]! @0 v$ I  f5 ?3 Q
                .name = "user_led1",
: J: ^' A% h9 \% u3 t5 m* G                .default_trigger = "default-on",/ W$ h" \# I2 }
        },  I& k5 m2 i7 U6 G
        {
8 X) R" `! \2 V                .active_low = 0,
) W4 A  `5 @, o( U$ v+ Z* P                .gpio = DA850_USER_LED2,
( h& e! Z" [4 N- h3 h, A* Y                .name = "user_led2",: J& j9 H3 _& _' ?- p% e" X
                .default_trigger = "default-on",
0 P$ j7 y3 i" ]7 U0 I! }        },
! u1 |/ N) t, F( j3 c        {
+ a) t" g- v0 P+ _  X, N                .active_low = 0,
- w( ^* d9 a+ r* Z                .gpio = DA850_USER_LED3,' }# B; v% |* F( S6 p
                .name = "user_led3",& k  [' V( h7 y$ G# B4 K
                .default_trigger = "default-on",
7 b* z8 n2 b9 K5 H3 j. l        },
% W; X* ~1 m9 _& p8 i2 E};
7 v3 O0 g* g+ T  t2 e6 Q- c
5 a& O. G% m% a3 p1 Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 j6 q" m  h! ]* a        .leds = da850_evm_tl_leds,
6 c" i: M1 D! e1 g        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; `! C. \* V' u, E9 I9 c$ @};: r" g1 i/ s$ N9 ?: m" Q* C, S
& k& |4 t2 K: W5 |. p3 O1 `0 a7 W
static void led_dev_release(struct device *dev)
, c* r% i! g3 {. x& G% Z& V% m{
7 V7 e/ E$ r. q) _9 i, h" l" d};% B& g- s( c9 p

& y; M" K  X2 q; z- ystatic struct platform_device da850_evm_tl_leds_device = {
0 c" i# |6 x1 e2 C$ w, U4 m1 ^        .name                = "leds-gpio",( y2 a1 g+ {7 B4 z
        .id                = 1,
2 i% @, r6 y7 _# t. e- B* ~& S        .dev = {2 I" F. @" J) G
                .platform_data = &da850_evm_tl_leds_pdata,7 u/ \, Q& F" X" G$ j
                .release = led_dev_release,
9 D4 a' o8 Z+ k- [1 ?2 U        }& I( I7 A/ X6 ~: S* G2 o
};
. X0 v: H& B( H$ l  g. y) m. N9 y* o* e4 A. a1 U8 n
static int __init led_platform_init(void)
$ @5 u- E2 ~+ s) i3 d{
/ [% I' d9 P0 ?0 u- P: T( x; V        int ret;
0 z+ `; t, l+ b! _; u% j2 Y#if 0
5 A! I! l% R2 n        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* j2 c4 P9 }9 o# ?        if (ret)
: z6 ?8 Y+ W( `3 W                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% A) N, j- S2 |0 M. @                                "%d\n", ret);
4 F# Y' v( f, s0 p% A! I#endif: B1 [0 R' p- S: X9 |, V; [6 a
        ret = platform_device_register(&da850_evm_tl_leds_device);, w5 W4 a4 v4 h9 s$ u
        if (ret)) s8 t2 E3 ~8 a$ h  S
                pr_warning("Could not register som GPIO expander LEDS");
2 E8 u3 L6 g& _3 W        else0 p* H* U3 c% V9 R% b
                printk(KERN_INFO "LED register sucessful!\n");
/ ^) n" e+ |* k6 C: S" ^% I1 h" U
) S1 }7 x. L' j- O9 h2 @! z        return ret;
( T: D6 ^- C* A: Q: r0 [}
: ]  k5 b: r6 L& Y
- L% z1 K+ j- p$ S3 Istatic void __exit led_platform_exit(void)1 u$ j3 p' W) z8 g3 m
{) @( c8 }- c8 m5 }0 [( a
        platform_device_unregister(&da850_evm_tl_leds_device);
- l- S( U, H# l. y* ]3 U
# y4 D3 c( X6 Z% b/ Q        printk(KERN_INFO "LED unregister!\n");- g8 I' h0 W4 ~3 {: p: K% d4 }
}2 G: n7 l' L0 \' F7 [' R2 r; a

" u8 l5 w. x0 ?/ h8 [0 o6 Rmodule_init(led_platform_init);
- q8 }" F7 Q$ t, kmodule_exit(led_platform_exit);- s- P- L: ]& P, w) U/ p
$ e- O' w* g- C# Y1 J* A
MODULE_DESCRIPTION("Led platform driver");
8 m- Q! e2 V$ J6 c+ v  i/ M2 Y3 FMODULE_AUTHOR("Tronlong");6 G( B* @# t: f7 u0 X" r( N
MODULE_LICENSE("GPL");1 _5 J; U- \$ C" `

* p0 |) g5 u* x& u' ^' c
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-7 03:08 , Processed in 0.036724 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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