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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。! d; ?, a# J$ n' m) l
#include <linux/init.h># x! }: S9 X( o
#include <linux/module.h>" S; R% M. s# W2 n& s2 ~3 y
#include <linux/kernel.h>
5 ^! D3 l) F* V7 k( g4 r- a& {#include <linux/types.h>
$ s& J6 f8 {& o8 Z6 W1 ^6 P4 m5 G0 J#include <linux/gpio.h>
+ ^  y! v  \3 C. K#include <linux/leds.h>
+ F5 `: Y. ?, m2 i% x" t#include <linux/platform_device.h>: s' M% m( q( d

' d# D0 Y% U) n! Z$ B1 K% c* Z( X/ ]#include <asm/mach-types.h>
- d" _: ?# ~# c! e3 P#include <asm/mach/arch.h>; F" F3 w1 m  @5 ?
#include <mach/da8xx.h>3 e# P$ H+ `! f6 I
#include <mach/mux.h>
4 R; |5 h: Y5 `2 d1 d$ ]. E: S
" ~6 `5 h8 j/ I#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)8 B; E, O) F6 r9 V
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
: B) |  J- w" V8 w  e#define DA850_USER_LED2        GPIO_TO_PIN(0, 1). s; P* k6 B! f* B7 ]" b8 C* B
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2). P& m  A' [. c9 U/ Z, d

+ @5 Z7 J: ~- g* U; d" F/* assign the tl som board LED-GPIOs*/% |, N. I+ K" [1 `7 I  Z
static const short da850_evm_tl_user_led_pins[] = {
9 e9 z% K& h; o5 \% ]        /* These pins are definition at <mach/mux.h> file */- T3 E$ f& f* t- [# s, l' [
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% Y% f/ n; c6 g7 _1 l
        -1
. O& u% _% j) p! e5 D3 ~5 i: V- m};
) ~" t' ~) n9 x* c, T" t# \* G
% x5 U/ C. P; ^- U. G7 m+ J: b* tstatic struct gpio_led da850_evm_tl_leds[] = {
; @( `5 f1 ~5 J        {
' m) E0 d9 G4 b8 }                .active_low = 0,( @9 J7 v0 U( g
                .gpio = DA850_USER_LED0,7 e6 R; g' D8 k3 r- e1 j  ^2 e& w
                .name = "user_led0",
. l  B& m& g$ m, q, g1 T                .default_trigger = "default-on",
9 H) z7 K+ T3 B4 d/ |# I# b4 z& ^        },  [2 z; E: Y) L3 \. o
        {. W' Z1 C, n) i8 |
                .active_low = 0,6 m+ H! u- P0 p  n
                .gpio = DA850_USER_LED1,
0 s& g# B& E$ |3 ^- A                .name = "user_led1",
" S5 [' X9 Y- B3 M$ }4 |                .default_trigger = "default-on",
7 w. E7 ^. e3 g) j        },
  c, ~: P$ Y4 P: `5 p+ ^& i8 J! _        {
: n( J( k8 U: y( B( k8 K4 y3 j                .active_low = 0,* B" h- g( j# L- [! M6 B/ p6 I
                .gpio = DA850_USER_LED2,
$ O9 O$ U: w+ X& a* ~! ^                .name = "user_led2",
5 B' j; z) N; i$ n( |3 u                .default_trigger = "default-on",
* n+ g/ h" x; U% s: }% H, s        },
" a3 G! B$ p6 ^7 ]7 ]5 M        {
: B5 j6 M) e* z7 v9 d                .active_low = 0,
3 |; J0 A0 k7 ^. j& m                .gpio = DA850_USER_LED3,
- w- ?0 u0 ^: {0 Q0 I/ L                .name = "user_led3",
- v+ Y- u' u0 p' D4 x- t5 {$ F" @) ?                .default_trigger = "default-on",9 B6 |7 M+ o! u+ X! k+ w' g/ M4 ?
        },
+ G* V: A5 |6 f2 A( j};0 O! Y; U/ N3 D- }3 g( k
0 H6 L2 Q3 ]' ^8 `3 J! g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% C* [3 T, |5 V; {) y& d4 p
        .leds = da850_evm_tl_leds,
0 a. A7 y' O1 z; Y' F        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% A/ W" y- }6 N
};
4 E6 Q; {- w2 p7 o
3 Y2 n$ C6 C2 E7 }) z) S3 J$ Qstatic void led_dev_release(struct device *dev)
" _/ u4 e9 c. L8 x1 j{
. l: F* `; M% F- X0 l; w2 g};
6 l% `: J+ \8 l% e+ x9 u+ x4 J5 I2 R- s; c0 `- I# V
static struct platform_device da850_evm_tl_leds_device = {
& b# ?0 E( |; s+ D, M# {        .name                = "leds-gpio",4 E" T& B4 z/ R) r4 z" `3 t
        .id                = 1,
