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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。" r/ A8 H: k6 C, R3 @7 B
#include <linux/init.h>
" @  h* n, j2 c3 F  E#include <linux/module.h>' o5 ~' s" H7 ]* u3 ~
#include <linux/kernel.h>
/ f& w2 @8 I0 @% Z: ]* ]/ r* n#include <linux/types.h>1 `+ _8 w0 p* ]' Z9 O9 X
#include <linux/gpio.h>
, |; j6 C. G4 J7 ^#include <linux/leds.h>
9 U8 B& [& t6 S#include <linux/platform_device.h># g( X7 l' E0 |* ]& \' P: t' l, T
6 p3 y% h3 `# |. h5 B& r
#include <asm/mach-types.h>
3 }, x/ n( A( F0 X: N. \#include <asm/mach/arch.h>
5 }3 U8 f% y. I' F#include <mach/da8xx.h>
/ @* |. G+ H7 v  x8 @% ]6 C- x; a#include <mach/mux.h>  R5 u, m7 l" o) W8 v8 i

: g# F+ F% h- o( H2 ]. ^4 a#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)/ q8 j) o+ [/ H2 O0 k, \0 o
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5): v, s) U" A: u: @/ x% ~3 b/ S" h
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)& G) W5 J! N( m' G/ x! h& F2 K& l0 P
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2). ~3 x# b; o& V0 K1 D0 f8 p

, a4 }# k& U1 S4 \$ z1 Q/* assign the tl som board LED-GPIOs*/
0 W. b5 f" V0 X: w2 m4 wstatic const short da850_evm_tl_user_led_pins[] = {) U& d0 T& O  N
        /* These pins are definition at <mach/mux.h> file */
- w; X7 `8 F) y+ s        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 i2 m* k! e5 ^        -1, {- Q: [: a0 r, p- V
};
2 m( K$ I9 }  G; t
( q! m9 }6 \# C6 U. Ystatic struct gpio_led da850_evm_tl_leds[] = {  ]" @  |; S5 ~$ W
        {6 g* J* p7 O. j' X
                .active_low = 0,
8 ~; Y1 ^! F3 T/ x: T                .gpio = DA850_USER_LED0,+ j- D/ y/ T4 e! ?. A! h
                .name = "user_led0",( p: U! L8 P: q/ n  r+ E
                .default_trigger = "default-on",
" Q3 X3 H6 v: W) _) {2 l        },+ p! Q+ Y* K" ~4 Z/ ?7 v/ F. x
        {
/ |: r7 P- I8 R1 f7 S' s% s/ F                .active_low = 0,
7 b9 L- o; f1 W  {( I/ R                .gpio = DA850_USER_LED1,  ^+ F% s5 v) b7 N7 t
                .name = "user_led1",
! L- P1 H" m/ L! V% ]                .default_trigger = "default-on",
& ]! i# ?# D5 Y        },8 Q$ |) a. q, s6 u0 P; b7 a
        {# v- K( [3 u2 I% ]) ?  O' @0 m- Q
                .active_low = 0,6 m- ^9 i& i- [% s
                .gpio = DA850_USER_LED2,+ q% I0 {; l; N& N
                .name = "user_led2",
; S4 c3 x$ B& _  o  Z. Y2 G                .default_trigger = "default-on",8 |# Q* A6 m4 b* W- W( d% y
        },
; t& I& @' O# A$ g( e- Z        {$ l2 y7 ^4 J  `2 f+ L
                .active_low = 0,: N9 }2 M( G4 r! d6 ], d3 o& m
                .gpio = DA850_USER_LED3,, N; _$ R7 d: c5 ~/ Y- ^
                .name = "user_led3",- F/ A5 E9 L9 f/ q- z
                .default_trigger = "default-on",/ A) J9 l! {3 U4 a: A! G. z2 O
        },
, Y# a2 k6 J& D9 i0 e# q};+ j  W; F' q, ^/ s4 I' h/ \
, Q" I, G* z! ^" |1 z2 M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- a9 ]6 C0 ]# j$ T        .leds = da850_evm_tl_leds,: K, |/ O) `. G* F( ~, |% k9 k5 l
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 O5 ]" M( X6 A2 t3 |
};* X  P- J& b  \6 L2 m1 |6 k- _5 I

