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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
# \+ P# o- y+ W, d. _#include <linux/init.h>
; |) W: O) N4 w7 E' _; y7 @% X#include <linux/module.h>
0 O3 }9 _( q8 k4 h#include <linux/kernel.h>
" n" a/ o! |6 [" n: c  |; J9 U#include <linux/types.h>
' `+ p% H2 _* @#include <linux/gpio.h>3 g5 ?/ Q8 b* F7 J
#include <linux/leds.h>9 \/ V$ Y7 H  |& ~% ?
#include <linux/platform_device.h>- s# n9 n1 d- z

) B2 L) ^: B2 J#include <asm/mach-types.h>7 f  j  \, X; p4 o
#include <asm/mach/arch.h>) S, r( w, P* I  }! l
#include <mach/da8xx.h>7 r; G, B! `; ]" `
#include <mach/mux.h>% X$ r4 j* j9 ?. x9 J- f2 J7 I
9 Y2 J: ]# J) y' i5 [
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)$ ]: {( |3 e% C5 W4 q& f: H1 I
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)( F# G0 X9 p. n! o: c8 L9 G
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
7 D% p8 |: h) s3 @1 x1 I#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
; m7 `$ O) O5 o
8 {1 l( z) ~7 f, p8 R) m8 A6 O/* assign the tl som board LED-GPIOs*/( R+ `# o# O' h7 w7 j! L! F9 u
static const short da850_evm_tl_user_led_pins[] = {4 k$ f, R9 ~) f: m
        /* These pins are definition at <mach/mux.h> file */
$ E8 G' h* H" s; e; |8 r2 ]) ]. J        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 o! I) x, Q7 n3 m$ ]' |1 k7 r        -1/ N' N* N, ~5 q
};
. ^2 i' \1 U- P( }2 A' _
" K1 W& _; m2 f5 {6 Dstatic struct gpio_led da850_evm_tl_leds[] = {
; Y# ~  f7 ]+ Q" h        {
" p* s$ A; D6 Z. v7 ^" n4 E                .active_low = 0,! Z& |7 N3 c6 ?6 i. e9 J  o
                .gpio = DA850_USER_LED0,7 _7 X" v! \' `0 ]- m8 Z3 O
                .name = "user_led0",8 ^2 z. |9 j9 k% C
                .default_trigger = "default-on",
- O0 {/ i7 Q# g! E' O        },; }# ~% X" ?# r  \2 e" i
        {
* \. L) f7 R4 Z1 g                .active_low = 0,+ J& V8 Y4 |4 N! U
                .gpio = DA850_USER_LED1,
4 X4 f! e/ [* O" o: d+ e' N- ?                .name = "user_led1",, i. z: Y' }; [( x
                .default_trigger = "default-on",
0 d" @0 q  \' H+ q6 z; `        },1 d4 [$ |8 F  o' Z: M* F
        {
9 p: }0 Z% I6 P4 J                .active_low = 0,( ~3 c6 g" V+ s8 e
                .gpio = DA850_USER_LED2,  E5 u. g9 b+ t+ ]* U
                .name = "user_led2",
1 v, G5 G7 C  M  w- x4 x                .default_trigger = "default-on",2 g" @3 x( W1 a& m
        },( M! L7 E/ ?+ J- e7 q
        {
9 n2 u; k5 P3 r1 o                .active_low = 0,
9 W6 L9 |! r5 m1 n                .gpio = DA850_USER_LED3,
) m" T/ x; R: ^; q2 R                .name = "user_led3",9 N3 u+ z2 s1 r
                .default_trigger = "default-on",6 y, b1 L: Z4 a* u: {
        },
$ L8 U! D# s2 `, e};, b, O1 n6 x  F! g3 e
0 g& c& K$ d& }  M1 I; `: v4 _" m
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 S; S, k# g& a. V9 w4 s; ^
        .leds = da850_evm_tl_leds,$ |# Z5 M$ _+ L3 V1 L6 O
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 D! x. R7 E1 ]$ I" a  P% U5 g};
7 q: }/ J. o1 V) i2 D0 R! x0 C+ w/ \- U! W( F  A" ^
static void led_dev_release(struct device *dev)
9 }+ F( Q$ z. u) n. p7 n! K{
+ n; X5 R# a. m& h  a6 L! V};
, q" H* O: [7 F6 Q7 O6 D, A2 \" h( [$ _+ A5 [# Z
static struct platform_device da850_evm_tl_leds_device = {
! F* m5 {8 S1 K        .name                = "leds-gpio",
0 p$ e9 x1 z  h5 |; b! C/ ?        .id                = 1,) F' ~' D& u1 o4 w
        .dev = {
3 O! e6 @( A( i4 p7 D2 f                .platform_data = &da850_evm_tl_leds_pdata,
! t$ v4 z+ M$ @& o7 ?& v                .release = led_dev_release,9 s7 z0 q/ @7 O' D6 i5 h/ w9 k2 n
        }, i/ I# ~: s3 N4 u" f* ]- m) b& m" h
};
  V; l) U+ ]3 T+ V" H
) |. N7 d+ |% Vstatic int __init led_platform_init(void)6 j+ T7 ]. S: m  f2 m
{
/ }6 I; W; o1 N4 v8 ^! s0 Q        int ret;
+ \/ n, E" i) r( G#if 05 u2 O( Z0 X1 `: P  O2 P
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 B/ J! V& Y2 y; g  S) r6 U        if (ret)
" p7 E  p5 `* j: a0 K                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 y+ q2 D9 t2 h' x5 v3 p$ O* s7 @/ y+ }
                                "%d\n", ret);9 Q) ~6 L$ w4 Y6 X: i3 i2 Q- E
#endif
8 g( Z! j$ V' y9 R1 V; @        ret = platform_device_register(&da850_evm_tl_leds_device);
0 t% l* i" H6 l% T2 ~        if (ret)
+ {! ?9 `( o& G                pr_warning("Could not register som GPIO expander LEDS");0 N  x# |* k7 m% U3 Z$ c9 U0 K3 v
        else
3 b$ \. C) X% y( F2 B: J" _                printk(KERN_INFO "LED register sucessful!\n");
1 e& C4 k9 X* c3 W- b5 L$ H! Y5 Q% v8 m) V: y2 o! L' m" k
        return ret;0 |* `" ?+ s3 l- ~1 f2 ~9 N+ A
}
1 Z! {1 Q0 x6 l/ j$ u6 a1 S4 [5 Z( d; ~. D3 V; m/ q
static void __exit led_platform_exit(void)
- x+ K- D2 C0 u2 m/ V{; p) T2 m8 @0 f' s% Z3 D# W1 |  O
        platform_device_unregister(&da850_evm_tl_leds_device);: f) ]4 G5 c3 a( ?& P
  M: m( }! R- ^% J1 z% Z9 c/ c1 ~& Z
        printk(KERN_INFO "LED unregister!\n");
  R  |; |+ A: X2 y% [}: R. `" W$ X% Q' {; A
) x) X$ F0 ~* a% D
module_init(led_platform_init);
% p2 n9 n; _# V( H' h7 P: D: t$ Gmodule_exit(led_platform_exit);7 x. G% t" @3 Q( ^: U; y3 v5 A
4 D1 n  e; w" D5 Z- ?+ ?6 F
MODULE_DESCRIPTION("Led platform driver");
$ f8 Y* B( Z" {8 _MODULE_AUTHOR("Tronlong");' W* p6 v: [: S9 ~/ u
MODULE_LICENSE("GPL");3 d; O/ X, X* h0 v

& S8 I& J! C* A0 D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-28 05:38 , Processed in 0.047585 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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