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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
# S. ]. k8 d+ y#include <linux/init.h>8 t+ s$ g! k9 b0 U- d$ ~& N7 W
#include <linux/module.h>0 k7 H6 _* m& O. Z" ]7 [3 s
#include <linux/kernel.h>
& r5 c7 _3 n9 R0 m1 }( X#include <linux/types.h>
) B! h; L7 ^! L5 @0 U$ M: O( Q#include <linux/gpio.h>
- n7 e  m; h: a, v( j#include <linux/leds.h>3 e' ], J( U! ~/ l
#include <linux/platform_device.h>0 y0 F; P$ M) m  `; Z( x$ G$ J
9 D& W5 f" V2 S' e+ m6 `. @
#include <asm/mach-types.h>: e, X. i: x$ z
#include <asm/mach/arch.h>- F; a3 P" E0 Q, C
#include <mach/da8xx.h>: t6 y# S' r/ R. I5 l9 v
#include <mach/mux.h>' A$ G- C( r& {. h" H5 _
3 s$ i4 L% x2 u% V
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)# d/ H& B5 h2 B' E) _
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)2 \8 h$ b3 Q( A9 n& ]! V; b" h
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)5 ?( a4 E$ X; L5 \
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)0 _! q" R- n: o, D9 [5 u
% d! ~8 R  ^8 j1 ^
/* assign the tl som board LED-GPIOs*/) W1 B0 z! H0 k) P/ ~# ]6 }
static const short da850_evm_tl_user_led_pins[] = {3 O5 J) N' Q& s; H& y
        /* These pins are definition at <mach/mux.h> file */) v# g0 \0 H! P6 e3 H* E
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ m( r5 Y; v( e! v) W        -1. `/ v# U% N- z  q
};6 u! W/ H! }: x
4 j( X1 ^4 e& i
static struct gpio_led da850_evm_tl_leds[] = {
0 a7 C2 P$ O' I: }        {, o3 f; M) ]' K
                .active_low = 0,
) ~+ U' B; J. V& ^. j                .gpio = DA850_USER_LED0,
# v7 w& Z! V' q9 l                .name = "user_led0",
8 T, k7 h9 A  z3 N                .default_trigger = "default-on",
. ~  s" L7 g  U        },
: ^( s3 E! _3 w: r        {) x- o' q" T. ]+ G$ u" X
                .active_low = 0,
( e9 C& m4 b, k0 ~$ \                .gpio = DA850_USER_LED1,1 y$ T8 u) C: q8 A
                .name = "user_led1",
- ?* h: {& K1 e  o% ^                .default_trigger = "default-on",
: e( V# @" w" @8 ]4 F        },
& z- v8 f. n, Y+ B& Y2 l        {
8 a3 q! X. }6 B4 N- `2 N) Z+ i' w                .active_low = 0,3 g1 A' o: S  U; n5 U- F
                .gpio = DA850_USER_LED2,9 d/ }: c# X) B2 r+ z. t
                .name = "user_led2",
9 ^! y& `7 m* q# |                .default_trigger = "default-on",
8 x# w. O$ E9 g. ?" _9 q& U) E        },
" Q/ B3 x$ c( k# v' c+ ]4 C& P        {: F6 g% H2 ?# X
                .active_low = 0,$ `& d: Q3 A# a, R# C
                .gpio = DA850_USER_LED3,
! c' y# W; N7 ]% x- q                .name = "user_led3",+ B7 h- h. b& u% ~& R
                .default_trigger = "default-on",
9 Q  _' q" e+ U+ L, C  Z        },
" o  ^/ O5 q% P' _9 I8 J0 t};) P1 g- _: P' Y& x: \- @. e% M( h

7 l* c/ v3 ~, |7 [9 q, J- mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# R- [& t2 s/ o7 C% ~$ t' ^: z        .leds = da850_evm_tl_leds,
( ?3 [) C- q' D1 e! A        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 V! a# s, a0 ]6 z8 Q3 E};. v7 u% a0 l% v' ~  F

' `1 y: {$ B9 t$ O. ?5 Kstatic void led_dev_release(struct device *dev)
  q3 e5 e. t* |1 }; y{1 e3 V0 @1 ^% ?
};
: C+ e* y% V% v  A: m1 }% h, |5 d2 K  m
static struct platform_device da850_evm_tl_leds_device = {
- _# F2 \, c8 A; Q1 q+ a0 m( h+ M$ {        .name                = "leds-gpio",
8 B! |/ ~+ X9 ]- U3 k, W        .id                = 1,9 L: Y; ?/ r) L1 y
        .dev = {
* d- ?0 s; a$ Y                .platform_data = &da850_evm_tl_leds_pdata,
6 l* L* I& z# }: o$ A                .release = led_dev_release,% W# O$ c4 s+ w; O, D! t0 m) m. n" x
        }% d* g2 l6 G6 n4 \; j! H3 ?
};8 ]% f5 d) Y+ R6 G( h! |2 U
* ^1 d9 `+ W/ `( p3 X
static int __init led_platform_init(void)
, C; w, P" H0 f2 T{
0 i# U1 x+ b- J. l; v4 P. @        int ret;
$ I( `; G- S3 E3 @. k) T: u) f#if 0( v6 _+ k! U2 \& S( {
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( s& S) w) \8 q7 j$ N7 k        if (ret)* n7 f7 v# J& m, L( L) b
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 e  C' `- ?  f5 j( d                                "%d\n", ret);% ~% x8 A# ?% y6 i
#endif
3 k3 L$ [5 Y1 ~: f  S9 B        ret = platform_device_register(&da850_evm_tl_leds_device);
2 U9 q7 q8 D5 B: ?- x        if (ret)
3 x/ V$ T) v1 i2 M6 v% {: R, J                pr_warning("Could not register som GPIO expander LEDS");: e% f6 F; O: u- Q/ G
        else
. O8 O3 v* n. T& l4 z+ ?! k                printk(KERN_INFO "LED register sucessful!\n");
. m* ]9 `  Y1 u8 C4 X/ N9 {$ D; ~% p4 h$ p
        return ret;
3 t! |. Q( S8 c8 D# V}
1 H3 n2 }7 H4 ~7 ]
. Q9 y  n& i; [- L* m& X, e# t7 Qstatic void __exit led_platform_exit(void)
% q0 R2 D' H" Z' z, e$ u9 n6 e{
1 n& e" e, F  }6 y        platform_device_unregister(&da850_evm_tl_leds_device);
6 h2 \. t/ t. o/ c
9 K7 A+ u5 J, a8 A' @        printk(KERN_INFO "LED unregister!\n");
% E0 g# s; {3 ^}8 W+ Q1 L; ^; x" O2 d# K& R

" o. D' Q: ?& Y5 \% T. A; imodule_init(led_platform_init);
  a+ j! S2 F4 d5 N/ ~! Umodule_exit(led_platform_exit);3 O8 ~/ u# _: d; T
/ P0 R+ N0 W7 R; S0 m" ^& c% @
MODULE_DESCRIPTION("Led platform driver");# u+ d0 U0 [8 p4 i8 l* S
MODULE_AUTHOR("Tronlong");
: Q5 o; K( ]- c  f# H$ y8 EMODULE_LICENSE("GPL");
2 X9 p4 ]3 ?5 \- T! ^9 `- l
8 D4 }8 [3 `+ F% |: d" W: i6 D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-7 07:43 , Processed in 0.037163 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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