' |$ B, f$ x$ k        .dev = {) m. j9 b% x; V! P/ q  J
                .platform_data = &da850_evm_tl_leds_pdata,. D# B, x5 }7 B1 w
                .release = led_dev_release,
0 v6 R5 _& r- T6 q: f        }
! i7 i' a& d) q" v' S* ^! o9 x8 U};% m; ~5 R1 w. k; A, u6 |4 J
6 g1 ]: u' n. c/ H6 c: Y* }& L
static int __init led_platform_init(void), _% E8 a9 N6 R
{
1 o$ F( U+ u6 B        int ret;6 L# C4 C- S1 K! M( F! U
#if 0
0 H" m" }5 u7 f5 ~$ ?4 z) U        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);  E9 T, [( c) g0 u( L
        if (ret)
+ S5 ~& R, k2 m+ b                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" {3 w9 k  X. {; k" R0 l2 t: f8 F                                "%d\n", ret);5 r& e, O( _6 }: v% ^7 w, u, ?/ A
#endif
# H* I  _! Z% j$ `" w' D" g- u        ret = platform_device_register(&da850_evm_tl_leds_device);
" _! I. ~: b( A- l. v; }        if (ret); K- k3 }2 {8 q: }$ P/ K6 f! V
                pr_warning("Could not register som GPIO expander LEDS");) `5 W* t1 `  ]* ?
        else
4 }  g9 ~7 M1 b' m  O* y# j                printk(KERN_INFO "LED register sucessful!\n");
* M2 k! ?* d3 i
9 g0 N' L1 |" y) @        return ret;2 B" e7 v8 J( O4 p
}" V) G1 r; X# @( V. V1 _

" S& l0 d8 v6 X& s3 O+ Ostatic void __exit led_platform_exit(void)
) M8 m; m* W5 Z! ?{
6 [2 y! G) k5 i( o2 `6 V        platform_device_unregister(&da850_evm_tl_leds_device);5 I2 y! ~" c3 t7 ~5 I
3 \( t: Q( r* E( Z" z( G
        printk(KERN_INFO "LED unregister!\n");0 @* r5 ]4 c5 n$ w% n6 n' P
}; u% Q1 S2 x0 z8 @; m; K/ }

7 W- y5 o# ]- L" C3 c5 `# emodule_init(led_platform_init);
* o3 O4 i# _* v( Ymodule_exit(led_platform_exit);) L+ A4 I2 h0 K! H. S! y
9 v/ F' i8 J: A0 Y
MODULE_DESCRIPTION("Led platform driver");+ p, l, E" x, k( ^( v" R8 I' `
MODULE_AUTHOR("Tronlong");
- _% G; {$ `0 _2 j* ]MODULE_LICENSE("GPL");
1 V# z9 H' [5 n, N- ], g5 t" l
/ q% r; I9 a5 L2 W8 E' C9 }, ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-31 09:08 , Processed in 0.038446 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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