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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
0 a: ?, t' ?+ d9 J, }6 x, x7 c#include <linux/init.h>
9 S* H$ S6 F* Z* G- Q#include <linux/module.h>! ]& z7 j1 p. X, |
#include <linux/kernel.h>% F; e: o& ]% C: ]. K7 n
#include <linux/types.h>$ X& y) ]. J! a! Q. }6 W8 O
#include <linux/gpio.h>8 ~9 f- ]$ i0 d; V2 V
#include <linux/leds.h>6 |( V) y, z2 d4 ?& U! Q7 b" ?. @
#include <linux/platform_device.h># j4 H7 ]0 V" @1 p% {& w

$ s" Q$ o( N5 ]" n1 j# u#include <asm/mach-types.h>
$ _4 t% ^7 R- X3 {  t#include <asm/mach/arch.h>
$ {8 N* y& S, I' L6 _% N( Y#include <mach/da8xx.h>1 C+ T$ S3 @3 Q0 [6 B5 L$ t
#include <mach/mux.h>. J) l0 _" n6 i# L$ H7 p) L" V1 k

; h( V7 X" i# U' x0 H5 x1 U: i#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)8 b1 n9 j7 R9 X9 E! T1 c
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5), k8 L: Y" Z6 g# e5 @  I+ F* V
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)9 v) d& s. f  z$ d3 J! Q
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ E5 U0 c* I$ h/ U
4 I3 r, g( B' x# s, H7 H! z  C
/* assign the tl som board LED-GPIOs*/5 C2 o/ [5 T% L/ ]* t/ q
static const short da850_evm_tl_user_led_pins[] = {! X$ k! o' |! F; h# I- c
        /* These pins are definition at <mach/mux.h> file */, f6 _' ]/ q! U4 R
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 n4 d" @7 t4 c6 x
        -1
8 `7 ?) c' Y' y& l2 @% I};
6 {) j: K. X" j9 d" n+ N  D* a; f6 L. h3 b8 I1 ~
static struct gpio_led da850_evm_tl_leds[] = {; y  `: z) }" D+ U0 ~" L# J
        {
* x3 A' b" X2 f9 X/ y2 a                .active_low = 0,* M5 J5 H8 a* ?6 i  w5 N! B3 Q
                .gpio = DA850_USER_LED0,
. c9 T2 P$ w4 c, j7 n; V- o4 t                .name = "user_led0",
% x' ?$ W+ {. P4 I1 K3 x1 m  s/ ?                .default_trigger = "default-on",  x% Z7 w2 k8 W
        },
1 G4 k( `, M4 G0 B1 V; e+ n        {
( T5 O- p) _5 \: p& y! d, n: r+ O                .active_low = 0,
" ~5 P9 }! E, V" X                .gpio = DA850_USER_LED1,
  B, p6 g0 z0 q6 O                .name = "user_led1",
% N1 Y0 Y0 Q- r& E& u                .default_trigger = "default-on",
% x; R' I# d3 M4 i, ^: J        },
6 \' M9 m4 Q& Z( B        {
3 u$ i( G* O, s( j; v                .active_low = 0,
) J% O2 q6 x0 g' e$ S7 ~                .gpio = DA850_USER_LED2,
! M; l0 k1 v5 s* @% c                .name = "user_led2",8 F4 b+ q; t: O8 y' d$ n" W
                .default_trigger = "default-on",
  {! }# V* M- h5 I        },
9 c. }9 k' `1 {5 z' {        {- @# B! o" c4 @5 X' m0 W( I
                .active_low = 0,+ o; g. ?/ [5 M" s
                .gpio = DA850_USER_LED3,
& a% C4 W! t7 `( _: p                .name = "user_led3",7 r7 ^$ T; n- u2 M
                .default_trigger = "default-on",5 U) n6 o0 ~+ l7 o$ b. K
        },
4 b' v* q( P( q3 t8 ?  r$ o};
2 H2 _  K6 C# Y' h+ _6 `& @; @1 W7 U$ V$ B+ }6 y. V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' b* |% K# Z2 c. ?6 K# m1 q
        .leds = da850_evm_tl_leds,. B: Y/ o% s9 L/ q
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 H1 D$ p) B& L3 T2 H  H};
% h$ S' |$ l  e. x  H: L* n! W6 @5 Y' V  Y
static void led_dev_release(struct device *dev)  Z7 E- p2 K5 Z
{" d5 m! f5 m2 Y) Z/ l( G
};- l& m% o0 f  r( K& Y
7 y% A3 y' L# I6 e2 c% r* @2 ?
static struct platform_device da850_evm_tl_leds_device = {1 c% a, X6 l( E- T
        .name                = "leds-gpio",
0 h) @% U/ u6 J# |, G5 E1 p/ L        .id                = 1,1 _" d9 g. Z0 t: E; T7 A
        .dev = {
: E. n4 l$ {) R; i2 R4 U" P2 G1 h                .platform_data = &da850_evm_tl_leds_pdata,: _( y* D( n8 W3 I; J2 ?
                .release = led_dev_release,% t. _% p& N% N/ n* n
        }
# X# }/ }. q# \/ x% g};- O+ U( w0 g5 B  Z% F, Z6 I

3 Y) G% Y1 E1 H$ y* n# b. cstatic int __init led_platform_init(void)
' y- ~- b% h# M$ _" r) m{8 V, B! Y9 J/ f0 C( l) N; S7 Z6 q
        int ret;
3 R+ d; }  |! p/ i2 H, `% T7 f5 j#if 0
2 }4 T+ S* a- W* v, n  t- m$ h        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* O& G9 m! E3 q0 d6 f
        if (ret): H! L% q5 C8 o$ W
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- E- h) u9 Z* c0 T6 E# K
                                "%d\n", ret);9 a8 T  I- d1 J" N) p5 }
#endif2 V, f4 Y7 @- M$ w; G; W+ f
        ret = platform_device_register(&da850_evm_tl_leds_device);' W5 @3 s" c$ V0 d+ W
        if (ret)3 D& V- b! h+ j- q3 U7 o  i  w
                pr_warning("Could not register som GPIO expander LEDS");% |! t; n  _/ M& }! O
        else
6 S1 E' |9 t; g- F( Q' w4 t                printk(KERN_INFO "LED register sucessful!\n");
& r# H& C+ {: f: N+ O" U" C0 K9 |2 b5 n# m! K' P
        return ret;
! B+ u# A4 w7 O- t}- ]& n, g9 w$ Q( \2 L/ I( u

  w* i* z5 T- |$ v" Q/ Bstatic void __exit led_platform_exit(void)
4 \' r. M1 m1 l! r4 O4 z{6 N0 O: z) m5 j8 b, n2 x
        platform_device_unregister(&da850_evm_tl_leds_device);- @6 x2 f; R) ?$ ~

2 x3 e! o; \- H3 {7 a        printk(KERN_INFO "LED unregister!\n");- @0 `4 @7 G+ d
}# U( F( @4 k; F# i0 {0 }' Y! U* c
: h- X' O; o) e7 }
module_init(led_platform_init);+ I, ^6 L7 J- g) o! h
module_exit(led_platform_exit);
9 ]0 D. P3 g& h; f4 @* [5 j3 }9 T% S8 T/ R' B. u* L) x
MODULE_DESCRIPTION("Led platform driver");
  A6 G4 E) c5 j! vMODULE_AUTHOR("Tronlong");2 t9 O+ U, }. }; G- |$ R
MODULE_LICENSE("GPL");
) D8 W& _+ b+ H7 W' ?1 _3 f3 v+ f  ~: V
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-30 05:12 , Processed in 0.045593 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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