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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。  `$ ~, _/ l6 M  T- Y. I' x4 J# F$ L
#include <linux/init.h>$ b% O+ S! ]  G0 T% J+ M2 `
#include <linux/module.h>
# d, x3 X# l) }) k  p3 l#include <linux/kernel.h>, a4 U( }/ k% a# K
#include <linux/types.h>
( r6 i. j6 T$ Z! ^' J- X9 o#include <linux/gpio.h>& f- F# e, p% i& r, C
#include <linux/leds.h>' H9 T9 X3 C) V: O' |
#include <linux/platform_device.h>
2 ~6 N, u+ y6 @, }! A3 p7 N  `4 g
; Q6 @  \0 m  B$ B) ~#include <asm/mach-types.h>
( X: }- N2 G4 N) V/ H#include <asm/mach/arch.h>7 [1 [& v) F2 `2 v& s
#include <mach/da8xx.h>& j( a) @$ p. Y: c% o5 Y
#include <mach/mux.h>
8 Q/ @7 C4 r$ w
4 C9 h5 g* B: E2 I& Q; D) v3 M! n#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)! s2 L( g: X( c: D5 u
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)7 y3 o. i/ P9 }7 ?  F
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)/ q. U# ?6 D# m& v0 E- x# ]
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)2 A) h, `5 G! {& S1 s6 c' x
' z% [* [' v5 W# y% k
/* assign the tl som board LED-GPIOs*/1 m7 n( d3 t2 M
static const short da850_evm_tl_user_led_pins[] = {  H! K/ u) w+ T1 Z. x
        /* These pins are definition at <mach/mux.h> file */: j+ s5 _6 m, o9 Y2 v) ]+ N
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 k: R8 M* Z; K1 F& h5 [, w
        -1
9 d& P, Z3 w8 b! T5 t1 Z};" z) I. _8 S4 c! J2 w& n1 s$ q1 {

, T( f9 ]: H8 H- h4 Zstatic struct gpio_led da850_evm_tl_leds[] = {2 Y" T8 }( T( R" \5 K
        {% f* W5 }4 v. H. |5 j5 s) t+ M
                .active_low = 0,+ J; i8 K3 m) j- j% O- M
                .gpio = DA850_USER_LED0,, c" o. p1 w+ f/ k7 N7 w2 n& b
                .name = "user_led0",
* }- C& d) I) r9 V+ @                .default_trigger = "default-on",
2 ?7 _/ C% C) r. J. o        },
" @% \4 g) r- c        {
: E" `  m' k2 H1 T" p. i                .active_low = 0,' X; Z# f1 G% q" R7 _+ i) w3 _
                .gpio = DA850_USER_LED1,8 c& U, j) o9 B4 c8 H; e/ m/ i
                .name = "user_led1",
