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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。. R& P) w) d- F, l. T+ [8 T, b
#include <linux/init.h>
; |6 t  u& f4 D#include <linux/module.h>& }& o" h% m; n0 K7 Y/ a6 w
#include <linux/kernel.h># a' D4 j9 h: @6 q
#include <linux/types.h>
8 h5 t7 P/ b2 m8 [, d. y#include <linux/gpio.h>  W% X4 d* F  `' ?: m9 K
#include <linux/leds.h>9 _# |0 s; o& G& R( y1 \* o4 C
#include <linux/platform_device.h>
) z4 L- _9 k$ M, u7 U/ Q, a
# a# d/ f7 b# C1 \#include <asm/mach-types.h>$ S- ~6 b7 c  F- ^3 v
#include <asm/mach/arch.h>$ w& @. ?# V( U% V; L( [2 m: H
#include <mach/da8xx.h>
: s8 [6 [7 L) m6 E$ u' l' K) o7 ~7 F#include <mach/mux.h>
+ q8 D, p- U. W' W' i: C; N5 W. \  f- _
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)# [: l' c- ~6 n, _/ b
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)4 f. H- ]: g+ e# j* Y8 z
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
, m+ P* z: i8 {/ q#define DA850_USER_LED3        GPIO_TO_PIN(0, 2); s$ n; m* M$ u7 n, J: r( y( [0 T

  G4 w2 F  }* a9 G- Z% @/* assign the tl som board LED-GPIOs*/9 D& A+ u9 J- e. P* G# m6 I
static const short da850_evm_tl_user_led_pins[] = {
2 o; `6 R: ^% p# m- @6 k. @        /* These pins are definition at <mach/mux.h> file */- y. h) R! u+ b& z/ h# V: }% T' ^
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 F9 ~2 e+ I( y2 I5 u; L        -1
3 G  C# ~) i3 h/ [( s};
5 U: C. T0 s9 T" a8 x  Q8 t/ t0 E( M) M2 H+ t) \( W
static struct gpio_led da850_evm_tl_leds[] = {
" a6 Z3 l9 {# }8 _- u. {; {( V7 x+ M        {9 a" ?! l" S+ J2 V0 @/ [1 e
                .active_low = 0,; s0 z6 @& S/ t0 _9 A
                .gpio = DA850_USER_LED0,  [0 p" W+ G$ c1 i
                .name = "user_led0",
; }2 A0 r' t7 V2 y# t                .default_trigger = "default-on",
- C6 A* a; K1 V" {1 e2 Y# x        },8 T$ m2 v7 `8 T- f( e4 N: d
        {  a7 v% h& O- S  \3 S* |( i) B& z# d
                .active_low = 0,6 k- a4 z, w* m
                .gpio = DA850_USER_LED1,! d, ~* j) q- {! d1 a( i! r8 j  p* ]
                .name = "user_led1",
$ G1 \" M* q9 M0 m9 P                .default_trigger = "default-on",, B7 A* D- D. w
        },0 t. f! g0 F: w: O
        {
( r7 C) [  U2 A1 E/ E                .active_low = 0,
" m) o8 j9 S: |: H: d                .gpio = DA850_USER_LED2,% o: k7 m$ l( M# c  H4 D& c7 X
                .name = "user_led2",9 t' \$ B6 L! d/ B2 U& a3 [) O
                .default_trigger = "default-on",
% W' q( j7 O2 u( {2 `3 d        },
* V' n- {: p+ p        {
4 q$ H! v% D7 q# k( V; @! ]                .active_low = 0,! x8 \$ O( }( J- y+ _
                .gpio = DA850_USER_LED3,
+ E# o$ P, V! o                .name = "user_led3",
8 t- e5 U( ?5 g; t                .default_trigger = "default-on",/ h- U3 e, f  w* a1 v
        },
7 T- |/ d# i6 K! C8 q" W- K4 i6 j};
3 B! ]! Y) Z: ^) I
9 d. X2 a4 {& X2 V3 F$ D4 |5 Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# Z1 i, D/ W  ]1 n' @  O
        .leds = da850_evm_tl_leds,
( x( p. R0 M) w; ^% _7 _: N7 l        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' N. u8 c2 J- l: z};2 M7 ~0 H, c+ h: D2 M" M

5 P4 A1 O7 e- b  a7 g  d% y3 [! I- astatic void led_dev_release(struct device *dev)
5 _( z5 {: x/ R# v+ b{' O+ h& ]& b" Y0 ?3 k( \
};; X8 q$ m5 t; \. L) x

4 J3 U& _/ p) L+ h& z/ R3 g) N! |static struct platform_device da850_evm_tl_leds_device = {
# V  ?# U! h$ M  s, u; z        .name                = "leds-gpio",
& k4 ?. d* x/ \( m, M& @( E        .id                = 1,+ _& c8 ~: J: t) \, V
        .dev = {( `. b) }9 _3 i. N6 ~; {& H
                .platform_data = &da850_evm_tl_leds_pdata,. X$ _  ^7 Y! p4 o1 g7 K/ r
                .release = led_dev_release,
, c' K# w9 u- p% V/ [3 w        }
* a9 h+ x. _9 p9 m};. n: ^8 E, `) j7 @3 h# I

3 W1 I0 O9 d  a7 w/ t$ y+ X$ I4 gstatic int __init led_platform_init(void)
" q7 T# m  b) G' o2 j7 L9 C) b* ]{
. u" H, F4 `9 E. s" `  f* p        int ret;& O- j. a" Q) _! k& \( a
#if 04 `! T- ]9 y+ }# _; Z; ]( h* K9 _
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 ~# n: z8 m3 m! k6 k" N! S, M        if (ret)1 S. l" h+ E! \
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& n4 }6 B) y8 ]% Z' A
                                "%d\n", ret);8 c' K( P6 E( L( R" _