# l% J/ x; Q( I. C5 [2 ~static void led_dev_release(struct device *dev)
& ^1 ^( _2 t( k( k, v" x: B{3 A: v9 \7 E8 J8 v
};
1 E2 N8 v5 T. m
) j% ?5 {7 y$ ]& ^7 \static struct platform_device da850_evm_tl_leds_device = {% f% d) T+ i1 J2 V* E
        .name                = "leds-gpio",  x% h- O* T9 y- R
        .id                = 1,
! ?- B5 C! D# f! X4 x2 P% l        .dev = {( z) j( q' }5 L" V, C
                .platform_data = &da850_evm_tl_leds_pdata,0 I! N9 Z4 u$ y2 s  |" G& Y1 i3 s
                .release = led_dev_release,/ @  P3 U$ _/ _! l  O2 `
        }
* g4 A' S8 U6 @8 B+ u};& G* i5 f1 d3 f$ t. v+ m* o. X

8 K! H# \6 V7 {- O2 F4 c1 M* Cstatic int __init led_platform_init(void)( [0 {$ P4 ~3 j1 ]
{
+ J- {$ V. C" G0 }' R        int ret;1 `# d8 i. V3 f' ?% z
#if 0
% U! N5 [2 }  L0 c% ~( Y& \& t        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; b, A" f+ j0 J! ~. N
        if (ret)& S6 U+ G9 e. w8 J
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 k, C; b/ u. E5 Q: e
                                "%d\n", ret);
! g; V, K9 b/ i7 T$ W% Y#endif. F! T9 \! I3 c1 i
        ret = platform_device_register(&da850_evm_tl_leds_device);1 Z' i, c* p. R5 T5 ^" h
        if (ret)
3 C: v4 c& W5 i  O8 v, f                pr_warning("Could not register som GPIO expander LEDS");3 a7 ~6 L" i) s! u& I& B  I
        else! z  [8 D4 ~$ u. U  z3 A
                printk(KERN_INFO "LED register sucessful!\n");
* L+ Q; ]7 g/ c) K  u2 n
! b/ e. D( W* a4 F( S" `        return ret;3 X! T% p/ V. ]2 N! [2 W. W! d. ^
}3 K7 |6 X8 a3 b# }7 m- M7 B( @
, J0 A. [3 p4 N, |: g1 k
static void __exit led_platform_exit(void)
9 H- V. d" R. b6 m+ f2 w% ?{1 `8 a, [9 y, L% ^; c
        platform_device_unregister(&da850_evm_tl_leds_device);6 X! D! q  ]+ T
3 j( b6 M: y4 J3 S* l  L' b; }
        printk(KERN_INFO "LED unregister!\n");" x2 x$ ~4 [4 S* k" y
}# J+ H( j- p7 j8 d7 i. h$ h
4 D$ {& @$ G( h2 a" {& f
module_init(led_platform_init);
2 _+ k  L* Z' q9 E- b4 G2 Wmodule_exit(led_platform_exit);
0 L5 Q8 x( V: B6 v4 f/ B  j; Y& E( ~+ c' T3 r# L
MODULE_DESCRIPTION("Led platform driver");+ R2 N5 x3 k! x1 [* F
MODULE_AUTHOR("Tronlong");' v% W+ x7 L* F. V( K3 I
MODULE_LICENSE("GPL");7 x2 ]$ T! Q9 m' H7 ?5 T$ R% j. }
3 U, p! `2 T- t
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-26 00:40 , Processed in 0.042343 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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