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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
" u+ L* Z- R# g$ |: k6 x  L#include <linux/init.h>5 B9 W  `% D* _( R( U' f! X
#include <linux/module.h>
: u6 F0 ~9 I( a# O9 M7 |#include <linux/kernel.h>
/ y- a! Q7 b4 C8 ]5 H2 E0 e#include <linux/types.h>1 @8 F3 T- ~! ]5 h- Z3 f
#include <linux/gpio.h>
6 a" M. Z  g+ L6 f4 k#include <linux/leds.h>9 S: Y1 g- h4 H5 i
#include <linux/platform_device.h>' c9 l# t% B, h
$ w4 N2 x1 E, a4 b3 y
#include <asm/mach-types.h>
0 |" a% M9 }6 e% ~& L. @- s; Y# r7 Y#include <asm/mach/arch.h>$ a, `( d. W; p; D' A  ]- L
#include <mach/da8xx.h>$ e6 R$ a4 _& n" S: S! B
#include <mach/mux.h>
1 ]- \7 o: T6 x# F7 [3 D! P0 Z- C  Z" f/ T
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0). ?) m2 l' x5 a& w7 D$ `: d
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)1 A4 n1 ~, U$ y& l, b' ]8 ]8 `* e
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
" a  l0 g, [( h#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 n& q) v8 y' u( K2 h9 j4 t$ k
4 A& M) P$ s9 w; Q2 ^. X
/* assign the tl som board LED-GPIOs*/+ J% }" E; Z) C9 ^
static const short da850_evm_tl_user_led_pins[] = {2 P" t5 B& C- D8 E% \9 _" p) k
        /* These pins are definition at <mach/mux.h> file */
) u+ {0 }# p" ~  _( [4 {        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 L! k$ v* N" {0 J
        -1! p- _( c) I, _/ K
};+ v" Y3 _/ J" z: |' S

; x4 |; B: Q! _: Pstatic struct gpio_led da850_evm_tl_leds[] = {
/ S7 C  {+ A- U9 S        {
# C2 P7 [5 l, t5 W8 U                .active_low = 0,4 c. `& o: z" x$ Q  C) L
                .gpio = DA850_USER_LED0,& h4 Y+ N, q+ X) }$ l
                .name = "user_led0",
5 R( u% W9 u% a3 N+ x                .default_trigger = "default-on",  B0 y; T9 b7 o. u; T* M8 \
        },' {: R" |" w( X
        {
1 v; g3 M" e3 N' _                .active_low = 0,
$ _# z0 H8 C7 _% n1 M                .gpio = DA850_USER_LED1,# Q! r( l0 ^! ?) [2 D
                .name = "user_led1",
5 U; q+ ~% W) }                .default_trigger = "default-on",5 O( V3 u# c; }
        },
% \" |, s, N. E7 ~        {
; c# Q& r. I$ [" U                .active_low = 0,
( j5 N# O1 D1 w( r/ f7 s- D3 a* |  p                .gpio = DA850_USER_LED2,
1 B4 g) F9 T; o                .name = "user_led2",
$ F3 p" @' H  C& Y* o                .default_trigger = "default-on",' Q, E$ I, K' r. B' _- N7 q
        },, S3 `4 A1 G* L6 C9 H9 k
        {
, M1 r# k( }. h* L                .active_low = 0,) L- i* G" q9 \# q, x( E
                .gpio = DA850_USER_LED3,
5 I+ p) @3 t" f6 ^- F: o5 z3 d+ ?                .name = "user_led3",+ t! F+ _7 z3 g) c6 O, f" H+ o& W3 w
                .default_trigger = "default-on",
' x4 [; E" l* |+ S& a        },, C7 }  `/ F, [1 {2 P  b  z
};
- u+ N2 W5 O2 q* W) w# O! }8 I# c3 Q% G. }+ p& a2 ~! w
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& l% H: X3 c( R- c& Z        .leds = da850_evm_tl_leds,& K( f- W" L0 e: g& o) l8 E! q
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 a" u' I+ Y2 l9 T$ c1 n* V
};
9 T- s* ]. e+ Z$ Q, a7 Q. _; X8 ?! N3 w& z) ?7 R
static void led_dev_release(struct device *dev)
( N- N" z% W) W1 E7 J0 V4 H{2 W5 \! c! n8 G
};
: \; p- e9 N  z" w" Z7 n" K% m/ l' J0 |3 n; G
static struct platform_device da850_evm_tl_leds_device = {) |% Q+ [+ l* j& q. I: @
        .name                = "leds-gpio",4 Z/ H% o: i: N% R, A! i- L/ X4 g2 b
        .id                = 1,
  o& G3 L# N' ~, V0 ]        .dev = {# g( U9 e4 L) t
                .platform_data = &da850_evm_tl_leds_pdata,
$ _/ j1 O) M  C. {2 E% p/ |. b                .release = led_dev_release,8 D- p" ~- ?4 [- a: s* M) H. ]
        }
