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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( J1 x' H* S, V. {8 m3 j! `) E
#include <linux/init.h>+ Q+ e- O; V- u7 ^
#include <linux/module.h>
- r/ @9 p, ?! F#include <linux/kernel.h>2 P- Z5 c4 J" D: N3 o
#include <linux/types.h>
6 l* x2 y, e+ Z! V6 ]0 ^) j#include <linux/gpio.h>
! v2 i: g7 d6 H' r+ z7 D#include <linux/leds.h>: s3 M3 U# m! q' b
#include <linux/platform_device.h>
- Y- m0 y7 N5 J" ^/ T# }
* k' k6 l( S3 ]$ c& {" A#include <asm/mach-types.h>
' v5 z9 c4 h4 R#include <asm/mach/arch.h>
" T1 h- E) r' d, X#include <mach/da8xx.h>
+ W# v$ d6 t  L9 [3 q; U#include <mach/mux.h>
* _% c( G# t/ ]( c  l# ~* i+ x+ i3 R. k. Y7 z6 O2 ]8 n! {2 ^
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
& S( `8 V( V3 s! u* i* X#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)$ S/ j5 ?- D" Q8 X, C' @% z
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)9 L) ^' z" N8 O$ \& b
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
: k( h3 ?6 i# P5 M# p) x( }! O! G. \
/* assign the tl som board LED-GPIOs*/& m: L- e3 T3 Q; W" G1 T5 n5 Y
static const short da850_evm_tl_user_led_pins[] = {4 W1 @1 P1 f" ?8 k( c; }/ b. B
        /* These pins are definition at <mach/mux.h> file */
$ s* y- ?$ F8 U- W, y: b0 R        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; V7 m1 ^3 |) c+ e        -1
# J: G; H7 p% G- F% s};
: a+ l) j0 B- x$ O1 X6 I6 Y' ~
' ~& j" S7 t/ N1 l( \5 D$ istatic struct gpio_led da850_evm_tl_leds[] = {$ `' ]/ m- m# z0 n, d2 D: F1 z7 q" J
        {  a) M/ J3 C* o# j
                .active_low = 0,
6 z7 [' M) _$ E* f1 t5 F$ f, Y                .gpio = DA850_USER_LED0,
5 Z' k/ c9 {8 v  ^' p. ]                .name = "user_led0",
( n  b- [2 T9 V) l# \. Z/ H                .default_trigger = "default-on",6 z1 Y2 {! u1 X( v: I0 ]
        },
# d5 P. g; x$ ~8 M9 ~        {; J1 U: R5 N! e) A( S
                .active_low = 0,$ V8 u0 p5 v& n" W
                .gpio = DA850_USER_LED1,+ o' H7 l/ I2 \5 _$ O6 Z' T
                .name = "user_led1",
! i1 Z6 x0 t* Q5 B                .default_trigger = "default-on",
7 V& ?4 _9 s" e1 j3 m: K        },
1 B! ~  ?/ Z/ D7 }4 d        {# ^2 M8 @2 w6 r2 [- q# U% `
                .active_low = 0,: m6 V; o; T1 X) X/ [; S
                .gpio = DA850_USER_LED2,- S. u& H3 W% h2 M
                .name = "user_led2",( @5 g/ J+ a7 x9 R5 w& U: r
                .default_trigger = "default-on",! D( Z; e* L% Y) m8 q# l* |
        },9 T; n( x. \9 G2 Q) V; b& d
        {" K! ]8 Y/ t) }  P
                .active_low = 0,; x/ o2 y. l  _' x$ b, ~
                .gpio = DA850_USER_LED3,
% p* F8 k& L; c2 P9 M& t5 n                .name = "user_led3",
" G# D4 |6 Z7 q" b                .default_trigger = "default-on",1 _8 }& R% D/ w. A+ i2 h7 W
        },8 P) k; Z$ {+ r* p/ r" j% u# _
};- T0 ]5 m% \3 y; [5 O7 `

' g& B+ E8 f* o" h0 d( j: V7 Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- G) s8 J+ r, o+ Q# l
        .leds = da850_evm_tl_leds,
! N. B. q6 K* U3 g. L7 v  ]+ ]8 B        .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," A7 N4 M" E& f( q' ]1 Z
};
+ K9 t% v/ N0 m/ w) ~+ V  j& w
% S; ?* g! R/ o, Pstatic void led_dev_release(struct device *dev)+ P' X: b/ A5 Q' g5 e/ T& ~# J
{
# }7 O2 A+ A0 O5 I};; N1 u' k0 }$ W% I9 R* z+ _

8 n! N! f1 j. Z8 t8 k6 |static struct platform_device da850_evm_tl_leds_device = {
4 L5 U$ N4 ]0 [/ P- ]5 U        .name                = "leds-gpio",
8 D! q6 p" n2 W. ?5 R        .id                = 1,5 w2 W2 M5 C/ `  ?2 u
        .dev = {
6 F3 Y8 o) G' f2 Q" W& I- t                .platform_data = &da850_evm_tl_leds_pdata,6 \" p6 r) K$ m6 T
                .release = led_dev_release," R8 C, @" g& S  F9 l' f5 z- d8 A
        }$ ?0 q9 O. x& Y; Y1 \3 D1 |
};4 D- z4 e6 \/ d! C  w: q' a2 a

