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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。; W0 ?5 |2 M7 x* N  N4 z
#include <linux/init.h>( x  F& b: G! X* ?/ z/ l& q3 O
#include <linux/module.h>
3 p6 M+ H, G1 ~: n#include <linux/kernel.h>, F+ A3 t5 E$ Z3 _! x0 A6 c3 v
#include <linux/types.h>
! J7 o- B8 b# y  `8 e4 B0 T8 O& v#include <linux/gpio.h>
$ H  V; C0 q, z2 @' s#include <linux/leds.h>
- ~' C' o/ F: v: \. z; L3 D! J#include <linux/platform_device.h>! l$ T' E+ ]$ ]  J, D
! u& s7 j7 @# X2 v
#include <asm/mach-types.h>
( Q6 E% W- F, a7 F6 K9 ~% Y: L#include <asm/mach/arch.h>; [' P9 k7 g# g/ g, P! w
#include <mach/da8xx.h>
! `6 |. S& t# t: X1 w# L#include <mach/mux.h>
2 A  s/ U% `$ P8 v) }- T+ H1 A" f% E2 B) s5 q
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)! ~  l2 g' U& A
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)& J! ~# x( a9 G+ P+ |. M* R
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)6 L! q, w. ^, Y4 C9 T: O+ ~
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)( V( D: j8 A; n1 f

" q' F; E8 u% u& M5 a/* assign the tl som board LED-GPIOs*/; U+ J# l3 \8 `0 ^3 ^3 b( |0 G
static const short da850_evm_tl_user_led_pins[] = {2 N% \5 L: l; B# j
        /* These pins are definition at <mach/mux.h> file */
: n3 q+ Y/ h9 ^3 i, F- @$ J        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) ^6 A! R2 s/ b* d
        -1; M3 _" J8 J! a* W- b
};6 d6 z* k* _; @4 M/ E; e0 ], [

1 z+ S  z$ x1 [( S. M" ]static struct gpio_led da850_evm_tl_leds[] = {
& V- Z' |- e7 T1 I- \        {
! j5 U, t& z6 K. n$ J- }                .active_low = 0,
8 n9 [' j! x2 l( Q4 g( f0 g4 }                .gpio = DA850_USER_LED0,
' r, J' v& b  @                .name = "user_led0",
0 ]& p9 [$ Z4 ?! R                .default_trigger = "default-on",* H# ?" t  v/ d% z
        },
) n( {( Q, h* I+ v        {% Y- B! \3 R0 a' D' C
                .active_low = 0,4 S) Q( x; q! [. D
                .gpio = DA850_USER_LED1,- f+ n$ |& I" w; ?7 H; r$ Z' k
                .name = "user_led1",, S7 v! }! u: Q8 X7 y
                .default_trigger = "default-on",- e% O) u4 z  p. R; v
        },
3 c+ B5 j& I' N7 y% r! s        {
+ d" l: N2 w# {* s! P                .active_low = 0,) B5 I- ]- u8 ]( F9 l
                .gpio = DA850_USER_LED2,
4 r* U1 N) ]# ]$ n                .name = "user_led2",2 B% l) v3 }: X+ r
                .default_trigger = "default-on",
5 v7 t8 ?6 H1 a% }/ A; w1 c        },
3 w9 ~6 W2 t7 S        {
4 D1 F' {9 I* K                .active_low = 0,; {' u+ R3 C* s: Q5 f' k
                .gpio = DA850_USER_LED3,
6 d' a5 r# \! i% N                .name = "user_led3",
  X1 v* D4 f# C* r! ]6 i6 ^: C8 T" w                .default_trigger = "default-on",) T) E7 R- V" @* \% ~
        },) z8 C- D4 y# Q: K
};
& a3 @) z0 h" i( p& p& O, [% O. q! t1 j$ Y6 B7 u2 M8 |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' _. \- ]: @& M0 ~# `0 t
        .leds = da850_evm_tl_leds,
! J' i% y+ g+ n. g. w$ }        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 W; A% B3 L3 X5 s- k3 F" o
};% C* _1 V) A) `! b/ O6 S
: J2 h1 W- L- ^& \6 B$ N9 m1 c
static void led_dev_release(struct device *dev)
( [; n9 D9 w7 l4 O  s8 t{
5 [6 D! g: g2 `9 h3 O; |};8 o6 p: O$ k8 W4 t
9 h# m3 ]9 O! p: U3 W. [0 N
static struct platform_device da850_evm_tl_leds_device = {2 Z5 @0 C; z1 n
        .name                = "leds-gpio",0 K) L5 s, P, e  s* V6 n
        .id                = 1,3 R% s$ ^) _5 [- {, K3 u5 e4 ?: a
        .dev = {
2 ^+ o0 {* R9 m9 n                .platform_data = &da850_evm_tl_leds_pdata,
8 |$ K9 s( U) D3 P" q                .release = led_dev_release,
) c- @7 T0 W6 o  s6 o        }
" E1 n5 f( N8 ~* H+ V- [};9 ?( x! w& Y& D  b! \/ X
- v+ k0 t6 o: Q9 T0 i, b! p* l
static int __init led_platform_init(void)
- G0 a3 U( P/ Y/ _3 d# `{  \% L6 l0 B! a
        int ret;
) Z8 ]5 \) m2 F6 s1 {2 u#if 0, b, V+ Z7 l7 l  n
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ F, b' A. h8 o! q# K) Z/ J) g        if (ret)
# Q) o2 E* l) l4 u3 }! i4 p                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" |( J* D. @$ H$ |                                "%d\n", ret);
& P+ }5 G% L4 |1 A#endif
" P: N6 q' `/ J. {8 G        ret = platform_device_register(&da850_evm_tl_leds_device);5 R, |+ i4 P+ C3 x
        if (ret)" V+ ?9 D* c( T+ `( w
                pr_warning("Could not register som GPIO expander LEDS");
0 @3 k- t# F) w& A! n7 u        else
1 l' g5 `+ g: ~5 o  Y                printk(KERN_INFO "LED register sucessful!\n");
, F8 V/ X3 D2 k- z# P; C' y' O1 s- q1 Q1 G6 \0 w6 f. u4 k" i8 o# c
        return ret;& D1 G7 Y$ N8 d4 L/ }
}; Z- d. Q7 }+ ~6 J  p

6 L- [8 W+ o4 e4 Sstatic void __exit led_platform_exit(void)
1 l% d: ^! m4 x) a" ~1 |$ J+ C{
1 k6 a" }+ F* p' T8 [9 |        platform_device_unregister(&da850_evm_tl_leds_device);0 C. l$ q- [& a2 F
; q& N) H; {! ?' f
        printk(KERN_INFO "LED unregister!\n");
  `: c5 S' j& O0 K# P, n0 v}
: ?" \3 l9 J; u  n6 A- k
4 Y; M' V: b$ {9 M/ v4 H0 jmodule_init(led_platform_init);
8 {: e4 [% y0 @& f* ^# ?7 _( Q; _module_exit(led_platform_exit);
0 T4 L; j6 H8 ~
& r- l; K" D8 y/ y8 t" P7 Y8 B4 VMODULE_DESCRIPTION("Led platform driver");
  n- e/ n& F% I  zMODULE_AUTHOR("Tronlong");
1 J' n- ^1 U0 c* |- UMODULE_LICENSE("GPL");
( P" Z1 I/ f: [) o! [5 y' I; D2 Z. u. k& P
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-23 19:49 , Processed in 0.061700 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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