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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。- T+ \3 Q; V0 d2 O/ v
#include <linux/init.h>
% v' [0 v# F( {: U$ F# D#include <linux/module.h>: b& q8 o& }: [: o1 y7 {
#include <linux/kernel.h>& K/ N) i. ~- X, `
#include <linux/types.h>
- {5 I! j; D0 P. [#include <linux/gpio.h>
: D. _+ j: h% {; _3 C6 f% g: s#include <linux/leds.h>5 G: E9 `- _- @7 i( x, J
#include <linux/platform_device.h>3 N! Z: [! N1 A+ o' e% j

; N1 W! h% ~- H! }( R2 ]1 {#include <asm/mach-types.h>9 u0 u$ D4 _& p6 I- z! f* @
#include <asm/mach/arch.h>7 j2 j8 X) ?, G" j
#include <mach/da8xx.h>* O) @% e2 d, t/ d
#include <mach/mux.h>
) I' d+ R- d7 {8 l* ?9 m& z; Q5 Y4 g' `* U! \) e% \, p8 R
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
0 n" T: u: y1 @. E. y: v  q. o#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
$ V$ }9 c' [& g9 y$ v#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)+ @' q7 }, `: z. Q
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
; ~9 ?, X8 _: y( V. q- j9 V. s: f/ U/ I. d! ^0 N; \% J; \) |. T
/* assign the tl som board LED-GPIOs*/
# |& l  P  {) ?& lstatic const short da850_evm_tl_user_led_pins[] = {: V) F. D) a7 R7 y6 u# }7 y
        /* These pins are definition at <mach/mux.h> file */
6 B4 m, K5 A1 K/ t# O        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 E6 ^' @" u2 V" m        -14 [8 \& M4 `- ]+ f5 m4 l: @9 {3 b
};3 }3 J! E8 [" X- ?; p. C- h

, O2 f" I( g! \: T. N1 k* v+ a1 Mstatic struct gpio_led da850_evm_tl_leds[] = {
0 y- R0 C5 f+ s; N  W! V        {, {8 v0 E# Q4 L9 b5 X6 G; e
                .active_low = 0,
% K& f+ W9 w, }                .gpio = DA850_USER_LED0,
5 z: @: e& `2 |' _/ P                .name = "user_led0",1 s" p+ V! Z9 R! E! m2 A# G- r& r
                .default_trigger = "default-on",2 H7 ?2 d/ i9 `- K0 C) v/ a
        },5 l0 T5 H# }  l+ s3 U- Y5 U
        {
2 E8 t) l9 V6 H+ t" u+ z! e2 c                .active_low = 0,0 A( b" P9 O- ]
                .gpio = DA850_USER_LED1,& h% q4 T& I. m
                .name = "user_led1",9 \  Z6 y7 x3 F
                .default_trigger = "default-on",
; u/ k- Y0 Q8 j/ U        },
  Y+ J8 l* i: _8 c: l# U        {4 P' x0 J4 [4 ^6 r8 Y( E' _0 q8 w: U
                .active_low = 0,% A  ^5 B6 Z: f8 S  q; j
                .gpio = DA850_USER_LED2,
7 Y$ }( z; e. d$ v2 i) G1 H                .name = "user_led2",, ^! w" b: P  z6 ]0 m. z/ ]: d
                .default_trigger = "default-on",
5 j- G. a+ u4 [- w- ~* a+ h        },, O' E5 v9 \- P9 C4 E
        {" Y; [4 x+ D; G
                .active_low = 0,
. H$ b. O0 U' _. m                .gpio = DA850_USER_LED3,
1 V) Z' V4 x4 V* O                .name = "user_led3",
6 c9 }0 G% [0 j, L/ @6 m                .default_trigger = "default-on",
" r! I! W! }& K- G; z6 ~        },: t+ L, w  L5 m: t9 B9 Q1 ^
};
" i; O: o# X6 r7 V  C( F2 q: A2 j+ W) {7 y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' o, y5 X7 u. _9 S8 P. x4 D! O
        .leds = da850_evm_tl_leds,
& R! B4 A# A. [' D- e) O        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) Y, H$ ]+ o  {5 F% ~* B0 p) g( C
};" R, Z) W, C. G& d: J( \
% ^# D- w! D: g+ q
static void led_dev_release(struct device *dev)
1 e1 w, z; i1 I3 d3 \4 J5 j{' O* ?" J$ V5 R# M
};
* b8 R" z& D/ E* k+ R) t9 H
2 |( r& B# b3 [1 {0 q# A$ Vstatic struct platform_device da850_evm_tl_leds_device = {
) x. k; w- M7 j/ i- N7 S+ C        .name                = "leds-gpio",# @# j, r" i8 ~
        .id                = 1,3 `$ U" ~3 ?& h, L2 n, m; ?5 n% y7 n- f
        .dev = {% \& \! W/ C$ b9 z0 \+ \& b
                .platform_data = &da850_evm_tl_leds_pdata,
! u' Y- `# s# l, \* r/ Y                .release = led_dev_release,
7 E) s+ ?' M: [* g4 v        }6 B! i' H& r3 w+ F" t/ f+ z
};
% ?9 t! t8 b* N6 u" W- f+ ^5 D+ P) n1 ]" w) {" G
static int __init led_platform_init(void)
3 _0 `* n% g- F- M, B/ d% I{
) w. t% P1 P; w- ^! M# g$ g4 C        int ret;7 A/ R. J  O: o! v* p( ?) W0 z5 R) d
#if 0
% ]( @0 H1 P) I) R        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' i) k+ x& {9 t5 a        if (ret)8 _* M1 T$ c" Y6 |- M/ h' j$ ~2 x
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( G: D7 R( [( g; J8 J- y1 B
                                "%d\n", ret);' v) h0 m. L" q9 S/ E& _
#endif. U6 d! X5 t, x: U6 w
        ret = platform_device_register(&da850_evm_tl_leds_device);2 `  N* R4 B! w) c- x/ q
        if (ret)
. M$ R& ^7 }2 d  p                pr_warning("Could not register som GPIO expander LEDS");6 A9 l8 D1 M# `) P
        else" X" e& \$ j0 C( j4 I: a- ]: d/ ]
                printk(KERN_INFO "LED register sucessful!\n");
* s/ c% K5 M" ^% W4 @# q0 K6 B0 ?
5 t% z% W0 K9 T- r9 g# w        return ret;
: P+ B2 z( d! j# I# r}: z, j8 g% x7 M. b
7 z+ f3 h' }8 w2 V# }
static void __exit led_platform_exit(void)
9 ^  B- Y7 \; |{; _3 I; {. ^4 _; U
        platform_device_unregister(&da850_evm_tl_leds_device);
7 ?8 R$ J  k4 }: L4 h3 n( V& ?, V% W* B
        printk(KERN_INFO "LED unregister!\n");
. u; o( Y# \& w8 b/ T}1 P1 [( C3 q2 j1 W6 f+ U" d8 e
5 B" v7 d/ R1 K
module_init(led_platform_init);
3 y; T1 L0 [9 g. j2 \, j# n1 `module_exit(led_platform_exit);: g2 Y& Q! U5 |( T2 ^3 d! s

! Y$ |/ R4 P/ b2 }6 \# aMODULE_DESCRIPTION("Led platform driver");9 D5 |, `- o5 G3 M/ H
MODULE_AUTHOR("Tronlong");- [! K0 t5 d+ _# Z8 }
MODULE_LICENSE("GPL");" ~8 b& P# n7 g1 V9 s; v

: P- ^4 C1 ]$ a+ J5 h5 f% I
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-16 18:56 , Processed in 0.039828 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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