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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
4 N" J3 [+ x- R' H#include <linux/init.h># A1 o3 ^6 C  z+ r3 V' m' q
#include <linux/module.h>
4 B9 D: P% J% {( B) k3 t#include <linux/kernel.h>& V' ^4 ]9 g3 y: o) n* s: H
#include <linux/types.h>
* o& X7 m( _* p6 B#include <linux/gpio.h>
" S+ u" s/ D( ^+ b  M0 x#include <linux/leds.h>& Q, \; L- n" [$ P) S
#include <linux/platform_device.h>0 D! ^5 V) v7 ?2 w) b

) B2 _0 Z  h# R" V2 U#include <asm/mach-types.h>8 }# u0 L9 D& m9 Z9 Z& D
#include <asm/mach/arch.h>
0 V2 V# B1 _  Q; A4 @#include <mach/da8xx.h>1 w2 W0 T/ G4 |* _
#include <mach/mux.h>
; ~( D. L. F6 ]" h) X5 i/ V( |) _# F; y
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)- X( p3 V3 j4 Z  W3 A$ ^
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
4 r% b4 T, c# U#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
) y, M4 @8 }) h) q, i; e7 x#define DA850_USER_LED3        GPIO_TO_PIN(0, 2), e6 }: [. i% _# p. ?

0 d6 h- f& r1 U8 O/* assign the tl som board LED-GPIOs*/
& G% v& {! `6 ostatic const short da850_evm_tl_user_led_pins[] = {
6 X" ?- t$ S0 r1 p9 h; _/ D        /* These pins are definition at <mach/mux.h> file */
, F. @' B# N7 R* `. i6 a8 S        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* U2 y6 u% H! f3 F9 l        -16 x$ v! {1 D# _4 k
};" X. f  x, Y) C) d& ~3 Y

- a4 G4 ]1 Q( cstatic struct gpio_led da850_evm_tl_leds[] = {
9 k% a6 {; @7 T$ P- T        {- g% T5 r- B4 |. Y+ J
                .active_low = 0,7 p0 R# v, J) }6 z+ [3 l
                .gpio = DA850_USER_LED0,6 @; J; R% L* }  P6 x
                .name = "user_led0",
0 K5 B4 @) a7 G$ h" p                .default_trigger = "default-on",+ V# j8 W* h5 n8 t6 b2 A
        },3 n& W! L0 ]9 F8 s- q4 m4 N
        {+ ]; ?4 `8 X- s- {# b4 Z2 ^- p
                .active_low = 0,: `- ~* H2 z0 j! T7 x- V
                .gpio = DA850_USER_LED1,
; G5 t; e  c! K7 T4 b6 R- v                .name = "user_led1",
9 J  j" @8 G" M2 h* y+ Z# f. w                .default_trigger = "default-on",
2 N; h2 I. }, ^5 E& C        },
7 E" S0 S4 g7 m7 u        {) j7 M' s0 i3 w" f
                .active_low = 0,# z/ I* X$ N% A7 p- y% n) t9 p
                .gpio = DA850_USER_LED2,7 b  v( o9 a0 m
                .name = "user_led2",
5 Q$ L3 }: j# W                .default_trigger = "default-on",
: d" S7 D' c' I9 z+ q7 f        },
$ C+ R2 A7 f- k        {/ @: y7 b: U" ?7 P
                .active_low = 0,
5 q5 a' C* g( P0 l                .gpio = DA850_USER_LED3,
$ T( k( o3 B. j( }) I9 J7 Z9 l2 n                .name = "user_led3",
; p0 l/ B2 n1 Y7 s                .default_trigger = "default-on",
: F4 x( n% A2 ]2 }        }," j/ l, e" N$ q- a# }
};
- g9 ]3 e8 I3 O& A+ t: D+ F
! J+ B5 [: Q1 wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 h& W, F& l. R4 I, e. Z, J
        .leds = da850_evm_tl_leds,
" [- e2 h4 t! h* e! x1 B/ a* v        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 K3 |! [0 J+ |% B9 H( C- x6 ~
};
7 u1 ~- [9 C7 j. w0 Z* c- n& z& b# I7 Z6 H; `$ E! b  x/ c, L% S
static void led_dev_release(struct device *dev)
$ t. k6 T' h& M+ x5 Z* I{" A* z2 F' [& Y6 k7 s
};
# w4 d2 W$ Q" c, n3 O8 D  k" \( p* O. Y: d1 w
static struct platform_device da850_evm_tl_leds_device = {+ F# F) Z: L& d; a
        .name                = "leds-gpio",5 q% W8 v5 Z: E+ Q- {: i, T
        .id                = 1,  J- L- W) c4 ~' l' T
        .dev = {
7 C: K5 ?+ \7 s6 Q* T                .platform_data = &da850_evm_tl_leds_pdata,9 [$ D+ V4 d% H  C0 S2 S6 f) K8 ]7 S, S* c
                .release = led_dev_release,2 _. [* h* X+ I( R4 L) }/ C
        }
4 g5 D% }. L* x1 {* v- ~4 Y};
# U2 V" L8 }: Q; ]7 o& L1 R) r3 S$ }# k
static int __init led_platform_init(void)9 E" S7 N3 ?9 {5 y4 T' t: c
{, x: h7 Z7 d8 s8 T
        int ret;$ s+ \+ L+ i+ n
#if 0
% v* M, b; \8 P- q  D7 P1 s- c& P        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" O, ]% v2 k7 u. \6 C! o. |        if (ret)- z8 l, d4 d' _7 }9 M3 \5 |  A
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. E6 N8 R, |. J9 U$ h: \) a                                "%d\n", ret);
/ k# G: Q+ N5 _5 h' T/ H2 B/ ]; `#endif" Y3 E- i( A4 X- W" r/ c
        ret = platform_device_register(&da850_evm_tl_leds_device);& o- m& `# }8 {: _7 f8 e
        if (ret)2 L/ @) x# t2 Y, w* ^
                pr_warning("Could not register som GPIO expander LEDS");
. X* }6 T" K! j+ m. N( x        else
6 I2 r( D' e8 M' w                printk(KERN_INFO "LED register sucessful!\n");- h' s% w) v: t( v8 j6 H
/ v- M4 Z* h& L
        return ret;5 H9 j1 k# V% e% z" d( y
}$ D8 l! f6 W- o) X0 |1 s
0 W1 u$ f: Y0 |3 b; F0 V& ^
static void __exit led_platform_exit(void)% O$ T- N% f' p( p" E
{- |4 u8 O2 m* I) ]4 _9 L
        platform_device_unregister(&da850_evm_tl_leds_device);
& D1 @3 `2 p! D+ e) L
, V2 Y( j0 j0 q0 f6 y8 @# U        printk(KERN_INFO "LED unregister!\n");8 \: j$ G" p& O; q0 c
}
+ c3 P  g; Y+ |( v5 f8 L+ @! ~
module_init(led_platform_init);
) u3 Y/ ~) W% }9 Wmodule_exit(led_platform_exit);2 h; w- m* a& B3 i
6 n- ]; B4 J# y* S7 H
MODULE_DESCRIPTION("Led platform driver");
. h/ C% K. }/ d/ y, L4 T1 ~! nMODULE_AUTHOR("Tronlong");  Q1 ?2 C1 G5 r
MODULE_LICENSE("GPL");
- v, s5 y* q- d, H" i
" E7 J9 @4 G7 F. x, S
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-16 23:03 , Processed in 0.043985 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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