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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
) }# ^# G/ J0 r- x1 X#include <linux/init.h>
+ V, ?. ~' e$ F  @* W! b  k#include <linux/module.h>
9 a1 Q; f+ x5 Z) @#include <linux/kernel.h>. u: ?! n" M( }0 Z. c3 G# d8 t
#include <linux/types.h>
$ b  a- A: ^! N: G  x) h( Y8 k#include <linux/gpio.h>1 P3 c; S+ p( w. T
#include <linux/leds.h># ]7 {0 V: b1 E$ Z' @8 y
#include <linux/platform_device.h>
; E1 t1 y7 x: G& F4 y" n. B, [7 h! H$ ~% _3 Q7 o: U
#include <asm/mach-types.h>5 g% M( K& O$ ~( x+ A
#include <asm/mach/arch.h>
0 J, ]1 ^; o5 ~4 S; n. ?7 i4 P#include <mach/da8xx.h>
) f" n% h6 l6 N7 F: X#include <mach/mux.h>) u) v3 ?/ S: K/ Z4 I: j+ Y% g3 l
, y1 U% u( f$ q1 m2 e7 c6 Z
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)5 k7 E7 _8 Y2 m, U  k5 S5 |" w. |
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
! }$ v( R! j: r7 j% w3 }# q#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
: x3 ?# b/ z$ k8 j#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)9 `- Q% {4 r+ e( Y7 i
! f& v" F- s' J  _1 I% Y& l& z- a/ N
/* assign the tl som board LED-GPIOs*/8 Q. P' r7 F$ J$ G; y0 J9 j
static const short da850_evm_tl_user_led_pins[] = {  P) ?% j! L! ?. T
        /* These pins are definition at <mach/mux.h> file */
- o( t, n8 e8 K! g) y1 l" n$ D        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ n; {$ D5 H6 b/ `        -1- s8 e. U2 k) C3 F' a* L
};: L2 I3 \" N: l# }7 n
" E6 P6 V$ r* ^2 ~( S5 u
static struct gpio_led da850_evm_tl_leds[] = {
8 @3 R# k3 ^. j3 ?        {$ E; y$ r8 l; V$ d+ p9 p
                .active_low = 0,. M5 C* Y& P3 ]  z
                .gpio = DA850_USER_LED0,( h% Z) m% W! {# K$ E
                .name = "user_led0",. k3 F1 u& I6 p" {: T
                .default_trigger = "default-on",% [3 j1 r4 I5 C* z
        },1 R* q& z; ^) |1 f2 i& r
        {" H* E- T: f4 E0 ?2 |1 A
                .active_low = 0,2 \( u2 j/ e/ X
                .gpio = DA850_USER_LED1,
3 p( U; z0 e1 o                .name = "user_led1",8 I( \) ^0 |! _+ ^
                .default_trigger = "default-on",* A1 X8 e9 B+ V' H$ Y8 ], Q* d
        },* w" E# U! p4 y7 f1 m
        {  {  G8 o$ r9 T+ \' B  w. G
                .active_low = 0,
$ w- f, }/ w% I* `% H. k                .gpio = DA850_USER_LED2,2 W/ Z9 w; N0 e4 N( L5 M, o, @
                .name = "user_led2",/ \8 ^! N- w4 J
                .default_trigger = "default-on",. u4 ?- g7 t" c4 I% k  O
        },
/ R# |3 x. o, M# Z7 B2 U. e: i& {        {7 m, j2 l: T  k# d! ]7 u
                .active_low = 0,
* l+ z/ c" T$ z) ~0 B1 U                .gpio = DA850_USER_LED3,
- e4 Y  I1 \- j7 E4 X7 E                .name = "user_led3",* T; E( T3 z; E  Y& f5 [. U
                .default_trigger = "default-on",
2 Q# l/ S( b9 \* v        },
1 r' e6 V* q# l7 X' ^$ [};
. L- p; O1 Z+ L# V" I/ ^2 ~: _* }1 r' f4 a  g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ a' P3 M1 t% E# s& y' r$ h        .leds = da850_evm_tl_leds,$ s. N1 |0 W, r! i* M5 O
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! `* }: d' Z" P  J
};1 w  J) N2 I& Q! y# ?
; {; X6 c9 i( b9 U3 C% a
static void led_dev_release(struct device *dev)
9 L3 m9 Q2 ~: i9 s7 w6 Q{9 l4 a0 V  O3 A" q7 U
};% _5 g2 @9 V) f

$ G, x# X6 }7 z, Ostatic struct platform_device da850_evm_tl_leds_device = {
" }$ p; P: w! ^! a/ A        .name                = "leds-gpio",: ]6 D  v  @1 @% W
        .id                = 1,
8 r2 S8 m+ l5 y. ]- I        .dev = {5 B/ X* d5 X( ~8 P2 b( z8 {8 ~( k
                .platform_data = &da850_evm_tl_leds_pdata,5 G1 f. h. N9 ?  Z6 T0 o$ x
                .release = led_dev_release,
+ k' s. i! A& H        }
) q' ~  F- q/ Q' ?* J$ J- Q8 [7 v};  [5 h0 B( H) M
  L. O% g- U* Z7 x! |
static int __init led_platform_init(void), Z, ?( z, j2 v  ?, v( K
{6 {8 V" Q" m6 m. v1 J
        int ret;
' e) p* `0 q$ v. d0 M  f#if 0
6 z6 v6 u& X7 U/ }        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ j9 S% _. k# x- n. m5 d! Y" g
        if (ret)" L0 \, i2 t7 j$ s7 \9 f* ?0 n; }
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; t- q: o; Z: S                                "%d\n", ret);
/ |' k/ J- M) g( A0 D) [#endif
0 B* f/ Z& \7 ~        ret = platform_device_register(&da850_evm_tl_leds_device);
, X) k& `* [! C6 H$ w        if (ret)! m9 }) n: K5 X1 g  r  _* j
                pr_warning("Could not register som GPIO expander LEDS");
! c7 l& ^  E; f: p  G        else5 O( i2 `3 {+ N
                printk(KERN_INFO "LED register sucessful!\n");
. d' d7 Z& P  E( c2 e2 T% n5 A: b! {. ]* `  K' m
        return ret;
. Z" A$ H5 Z$ s}4 R: |; K4 |& D- f
& [7 P, M- z: V
static void __exit led_platform_exit(void)
+ F( Y7 C3 D7 f- t/ S, [8 [{1 b$ h# t, o5 z4 p' M
        platform_device_unregister(&da850_evm_tl_leds_device);! R3 G9 b6 B$ X% p/ K
# m1 X6 `+ d# `5 \
        printk(KERN_INFO "LED unregister!\n");: ^/ D# t0 P4 n% m/ q; M+ m
}
$ C: \% |# M" b* q" _$ P2 t$ e* d# N. j- v$ E9 q+ u
module_init(led_platform_init);& |7 \, x4 a" G0 Z, N; f& l
module_exit(led_platform_exit);/ [0 D1 w8 E  @6 e* U" x) K

3 j8 i* m5 e0 X9 `# I, DMODULE_DESCRIPTION("Led platform driver");
3 g: A/ s, ]" @+ J# a$ y- M1 jMODULE_AUTHOR("Tronlong");3 a+ t& S9 N' \( x/ V% _
MODULE_LICENSE("GPL");9 v$ _! w% X1 }2 {* ~9 t
3 Q' j1 A; H. Q. ^! P/ V+ C& y# m
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-28 16:27 , Processed in 0.038622 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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