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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。. G+ Z' c$ p+ |# G$ B
#include <linux/init.h>
5 K5 y; a. K! I5 i  \#include <linux/module.h>
1 {: v( c: L' K! X. k#include <linux/kernel.h>9 F/ j% L5 t  s4 U& b
#include <linux/types.h>! v6 p4 k, i% t, ]
#include <linux/gpio.h>+ o: E$ m9 u8 F; i' i3 _% @5 Q
#include <linux/leds.h>
5 \" x: P9 ^2 W) y2 l7 u1 A#include <linux/platform_device.h>
! V6 S7 [2 |+ R: r6 t5 [5 e% @1 p! O+ O) W/ N) A
#include <asm/mach-types.h>: W( b& k7 X6 b# Y5 b0 G, k
#include <asm/mach/arch.h>
8 T( u6 F* K1 A; m$ g6 x#include <mach/da8xx.h>2 E! D0 x, O5 H, _) L  R' d
#include <mach/mux.h>" q4 {' j. k; G% J7 T. @; `! m4 H

# D+ v5 I. K. z4 W5 Y  w, |( }#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)0 x3 O" @' {! a' t
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)& q6 L6 {5 K# P9 p- E
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)/ I- B  N, [7 S' w/ T" }/ D6 C
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
9 o2 n6 y' f2 }9 O. K3 e0 t
" m. C' f$ {7 W  H" }9 b/* assign the tl som board LED-GPIOs*/  z3 T' x6 w1 R, f3 A% L9 ]+ X- E
static const short da850_evm_tl_user_led_pins[] = {4 |1 t* \0 }0 V# C  i
        /* These pins are definition at <mach/mux.h> file */* E3 f- l' u3 W* T- X, {9 f8 T
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' I" [& U& K* q* ^4 e8 x8 \        -1
1 [, B- X7 W0 g8 e};
5 {( L. Z, P8 N" f- l6 o8 @* n8 M0 K1 o
static struct gpio_led da850_evm_tl_leds[] = {/ ?9 s- d, I9 \) v, _, q6 L0 Z  x
        {
0 ?% D8 U! L9 f6 q. B' b: O: d$ A5 q                .active_low = 0,
6 Q0 i' T) p) m% d                .gpio = DA850_USER_LED0,6 ~3 e; D- T8 U+ [+ P0 [5 s
                .name = "user_led0",
0 u- H1 N0 Z1 ~+ t- X+ q                .default_trigger = "default-on",8 V; \/ [$ r/ _
        },' r/ K8 E. u  C. L1 E: y
        {
# p. |8 R% R, d* K2 d1 C, U& Z                .active_low = 0,0 `: }$ ?# P+ E* C, G
                .gpio = DA850_USER_LED1,
# e$ P! R  G* G$ t/ z0 C                .name = "user_led1",
; M6 h# a; R# ^+ w                .default_trigger = "default-on",$ h$ f# Y  y/ n8 m% S
        },
" m" U% p* z, ?        {) |/ o. Z1 C8 X% J" }$ J: @
                .active_low = 0,
" {* V$ A/ `2 S$ Z! M0 R3 |6 N2 |                .gpio = DA850_USER_LED2,
" ]! [) G4 o" Y3 Y0 G                .name = "user_led2",0 n& `% b0 i5 s) n0 C, n8 w& U) z5 N2 O
                .default_trigger = "default-on",
( u$ W; P* Q( c' Z5 s        },
1 x3 X5 o  S3 f. {* a        {
( t, W1 I1 p: ^5 q                .active_low = 0,. V/ Z) w( N* o. C3 X7 e: `# h
                .gpio = DA850_USER_LED3,
* o5 I5 h" l0 m& p0 g8 |& S                .name = "user_led3",' j1 L6 p8 C" U  u: i8 \* z" \
                .default_trigger = "default-on",8 L8 f8 h/ Z' [4 H0 h4 W
        },. l# M3 r6 S6 O% }5 v; s$ U
};" [' F* q4 J+ n

! A" J2 v' @- ^8 |/ R1 z' Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 I' L) W* Z/ S# E
        .leds = da850_evm_tl_leds,9 A. L0 M+ L7 o" |+ T
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ P- L% f; c1 Y: z& G% ]0 ^" t
};
& l7 H0 s  w" @7 k' D, g0 e; y
; V# g, u- s' M3 tstatic void led_dev_release(struct device *dev)$ s8 P. A7 w& f* t, T" X* f) d
{( B% E0 C9 g% I! b, S
};
/ z/ I% [' f* ?. F
1 z; ]3 d8 }5 k" Astatic struct platform_device da850_evm_tl_leds_device = {
7 J5 e" k( k& ?/ F! X' s        .name                = "leds-gpio",! e7 |7 E* {6 u( R3 ^
        .id                = 1,; u4 @0 p! {/ h! t1 c7 \
        .dev = {9 K- g6 q& P- P: [
                .platform_data = &da850_evm_tl_leds_pdata,4 n; l+ ~* o) J6 |3 n4 c. C5 J
                .release = led_dev_release,
, I3 u8 y0 y: V+ E! |2 p: V        }
  d- B! q0 \& L; N5 _};9 @) E9 R$ k/ D2 L  U* H, b6 G
