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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ p5 H. Y" \6 K6 S#include <linux/init.h>
7 @7 M  M* V9 s6 q  @8 }#include <linux/module.h>" \( _5 p, m) a/ x
#include <linux/kernel.h>8 W) {" p# J* K3 B3 J( H  a
#include <linux/types.h>
  H6 ?7 s1 t! f5 B' t: x#include <linux/gpio.h>5 b0 f& T) I$ l( O
#include <linux/leds.h>
( Y0 p9 j, B6 X. F% O" f#include <linux/platform_device.h>
( Z7 A! X2 e! \# N1 ~8 V: k# P3 d/ R9 l7 ?( t6 r
#include <asm/mach-types.h>5 s3 S! R7 i# q/ t3 y% a) b
#include <asm/mach/arch.h>
. R) U( w& Z1 y: M* ^. C: n8 L#include <mach/da8xx.h>
" ~& R& }+ s3 A9 G#include <mach/mux.h>- a# x6 a( L" q/ |; L
1 b0 o+ t7 e' a$ e/ ~# J: n
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)% M1 B7 J, C' r4 _. Z* y* r, w
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
( Z6 ?- t! }1 K; T% b+ n#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)$ O. w: @+ i+ `- P0 Z: J  N9 d3 F
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
& k3 k& B1 t7 |4 }
, @; m. w* n. [6 v) A* M. B/* assign the tl som board LED-GPIOs*/, i5 ^& g( [8 y. J  _
static const short da850_evm_tl_user_led_pins[] = {" n: h$ c; |9 A( Z
        /* These pins are definition at <mach/mux.h> file */
9 |" P0 m+ [6 {* P- [        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) U0 c+ |0 @- g0 [6 X
        -1
- h3 |/ d1 D* B! L6 _};9 c8 Y8 M! c; ?- H! U- Q2 k" I% V
2 T! o, e, @1 X  V; l5 K3 s# p
static struct gpio_led da850_evm_tl_leds[] = {# o# E- Q+ s: ?/ A0 |1 ^! C/ B
        {
: T0 W8 S  m( p) J: a/ x                .active_low = 0,7 B, U) z# _3 |" P
                .gpio = DA850_USER_LED0,( R+ ]( f, A0 s4 t
                .name = "user_led0",* S. N, T% Z! t, n3 D- z
                .default_trigger = "default-on",
" J, b5 K) |* V# t& b# L+ m, n        },  {! L( a" ?1 C+ q2 B, u
        {  O$ U. m% \3 ~& U! h  t. n
                .active_low = 0,
2 W9 A  D2 ~5 u- r/ \                .gpio = DA850_USER_LED1,& a' }% H, b- X
                .name = "user_led1",7 C9 ^/ [- `2 V+ j& o
                .default_trigger = "default-on",* E% I* _0 d" q# o
        },
! t) i6 z, D8 P" D& w! ~        {- I# l' }9 H1 l9 U
                .active_low = 0,: a7 _# v5 N: \2 {: O
                .gpio = DA850_USER_LED2,* o  S/ p9 S* k+ o1 I* h8 p, D& Y
                .name = "user_led2",$ H" u0 n; P! @4 B' D1 Q7 a' {' ?
                .default_trigger = "default-on",
# Y2 D4 U  R' T. C! t        },3 u7 A6 A  c& R; i$ q
        {, i. Q" ~+ f; n! Z. Z
                .active_low = 0,
' C- n* @+ g. @4 n& x7 u                .gpio = DA850_USER_LED3,' u# m: u: l1 M4 L
                .name = "user_led3",
$ |1 E& y& R9 D+ E& F1 m  R                .default_trigger = "default-on",* p7 f, [: t6 V( C9 I" Y3 z/ W! e. l
        },
" t: I, j4 J& T5 @' T};' M$ B/ x2 m' l: s4 D3 U
, J3 Y* e- n  y& Q+ D7 Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% \& o2 `6 r9 l1 U# c8 n/ @        .leds = da850_evm_tl_leds,
: R$ ]' ]; i" Q& V5 x        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, b# D& l8 ^$ F# n};$ S5 k' G  r, p3 r" t
% W8 j: ^& X: m* ]9 a
static void led_dev_release(struct device *dev)! u+ ?, J" A: L
{
. W: u( K3 }9 H};
4 v' R) Z5 o) i5 i4 I& d4 z8 C
& Y4 v$ W5 q& V# pstatic struct platform_device da850_evm_tl_leds_device = {  y# n4 W8 a) n1 b* s) Y/ `, a
        .name                = "leds-gpio",
0 D/ l! Y! U6 q* i: }  b2 E        .id                = 1,
2 i& i+ t2 I% j. |  |  L" }+ o$ _        .dev = {. B4 _$ Y$ |5 o3 z( V: ^4 [' B
                .platform_data = &da850_evm_tl_leds_pdata,! j% o* Y7 G% w- i
                .release = led_dev_release,$ f- v" ^- T& B) K* p& e, y
        }
3 `9 A. e( d$ u5 e};! a0 A/ _- x  u

, D# t* k; D# f% Bstatic int __init led_platform_init(void)
$ u) a. h+ d& B6 K) V% g' F" b{
' o; n1 x8 M/ Q5 L/ D/ n& ^/ k. O        int ret;
! t4 Z; e, X* ^; b- N: U+ s#if 08 Y3 n. q9 D5 g9 @! K5 n: }9 M
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! r- P% V- z- R" q4 b
        if (ret)0 V! r2 u( u4 I0 d* K
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( k' Y7 |( Y9 \7 h% t/ g% t8 p                                "%d\n", ret);' u& q& }* `" B2 ^( G" o0 o
#endif
* o( K  R2 s4 E7 j7 g. x        ret = platform_device_register(&da850_evm_tl_leds_device);
* R3 k9 l* r+ ]% d/ ]        if (ret)
$ v  F0 A) r6 |* `% N6 I                pr_warning("Could not register som GPIO expander LEDS");0 u( z# l1 M: n& J# L# B
        else# D% L8 ]3 t5 _. u  ?5 I7 \
                printk(KERN_INFO "LED register sucessful!\n");8 Y# h' o; f3 u2 R8 u  b0 f! P& x
3 _& f. m3 y& D* Q4 @
        return ret;
- z) _* [4 E; ~5 O' B}3 V% E' T$ m/ {, j, x) A
1 A# D, u( A' H' n
static void __exit led_platform_exit(void)/ J$ n4 R9 z0 |9 g) a- Z' c0 D
{  g3 q% T6 e+ L+ H# F
        platform_device_unregister(&da850_evm_tl_leds_device);2 z. h1 M7 f+ @& U1 l" Y7 y

" O$ S( h# B4 `+ _# o6 ?        printk(KERN_INFO "LED unregister!\n");( s  H3 R: A- d+ P0 S) S
}6 n6 y8 o4 _3 f
! g0 d* R9 t) I+ F' v8 B" L
module_init(led_platform_init);
# o+ [( b. i" B; j+ P. J% qmodule_exit(led_platform_exit);  k3 b2 t- q# A8 G& ?+ r; }
, E1 B" Q; n. w" L
MODULE_DESCRIPTION("Led platform driver");
3 r' o* p  k7 V% u: p' m2 c3 E) XMODULE_AUTHOR("Tronlong");
1 Q2 s& |1 H9 E% L% k, EMODULE_LICENSE("GPL");- U5 }/ S) P' p5 @# d
, E6 C% S$ S3 e! C7 ~
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-21 21:46 , Processed in 0.036840 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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