. Q3 S/ o5 ^; [  P( N' R% i/ k, G                .default_trigger = "default-on",+ S% c& c* O, Y* @( ?' J% B
        },( \. @6 w, |. p1 D: U2 K, T
        {3 K: _+ l, A8 q# f) C
                .active_low = 0,
. Y6 i5 V3 w- c) |; N                .gpio = DA850_USER_LED2,
9 R* J4 R1 Y0 ]# q                .name = "user_led2",
" S: t  C6 p% m2 e. \- N5 _) I) D                .default_trigger = "default-on",) e1 ^+ k0 H6 |$ j' X0 C6 I% }
        },  `1 t5 E6 V& v
        {& H# L" t, W& g) g4 f, l! J
                .active_low = 0,( S/ I- ]* t& K- G7 @
                .gpio = DA850_USER_LED3,
. F# r2 @+ ^' r  a& |: r2 O# @! R                .name = "user_led3",# n: g. n' b% _5 K+ F+ r
                .default_trigger = "default-on",0 Y# j. T2 i/ T# X- c
        },% @9 I& v* l' p) f9 B
};- U0 A$ K5 o5 o" p

" m' M. B& u% Y4 G3 C3 A) Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! P7 ^* E( S& s1 w$ q$ k+ L
        .leds = da850_evm_tl_leds,4 ]8 S6 k, s9 o4 z7 n: H
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# [; b7 C! |) S0 M. h. b6 H: n4 o6 `};1 U9 p- a$ P7 X/ S
; A0 C. a+ h& n; P2 g$ O, F
static void led_dev_release(struct device *dev)1 O. g6 H) |8 P: c2 W
{4 G3 G* L- ~) R0 P& y6 ~  p
};
) |; H+ s4 R8 X7 x; U7 D2 V
1 m# V5 ^* E5 {, @: h& _8 A* qstatic struct platform_device da850_evm_tl_leds_device = {
. N' t& {) i7 K" z3 }6 d2 [% s        .name                = "leds-gpio",
/ G! R7 P4 G; A  b0 U0 @- z        .id                = 1,, y0 s' ?: a! O# |" P! N
        .dev = {" l4 c7 u& ?. I$ D# @7 }/ V- k2 Z7 [
                .platform_data = &da850_evm_tl_leds_pdata,9 m* A1 Y9 e' a$ A! V6 u
                .release = led_dev_release,2 {; y! ~4 S, ?4 E5 T; e: P7 t
        }5 @1 B/ N/ D+ f) E" W, F7 n/ R9 U
};
" T6 Z/ N% f3 C4 g
, V3 ?6 r! m1 n; w7 V1 X4 B* E5 \  U" @static int __init led_platform_init(void)
* {) I. l' M2 Q- y{7 Q. |! ^4 ^3 h- C: n
        int ret;
+ j* S6 h( _$ b5 ^#if 05 I1 }. {  I5 p. ^" x$ j6 l
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# d" |, P$ [  I3 i        if (ret)0 m  _+ F' L+ i7 \; M" o
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ \3 o8 d# Z* \3 {# C) W; [/ b# ~                                "%d\n", ret);
" I; s$ \- S+ j2 f. I#endif
. I; J% ?! a3 h5 W        ret = platform_device_register(&da850_evm_tl_leds_device);8 J- I, ]' }' B
        if (ret)
( C' ~* @/ k" _9 h                pr_warning("Could not register som GPIO expander LEDS");
0 e5 T( [4 W7 q/ q  w! F        else
$ j) W- J' e2 I6 L  w4 b                printk(KERN_INFO "LED register sucessful!\n");* h2 e& h/ G. `# o
' L6 F, ~1 u& V2 n8 |$ |  Z4 Z
        return ret;
$ \% t3 ?' `* M1 N0 B0 G}* k3 f2 A& b2 m' K2 o/ O

' w. @. O# o5 E3 d! k4 a4 Ustatic void __exit led_platform_exit(void)
& v3 R! d7 n3 V6 h* |4 l. H1 A4 d; E{& R6 N2 H! n, S+ b8 c1 z: h
        platform_device_unregister(&da850_evm_tl_leds_device);
4 }: u! _+ v9 l: V" \# w
: W/ w4 E: l" k3 H: n# g        printk(KERN_INFO "LED unregister!\n");
# C7 F& X9 F. F7 M}8 a+ o' \% B6 K, a
! R  \! z2 B, u; E5 D
module_init(led_platform_init);
* d' y# g' @- C- e/ s$ w* _( @module_exit(led_platform_exit);
) g# g' b7 W! Z6 M+ y5 r3 l
9 u/ K  }: f; B* A+ h- ]  u8 [MODULE_DESCRIPTION("Led platform driver");
! ]& x4 v! K) z  }MODULE_AUTHOR("Tronlong");
$ D- K8 N' M) G8 v8 m6 jMODULE_LICENSE("GPL");+ Q) _8 J0 X! w* u
! a& t4 v5 U- l, k5 `) d  B
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-22 08:22 , Processed in 0.039748 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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