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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
% b" f% l# g  R7 Z5 ^#include <linux/init.h>8 U- k  {5 P( K: U; L
#include <linux/module.h>
: J6 h6 G& e/ f- C#include <linux/kernel.h>
! b, E, o+ V' D- X#include <linux/types.h>; J- N) W  x) J6 i( M! E2 _, E# R
#include <linux/gpio.h>/ {) y4 v9 G$ d& q5 x' M
#include <linux/leds.h>7 M& u: j! Z# I/ e, k) ~7 b/ Q# i- j
#include <linux/platform_device.h>
) M/ {' R/ j  Y% u) V/ Y
. |$ z2 V9 a" ^; r1 V: \3 ^" @#include <asm/mach-types.h>
4 Q+ L7 Y# k4 S, V8 U" X#include <asm/mach/arch.h>
  @6 Y- l  I% e5 `#include <mach/da8xx.h>% ~/ z% w/ z2 l. B; m& M
#include <mach/mux.h>6 O/ l% l! n' Q# P) w5 I

2 q5 [$ O* o+ b: u#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
; }3 {) n9 A; p* e$ C/ o#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
' d8 T, |" j. W( {* e% }. d- h#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)7 `" l) m3 X3 M
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)2 i( B/ F- K1 ^2 H$ z8 {1 O/ Z
" \4 d0 s: E' ~4 _) t6 @6 R
/* assign the tl som board LED-GPIOs*/
) L5 J+ @: G6 n4 V& _static const short da850_evm_tl_user_led_pins[] = {) F# G3 Z$ m( U3 x: O. M/ |
        /* These pins are definition at <mach/mux.h> file */
7 V+ B5 X. L* P4 }1 \7 n/ w8 Y        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ M5 d2 n. I1 v& S: ?8 X* }; y4 t! r# r        -1
5 j* ]9 k$ u! a! ?: _  A};
6 m8 I' i' l2 i, {) d9 X3 a& F; U9 y$ X! q7 }6 a4 N
static struct gpio_led da850_evm_tl_leds[] = {
5 E' u% R1 \0 b- w# s        {, ?  r. F+ h7 q; T$ i  D
                .active_low = 0,
8 m9 R2 s6 G# I! ^+ G5 A5 r+ r* _                .gpio = DA850_USER_LED0,
" r6 R) W# N+ T" l: ]                .name = "user_led0",8 w7 R, D, R9 P. b7 X
                .default_trigger = "default-on",% E8 |/ \. z3 q. ?1 g
        },  O. X; t" c9 q3 B* ^' Q
        {
8 o1 n2 T! o' }5 q/ T# x                .active_low = 0,
3 d( X5 h7 m: }' B( k6 k                .gpio = DA850_USER_LED1,
% Z) Q2 |  g( ~4 e                .name = "user_led1",; v+ J9 q3 U' i: Y$ \  x7 o7 |
                .default_trigger = "default-on",& \$ U4 e# m: k% R: O
        },
: I! r* ]# Y$ ~% ]        {
9 b0 n, K- s: u                .active_low = 0,
% ^$ h+ w0 ?5 {- d* ]                .gpio = DA850_USER_LED2,/ B! J3 P/ K3 l
                .name = "user_led2",