$ |6 x: g( e5 Z# A6 N. ^};$ ?  l! g8 q. L; i! I4 @( X
$ p2 U# S) u7 u5 m
static int __init led_platform_init(void)2 R6 i7 Z7 K9 q+ I
{
$ u$ O/ @- a; d+ p  E        int ret;
9 P) N! u' s; E- D! H6 ~/ N#if 0
) `  t) P* b4 u6 x3 w        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ c0 l" ]: T: {& U& ^- r
        if (ret)
9 D( h+ D/ \' I' X8 d+ \$ r4 t                pr_warning("da850_evm_tl_leds_init : User LED mux failed :") B- p- w1 i. g# D$ A$ Y4 u
                                "%d\n", ret);
) ~6 ?* u6 e  L) y#endif
! L/ S( u  ]' X% `5 _3 ?        ret = platform_device_register(&da850_evm_tl_leds_device);
' [; U5 E. v2 w3 Z* k        if (ret)
  b6 m4 V6 @0 \9 p' m' E+ J( ], [, r                pr_warning("Could not register som GPIO expander LEDS");
# v9 N* [* B4 P  l6 c        else
' O1 M9 b( I: l6 @6 V2 r( M8 J4 ?$ q                printk(KERN_INFO "LED register sucessful!\n");
4 h/ |1 e+ j1 G. T1 v4 D& I0 c/ f, h; P
        return ret;
: n; G! C3 ?. t3 E: Y}
0 a. o: \3 |3 X; s) o2 I
* h& H. y$ |+ F% [, D$ astatic void __exit led_platform_exit(void)/ F% C* H; o! U+ I$ n7 }$ m9 O" I2 F+ _
{
* U- g; U* f  E3 s9 S) }! V) W2 k- n        platform_device_unregister(&da850_evm_tl_leds_device);( s. b  l+ p) A5 `) n0 A
8 w" y+ W$ d' W5 o% d2 V9 @
        printk(KERN_INFO "LED unregister!\n");
5 r4 R- n3 \* O2 a}$ u6 }/ H! P+ \* n2 ]$ X
9 [) Y" N7 W3 d" W% H
module_init(led_platform_init);
# X9 v7 r5 |+ h  i% q5 M8 z- Vmodule_exit(led_platform_exit);( V- y" Q& D" z% s" [: a0 L7 n
: _$ l' o2 E! y2 L
MODULE_DESCRIPTION("Led platform driver");
/ t1 o( ]( B$ d5 O+ Q& t, ^MODULE_AUTHOR("Tronlong");) n) [6 @7 p" j3 o1 Y3 h' ]9 W
MODULE_LICENSE("GPL");0 Z; z0 j1 D/ s1 v! f5 B, B1 D

8 i* B( ~& I* N4 u
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-16 21:24 , Processed in 0.059043 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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