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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
' J- s: g* S) w# F3 d#include <linux/init.h>
9 H/ Z0 x0 j* b6 T#include <linux/module.h>
" b; ]+ }0 |4 I* U#include <linux/kernel.h>
( I% q( @# w* Y7 H# M#include <linux/types.h>
  [+ e5 {, n) L. w( X$ y#include <linux/gpio.h>. p. U3 C4 d( j$ h/ h
#include <linux/leds.h>
- X8 d/ X1 v& z! \# L8 n' \#include <linux/platform_device.h>1 N5 D' J% n% w% ~4 J8 b- J

( l# D( L1 ~! X% y& a6 W; z5 D#include <asm/mach-types.h>
. }3 G- u2 t! i/ L#include <asm/mach/arch.h>
, ~: E. X, a0 K. v2 U( V$ t#include <mach/da8xx.h>/ V  m" D! A) C3 R
#include <mach/mux.h>+ W* C3 N/ S9 C* N
1 [9 h5 o) W$ X4 Q
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)/ V3 j3 [6 b4 d
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
$ P* l# F$ G6 R  ^! l( X#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
3 L0 {6 K) y8 L! N) h3 g#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
' K0 w. }4 O# X! e7 K2 A$ `- }  J( y8 n* ~
/* assign the tl som board LED-GPIOs*/) h$ t+ R/ F: Z8 _
static const short da850_evm_tl_user_led_pins[] = {
* |* A5 p0 D) S  Y, k        /* These pins are definition at <mach/mux.h> file */8 }, U! v8 K4 V
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," L) Q9 W9 m% J& D$ a: J
        -1  z, M) E0 E% T( G" w9 G1 s
};1 S1 }; A8 Z' F$ c
2 `# c3 ?; l: F, j# a/ \6 i6 [( F0 g4 `3 Q
static struct gpio_led da850_evm_tl_leds[] = {% q/ D: K# Y( _  R; Q) \3 d
        {8 w0 c( T$ r5 r3 Z: h3 O/ Z
                .active_low = 0,
0 }0 ^# n$ ^2 Z3 h; z$ s* o                .gpio = DA850_USER_LED0,0 |1 |. K( C6 e- C9 [- ^
                .name = "user_led0",
, i! n! x$ `5 U                .default_trigger = "default-on",
7 [: y2 C% s# D. d        },6 r& O1 [( k& C
        {
5 L" b( G' n# @                .active_low = 0,
' a3 @  N1 P8 P- O& Q  O/ F7 j+ O                .gpio = DA850_USER_LED1,4 P# a. J" J; j4 C
                .name = "user_led1",* g( p+ a/ d' p
                .default_trigger = "default-on",2 `$ G1 M6 P$ K" P# c8 o# |7 G% M
        },* G: |- E5 x" n8 \
        {
7 X$ k9 }. {# m                .active_low = 0,: {" M  P0 y. x
                .gpio = DA850_USER_LED2,
% _2 p# U; K# Q/ |0 o+ ?                .name = "user_led2",
- P) ~1 u) M' m  J4 [" e: ~3 v6 [                .default_trigger = "default-on",
$ y! h# t  P! B* j0 b- |, }9 z        },
  }2 f$ X2 X! y: T# z# ~  a        {
. ]0 ^- a( v! ], r  X5 A* y                .active_low = 0," a/ r5 N( b0 \4 X" N
                .gpio = DA850_USER_LED3,
: a, G; i( n: E0 r                .name = "user_led3",
. U3 y6 _: K9 |( d  g, l                .default_trigger = "default-on",2 Y) v2 ]7 m& \$ W$ _; R8 r
        },% U1 B; b$ z  z. P( x9 ^4 k. \' [
};2 a+ n# j$ |  J% W% J
- D5 B, `+ z3 z4 @5 \/ b3 v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 q4 Z2 W8 x, j5 V' G
        .leds = da850_evm_tl_leds,
" s. x5 L  Y3 _% ]        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) m( o- _( X& L+ j$ d3 K};
- [7 r+ A5 S: x9 b; K
- S- ^4 H: q; ustatic void led_dev_release(struct device *dev)
$ Y* M, P5 N! }( k{0 j- r6 {# r3 s# a" d6 U; ~
};
2 `; Q8 }! I6 d# ]0 P, l$ a4 d5 z$ z( d4 t& a# i, [0 L% t
static struct platform_device da850_evm_tl_leds_device = {2 A+ d) }5 I7 B2 y- y/ }" n' s
        .name                = "leds-gpio",
6 m7 u- l% z: L! P8 V6 Z  F. y* \" U        .id                = 1,
! Z6 d' {# q- @        .dev = {
6 e, n' c# @0 E                .platform_data = &da850_evm_tl_leds_pdata,
, e& E8 I/ e' _( b                .release = led_dev_release,
& P6 r! J7 r4 r8 t9 v8 s0 j$ q$ X        }; x% B7 l, {+ }4 t9 l: u9 ]
};
( O: W2 F1 R) o% v" T- [: _+ |
* G& @  X4 a) {  w7 Istatic int __init led_platform_init(void)! \  Y9 ^. E5 b9 y
{
+ A) o1 ]2 ?0 H( F6 ?3 ]( q        int ret;
7 `, ]* F5 n/ Q6 Z. s4 V#if 07 \  z: Z" ?) `; z& @( }) a
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) M$ @; @( y5 I) y" Q. Z: j        if (ret)% _9 [6 F: ]& M
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( N# P6 t8 ~! s, F, X- n
                                "%d\n", ret);7 F, ?& N+ x) h3 U+ C6 _$ W3 m
#endif: e" J) y6 i( T1 ~" N6 R# R' x
        ret = platform_device_register(&da850_evm_tl_leds_device);; b( Z7 |; x" D
        if (ret)
* \6 w. h. Z# M! \                pr_warning("Could not register som GPIO expander LEDS");
3 x% F2 v* v/ x9 w5 R        else( j8 a* ~$ X1 b, E; g) E
                printk(KERN_INFO "LED register sucessful!\n");  G" n8 X. `+ w6 ?" t# V& r
: s1 e# G! d2 g) ^
        return ret;
0 g: M. E( Z; K1 A0 S% D/ T}: a! f* n* J  d. u
5 o+ a2 V  f0 [
static void __exit led_platform_exit(void)
9 J4 a  f  V; C( m% ]/ x{
$ }# J" k8 U  S& s) v        platform_device_unregister(&da850_evm_tl_leds_device);; Z  G  d4 S! b; i+ c" \$ A% B
% E3 O$ g  L& @  u1 @
        printk(KERN_INFO "LED unregister!\n");0 k0 v/ e; N% [* R' p/ b" I
}
0 C+ h$ u9 L3 Y4 q# B( Q+ Y
( }% U. H5 A! z% L0 jmodule_init(led_platform_init);- ~0 B$ R1 s* J7 e' n, n( c
module_exit(led_platform_exit);
) s" `9 @# }4 ?* `; d( f! M3 M6 ?
MODULE_DESCRIPTION("Led platform driver");0 p# B3 I; U  P- O- b1 g
MODULE_AUTHOR("Tronlong");7 @. r& q' j6 F. u& H5 R
MODULE_LICENSE("GPL");
- Q8 i, i- i" a) ^5 ^  p. t  |$ ?+ ]6 {3 O# G' u! b  }* J$ V$ y$ h! X
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-13 11:26 , Processed in 0.040915 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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