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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。7 }1 o! a$ O* m- g9 ~
#include <linux/init.h>7 ]' [. A: N! E. M$ _! J! o
#include <linux/module.h>, [# u6 c% G) {$ v9 a
#include <linux/kernel.h>
2 u# m: d3 d6 [+ \; o" f( I& J#include <linux/types.h>" P: b7 @7 k$ _) r  q
#include <linux/gpio.h>) ?- r  w+ S! c: Q0 |, D) g
#include <linux/leds.h># I. \9 q5 m; n9 u8 n0 _
#include <linux/platform_device.h>: m( _. l/ f8 B+ h6 K$ _1 U

  [: l, ^  J( ~4 F( f#include <asm/mach-types.h>
5 ]% Z. G* H3 M4 W4 @#include <asm/mach/arch.h>
" W& U0 b5 f8 N5 e5 U#include <mach/da8xx.h>
1 [: R( e- u& u/ k+ y4 ^#include <mach/mux.h>
# ^- ?8 V  q* m, n, A8 T# E; r7 b. L' Z
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)% J' X( }" g2 Y5 y" j
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
+ M* |8 f+ z$ W, z5 l" m& D#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
3 a: I. j) W7 h+ ?; n: T#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# q  k- f! ], u0 D, P, f' A1 `

/ W) y1 B$ L4 ]/ W8 e* ~/* assign the tl som board LED-GPIOs*/
) E1 s8 m; }) S; p# G% Kstatic const short da850_evm_tl_user_led_pins[] = {5 a0 }9 f( V" o0 S$ C" Y( O
        /* These pins are definition at <mach/mux.h> file */8 O7 ~+ h& f9 C6 w& Y
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 @; N' x( b  W, H% H        -1  @* H2 J5 A1 [; ~
};% c5 A: n9 x7 h6 T$ ~# C! O

( ?4 X5 D0 t0 R$ W; J8 t- ]static struct gpio_led da850_evm_tl_leds[] = {0 U+ g  E  N; q1 `
        {6 M% G( c" d0 U
                .active_low = 0,
+ o. m7 V+ \8 d$ O* y4 y4 ^                .gpio = DA850_USER_LED0,$ v1 {& M+ H: Y/ K6 d1 f
                .name = "user_led0",. H; h5 i0 Z" a
                .default_trigger = "default-on",
3 \' [; K' [* m# J: Q        },6 o/ V- g$ X: \$ |: C
        {
: H# C% P. v. z" g. z4 _                .active_low = 0,
0 @' ?# a' }0 _2 z2 V' ?7 C                .gpio = DA850_USER_LED1,
- f8 g* }7 f; {                .name = "user_led1",, A; D% Q0 C( h. \& |+ ^* N
                .default_trigger = "default-on",
" \8 j0 Z$ o4 X0 w/ w        },, ]3 K( }5 b9 s* k2 i) o& _0 H
        {
- r- y' b. S# r. u% U8 J8 M. z# A                .active_low = 0,, o) S# u5 z7 S- o/ G: S
                .gpio = DA850_USER_LED2,* ~, W$ P! i) y8 a/ G+ g+ F3 _" D
                .name = "user_led2",  @9 ^* n) j' r& |! J
                .default_trigger = "default-on",; G5 S  l, `" h& o! ?# t
        },/ W& W1 |5 P: I# g% ^. B) Y
        {7 m( }. E/ f/ c3 ~
                .active_low = 0,- s3 m( x+ t7 e/ Q' i8 c
                .gpio = DA850_USER_LED3,' ?- ~! [0 {) w( _6 h# ^9 M
                .name = "user_led3",3 q- w- z1 \8 }4 k' c" U0 V& ~! J
                .default_trigger = "default-on",
/ L0 d# C+ W- I2 a/ z# ?4 p        }," C' a9 I, P; ?1 N- a  n0 Z# m
};
* {+ T+ e3 n- w& P" g
9 D+ C, N% t( C. n" Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 A1 z) r9 ?. S9 ?6 p: Z% W/ ?        .leds = da850_evm_tl_leds,! d3 L5 z  F2 \( @$ u  z$ ~  N6 L
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) K; m3 N  ]- g$ I$ Y0 E4 l% P};9 i  E; ]& h4 v. |- c