( z( h; R0 z- y' ~$ M* v" ~& ]
static int __init led_platform_init(void)8 s/ T, U( r1 X$ S( N3 R
{4 c; q% V' p( X7 Q  `$ M! x
        int ret;2 F: _6 f/ n- j/ M9 L, o
#if 0
8 s7 i5 `7 d4 T5 H        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 h4 {8 d1 Y5 J
        if (ret)
7 r: u5 |! V) p! {* Y- M" w/ ?                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ o0 W7 B9 J6 K5 ~) \5 Z2 J3 G, a
                                "%d\n", ret);$ _: H8 M# N" \9 u9 Y- e$ p: Q
#endif
5 ]0 {  h) F3 Y4 l8 F        ret = platform_device_register(&da850_evm_tl_leds_device);
& l0 r. k9 a5 q1 E. z. b        if (ret)  }9 }; V4 c4 g% ~
                pr_warning("Could not register som GPIO expander LEDS");9 l% e8 g" D* a; ]. r
        else
3 N3 T" L8 _" ^; U; [: i                printk(KERN_INFO "LED register sucessful!\n");
) ?/ g  ~, y0 \# a5 i% p1 O
6 B/ ?0 l+ ~# I; S; n7 [4 A( O        return ret;
' l( B% }% f2 |* i9 W+ I1 F}
; x5 o' U. T. T# H) P# B
# {: j; m( r* y. d/ cstatic void __exit led_platform_exit(void)
2 U# y, k- y8 }' \8 T; Q  v' h{
! w0 \8 v$ W( z, ^5 y" j/ l        platform_device_unregister(&da850_evm_tl_leds_device);
9 m1 M8 R% a! @' @. E
* c" N  s( Y! ]; y& x- i7 U, Y& Y6 D        printk(KERN_INFO "LED unregister!\n");
" D# b5 K0 E+ |* _) M" m}( L* L( h; t  W# L& s  ?( _

; b6 q2 A  {& N9 Imodule_init(led_platform_init);+ |% L, S9 y; Q! y2 |
module_exit(led_platform_exit);
: Q0 h. t% F! D& _
6 ]$ Q5 s5 X# O* L6 \+ {1 uMODULE_DESCRIPTION("Led platform driver");
1 [( D* }. F# M, Y& i$ eMODULE_AUTHOR("Tronlong");
) p, Z! o! Q5 F( a* e( r) M% bMODULE_LICENSE("GPL");* ?" T8 j; D' |) x$ K

9 V! m; A3 Q+ p. d. F; R: J
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-6 20:33 , Processed in 0.046631 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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