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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
$ @: d+ b( C4 t2 K- Y( Z+ [#include <linux/init.h>
. B9 z0 p  ?. k! V2 P  B, M$ t( W#include <linux/module.h>$ k) `6 \  o) t/ q4 r" A
#include <linux/kernel.h>
( [. X8 K. t$ E) Y0 C#include <linux/types.h>
1 z) {& o1 Z7 v& Y( }! j9 w#include <linux/gpio.h>  V" A2 P5 f1 E$ X& Y3 h
#include <linux/leds.h>
$ y/ T! v, s: e9 K' u3 u#include <linux/platform_device.h>
  s6 i% T' C1 A6 n. U  w, a: }
. m: h# D5 e, {; \+ t% Z; s: y#include <asm/mach-types.h>2 r! }+ c. s5 J0 X3 t
#include <asm/mach/arch.h>
) F( p4 T+ a" O9 c% n, a#include <mach/da8xx.h>
' I2 m5 q  v8 Y#include <mach/mux.h>" Q; f* M  B7 @1 b: Y
, j8 L/ M1 f0 u& S* \! E2 \3 T
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
7 R) ]# \0 k6 S! q#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
" Y9 D# H4 _+ ?; t8 Y# M9 C( E* f& }4 ]#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)! T( e* O( x1 m1 \/ q6 s- M
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)1 d. @3 ]1 V, K% O2 b6 g. j2 J
2 p7 m) D: G" p
/* assign the tl som board LED-GPIOs*/
% W0 B7 r% N7 x- H: M) ustatic const short da850_evm_tl_user_led_pins[] = {/ O, O! O- T0 v5 _: }0 \; }; r+ u+ O- J
        /* These pins are definition at <mach/mux.h> file */# ~$ S6 v7 A& _+ l& ]
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; L* P7 z; n' n1 G
        -1
5 S- J7 [$ i1 @% b( f! X};
, f  ?* g. O+ Y# \: b1 E. d
. D3 r0 W& F) J+ _+ estatic struct gpio_led da850_evm_tl_leds[] = {6 ]* g) Y: @3 j0 ~/ d
        {
6 |. v, a& ?+ [8 H. M                .active_low = 0,) Z9 G) D9 a  e+ z  z7 \# t( ^
                .gpio = DA850_USER_LED0,
