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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
! \3 j, Q% a, e# Q/ @' |/ e8 P/ K#include <linux/init.h>
5 o! |3 l% F2 k: r5 U# ]5 h#include <linux/module.h>0 ?6 T  D! e0 M; S- k& F0 H
#include <linux/kernel.h>, H. F9 N+ a8 [" k8 P
#include <linux/types.h>/ w& \: M8 x! j6 M
#include <linux/gpio.h>
1 p8 N7 j) f- N' h2 S$ H9 z. ~#include <linux/leds.h>
6 s: t* H* A7 q; I- t, R, a$ [#include <linux/platform_device.h>+ |% `3 q0 o% G

6 T+ T8 J! r+ h2 g9 K! Y! c/ k#include <asm/mach-types.h>
8 @3 d, G3 v+ I1 ~! G#include <asm/mach/arch.h>, T( F. D* U# J; @
#include <mach/da8xx.h>; a$ V" b; j) z0 f/ y, a
#include <mach/mux.h>- S- Y' {: y0 I# t5 B( G) x
( A. g9 s9 i0 p
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)8 F' A, f7 b# I% a) o4 t2 A
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
4 \1 Z) _+ K3 F#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
3 A6 J+ L6 W8 P#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
. t; T7 u7 m! @: H+ b1 ^/ [1 s0 Q# B: j8 ]& w4 o
/* assign the tl som board LED-GPIOs*/
, C+ P7 R! L6 ~+ mstatic const short da850_evm_tl_user_led_pins[] = {
& O: {0 x+ p; D" v% Y/ D, F  w        /* These pins are definition at <mach/mux.h> file */
! l7 g' S) }$ W9 U& G9 n  }9 N9 E        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% T6 u1 \4 ?+ s9 @2 N: Z        -1
+ T, ?" \8 h# w/ n4 T};. c) p0 z2 X3 D' J

- M% c: B7 f7 ]7 _! astatic struct gpio_led da850_evm_tl_leds[] = {
- L. R, ?# T$ E2 K: g- r2 G3 z* k4 ~        {
2 t% U, U( K, ~; V                .active_low = 0,, M1 R2 g7 o) x% Q
                .gpio = DA850_USER_LED0,( v: ^" `3 V, k9 D8 e4 C' I8 N
                .name = "user_led0",
+ v1 Q; e& o7 W7 N7 `9 L7 o  y                .default_trigger = "default-on",' j$ T5 Q0 z5 h9 {- U- \0 V
        },( U& j, z( d: U1 T% s  D: E( x
        {1 p: c8 A- f# F
                .active_low = 0,
$ [' W' o: r9 g' ]7 b                .gpio = DA850_USER_LED1,
  a' G1 c  t. L                .name = "user_led1",
- o) G+ y* P# O% n/ S9 _& G# y                .default_trigger = "default-on",. o# B1 [: K7 E4 M7 Y" I1 V" |$ _
        },
; N1 ], q% W2 A        {. u0 z6 k) Z& r2 J2 ^
                .active_low = 0,0 [6 `. K6 B+ R, ]0 u
                .gpio = DA850_USER_LED2,& o3 l! |! V& r6 a% R' A4 G
                .name = "user_led2",
9 \; }8 J3 O( B3 y                .default_trigger = "default-on",2 x- I4 A! d, E; l) w7 A0 M
        },7 k; e$ h  |/ m3 f% ?# y" J
        {
; f" i4 i" a; x1 a# `1 K                .active_low = 0,9 w) F. G0 w5 _! I
                .gpio = DA850_USER_LED3,
; l% R* V; y) _: X                .name = "user_led3",
; L% U& \; U% r% c8 R                .default_trigger = "default-on",% Z) B6 z. p6 |
        },' R9 r% V0 @: f; o
};
& e- f3 l7 J3 c  ~. F5 W9 L2 l- \' E( K7 `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
  Q" w2 U# g& A        .leds = da850_evm_tl_leds," @+ ?  l) x; T
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' Z/ e4 ?6 q$ R, w};& H. s5 ~5 d8 J% A( n8 ~( J0 y
+ h7 u9 H/ T8 v( \, i9 n3 P. D( G
static void led_dev_release(struct device *dev)- _1 |& f/ J. I
{
: @6 R2 G' G' o: ~' }! o/ P};
( P! v0 Y5 z9 I. ~( U
) W$ X# e, H2 I- h3 F+ [- ustatic struct platform_device da850_evm_tl_leds_device = {# }& V4 S8 M/ x
        .name                = "leds-gpio",
. B% n6 A7 J- m3 S        .id                = 1,
) `( j/ t$ q( `4 p0 c+ O. O        .dev = {
! F/ {+ z- Z* B$ V  Z                .platform_data = &da850_evm_tl_leds_pdata,% C6 y) N0 _( F7 b
                .release = led_dev_release,9 v8 j; f6 k; e$ G, e4 p
        }
5 R1 y. f9 M( u' z};1 x  B: A& k8 ~
0 R) _6 |8 A+ ?5 T$ e
static int __init led_platform_init(void)
5 x2 n8 T1 ^! r2 v; r{2 _$ w4 u! r1 e. Q, v- \$ s( Q+ A
        int ret;
6 q# h# D% C! E9 @% u5 n) t#if 01 G, g+ v/ d( v* ^9 F4 E0 o3 f
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ n9 ~" W+ ~8 k2 d/ N( ^7 k        if (ret)+ d5 k9 |! @; M1 w+ N/ P& K& O3 H0 u
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" o% g+ E5 q; D2 y) ^6 C
                                "%d\n", ret);
% c. K/ e1 x* j3 @* Z#endif3 k0 d% f6 }; Q# f
        ret = platform_device_register(&da850_evm_tl_leds_device);; `# {/ J& u* @# l0 l5 u
        if (ret)# d- d- c" i6 p5 z, Y
                pr_warning("Could not register som GPIO expander LEDS");" A2 v& N4 r- P2 F
        else) A  M$ G0 ?1 m+ N
                printk(KERN_INFO "LED register sucessful!\n");7 \9 S1 x6 P% p$ H7 R

: Y+ ~7 D4 n: O+ O( p4 k4 }; J        return ret;
3 }+ a8 x0 o- n}# ^- M8 v. b! ?3 R1 a

6 D  k3 I7 @: P( ]; Bstatic void __exit led_platform_exit(void): R. |4 m6 ^2 l* }7 ?% t
{
. c, Q) t; }9 V4 g4 z5 K        platform_device_unregister(&da850_evm_tl_leds_device);
; N  C4 p- ?9 P: q
( W8 J4 S, g! Q  P        printk(KERN_INFO "LED unregister!\n");9 o' U- v% H; A
}$ F" Q6 G8 a  r3 s1 a3 n# q
; |3 n( w9 t% B6 _) S
module_init(led_platform_init);: ~, a( a, v0 i
module_exit(led_platform_exit);7 B$ J2 X* }. @

+ E% ~: N" k8 z1 j* S! Y9 {MODULE_DESCRIPTION("Led platform driver");: D1 g) {2 K$ C% ^) b: }( A, u3 Y
MODULE_AUTHOR("Tronlong");
% F3 ^5 O% g3 G2 C+ w: qMODULE_LICENSE("GPL");  F3 V8 h" I0 B$ v+ ?

2 K* ?# R) N7 N2 c6 J" Z3 ~
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-3 08:07 , Processed in 0.037457 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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