. w5 W: ~* i8 D: I                .default_trigger = "default-on",5 K6 W$ ?4 J9 S* o0 k/ \
        },6 s' b- {5 F. ~$ W" C5 k' }
        {
: T- l, z) B1 v                .active_low = 0,
. z: V# N8 k. w* M                .gpio = DA850_USER_LED3,
# b$ S6 b/ N3 Y* O* E( t0 }6 y                .name = "user_led3",
& t3 T- U1 Y' l. a! I2 d8 r& m                .default_trigger = "default-on",
4 ~# q  c& l3 L$ v5 z6 r( |        },
7 ]( Q; s% s  O6 T};
! D6 G  d! D" L. g6 m0 C- I
; p' x. r' ~% P& |9 D( Q7 ?4 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; l4 r4 ^* ?; S6 W$ d9 M$ W8 t# [  ^$ Y( B
        .leds = da850_evm_tl_leds,
1 I* z3 N# s* y+ [5 O        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 w7 ]; n* [, p1 V. R, f7 T};
+ T' E' l4 H; W- q1 ]! {7 S
7 `# L! c8 `6 X# P& Ystatic void led_dev_release(struct device *dev)5 t7 Z$ g/ w0 x& r" D7 A9 E- i1 H' P- Y
{
- i/ [; \2 q$ ~9 t9 W/ @};. ]* c3 }% p, B" k4 P, ?# `: p

2 I. i* C: a6 c/ g8 T: j0 Dstatic struct platform_device da850_evm_tl_leds_device = {
3 \" V- {8 }; f; |: O. e+ @        .name                = "leds-gpio",! W0 A& Z! e5 Y! W
        .id                = 1,* Z$ s& l" P. T; O7 R! E' G9 q$ M
        .dev = {6 O2 s& B; E- o. W! z) p% c. g! g
                .platform_data = &da850_evm_tl_leds_pdata,, L2 [4 [6 }0 {" Y% T3 y$ s
                .release = led_dev_release,% d) ?8 `& t5 |( d, z  D$ y, V* ^
        }! [% ?1 F$ j2 i9 A7 B
};: q* u0 r* J0 i$ V7 U1 l
! H/ x5 ^# P3 c  O8 ~
static int __init led_platform_init(void)0 ]- y6 U1 ]2 ]8 Q! \6 Z# o, A
{
0 G, I; ]2 T7 c8 d        int ret;
- |, u7 U( }3 r- C7 M/ p#if 0
/ p' H) E" m3 t' g2 x        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 F7 }) m+ `5 ^9 L
        if (ret)
& u- _! b3 Z; J                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ L" `$ o6 E6 a) U1 ~                                "%d\n", ret);
/ i2 O* n/ l+ Q6 O  h- \6 O9 g! g$ z#endif, q& _" R# s' R* P2 ]! x
        ret = platform_device_register(&da850_evm_tl_leds_device);
& O; J# q: O& ~        if (ret)  t; z" c& c1 M- o: f
                pr_warning("Could not register som GPIO expander LEDS");. f- E( {9 n; k' M
        else1 _6 U  x: w) x# K1 x
                printk(KERN_INFO "LED register sucessful!\n");, ?- P! N2 v6 @* e% }9 J- e
3 R, e2 V0 j- |6 }
        return ret;3 t% ?' ]% l; y0 C. _2 ~% k1 ?
}
: Z  R( \  C. l! e
; X3 [1 @' h4 I1 S3 ]static void __exit led_platform_exit(void)
4 K( D. W! d, ^4 S/ ]8 n8 F{: X: G$ y% E# d+ ~& v6 n; ~
        platform_device_unregister(&da850_evm_tl_leds_device);8 n, ]* M9 a. z- B6 l3 k
) p+ `; s/ \; ^
        printk(KERN_INFO "LED unregister!\n");
5 H$ o8 Q% V% n# Q1 x0 a; P}
* R4 W1 |) ~! f' z# n7 Q! _# t: v( B* C
module_init(led_platform_init);
7 X& x2 ^5 s/ fmodule_exit(led_platform_exit);: J. N4 n. D0 x/ g1 ]$ ~' U' i

, a" _4 _% O  Q: r8 s& |* WMODULE_DESCRIPTION("Led platform driver");
% f/ e; C5 e# W% n- a# O0 E$ ?. RMODULE_AUTHOR("Tronlong");$ }# O  f1 _/ ?1 `% v
MODULE_LICENSE("GPL");
; a' f% e! |* C1 m3 F
% V+ d# M7 e0 p; l- ^- s" t& Y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-14 13:36 , Processed in 0.043111 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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