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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。3 w6 {; K0 K7 ?' [% T& M4 W
#include <linux/init.h>- A. a" t) b% ]
#include <linux/module.h>7 L9 I# }7 e$ @) o( E% d" t/ d3 D
#include <linux/kernel.h>
& I4 k: @- u& J* @1 B' F#include <linux/types.h>1 S" U1 s- I, ~* s$ R" R
#include <linux/gpio.h>
- _& K; I1 ^- X5 n#include <linux/leds.h>
- z: a' m  r5 a! H, _; p2 ^8 ]#include <linux/platform_device.h>) F5 }: @6 A3 U3 }
$ F' q; a6 @& j0 ?% R) }
#include <asm/mach-types.h>, P5 l3 H- {9 E$ f$ G( d8 s$ z
#include <asm/mach/arch.h>' g& B! g- ^, k; u
#include <mach/da8xx.h>- Z/ B! h0 O5 Q, i/ {. I' S( f
#include <mach/mux.h>. C6 P7 E% V  Y

( E) b/ ], l* [$ M( B" ]; c9 h* U#define DA850_USER_LED0        GPIO_TO_PIN(0, 0), M3 `6 }- A7 Q( U2 B" N
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)- q- C  r! z% t" R6 _  ?
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
+ P) V2 i! ^  d8 b& `$ @#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
. B8 r- g: g: ~2 r2 ^$ G: ?: F/ E: d( x
/* assign the tl som board LED-GPIOs*/
+ |. H8 [8 S0 L5 Z, M9 K1 b5 ]+ Kstatic const short da850_evm_tl_user_led_pins[] = {
% D* Z8 c- i* s0 E  c$ C1 ?        /* These pins are definition at <mach/mux.h> file */
" k4 @# `% k. t        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- a( V' E( q8 V) E  P: ?        -1- Z* B  T. Q; W+ y) r" Y
};8 U  R- H$ H: S
6 ~/ z& ^9 _0 l- S. l7 a
static struct gpio_led da850_evm_tl_leds[] = {
- E% \( j4 ~. J" r* Y        {! a6 @! z8 z: R" }1 ]* E
                .active_low = 0,2 k" F: c  R' b# `& T$ C
                .gpio = DA850_USER_LED0,
4 y+ }; y! U9 H5 e+ S2 n                .name = "user_led0",
# a" K& O% G7 w8 r3 L                .default_trigger = "default-on",) c* v% K/ q' H3 i* L* U
        },
$ z% C3 c6 L) z        {
5 ~1 V- f: I8 ?: d                .active_low = 0,
2 b3 u4 d$ Y% C7 u                .gpio = DA850_USER_LED1,! m( k9 @2 y: F" e& ?
                .name = "user_led1",
7 a* F6 \* E0 ^                .default_trigger = "default-on",
4 p$ j9 T- K9 G( k2 c7 N        },
- n0 e4 Y- g8 F4 }( k9 x4 f        {
, X5 H- N7 t* J8 J; x+ m! ~8 S                .active_low = 0,7 {2 J# }2 a4 l0 c. H" @3 O& P0 ^. C
                .gpio = DA850_USER_LED2,
9 H$ h3 a3 O* R3 c! V                .name = "user_led2",% o. N* N9 ?3 z2 g. X
                .default_trigger = "default-on",
5 I0 Z4 G- _, K6 d) O- E. l7 c        },
; y! |  w4 U) c+ |2 q; v        {
7 k( H* g. h" b# y                .active_low = 0,- e8 ~( c5 x; r- W, s' X( n
                .gpio = DA850_USER_LED3,
* G' X0 ]1 V! e3 n( f                .name = "user_led3",: D$ i1 \4 p2 n# K- K6 q$ N$ M
                .default_trigger = "default-on",
* i; X1 T% c7 O  N8 ?9 x! \( B        },
& g4 E- w. w+ \! B$ W};
0 Y4 U; N( D% x6 A6 G& ^
8 u9 L: y9 z% T! q+ c( L1 z; qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% \, ]& U9 B, x        .leds = da850_evm_tl_leds,
8 M) m2 ?' ~" a! {        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* |, K% l; d( W/ R1 j& B: O" u
};& n# H9 _4 Y4 n/ X1 B

4 X+ b5 d0 K9 S4 dstatic void led_dev_release(struct device *dev)
9 `2 h/ u5 S5 j{( H/ Z% J& ^7 t9 a* e, e9 `
};
4 C7 O, J! ?6 C. u% Q7 E+ c" M% g+ l* \" O
static struct platform_device da850_evm_tl_leds_device = {; D( z7 \% {, ?: ?4 ^
        .name                = "leds-gpio",. Q6 B$ N' i8 m
        .id                = 1,
( j- |: b) n5 l' g6 ]9 R. Y( Y        .dev = {
1 [% i1 W+ y* p' l' q                .platform_data = &da850_evm_tl_leds_pdata,
/ c9 \6 N8 p9 V' b$ z4 V" [                .release = led_dev_release,, @: S; Z$ r6 z- h/ g5 B2 c
        }
  k8 j1 H  I, F};) d0 G' b, ]! P. F! R5 q& g

6 a9 A  ^+ @2 W4 _7 X. ~static int __init led_platform_init(void)
& ]/ r* x9 J  N% {# J4 J3 _{- ~) t# {# }! N  h* {
        int ret;
! }( W" w: n! A* N& \#if 0
7 c) A2 d; n- P# s' O7 C* \        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% M* k; ?" P6 {
        if (ret)% f3 b) ?+ w  ^* z2 \2 W
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! a. ]' B$ S; h                                "%d\n", ret);
" i' n+ H) H4 k: w# [#endif
# _# p5 V# B! u6 w7 C! j' O        ret = platform_device_register(&da850_evm_tl_leds_device);4 T- \6 B5 U+ k5 d, X+ G
        if (ret)$ q" ]1 C& H3 [
                pr_warning("Could not register som GPIO expander LEDS");/ o! X0 ?- o6 H: O1 N
        else& x0 ]# [0 t% z: n6 ~5 z: N& V
                printk(KERN_INFO "LED register sucessful!\n");: I  J4 C+ B5 M- P! ?3 i+ O

/ X; }1 w% ^, g( `3 k" |        return ret;
$ H' f! c5 O6 G5 U! D" a}
9 z( m' Y& {  l8 T/ y2 ~9 ~' y9 F
static void __exit led_platform_exit(void)
8 C2 V+ @' I4 N3 F{
, t8 f& ^' }& Y' F4 E& I2 R+ G        platform_device_unregister(&da850_evm_tl_leds_device);
6 ^; K* b: J- ]# I) i7 g0 o, T# G$ I& [# \$ Z4 ^0 k( y3 b' x9 h
        printk(KERN_INFO "LED unregister!\n");
6 t$ r1 N+ Y6 {}
+ [  D1 u9 d% F  f( n
, F& K% |/ |7 _& E, }* C/ f  v# umodule_init(led_platform_init);
% q1 F) R1 x! F/ b: V+ Smodule_exit(led_platform_exit);
" [7 X( J3 }8 ?3 f$ K
3 T6 Y& F2 M: Z) c/ F1 R& P# k$ j. C: o" nMODULE_DESCRIPTION("Led platform driver");; S# W7 l% {0 S' M, x7 _
MODULE_AUTHOR("Tronlong");
( s9 u! ~6 c/ |% t( oMODULE_LICENSE("GPL");6 h& Q# D) ]' n9 {: P5 Z$ }7 [
- W6 C+ D+ u* D8 v1 g
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-8 08:46 , Processed in 0.040286 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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