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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
& x" i& \. n+ B( L: `! f9 |#include <linux/init.h>
; {# E: z2 B- n$ x$ e#include <linux/module.h>+ {2 u; ?4 ]) q$ c
#include <linux/kernel.h>/ d3 m" V) N" b  Z) {7 ^0 J
#include <linux/types.h>9 W' G& `; E6 v, M7 a
#include <linux/gpio.h>( O" a- w) s( y9 v
#include <linux/leds.h>
, G/ \0 ~+ Q8 N#include <linux/platform_device.h>
1 w  h. j0 V( L) m. ?) p- G' U/ o# x7 S$ ^5 n& s" Y
#include <asm/mach-types.h>
) ~% P6 m: Y  t9 x. K/ ~0 f2 Q0 K#include <asm/mach/arch.h>9 I% T$ h0 S+ L3 ~$ n
#include <mach/da8xx.h>5 x) ~3 @6 Z' U# x
#include <mach/mux.h>
' j' o  T% y; j+ f3 P: h* t1 ?2 |
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
! J- G" z( C, ^3 n7 z# V, k. A! @#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)& j" |6 B; |; n* {: i% b9 M2 K: ^
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
& z$ _# V2 x) U% [- H% K#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 K) ~) ^/ P% U
1 T! a3 s3 D6 o5 _6 q
/* assign the tl som board LED-GPIOs*/! f( n9 V5 t; ^! \
static const short da850_evm_tl_user_led_pins[] = {6 n# G. T6 `; U- H$ A! [
        /* These pins are definition at <mach/mux.h> file */: f* ^5 P1 Y# I( Q( W3 ]( D
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ K' t) d9 A$ U! Y5 ^" D1 [
        -1  Q( C1 I# I9 O* D2 L. S
};
7 Q% R) U5 B( v  h
& z7 T8 e9 g- O/ M* @* |static struct gpio_led da850_evm_tl_leds[] = {
. |$ ]+ j$ f- c, b- v1 k        {/ _$ q+ }  T8 }% R, t
                .active_low = 0,
+ Q% X* s  u& N% [% f2 x7 y2 e4 i                .gpio = DA850_USER_LED0,  B" V( u6 n0 l. {
                .name = "user_led0",
0 @) d9 M2 e' d2 c  k                .default_trigger = "default-on",
2 I0 w: ^7 c. |        }," [' p; m+ T2 ~: n# f. i
        {
2 G) x/ K, v+ @8 O! j# L                .active_low = 0,; N( Q# G+ N# c+ K3 l
                .gpio = DA850_USER_LED1,. q6 f/ ^3 Y2 C
                .name = "user_led1",
- Q1 @( z1 K2 Q7 C+ ~0 c                .default_trigger = "default-on",- d/ ?3 T6 _& X6 Z9 I- v
        },2 M2 N8 S1 z7 n' j6 V( B
        {
, K; k6 S3 E/ v8 b' S- p% _7 d                .active_low = 0,
% d* _! L, D% Y3 c0 {                .gpio = DA850_USER_LED2,, v& y9 Z1 t4 E& T  U8 b
                .name = "user_led2",; k5 x/ U+ {- z3 R
                .default_trigger = "default-on",
1 ~: x4 o- V& w" Z2 l        },7 h6 j5 S2 R3 h/ x$ K9 U+ q8 B
        {! \( v. O  ~' n) S
                .active_low = 0,; c+ L3 d6 t& W$ n5 }/ g
                .gpio = DA850_USER_LED3,
% U- y7 x! m: R4 M5 T5 @                .name = "user_led3",3 ^( t0 y3 Q  P, n
                .default_trigger = "default-on",: h9 f. b1 ^& \) t' r* I( r" h  N
        },% v. t) V0 a$ l
};
4 i, W5 V0 j0 P% L' O! c$ c* R7 c, p: a9 h0 r) C3 [, S: |+ g3 X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 K' r* r1 f" t! E& z3 v2 |
        .leds = da850_evm_tl_leds,
. {# J. q1 p( ?. ?4 f        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( ?9 I0 D& M1 ^};
7 m8 c) `5 r. E/ e( b# ?+ D9 W1 j
% ^' F* d3 O7 [: S% G8 Cstatic void led_dev_release(struct device *dev)( R& X* ]( j6 v* ^
{
. y' s* n: t4 R+ F# {! i};
( ?0 g/ s! g- O
9 v6 D2 v' c2 i1 Zstatic struct platform_device da850_evm_tl_leds_device = {9 n1 V3 A% y+ F. F! H: J, y
        .name                = "leds-gpio",% y5 B) P' K1 a$ ?( W, N
        .id                = 1,/ Z4 q! J' T* R# i* |: I
        .dev = {
8 \) i* W1 w- C- R* {                .platform_data = &da850_evm_tl_leds_pdata,9 }, e% C  m, m. C; J
                .release = led_dev_release,
7 F# T! @0 q) _$ a- w9 P) Y        }
9 F; `1 K; b& H. {  g5 x7 G};
7 k( m1 n/ s4 m* ~( K. J( f
0 ?2 X, D% S( N6 @6 _static int __init led_platform_init(void)8 Q5 W7 G8 q5 ^- Z, ?
{4 L# c  e2 V, p# ?/ o' M$ [9 F
        int ret;
" y% o$ x# f/ A8 I. B- ]* G# R* C#if 04 ]" C1 j& s& S+ n
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% C2 f: a! z6 y; U4 u        if (ret)- ~7 t- c. T% T3 D& c
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, i6 \* J! B6 x7 ]                                "%d\n", ret);
/ a) i1 p7 `( `. I% R/ ]/ w#endif
4 q6 ~) U* G$ ]3 J6 }2 g" _9 o3 R& h        ret = platform_device_register(&da850_evm_tl_leds_device);& q1 y9 b$ e% S) ~- \
        if (ret)5 P% A& P' ~1 L: c7 w0 R5 s. y
                pr_warning("Could not register som GPIO expander LEDS");9 I" ?" V1 i$ R+ R  F* ]  D, ^8 }
        else
* S: g% p+ P' A                printk(KERN_INFO "LED register sucessful!\n");8 r1 I8 w% t( Y% [$ z3 W

/ S! l0 G% M8 A; }5 q        return ret;2 J  ~: P# ^# V% o0 [
}" z; D' h6 x! P+ ^6 _4 A1 b, K
+ h% d9 t( [; [1 e
static void __exit led_platform_exit(void)
+ Q: _" }  k- u' d0 b% |) h% K. ^{5 V2 u- e0 w& @% S, q/ W9 Q
        platform_device_unregister(&da850_evm_tl_leds_device);
) _, M: f  u% Z$ T5 G8 V) \+ B6 m+ e$ C( i& Z4 H- {3 v
        printk(KERN_INFO "LED unregister!\n");; ~- P2 @5 g' _; \' m
}
2 ?* i! d( }$ I6 E5 M: G
0 w' w8 k3 E& L  N2 i9 }1 Z$ `module_init(led_platform_init);
; U/ t3 h$ U& N  fmodule_exit(led_platform_exit);
& Z3 F6 {" @- S; v& h+ V" q3 E% C
5 f; z: r: Z2 Q) C3 W, n$ p* DMODULE_DESCRIPTION("Led platform driver");
1 o# {+ O1 q7 c7 B# U8 nMODULE_AUTHOR("Tronlong");
9 o2 M9 f& [5 F  u- JMODULE_LICENSE("GPL");
  K1 q8 G; \# z  ^% t2 a$ }. H+ _; M) ?2 a
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-7 09:46 , Processed in 0.038726 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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