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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。- h7 i( d+ d" v
#include <linux/init.h>
6 D+ q& s" f. j#include <linux/module.h>2 \$ L8 A& m/ t0 v
#include <linux/kernel.h>+ }- h+ ~8 |/ |; Y: T* J
#include <linux/types.h>
! B! C; u9 C: Y& ]#include <linux/gpio.h>
2 }# D+ l: r" Z#include <linux/leds.h>" V7 B! n: ^; ]8 v( h$ Y
#include <linux/platform_device.h>; `, M( Z: y! @$ n. z
8 W4 O7 P. p% p! ~* w" I- ~3 K
#include <asm/mach-types.h>( l7 S: d+ }) b! d1 \6 z% R
#include <asm/mach/arch.h>
7 e7 N" G3 E* x1 U" N! o0 s/ Q9 O#include <mach/da8xx.h>/ R# o  k* }0 a- \! U0 P. N3 L. J
#include <mach/mux.h>0 v8 {) W$ N6 q8 z2 q

7 B5 Q1 Z! n' e9 a! ], B4 A) y#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
2 g$ p9 O, t- G$ h6 g& E" X/ P#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
' y: o0 `% p$ J6 ?#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
8 z" i& E" N, V+ ?; c$ V" t#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 r7 T2 q7 F3 Z* k

6 [3 O6 v8 e+ t* j5 O/* assign the tl som board LED-GPIOs*/- S6 Z9 B. }$ q5 G- O' Z' t
static const short da850_evm_tl_user_led_pins[] = {$ i8 Q# K9 E4 a" [7 j+ j3 K' V% X; I
        /* These pins are definition at <mach/mux.h> file */
! a: y  H3 G1 h3 K. R        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# v6 g4 E7 I% N0 `5 V
        -1
- g$ q; s, t6 C2 s. e};% u& ]1 [) k2 ^
: b$ m( o* R& N$ n
static struct gpio_led da850_evm_tl_leds[] = {; R: k0 ~# ^7 i! G. O2 k+ B
        {
" R4 P) G" _& `  D0 o                .active_low = 0,/ S; {# H% B6 h# q' j
                .gpio = DA850_USER_LED0,8 I5 [7 Q0 o9 u3 I. }
                .name = "user_led0",
& O( F; g- f8 x0 O# y+ ?                .default_trigger = "default-on",
+ r$ d/ }6 M; W        },) V2 ^( f' i) Q/ x. R9 E2 G
        {! [! W" [$ L3 k" [  o7 |/ _1 {6 ^8 k
                .active_low = 0,* a$ [% T+ r" K5 I
                .gpio = DA850_USER_LED1,
, V, O# ?  ?$ N5 c+ j                .name = "user_led1",
" L8 \4 _2 F* H7 S! B! k' h& w                .default_trigger = "default-on",
. Z( ^7 N6 O: X5 k) k- `        },
2 a5 Y8 i4 t/ m3 @  Y' J! E+ a        {/ f7 \' v  C& U+ D
                .active_low = 0,
4 z+ q, O( l. M2 Z                .gpio = DA850_USER_LED2,! C* o$ f6 e0 j" A  H+ P! X: f/ o
                .name = "user_led2",  T0 s; a6 m1 b/ {4 h
                .default_trigger = "default-on",6 [$ N2 I; g& n, E
        },
2 D6 f4 F8 [4 o6 `        {9 b7 m9 l" J) O0 R: r; P' T
                .active_low = 0,
5 m& v. ]2 Q/ w' [8 b8 S; n% f                .gpio = DA850_USER_LED3,
5 f. Y- F8 Q$ x& G# T  W                .name = "user_led3",
+ ^: Y. f0 W+ x4 {                .default_trigger = "default-on",
  e& B8 E. a( s; N+ b! Q        },
3 F5 P* \9 C: n3 F* y! n};
, q( v. |# Y& b; U$ M3 \1 `. Q
5 x1 V0 J( R' \4 q( zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, N& r) e% u. j- x0 T: X
        .leds = da850_evm_tl_leds,; @& h* X. ?: Z7 T
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" ^4 _5 y& x. e' p/ V% Y: c' Q};; w0 V. u2 C! l

) W) o0 J+ O" o# estatic void led_dev_release(struct device *dev)
6 j, Y, ^2 ^0 d2 w9 I- ~5 Q, ]8 u$ P, y{- |, {$ n: S/ o) M
};
" ^. {5 P- g4 t6 \8 q/ G+ B* d* x' p9 e. h% L& n. l
static struct platform_device da850_evm_tl_leds_device = {
6 K2 z' u# r7 k/ ]/ ~  `" b        .name                = "leds-gpio",
2 ~$ S/ u+ O* J# d        .id                = 1,
0 t- `) f: D) k$ d; C$ E        .dev = {0 d6 `8 ]- A2 V8 Y" Z4 l* t
                .platform_data = &da850_evm_tl_leds_pdata,
3 }5 F8 j& I8 ^                .release = led_dev_release,* v1 b. B4 ]5 F
        }
& Y3 T9 |; m/ Z4 P};$ d* d: E2 R! O& J* l, M9 i
4 r/ C; [# k- P2 m( j6 v: d: [
static int __init led_platform_init(void)+ H& R0 l8 t. ~) g: B
{  c5 A* p8 n1 B8 J" Y+ M
        int ret;
" K8 r. ~" m' [#if 0
6 k2 J- R  i" x( D# _- e        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, D8 E9 w& W1 K! |6 K+ R( m% H        if (ret)! s/ T- B/ ?7 g( D( k
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :") F  e( i( w2 R# s4 d% k
                                "%d\n", ret);
6 \! W2 c  Z) Q; t/ s#endif
! t0 j- Y/ H" ]2 D; N        ret = platform_device_register(&da850_evm_tl_leds_device);) o' ]" b/ ~: Y- ~% f, \6 |
        if (ret)) D  o, x9 b2 ?! x
                pr_warning("Could not register som GPIO expander LEDS");4 `5 [. G# m0 r% Y  E) k. _
        else! A" j, z' i( @+ m. U3 \9 w* H
                printk(KERN_INFO "LED register sucessful!\n");5 B! g- P; j( Y
5 |- Z4 e% w! _+ w6 H
        return ret;( w& o5 ]1 k8 @4 E7 w- X& P
}; q: o' z0 k$ P% M/ ~6 W

7 J5 {7 n2 D9 T4 \  nstatic void __exit led_platform_exit(void)0 f( n5 a$ {4 b  \$ |4 g
{
8 p- r2 W8 b. v2 X+ M  G& b, K        platform_device_unregister(&da850_evm_tl_leds_device);
2 V. t6 m/ W4 f" c, s! S# n$ n8 I1 i% l. x3 _, A
        printk(KERN_INFO "LED unregister!\n");% F7 Y% u/ x' X: L% i9 K
}5 Y/ m& L' P% R# Q+ I1 a2 X5 d1 i% M& U

9 X8 ?: |6 G  {/ e5 Bmodule_init(led_platform_init);
2 A% X- L' I, Omodule_exit(led_platform_exit);
) T% ^0 ?( {5 m( t8 {
/ f5 \) d0 c4 ^MODULE_DESCRIPTION("Led platform driver");' M' W3 h# X% w# w$ z
MODULE_AUTHOR("Tronlong");5 K7 @! @$ h2 b# \
MODULE_LICENSE("GPL");
: i8 ?- ^' y* f% ]& t& K9 D+ G; f( S9 _2 i  n" i
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-31 18:31 , Processed in 0.039319 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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