程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
  H+ m4 L( |! ]6 m; h% w1 e#include <linux/init.h>
  W; H3 J8 i5 y" m: q#include <linux/module.h>
7 c8 M: f& [( G" z9 t1 Z4 o( r! \#include <linux/kernel.h>4 Q1 O5 r) u3 x2 W* k7 W$ B
#include <linux/types.h>
6 A5 O9 \4 T6 v2 B; |4 y- ?( d: t4 [#include <linux/gpio.h>: ?% r, ^6 ^3 H
#include <linux/leds.h>
% R8 [: V" ?1 J! W0 E#include <linux/platform_device.h>9 y% }# C* V5 o. b% X9 x

3 D  o7 v6 H% J# t8 @7 R  T' A( ?, p#include <asm/mach-types.h>5 B, i+ ^( E) Z+ L! _6 q9 @5 [
#include <asm/mach/arch.h>
) `, @' Y  y# e) }* ]5 a#include <mach/da8xx.h>
9 }) w! }2 d( L& o/ e3 [#include <mach/mux.h>
4 ?! j: Y4 C( N. j
8 H8 K1 c2 r  u1 E: C#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
, Y+ T. z1 b7 H8 B#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
! t' O% \$ j5 ^7 E) B#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)2 h2 B% O- C- a6 g5 G
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)6 ~( p" _  }# l; g8 Z# \, f! t
- f9 c4 ~6 D1 e$ i8 N' E
/* assign the tl som board LED-GPIOs*/2 b7 `6 e5 U/ _+ q! k
static const short da850_evm_tl_user_led_pins[] = {4 |& G  \' ?6 f/ ~9 ~! _1 v
        /* These pins are definition at <mach/mux.h> file */
# C% Q( y. |, S) R        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# d0 Z; v5 i& M) `) y        -1
! ?5 I4 h2 `& i( v  b; r};- A7 _2 D( G: o  Y( r& \" U

! ^4 n2 C1 P0 J7 qstatic struct gpio_led da850_evm_tl_leds[] = {
$ V$ `& `4 o- Y1 v2 B: J. f        {6 T) ~( D1 g7 q; Z. q" C
                .active_low = 0,
/ ?3 P$ c  J9 Y- G- D; j- T5 `, a                .gpio = DA850_USER_LED0,
6 q9 B9 T" Q0 _& v$ O" p+ U                .name = "user_led0",
1 u. N" N0 B6 ~  P* W3 K/ W: B( h                .default_trigger = "default-on",
7 X( q7 d& P' N        },3 V8 B8 N% @# a
        {
$ G, |$ A( J. ^2 x                .active_low = 0,, N5 B+ f1 t6 Y4 H) `- K$ R! X
                .gpio = DA850_USER_LED1,
7 j. \% a% f; U3 A' @5 G: _+ {0 l                .name = "user_led1",) Z- o+ x0 Z9 h6 s7 c  y. B
                .default_trigger = "default-on",1 ?% Z3 A8 q5 T0 A0 n
        },& T5 i* O) n. S7 w/ }8 z! \- a& u
        {
3 M. g) `+ d. q6 ^                .active_low = 0,: z" ]8 h1 h5 U9 Q$ Y
                .gpio = DA850_USER_LED2,3 I+ f: C7 [1 @* E5 I
                .name = "user_led2",
, G. l! c' P& M: g                .default_trigger = "default-on",! P4 |/ ^6 F9 e
        },- _" o' `+ ?( {0 N' Z3 y& X0 k
        {
. {, d" `; p/ K; _  N$ h% q                .active_low = 0,
5 x. Z9 }/ @- l% ]4 E4 A0 y! P                .gpio = DA850_USER_LED3,0 j+ D7 M. B5 C9 L
                .name = "user_led3",
% q# N5 M5 I) ?! O  l2 k/ e( E                .default_trigger = "default-on",' D9 J: ]5 n+ g& ~0 {4 G
        },- V& }# ~( n+ Y$ u# i' x- S
};
$ c% k+ L' Y' K. [; N' O  N$ E
9 w$ w6 f4 V7 G1 q% G! estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; F. Y+ Z: \" G, M5 d% V
        .leds = da850_evm_tl_leds,% U) i2 I& F9 T% X6 L5 d
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 ]# o5 t# y* T5 B7 Q% s
};
5 x9 C  x( V- B, F  K$ t9 r$ F% z5 K8 g6 f. U( n
static void led_dev_release(struct device *dev)
  r# B* n" A4 K{
& i5 C. C1 A3 E# r% ?+ u};3 A4 |+ S5 k$ J) r* F

; w; v. @% y" B0 hstatic struct platform_device da850_evm_tl_leds_device = {2 }6 X9 ~, P% b7 W& \  G
        .name                = "leds-gpio",
6 h& b3 ?- A& x/ F* A5 E/ a        .id                = 1,
4 x& v* s5 d0 j9 O5 y        .dev = {
& \- x: \* g  \6 V% z                .platform_data = &da850_evm_tl_leds_pdata,
% M, D5 d! Z/ k8 n                .release = led_dev_release,  q' q9 O  a7 m% |
        }* n3 b5 A/ L1 L; H6 @
};( _+ ?' z% K) C; X
8 j3 e$ f& L* D
static int __init led_platform_init(void)* ^: U% r, R: s. R5 X( {, ?
{
. |: e# F8 b1 Z( ~        int ret;
5 F& @, y  _2 Z6 ^3 B/ h' Y#if 09 [* i9 i7 `) \' B, O
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
  h+ M9 O4 {2 q) a; s! f        if (ret)
7 L0 N$ S8 a, M: f3 f$ u5 v, K                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ B9 }+ w& V1 T& ^
                                "%d\n", ret);
/ H9 Z% H# o, H; y#endif* S3 w4 ^+ ^4 U6 a: q  J! L; a) |
        ret = platform_device_register(&da850_evm_tl_leds_device);
* O4 ], @3 _; j  D" K' p4 E. K# C        if (ret)% L4 t; }/ R0 c/ O4 N
                pr_warning("Could not register som GPIO expander LEDS");- B: H2 u/ G- f, N7 ?. W
        else
9 g$ c, E( t! j6 \- u1 [                printk(KERN_INFO "LED register sucessful!\n");! s3 X+ @0 E2 s

2 x6 ]! Q) k: G1 W/ I5 E        return ret;8 e8 g$ L$ N- L5 j6 v( L$ a
}
! O% F' f# }. f' K! a
5 y! r8 E' f) `6 ?static void __exit led_platform_exit(void)
' ^7 |5 {6 H' O- [" Q{6 z4 {/ `5 s8 x
        platform_device_unregister(&da850_evm_tl_leds_device);
) B" p0 `# h# M" W/ d! z. G* [
4 x5 A, p8 r( a- f        printk(KERN_INFO "LED unregister!\n");
, g  G( b) N3 i$ R: u}
7 j/ g1 \4 Y+ O
5 _+ ]4 J; G7 Y7 I; V$ n# u& Kmodule_init(led_platform_init);" ?2 Y/ U& m7 |/ z4 x
module_exit(led_platform_exit);
5 A7 h6 w4 q6 R! y5 [- f5 @* P4 l. q4 s
MODULE_DESCRIPTION("Led platform driver");- K9 M2 o4 j2 D4 k
MODULE_AUTHOR("Tronlong");
, I1 w" v7 X0 O/ r8 p7 M/ \4 iMODULE_LICENSE("GPL");! j/ x  t4 f4 |7 U! t2 i4 Z* G" g

0 O% V- X/ y/ v6 Z) _9 |3 l% F4 z1 y$ |8 Q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-20 21:42 , Processed in 0.060017 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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