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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
. c9 A/ [: O# b9 I( K$ F! l#include <linux/init.h>3 x- p% [. f$ `; L) x2 n. U, K
#include <linux/module.h>* I$ ?9 R, s5 U3 e( e# D
#include <linux/kernel.h>
, v& m% a$ V3 ?5 e9 b+ v#include <linux/types.h>' i5 q: C8 |4 C# s* K
#include <linux/gpio.h>. z; e0 i; W+ Y: l$ z" f' _/ a- W
#include <linux/leds.h>1 u4 k* U) [  L( |
#include <linux/platform_device.h>" m: o0 h6 P. }2 x$ S# V
: _1 W2 t' W; E. d
#include <asm/mach-types.h>9 p7 F0 O6 ]( E. U( a
#include <asm/mach/arch.h>
% I) y" [* b8 W0 L' ?6 i% }0 r( F#include <mach/da8xx.h>" y( J8 a# D5 h& v$ L# D
#include <mach/mux.h>( \; `8 w, O3 r
0 C6 h3 R  O6 n' b( O
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
* z0 t# ?7 L" _% W/ }% d1 c# d#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
0 y* P5 E) O6 n9 S) ]#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
. R7 U) }- _) c% [% L5 z#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
0 I9 b% p0 K5 f, \
9 a, t. ?6 x' ~# q- E1 |/* assign the tl som board LED-GPIOs*/1 V: ]2 n  x2 c! B- o/ u
static const short da850_evm_tl_user_led_pins[] = {4 O2 s) \- S# j& D+ }( t
        /* These pins are definition at <mach/mux.h> file */) X9 n6 T* t6 @6 {5 R" [- E
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( W$ s* P0 V& C
        -1
  d1 y/ ?4 ?& d$ ~};  R9 y) D1 V9 n1 J

8 G# k! |+ D$ u1 Q+ bstatic struct gpio_led da850_evm_tl_leds[] = {! D. v, z+ ~# v8 f6 k  M; e
        {' j1 g3 C$ y& a! [
                .active_low = 0,
& L2 z7 k) F- H' I# a$ G9 E                .gpio = DA850_USER_LED0,4 [: @/ N% ^( ^
                .name = "user_led0",( z- a* f, j* A- \
                .default_trigger = "default-on",
7 s& w" r' y$ Z5 j        },
5 L" ~  o* O$ r; g; s1 Q        {
5 E" \4 g, I( x8 [5 R3 k. \* o                .active_low = 0,
& Q3 X% u) k" n' ~* G9 t                .gpio = DA850_USER_LED1,
" Y2 L6 z* c' r# w" L* g                .name = "user_led1",
/ S6 L; i: g. b; T' w                .default_trigger = "default-on",5 L' c. j9 \7 |* x% ^
        },& Y6 ~0 n& b; J7 ^% y! W: w
        {
- B+ d% o" t* T' f7 C# l                .active_low = 0,; a' n$ p/ V7 K- h/ t
                .gpio = DA850_USER_LED2,
  M2 @0 l* s2 Q# \& Y" u: O                .name = "user_led2",) k5 o/ `8 m- b, w4 ?
                .default_trigger = "default-on",, ?% @! h+ O- r% b7 c/ A9 d9 A
        },
/ i/ W1 m) Q& C1 s  _8 A        {1 `4 `1 Y2 J& u3 m2 X: S
                .active_low = 0,) ]0 R- O9 P1 n0 [2 n1 v
                .gpio = DA850_USER_LED3,
& ?7 S& H! X7 `; [                .name = "user_led3"," l7 @6 T  y! z- {6 I: c
                .default_trigger = "default-on",# e# J; t" O% n7 a( a
        },! V( C, G( M" b: K( t6 p
};- f; p, Z  z5 n

3 E* E% a6 x0 J' Y2 E3 v; e: }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ p* \1 m. {5 Z  d8 c8 \
        .leds = da850_evm_tl_leds,
- Y( F% g7 p& [. S: g, J% o# ]! r% f        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 e3 Q3 S" J4 \& B6 P};
' R1 F, M7 f* i
. i) |% Y1 V' ~; d- _9 u, A7 }; ?9 ^static void led_dev_release(struct device *dev)0 e0 M! R6 I$ H6 \8 l$ I
{
" X2 J6 D+ X- l, Z, k! }( r};4 C& V+ x, w9 {7 i; Y, F

, {% ]6 B8 n$ Fstatic struct platform_device da850_evm_tl_leds_device = {
( p- p2 {% G2 ]9 t/ A5 |& y2 g        .name                = "leds-gpio",
1 A% G2 I  V4 M: ?        .id                = 1,
/ x7 j; a2 n* ?. t- M  ^        .dev = {( Q, r* ]5 B+ `( z, v
                .platform_data = &da850_evm_tl_leds_pdata,  I, a7 X( J4 w! e
                .release = led_dev_release,
4 L' N6 M( @; o1 I* v8 s3 c% v% P6 g        }; e2 v  u, B! {8 s5 t: [( \+ E
};
5 C3 M$ N! u; @, u
0 K1 h& f4 X( i2 Z* u( ^static int __init led_platform_init(void)! C! ^% Z5 M, W) I: c3 A
{- }* u# N3 o7 j7 g% \
        int ret;" @  h, i# `2 {* Q! L5 o
#if 0' h2 W& A) o# G0 o; B/ Z) }
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 ?$ S* M( H. O5 k5 i3 b( Y        if (ret), W3 y. ?# _$ o" s" R: G3 Y
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 y, S% a' R7 W; a+ [
                                "%d\n", ret);6 e/ r% |+ Q7 K
#endif
! H0 E+ k& D- s' `! _' h9 }        ret = platform_device_register(&da850_evm_tl_leds_device);  K6 R$ l: _  s/ p
        if (ret)  ^7 f! d& V( Q. S
                pr_warning("Could not register som GPIO expander LEDS");
7 }7 m/ y  C' ~( Z( N        else8 U% E6 B1 |8 Q9 h8 `
                printk(KERN_INFO "LED register sucessful!\n");2 |' m8 D8 u' A5 X1 P, p

; s% q  H+ u. n) f, o        return ret;  G5 }2 [: ]: ?) Z% O
}2 D+ |" n% q5 Q+ u" p$ k  K

% \) M0 w+ Q1 Gstatic void __exit led_platform_exit(void)$ q) _9 ~5 s1 l; ]( Q
{
# [4 X# ?3 D0 @4 u. H; r        platform_device_unregister(&da850_evm_tl_leds_device);4 ^  V( m4 n8 C* d

9 Z0 E; _. @8 u        printk(KERN_INFO "LED unregister!\n");
+ W! [8 g0 z8 O7 r: P}6 C/ r, g/ }% ~* V" I/ J  L

( Z/ {9 q$ W0 Emodule_init(led_platform_init);
) Q" d8 @# d5 e" Fmodule_exit(led_platform_exit);
% U2 J  @7 r' a' ^( _
$ q8 A0 R% v3 N2 F  T2 f0 ?; `8 G6 pMODULE_DESCRIPTION("Led platform driver");5 _- ~( I) V3 v4 e8 L; y. I% d) k% P
MODULE_AUTHOR("Tronlong");# G; K& k0 p! P2 r: y2 x
MODULE_LICENSE("GPL");
7 |9 _4 x; L( p' M& i: ^
* T% H1 }0 ^5 i( w6 z  J2 q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-19 02:20 , Processed in 0.043436 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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