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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ s6 t" O3 n$ u8 |! Q3 F5 V# |" A#include <linux/init.h>
) M  p; e0 F, F, @#include <linux/module.h>. h4 k7 K7 T& Y* n# o/ S# }7 r7 j$ h
#include <linux/kernel.h># d0 W' x7 J, m) l# l6 @7 K
#include <linux/types.h>1 Y( K' p' C/ R
#include <linux/gpio.h>0 m% ~  e3 [& _3 N, \/ A9 b/ t8 A
#include <linux/leds.h>: P  X' J/ O3 a* w2 v/ P
#include <linux/platform_device.h>% X" V. Z2 n( C/ u# |  _; P* \
# E" M7 q' W/ N9 b
#include <asm/mach-types.h>2 B7 ]9 J% z$ f. n3 t+ \
#include <asm/mach/arch.h>
; V$ \4 `7 |5 g% y#include <mach/da8xx.h>% R. n3 a5 R6 g7 o! \6 c* k
#include <mach/mux.h>
0 g5 R6 a2 k3 M3 a  P" V0 Q# i- y
: j8 P% V: U& U. j3 k0 K* P% O#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)" ^. t  n; K8 I3 j1 P- v: B1 `3 B: T
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
. b2 Z) T7 W$ Z9 Q8 ]6 w#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)+ }$ [% B$ b& I% T+ f+ m8 \
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)6 R: t3 M/ b: a; y1 C: _
+ j; }7 H' B' ~3 j- l/ J
/* assign the tl som board LED-GPIOs*/
+ ?6 N; g% L" Fstatic const short da850_evm_tl_user_led_pins[] = {: F& J3 ?( `7 C
        /* These pins are definition at <mach/mux.h> file */4 M: n7 m1 `( t# l& z" X
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 l! C% l' H+ G" q        -1
. j9 K* i' T) J};6 f' F/ k. ]# x2 n
0 N  D6 t+ _" w: K4 V( r
static struct gpio_led da850_evm_tl_leds[] = {5 c+ n; l1 a! Z# e' P
        {# ]4 h3 r1 k  Q+ Q' N% F
                .active_low = 0,2 U+ X2 u% D1 _8 A0 p
                .gpio = DA850_USER_LED0,
  R7 Q9 C& T) @, g/ u                .name = "user_led0",
' U* T( P0 g- q1 Y                .default_trigger = "default-on",
  t- d; u0 W# }: _' m        },
0 a5 R% R, T% ]# \5 D4 O8 p        {, ?4 v3 {% ]! `0 P2 Y
                .active_low = 0,7 w" v5 U0 P/ u& }# c
                .gpio = DA850_USER_LED1,: p! P/ H" d" \4 V8 o
                .name = "user_led1",# W) P. s# Y6 B4 i
                .default_trigger = "default-on",