#endif! s5 a+ |" K9 v2 U
        ret = platform_device_register(&da850_evm_tl_leds_device);
+ r9 u  z9 p; q3 u2 g        if (ret)
9 v: @' j! u* i. Z0 Z1 g                pr_warning("Could not register som GPIO expander LEDS");0 V; \7 A& f: m) C0 k( w: R
        else, `5 t, W) D* E! f7 T
                printk(KERN_INFO "LED register sucessful!\n");
6 C4 v7 z# Q' @2 [! F
% @% c" i* }$ f1 B        return ret;# c' E7 E! L7 S! g8 B- k) `
}
# k7 a! n* K0 C, [9 V' W* k+ f$ z5 Q' S2 X/ J6 e3 c* p
static void __exit led_platform_exit(void)0 o8 w) Y1 V1 c  W
{
; W7 [. Y" Q+ ]; ?" [  y        platform_device_unregister(&da850_evm_tl_leds_device);9 z$ Z& n+ C1 C9 {  t

5 s. R+ A' A6 @: E' }. f% N  g        printk(KERN_INFO "LED unregister!\n");
$ Z, E4 Y, [- H; X5 S. p( ~}
. j8 t% u* e4 s! `# r1 m) O8 D& ]- f8 D6 G
module_init(led_platform_init);4 d* |7 o+ u& J( \3 w1 m" @
module_exit(led_platform_exit);" i3 {. p- l6 T7 }; z
7 H& O' M: W+ j2 j3 K6 e
MODULE_DESCRIPTION("Led platform driver");9 }2 l3 k+ x- G/ m, E$ O4 a  M" B; G6 s0 E4 C
MODULE_AUTHOR("Tronlong");& Z0 u7 i. P  k
MODULE_LICENSE("GPL");
: j% Y" F9 W' i& X9 L5 F% g5 c$ e: L: }( j% X; ^# ]9 v
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-8 15:34 , Processed in 0.040598 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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