, Z! V6 z1 x2 U7 Zstatic void led_dev_release(struct device *dev)5 z/ s( |( `3 k; i
{
$ W2 ?( U/ Z# z7 ~; _* ~& d};/ p; }' M# W, a8 z, K" \$ D% N- ?  L
$ g/ q8 ~* t4 d% I
static struct platform_device da850_evm_tl_leds_device = {
. E. C* _, A" ?$ v' v/ C* `! q        .name                = "leds-gpio",
' l; n3 G- c( t0 l        .id                = 1,; [, e0 C1 _2 v0 e" q) J
        .dev = {/ e! c3 e8 ~/ Q% f' W6 b
                .platform_data = &da850_evm_tl_leds_pdata,
2 m( c2 ~4 J0 \  d: a                .release = led_dev_release,
9 M  m1 E1 e- |8 Q        }
. S. V- G' m5 n};" j7 H9 n# u* f! s4 ]# t) O
) t6 S$ o) z2 E& _) D3 p
static int __init led_platform_init(void). }' N: a# m) `7 O5 M1 }0 @
{' N# H0 l8 W$ X$ Y! A
        int ret;
( \, r; T+ t+ v9 y1 L$ r  ~- V& b) w4 k#if 0/ k* d/ V+ F( o( f( X9 x
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; ~; Y; n- g5 m: _& e5 }        if (ret). x9 `( [8 m0 `& o
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- W3 u6 \' Q/ A- l* W# L1 R7 w0 U$ n                                "%d\n", ret);: ]1 v9 C; ?5 ~# p0 h6 N
#endif+ M9 e+ N& Z  [7 V0 w$ @
        ret = platform_device_register(&da850_evm_tl_leds_device);& l8 |2 E3 e1 V
        if (ret)
+ k3 R& A: O8 B2 F                pr_warning("Could not register som GPIO expander LEDS");
: n. x3 o$ e1 b6 n# c        else9 l: ?/ b0 K9 i3 ?
                printk(KERN_INFO "LED register sucessful!\n");7 I' `. l8 H7 X) t8 a" A3 v
2 g; ^' Z3 J# ~1 m7 [6 H$ A
        return ret;* s  E; v% {7 V! a
}5 M, d* N1 T. g, g) d  F

/ z/ i7 Y: F# x  Y/ j; fstatic void __exit led_platform_exit(void)0 t! V9 Q- _- a. P4 }% s! [0 U
{3 d6 N9 d, e4 M9 K- ]9 f4 ?
        platform_device_unregister(&da850_evm_tl_leds_device);
+ |+ k+ @; T' C, u; g
; h3 M+ U  E+ a% ~4 N: H        printk(KERN_INFO "LED unregister!\n");7 Y/ d; s/ K. d1 M
}; g1 n) m* f$ ^: _- m4 X
! R) \+ I& x& v4 P# Y# R! C* ?3 I. i
module_init(led_platform_init);
) b$ I7 i, p( a$ v5 Kmodule_exit(led_platform_exit);& R8 o: T; b5 k. ^
+ U( S, x$ X% F5 o9 S3 P
MODULE_DESCRIPTION("Led platform driver");
" n1 v% _1 o$ ^; b) K7 {! IMODULE_AUTHOR("Tronlong");
" ~! O  m% t) P; Q+ s. G( W" e2 GMODULE_LICENSE("GPL");
) E3 E; g1 S0 r. X8 M: _
, l# Z0 B; M& ^
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-23 11:54 , Processed in 0.039936 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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