% K4 ~$ `; Y& z4 M3 P        },+ ]/ M) V7 J! ~& s0 v
        {/ g9 Y! f, `, C# g
                .active_low = 0,! i, P9 g  x. w+ r) S" N5 A* ?/ _* L
                .gpio = DA850_USER_LED2,- Y) |" E- {4 i$ r5 F( w% I5 U4 d
                .name = "user_led2",5 P: k% c7 C. M% @# }- `+ n
                .default_trigger = "default-on",5 o6 B0 k9 Y  b; g* o
        },8 P  @! a" |, X9 X0 A+ {9 I
        {$ v. {4 Q. ~. q( ~7 r4 \
                .active_low = 0,( |8 ]5 A0 o! f. Y$ x& r1 Y! n
                .gpio = DA850_USER_LED3,
; {' m2 D% p+ y: V  H                .name = "user_led3",  L+ K; d5 S$ V6 y0 ?+ A) t' n
                .default_trigger = "default-on",
3 {$ S2 j6 l- W0 {* G        },; \& |$ D7 h& p1 ^4 m" u5 L
};$ y3 g" y* ~9 ?# Z0 e- U2 u: ?. m2 i' X
0 q, J5 u: E9 N) K& M5 o( x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ Y% P& k6 X- u3 Z
        .leds = da850_evm_tl_leds,
5 u6 d2 p$ N. H+ j3 ~        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. z$ c; i. P  Y6 E7 b0 n4 I1 V
};) U2 c8 c- D% d: F) ^) _/ t2 @% R
4 f; Y% J8 x* N) {
static void led_dev_release(struct device *dev)
8 H6 x3 |6 i4 {9 ]$ e; j{
: N  X# h, p5 T; }' u};, s/ x  W4 T# X) a4 y% @: G4 Z
% x8 G$ \2 S3 d) k/ C! C4 A3 m
static struct platform_device da850_evm_tl_leds_device = {
# _: [1 k8 r8 i8 c& H        .name                = "leds-gpio",
8 }8 y# B: h# S( K0 y8 L1 j% M        .id                = 1,
; J; s9 O9 D8 @" N  j        .dev = {5 ~, o' M- o  X5 p1 B. _
                .platform_data = &da850_evm_tl_leds_pdata,
% ]1 \% C  H) Y+ o; f                .release = led_dev_release,7 |; m, d; q0 {( r" }9 l
        }
" K3 Z2 Z" @; b: l/ ~$ X};9 N& G8 c! V+ x% a: C7 e
( U1 ]! S$ J* _0 Z
static int __init led_platform_init(void)& W: X3 Z0 F; s! O
{1 F  A+ N" B8 B+ {; }
        int ret;
6 [8 e6 B3 H% l  V#if 0
3 l9 A/ D; a4 B; d! b( `6 A        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) ~# u+ S. b! c$ w- ~        if (ret)4 T" D9 O, s$ J5 g( h* O
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 m: H: V  @, u8 F1 k+ o                                "%d\n", ret);
% r- I+ ?1 |9 [5 p+ W% d8 m#endif
$ ^" T2 r) O5 a" I        ret = platform_device_register(&da850_evm_tl_leds_device);; w( j7 E& ?. o/ }# u1 |5 m% E
        if (ret)
+ r4 R$ h. g( X, p0 K, \) F+ ^9 S                pr_warning("Could not register som GPIO expander LEDS");
  I) |* g+ O# j* ?& y# M        else
/ F: _$ o* p% U                printk(KERN_INFO "LED register sucessful!\n");
' q5 k6 w! q4 k. Y+ Y" }+ `: W* i& ]; H$ D+ U* a
        return ret;
0 V, B# Y1 V: d" k# J}
4 R2 g' K1 \+ Z& e+ R
4 s( J  k6 N: D3 sstatic void __exit led_platform_exit(void)
! T6 |- W3 f5 a! h2 x3 Y& w{4 V! b/ @" f& a. [$ u; l
        platform_device_unregister(&da850_evm_tl_leds_device);  p6 U9 r9 {! I

) H9 ]8 A4 K( o9 \5 W* e& [6 A        printk(KERN_INFO "LED unregister!\n");. Z" N$ V) G1 ]' `( q; u
}
' |$ b0 Y2 S( o# W1 r% o4 Q/ N
+ p# ^& X# B2 s2 _- smodule_init(led_platform_init);. W+ j  |. q/ o2 _
module_exit(led_platform_exit);" m4 O  u' v  u! k/ I$ Q9 O* }1 ?

. v( p# A; U2 C: j& w$ Z. RMODULE_DESCRIPTION("Led platform driver");; o5 @1 q  Z# n3 H) i, j' m8 T. L
MODULE_AUTHOR("Tronlong");
9 ?9 I" Q/ J0 ^$ OMODULE_LICENSE("GPL");& v# H* d4 H/ B+ t  `
$ p! v* y. C& v: [4 }7 `
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-30 19:01 , Processed in 0.040517 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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