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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。6 O+ C+ B+ ~& `& q7 p0 T) r
#include <linux/init.h>. E$ Y9 U4 _! X8 d( o1 r
#include <linux/module.h>
- H/ m: g2 ]7 j) M% X' }4 b#include <linux/kernel.h>
) s* H% u0 p; c2 }#include <linux/types.h>5 C4 y% L2 D2 r3 n& X1 B+ \$ l
#include <linux/gpio.h>
3 o. l+ M) Z  V# w  _#include <linux/leds.h>: t# k: i# I) V4 N7 r# h1 G
#include <linux/platform_device.h>) B* `0 T8 z2 z3 ~2 o
2 I$ a$ H7 g+ X
#include <asm/mach-types.h>
! B  ~  v1 k, w$ }# k6 f#include <asm/mach/arch.h>4 U  A0 r5 ^- }; m8 L& n8 n: r
#include <mach/da8xx.h>) T; l; n5 n+ M9 E' B0 l+ |* E
#include <mach/mux.h>- ~/ Q  j7 t3 S( i5 I6 y

5 A7 j& l! q, e1 D% o#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)  [& ]* F0 _+ n7 c8 Y8 m, A
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
1 \# |- @/ n" v2 I#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
4 M, i; m7 Y$ t; r+ A, [' F# E8 Y- h#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)" t* M# p8 _; ^9 x2 }( Z
+ A3 r: u$ [2 ?2 c% I
/* assign the tl som board LED-GPIOs*/
1 S; _5 `& s, p- Y, B. }' G. Nstatic const short da850_evm_tl_user_led_pins[] = {4 X$ _5 h- h+ V) P1 ^8 d$ O
        /* These pins are definition at <mach/mux.h> file */
" x* s4 O" t/ a4 q" A+ F/ G        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# P( \/ ?$ M; q; }        -1$ T6 V, Y" M. @/ K  z+ y
};
0 M4 F5 k* B9 S$ }( q( U, u/ Y; ^; p" L4 s% w
static struct gpio_led da850_evm_tl_leds[] = {; t. ?8 W, F" ^: e
        {5 x- B; b3 y9 r2 v& [* D; A# k4 i
                .active_low = 0,
- N* G5 w* t0 o; c" K: l                .gpio = DA850_USER_LED0,8 A+ R( J# D1 T3 r7 I
                .name = "user_led0",. w# T7 {! X: c9 G  _* o
                .default_trigger = "default-on",
6 d9 b0 ?6 [$ x' a4 q, @8 M        },1 O" ]2 u3 u- B+ Y" m* j# K, o# ]
        {
, Q; U" S/ m: f7 @8 e; Q* z                .active_low = 0,
. u0 Q9 |( L+ L( ]5 y" c$ o                .gpio = DA850_USER_LED1,# n, B9 [) I3 }2 \: k3 e
                .name = "user_led1",( l( R+ W. d( \+ Q* ]
                .default_trigger = "default-on",
/ @  G" l7 A4 x8 X3 I* {# o0 m. k: j        },1 \2 p1 ^- B4 j, Z
        {8 M- @. y& R5 z7 t" b
                .active_low = 0,
5 ~/ ]% C! e8 f/ J0 c* H! u                .gpio = DA850_USER_LED2,9 z6 C2 H9 ~1 h/ {4 S% S
                .name = "user_led2",
- b3 C5 v* q: L: q1 X                .default_trigger = "default-on",
- K* q! x' a: l: _! r5 B        },4 ^& D5 G* ]5 d+ A0 l2 f) m7 N$ q9 L
        {
" C  [( W8 ]" A  Q7 M4 Q# L                .active_low = 0,
1 b0 i/ x# {" t+ A6 }" F3 ~                .gpio = DA850_USER_LED3,: W$ Q5 v4 @8 w" u" N
                .name = "user_led3",
$ a' f1 T, ~5 z* I7 B7 q                .default_trigger = "default-on",( }/ N5 m5 R- Y# y3 a% [
        },
4 x( l* K" n" @  i  Z6 B};1 j  ?& B4 A0 q9 s; t* m' S

3 C! n0 z# d( D0 {+ _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" [3 B3 ]3 D& Z8 e% ]9 D
        .leds = da850_evm_tl_leds,5 n* @6 e* S9 ~6 d. W2 B' v
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 z: w& x9 {  h7 d# S
};; `! L. ]  i" V/ c. ~# j

3 A7 e4 W5 w: o* y5 j% Hstatic void led_dev_release(struct device *dev)
7 X/ I, K6 j# w& m/ C. y. D{
$ R4 P# r: K0 h6 x/ V};
: X$ F% I- O; {3 _6 d0 z) a5 D9 E
) x) ]6 Q9 ]* i3 n/ G/ Rstatic struct platform_device da850_evm_tl_leds_device = {; _4 X9 k4 ?* }, _9 H3 e- \
        .name                = "leds-gpio",$ W4 b& a) G- j
        .id                = 1,) ]1 Q7 l. z+ Y" P, g1 L6 n4 `. `
        .dev = {) W/ l: z5 s' T0 X
                .platform_data = &da850_evm_tl_leds_pdata,3 o4 [5 e9 _- i. X. x" B! C: F
                .release = led_dev_release,
0 G& h6 |) V' @' X( s- c6 ^" b' ]% w        }
/ C3 }$ z! ^7 u. @! W4 u0 o4 {};" t2 Y1 ?- o/ @: r
9 w0 a& N4 K* T! ?' z* u0 b+ U5 h
static int __init led_platform_init(void); i8 f8 y9 D7 t% V5 F
{$ Z& h/ T# A0 R, {% s1 K9 {
        int ret;" U4 i" y7 l; v6 u1 _8 s" y3 `
#if 0
- a: \; B- T+ ~8 s6 {4 j2 t        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% a9 G* g1 j' ^7 \  R0 E
        if (ret)  |3 u8 b! z( q- J4 c+ Z- r
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: k# V; J$ E- ?, K: }, z                                "%d\n", ret);
+ O9 k& R9 z. S- A, d" C#endif
! `* W2 ^3 K' Y8 Y# T        ret = platform_device_register(&da850_evm_tl_leds_device);
- U9 M8 f; a; _) o: Y        if (ret)
. u+ Y* f# R: E- K                pr_warning("Could not register som GPIO expander LEDS");
, v7 _* i3 ], [" ?, @, R. W; u        else
* K$ d, d! Y7 h0 v# a. h, J  f; [% G                printk(KERN_INFO "LED register sucessful!\n");8 O' O) J/ L, |" a/ i! L- k" ]

, P( ^' ]) v9 a% \. N2 e        return ret;
  Q4 q* }0 T6 C7 Z}# R# n6 [' q5 C; L4 O4 H
' K0 R: |. q/ i3 w
static void __exit led_platform_exit(void)7 Y7 Q2 C! B& S7 e
{( k3 v: _$ w6 @" L) S
        platform_device_unregister(&da850_evm_tl_leds_device);
$ b/ K; d8 o  q+ _; [7 f6 n' a
+ q; P5 l. w$ b2 i% b6 l        printk(KERN_INFO "LED unregister!\n");
3 B, y1 a5 t' }3 a}& }2 }& g* a9 f: p; K% ]% x

; I7 L8 s+ L( Pmodule_init(led_platform_init);
6 {6 }" G9 @. W' I; }module_exit(led_platform_exit);& [1 M9 v/ M6 @) Y0 z& k

; |  ^2 G2 m( D; r& P6 X# vMODULE_DESCRIPTION("Led platform driver");
4 Q0 o0 d: l8 ?2 {MODULE_AUTHOR("Tronlong");: [5 M' j# Y& T3 o* `
MODULE_LICENSE("GPL");0 s# E0 f( h6 Z7 Y
( ~$ x: q% l& p' u& z$ j- k
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-28 17:50 , Processed in 0.041559 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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