& t+ \. F& r2 ^! c$ b$ N                .name = "user_led0",
. t9 _# W4 L. Q+ N6 [" V, D! d                .default_trigger = "default-on",
! a$ T$ c0 X, {        },
8 t- C2 Y. _; O) ~0 K0 y& B, H9 x        {
; k0 B$ q  R1 u7 u9 {4 O                .active_low = 0,: m% S6 G( m0 N" g/ D8 d7 J8 b
                .gpio = DA850_USER_LED1,  p. `; W+ p+ Q* {- N* o5 a. U1 C
                .name = "user_led1",
% s) n  N# d' v8 f7 b4 ^; {% w                .default_trigger = "default-on",# U! p; B( Q* ]; e, B+ {
        },7 Y5 j- n# {/ ~# K$ U# a
        {- p9 M" R* Y& z$ H9 j
                .active_low = 0,( m( F. u4 c" o6 T5 g
                .gpio = DA850_USER_LED2,
" j" H  z- V3 M8 z% p                .name = "user_led2",0 ?1 Z/ r1 X/ G7 k2 W* Y, p
                .default_trigger = "default-on",
+ M  F- D( w. N' y5 l, i        },
1 G& q! T. x% ?) f0 I        {
3 ~4 v6 P7 I. }                .active_low = 0,
8 S' [  ]1 h6 h3 x# ]3 j                .gpio = DA850_USER_LED3,; |: m" \  @+ P0 ~( A4 T
                .name = "user_led3",
5 P3 h7 X% u% t3 X- G6 t                .default_trigger = "default-on",1 J& p6 C% a' X# w/ O1 v) v
        },. U4 y. _2 u. B  J
};
" n7 E  F/ |2 \5 n0 |: S  N; T8 `  D3 ~9 }3 v6 P2 D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 G' V% Y! g* T  g* D( V# U
        .leds = da850_evm_tl_leds," \3 y; L: B# R  ~2 c3 t! f/ x
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; \6 T" U$ H+ X) r+ d# V/ T# W};0 _( z% ]0 L1 R/ n) v/ i0 }$ A/ @! P* o

" M2 {8 b7 W9 v* k+ t' Cstatic void led_dev_release(struct device *dev)
: b, @3 O. n& o# ^- B! L* k1 t+ Z{7 P8 I; I; Y3 ?- }. V) ]6 O" g2 s
};; ~, G% b9 W& k3 h. O

  c/ C+ a( `/ I5 w/ S  O, H& l2 Ustatic struct platform_device da850_evm_tl_leds_device = {
! g% B- B0 U8 y5 M2 Y3 K, D8 x; N        .name                = "leds-gpio",
  L7 r1 m3 [- ?% y2 S        .id                = 1,0 Y- G" z$ |; H6 l* ?- R
        .dev = {+ Y1 v: w4 t3 ?! P7 C+ c9 E  v
                .platform_data = &da850_evm_tl_leds_pdata,
! s! ^2 T+ h# D) @9 s+ L" I% b1 ~                .release = led_dev_release,
  o4 ~% t2 a4 \" ^        }
: K# y2 [9 }& S9 O6 V4 `7 o2 U};
0 S6 ]5 E; S! H1 t! a
5 ]) ~$ S- M. X* l6 K8 K* s/ istatic int __init led_platform_init(void)
4 L. u1 p8 r4 i( M/ E{
4 ?7 n# Z  i& _        int ret;
& D8 {  _' S+ D( |/ t$ G: J#if 0; w' G5 U( V5 ^
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* d1 h: Z6 d0 e( ~$ I0 t5 `        if (ret)
, I- H! p9 |: o2 J' U                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 K5 k$ B9 D4 X5 |
                                "%d\n", ret);/ Q! e3 N  E* Q) x  E1 z
#endif
2 n6 \' J: P( S( @* d% p  @        ret = platform_device_register(&da850_evm_tl_leds_device);6 b+ o: S- ^; {+ ^
        if (ret)
' s! p6 _* e0 Y2 l* V' k                pr_warning("Could not register som GPIO expander LEDS");5 w, G" M( m" H
        else
$ I5 _& ]0 G% g( s3 A                printk(KERN_INFO "LED register sucessful!\n");7 ?; O- p  R/ l: U) C

& b0 s- P& \/ w* Z        return ret;
) K0 X: Z3 c- t! ]( _! d% m' m}
+ L( P+ ]- }3 b# n4 w  b3 F: t7 z- y' Z+ s7 t
static void __exit led_platform_exit(void)
8 Q3 X9 f% o/ |" q. I  }* m3 b{! ^8 T4 c3 X! X! t, f% t
        platform_device_unregister(&da850_evm_tl_leds_device);7 d- K; \1 Q- m1 N; f
: u; B, {8 l! m* m* @
        printk(KERN_INFO "LED unregister!\n");& D% ?# ?+ y" Y" J+ ~
}& v/ A& X9 l6 B1 L# \7 x
" f  [2 F( i2 }$ u6 W6 C
module_init(led_platform_init);( W) E% R! M/ K8 z$ c' `! S
module_exit(led_platform_exit);
4 L: ^9 K! A' _5 b
+ c0 b+ |# F9 J8 S. ^: ]MODULE_DESCRIPTION("Led platform driver");
' {! Q* V- C6 Z2 M9 f+ U0 P4 kMODULE_AUTHOR("Tronlong");" J$ U  @6 Q8 f- k( D5 L
MODULE_LICENSE("GPL");$ X2 r$ Y. t  O* [& A

3 d3 `# m$ M# \3 W# {0 K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-9-6 07:05 , Processed in 0.046507 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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