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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
  P/ {% _( q- \9 n$ T6 g- O. I% R#include <linux/init.h>
$ W! |0 Y* L/ r- K6 s) C( Y. H6 O#include <linux/module.h>
9 c/ _" ^2 e1 {#include <linux/kernel.h>
" p" N3 v* C$ `. K#include <linux/types.h>
2 y7 F8 k7 p  y: A' s/ d- J#include <linux/gpio.h>1 g$ [3 ~- i  P* H! ?& a# p
#include <linux/leds.h>
1 m' K2 ~: Z5 O9 j#include <linux/platform_device.h>
" ]5 ?3 K! g( \9 v+ S7 _
) n5 y* n; g, c) u2 g#include <asm/mach-types.h>5 N9 j, S7 l9 s: L8 J3 p) i
#include <asm/mach/arch.h>: n' m+ W2 R( r9 t# Y/ M
#include <mach/da8xx.h>7 _$ T. ]* j. m. p
#include <mach/mux.h>
3 R1 a5 w3 t8 m/ P" U. d# Z  C4 j1 B+ I* r1 i5 q
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
  U4 t! F; F9 n1 y#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)5 `/ l+ J+ b# e9 y, r. M
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
. E) I0 ~7 r- S5 o1 `#define DA850_USER_LED3        GPIO_TO_PIN(0, 2); D. K: a1 c& V  P( H! P* _* m

* r; y( l( X  ^( k/* assign the tl som board LED-GPIOs*/
4 j0 T  d# p7 R! ~2 j' bstatic const short da850_evm_tl_user_led_pins[] = {
: O% g; Y4 Y+ \2 I5 C! U" w        /* These pins are definition at <mach/mux.h> file */1 q5 q( z& `3 h( B  }4 }3 I, q
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% Z: e# w3 f; I) f: G        -1
$ s/ Z& B7 |7 F7 [: c; |};( Q7 u4 g, v8 j; Z) h' B9 T
9 x9 J7 H! a1 o6 |3 H5 w
static struct gpio_led da850_evm_tl_leds[] = {8 ^, R6 J( d2 K
        {* l: K' M: o& ^' C# i
                .active_low = 0,: X$ k: V* {  ^0 @6 S' f
                .gpio = DA850_USER_LED0,
! S; w1 n% H9 w& [5 m, e+ R                .name = "user_led0",, q1 [7 @; H. l& }+ u- j2 T
                .default_trigger = "default-on",3 Y- X% D1 `* L- d; c( w
        },
6 ~  |2 e" M$ S" F        {- M- O. x4 }, s( b
                .active_low = 0,8 x7 }% S$ F5 l7 F
                .gpio = DA850_USER_LED1,
' d# H9 ~* @1 }- Z% g                .name = "user_led1",# X% t- z2 ]( H1 C( J3 ?( a3 G
                .default_trigger = "default-on",
) A# ?' c' M4 x; p  S7 Z# [) h+ n& U" Z        },
2 O8 @4 L* x! U& H* j        {
, h2 H; F: ]: ?6 Z9 d! B                .active_low = 0,- i1 N1 ^4 U& V% ~& F4 @. d4 C
                .gpio = DA850_USER_LED2,- `9 ^& H% ]$ g* t4 C' H7 q
                .name = "user_led2",: f+ A  j/ `0 \" I
                .default_trigger = "default-on",9 T+ H, ]0 v5 I0 O7 s9 e3 c
        },
8 V6 x" a. E" h  A, G6 B        {
% a$ C( [3 z, \7 t% u% G                .active_low = 0,
# `& H- z8 U  y                .gpio = DA850_USER_LED3,
8 G6 S& m# o4 B- _9 Q                .name = "user_led3",' o+ e( O3 k; @9 b* F( m9 ^
                .default_trigger = "default-on",- i# \7 }% H+ Y0 J
        },' i" Q1 n' z! M; o( _
};" ~1 R+ H. ]# k; d2 M% t
1 }3 C! p; {: q9 ?3 Z. n9 s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, r( d/ B) G* E
        .leds = da850_evm_tl_leds,9 f2 ]  a, G$ |& o
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# J' Z) N; M: H};1 ~5 M" w+ a0 g- S2 M' M
1 v1 b  W1 [: ?$ D% J
static void led_dev_release(struct device *dev)
0 {: c( @6 H3 u8 S. h, Q, w{2 S; E( {# a6 V6 z
};$ T* ]( {- b, c8 ?

7 V1 {" P1 m" Zstatic struct platform_device da850_evm_tl_leds_device = {5 h9 o+ _4 n; R% u* s
        .name                = "leds-gpio",
5 l0 V" D$ ?/ k/ Z3 t6 x3 c        .id                = 1,
0 e& h- ^: x  K3 d6 m: F        .dev = {8 V) K7 @! _3 O
                .platform_data = &da850_evm_tl_leds_pdata,; L. _6 I; l7 b
                .release = led_dev_release,$ _/ H9 W* J  ]
        }6 J; Z1 h2 u' `% X
};; K4 `/ t5 k0 R6 ?
/ k* l* \. P9 s; @0 w# ?# j
static int __init led_platform_init(void). F# ~9 ]7 a! c: v0 {7 _
{
6 `( S5 Y5 {/ z. m+ `6 ]        int ret;
$ m4 F* `9 q- v$ `#if 0% h: \3 _& l" m* \
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 K' p% w& H! q" ]# I; K% T( }& K        if (ret)' {) T0 t+ w" Z5 |3 O' A8 F) H$ L
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"  ~# y1 K% ?/ |6 Z( Z! q( L
                                "%d\n", ret);
8 G$ k3 n; Q: \  `5 j# L#endif
5 g$ t' z! t5 j0 ?        ret = platform_device_register(&da850_evm_tl_leds_device);
5 ^9 n, l3 o+ ^- V4 B7 ?- ]: t        if (ret)" i  m6 q. r1 _
                pr_warning("Could not register som GPIO expander LEDS");" U- F5 ]. H2 {- C0 n* s
        else/ ]4 U1 c  L1 Q9 W9 }1 H
                printk(KERN_INFO "LED register sucessful!\n");: h" H( O* k$ y

- a) S1 j3 B! X7 l' ^( X- K        return ret;/ Z% d5 C! T. P9 @6 m: A
}
7 N8 \+ _- i1 N" ?5 f, A+ e" u8 C
9 s) E8 q) z9 z7 ]+ \! ?2 r+ N8 Xstatic void __exit led_platform_exit(void), V" Q+ [/ U( C! s; ^
{
7 w6 H* F" X% a- s        platform_device_unregister(&da850_evm_tl_leds_device);, d% y" k2 p9 q4 q

* L- g1 }9 |! @; ]        printk(KERN_INFO "LED unregister!\n");# I* Q; Z/ v$ x% f6 i- b& x+ e
}; Z: t1 F1 p: h

" v% D! q3 W# p2 c+ T5 k7 w- _module_init(led_platform_init);
3 t4 e3 b, U: n" m+ F: d$ bmodule_exit(led_platform_exit);
! I8 K7 I' E. e$ k& r- r% j- y' k7 N0 c2 |! n' A& c
MODULE_DESCRIPTION("Led platform driver");
" f* c) u% T. \  R8 y% nMODULE_AUTHOR("Tronlong");! J) X$ |! ?) g# C+ q  H" S7 x6 P
MODULE_LICENSE("GPL");, P/ B% E& U4 B$ L, ?' l

6 i/ r* x3 \& S- j
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-26 13:46 , Processed in 0.037801 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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