: i9 y) F/ g9 R% nstatic int __init led_platform_init(void)
& u! `* D" h( ~0 C2 o1 ?+ P- @{$ O/ i: J3 j. n  F9 `  v
        int ret;
8 v2 X0 r: r) d5 a" E! Y+ p+ f9 k#if 0" |6 Y2 M. H7 V$ @  f4 S
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* a" c' Z  c/ e: I8 {; V
        if (ret)
! @- i4 o7 n0 f. @) Z                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 {* {1 L- {; s- m  _! s! N
                                "%d\n", ret);
. ?  b/ w7 w8 p#endif3 ?: l" W9 b2 |8 H5 G, E, _
        ret = platform_device_register(&da850_evm_tl_leds_device);
$ t! w/ _2 ~1 Z        if (ret)
5 N+ ~. y7 a9 X9 m* q' ^3 ?                pr_warning("Could not register som GPIO expander LEDS");
% c; `2 A$ x0 _5 a        else. \9 ~$ O& @7 E1 L7 K1 U
                printk(KERN_INFO "LED register sucessful!\n");
; j5 x, w1 d: ~% ?# z6 q8 a: ^/ @) M5 E6 c& {
        return ret;7 N& L0 z" S3 F& Z- ?- ~5 T+ G
}
* p# }3 r5 _8 \. m  [9 ]( b6 q* g5 O( g6 [; h" Q9 u
static void __exit led_platform_exit(void)
' H  ~& X% {6 \- R) A{+ H: v: g, {" B1 b% u( k% U7 J
        platform_device_unregister(&da850_evm_tl_leds_device);
& t8 ]5 a& I$ s& a. k
8 `: I) e: {6 q4 r; p5 [, g        printk(KERN_INFO "LED unregister!\n");
2 ~$ ?; B# F2 h6 m+ I}
/ t# Q! V4 p& X( N0 U+ c$ i* {/ h% ^' A/ J7 n. [0 b- r$ o
module_init(led_platform_init);  j3 P/ B7 J5 ^) _, C  m
module_exit(led_platform_exit);/ `" \3 s6 w; S' _  ~

$ v7 H. ^$ V/ h0 y6 m: Z8 [# CMODULE_DESCRIPTION("Led platform driver");3 K$ H  n- e$ \3 y* n
MODULE_AUTHOR("Tronlong");
* m! c9 a6 P7 oMODULE_LICENSE("GPL");! V3 R/ X/ w! C# m$ p( p$ c5 T
  @' }5 X  x5 A4 w% F6 i" Y# Q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-10 07:30 , Processed in 0.040434 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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