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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
2 [/ M$ f- w* p#include <linux/init.h>! k$ g. u; y: G
#include <linux/module.h>
/ S4 `  c8 }- ?7 q#include <linux/kernel.h>' T7 r5 e/ [6 |! P( r: V
#include <linux/types.h>
; ^0 D; r6 k( V$ o3 ]- ^" D: c#include <linux/gpio.h>
9 t1 y8 N. [, ^3 E+ I#include <linux/leds.h>
* l4 ^, s2 Y4 ^+ m( l+ y' h#include <linux/platform_device.h>8 m& m$ o" L1 D/ T  C
, @# t9 z/ Q- K9 K% j
#include <asm/mach-types.h>
, _4 v4 |4 ?6 i2 V. @0 w#include <asm/mach/arch.h>) \: q9 @1 m6 S! |6 U. ]( P7 }+ y
#include <mach/da8xx.h>4 u* @( \6 x" R1 h! \1 ]  [
#include <mach/mux.h>4 a# Z+ p" w! |

8 A1 O! T" F6 E. ?# X9 \#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
( u1 p. ^& {* B5 i% T) N6 a7 g5 F#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
4 S. ~& f/ ]2 s, o) p: T#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)4 \% @) `: G8 ?9 {
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)7 V# w! U- _: s+ J1 b$ ?

) d, a) g' f& U" S, f" L/* assign the tl som board LED-GPIOs*/; {  X# c2 K4 W6 V9 B: ^5 d
static const short da850_evm_tl_user_led_pins[] = {
1 b: v) a* R7 y# ?7 I5 X" o- y& F        /* These pins are definition at <mach/mux.h> file */' R/ z2 n; |9 w9 A- X) w& J
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 E% `5 g; x8 w, O7 o+ P        -1" h/ y1 D' b/ N, V
};" T3 u7 |# b3 N2 m, o5 B9 z) c7 w* u
6 x9 l7 t0 K% ~  j$ w8 A3 f3 n- A
static struct gpio_led da850_evm_tl_leds[] = {7 V6 S4 y/ r1 A7 B
        {& Y' I+ v: e. {! K! d+ M
                .active_low = 0,8 n9 d0 ~+ x3 |+ q9 g/ f: O) r
                .gpio = DA850_USER_LED0,# L9 }, F& J, U& Q( E' D" Y
                .name = "user_led0",$ B- ]3 v* [7 `9 S- M- Y' y
                .default_trigger = "default-on",. o, p: O+ }/ M; w$ s
        },
/ s% S- V/ V( U1 N  @+ [, x# \4 z4 `        {" `7 c+ Y! v$ b/ _3 q
                .active_low = 0,0 f' [6 h( u1 F* h, L9 u! T
                .gpio = DA850_USER_LED1,
2 {+ }& q8 m% F* u                .name = "user_led1",
, M4 d0 L  w  n0 s3 @, q* W+ [                .default_trigger = "default-on",( ?( h4 v2 @) z: G
        },8 C6 M5 Z1 y/ O! j
        {4 T' K$ v1 c* l
                .active_low = 0,
; J( n. h- I1 h6 ]& {0 D/ _  n                .gpio = DA850_USER_LED2,
  \) p" V' n. D                .name = "user_led2",
! x. m+ `' J( T$ R                .default_trigger = "default-on",7 v9 ?) k) M! d/ d
        },/ b: Z- P; ]: p' x
        {
% ?$ j: S& ?. z% ]) p9 O                .active_low = 0,
% X! q6 `) m: _3 ?& \                .gpio = DA850_USER_LED3,- G6 y" ~5 G# F% K' l
                .name = "user_led3",7 W4 q3 W3 Q" N
                .default_trigger = "default-on",
* b2 f& E: o: }. T3 I; Q        },; `+ u; E: T% `% d4 K
};
& A$ q$ R) c2 ?* z: D/ {3 s* B& c& n4 Z) ]' a
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, b+ H$ \7 S2 Q" f" _7 h# G        .leds = da850_evm_tl_leds,: I: p( S* L- c
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& T2 V/ y5 @0 T' k" Z};
1 p* Z0 P, g! B$ t
" @, L" C; u& H9 [9 \static void led_dev_release(struct device *dev)% x6 I: {8 T& W/ n. V6 N
{7 M2 A" [% `: B5 _8 Q9 n! b
};
1 M' x1 |" m8 d8 }* c. `: @) c& R. \
static struct platform_device da850_evm_tl_leds_device = {1 x; q# ~* H9 G, n
        .name                = "leds-gpio",
0 C. v9 z0 L* M+ [1 D  t2 v        .id                = 1,0 C; J0 ]3 u! D
        .dev = {# |0 {% I) G( o/ n# b7 C0 @
                .platform_data = &da850_evm_tl_leds_pdata,8 K: |3 V' Q$ ?, g
                .release = led_dev_release,
8 B0 w, N* A9 A6 {' K        }4 p0 b9 [2 A' \$ k! w; g" k
};6 o1 @% V. j' G! N

" ?% ^/ d( F8 [1 f- }: Gstatic int __init led_platform_init(void)2 V+ n3 t2 A" Z; q
{
8 Q8 R  N( `% Q        int ret;4 Z: X% q- d$ E5 w2 v! l9 R$ n5 a
#if 0
; H# a" w5 Z4 \- L; C4 I/ a        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* w! o9 z7 d" d9 Q
        if (ret)$ l) H( X/ _3 s7 u0 Z
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"  Z' M" U6 x' `  z% d
                                "%d\n", ret);1 [9 f, O. c0 m& B' p5 A% i
#endif
3 I; m: y. z1 O1 `% W        ret = platform_device_register(&da850_evm_tl_leds_device);, N# \9 {1 L: t( n4 l! B& [5 ^
        if (ret)4 ]" L) i7 W$ d) G; U
                pr_warning("Could not register som GPIO expander LEDS");
9 i. O, r0 y5 M3 H8 a        else( \& }+ _2 k# [+ @9 d
                printk(KERN_INFO "LED register sucessful!\n");
- i! j* U! A' S" b) S5 W: {2 _6 E9 b9 h/ F) c# d7 `
        return ret;) H$ l3 q( T4 D- j5 Z% |1 Q, p, u
}( v9 _: @; {% z! K
( z3 f# k. j9 Y8 x* T" a0 X
static void __exit led_platform_exit(void)
" H' T4 I, M7 A+ l' ~5 F4 y{1 x2 I- P( ]) A
        platform_device_unregister(&da850_evm_tl_leds_device);
8 l" ], R7 x  D& u* B" q
, j2 r, L! k9 s9 p$ U        printk(KERN_INFO "LED unregister!\n");
, r' ^' X- J0 k# ?. U. {/ d. H* B}
* f( o  }# q9 s! E2 S
- Z" z6 ]6 Q# m( [module_init(led_platform_init);) ?3 K3 V# x1 Y' F
module_exit(led_platform_exit);: L. B( i6 V: L. d
# _; d3 m; D- W- W6 u& H
MODULE_DESCRIPTION("Led platform driver");
/ l+ j; @- |! F6 C7 |; iMODULE_AUTHOR("Tronlong");
9 D$ a! K& \6 e4 IMODULE_LICENSE("GPL");5 s5 r( `) F' u2 n% A8 d2 D
3 p! p% y: T! q/ P
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-27 23:45 , Processed in 0.043328 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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