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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。9 s6 @  ?" D) U% X- a, P
#include <linux/init.h>2 E$ C  _2 i" ?9 F8 m
#include <linux/module.h>
* _, M6 Y7 B5 C: q#include <linux/kernel.h>7 Q% T7 k6 Q% t# I# |& J
#include <linux/types.h>
" m& ?  C: G, T/ c" o: a#include <linux/gpio.h>
" h- W: K* L0 L5 z; M#include <linux/leds.h>
4 l0 U+ \8 [$ ^% |; s" U" w#include <linux/platform_device.h>& n6 c- w5 q+ E# {1 w$ d+ f

& L  ]/ [0 ]$ O, T6 Y! }2 `, Y. f#include <asm/mach-types.h>) x/ G# U3 ^# I8 l
#include <asm/mach/arch.h>8 w' ^7 S- f& I& S
#include <mach/da8xx.h>, a8 c$ b: K1 F  _2 Q
#include <mach/mux.h>. r; {' u3 G' N* g& Q- e( C

) |' ~2 |; [& N% m- ]1 _#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)/ X& q+ j4 K- O/ P' c3 g
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
7 N9 A1 p* E5 d0 r# ^3 F7 M6 x#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)4 m, V& }" n6 j5 S$ Z3 a4 O1 X9 P
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)" ]; ?5 x+ ?6 r- j9 `* G( b
* N7 R2 `% Q/ E
/* assign the tl som board LED-GPIOs*/0 C0 V  i" g' C! H: X4 e
static const short da850_evm_tl_user_led_pins[] = {5 h4 o2 c6 U. A. Z
        /* These pins are definition at <mach/mux.h> file */2 K& ?- G2 B0 R
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 v" q+ t  m  S
        -1& f6 ^  ~2 Y! D5 S7 ^7 W7 K
};3 S0 m, x* |- K
$ B4 N" u+ ]( C2 n, S7 V: U* R
static struct gpio_led da850_evm_tl_leds[] = {
1 p* `: Z' W1 N2 U* N        {) L( @5 L6 Q3 P. G; T
                .active_low = 0,) E0 @: x9 M9 R
                .gpio = DA850_USER_LED0,  H6 f; G! |5 d3 l  q
                .name = "user_led0",
8 Z! S* j. N' ^  R/ {$ E* b; x                .default_trigger = "default-on",% X5 r: r5 @; b/ T6 S
        },
( n. ^# U7 _$ d+ e( I        {
( f* a4 j  L, F& t+ B                .active_low = 0,& d6 }2 W# u, c; T! D1 a- ?
                .gpio = DA850_USER_LED1,
* O6 c4 G# |9 X; d3 n6 D* ?                .name = "user_led1",
+ ?  n9 i% \' f" Y* b+ B6 ?                .default_trigger = "default-on",
1 U! G, b: B4 d, E' f        },
& Y/ Q( f2 c. z; i  [: P+ d0 h        {5 s/ ~% ]9 Z! R! r" E- H
                .active_low = 0,
4 t1 m% g3 `$ D                .gpio = DA850_USER_LED2,
5 C: x* U$ C) C( k  a                .name = "user_led2",
. U+ O! M/ R" u9 S                .default_trigger = "default-on",
8 R/ Z2 l# g. d( ~5 W        },
( V5 A( d: {4 e9 r" I: \        {
, |& [3 P) {" \                .active_low = 0,
+ I) J% @% s/ j                .gpio = DA850_USER_LED3,
0 l) X; Z2 t" z) f$ r                .name = "user_led3",: {- @, ~$ O  [8 r$ L
                .default_trigger = "default-on",3 P! Z( V2 l. h' t' A( R
        },# x& ?$ n  [/ V( m6 _% {2 L4 r
};& S( X4 {* |! i6 u( i( i

, S6 z" Z+ K  x  D$ Z# kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 h3 Q: ^# q: H- O' \+ R" r        .leds = da850_evm_tl_leds,8 ?$ v% h7 |# a3 p4 N0 x
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- i  \$ N5 S  C3 t) f4 \};
' _# E& i4 A# M) j4 l: r( `" Q( H$ |. J9 {' \
static void led_dev_release(struct device *dev)
, U8 f$ ^2 Z. w$ y  n. U{2 l- C, d4 K, W- z
};. d  P/ V1 m  p3 `4 @& a

* z& Y6 O! I9 J% N# Sstatic struct platform_device da850_evm_tl_leds_device = {4 F# e8 s8 k" V$ i$ D% X, `
        .name                = "leds-gpio",
9 y: F5 C. o% _9 Z0 I( E        .id                = 1,
5 r; u0 P, P# C: \        .dev = {( z9 Q. N( D+ f4 u
                .platform_data = &da850_evm_tl_leds_pdata,# x3 l! K$ @$ u! q2 V% l" k& J
                .release = led_dev_release,
( t1 c2 L$ Z! C3 F8 n2 f        }# a& h+ e* k) j
};
4 b* k8 W- H* ?& h* o
! h- i$ L" }8 v, Estatic int __init led_platform_init(void)
+ c* }- Y6 b$ W/ k# D9 v- ?{/ ^, K/ J& I" [/ n  a3 X$ ^
        int ret;
8 T9 U# p5 J0 d; l#if 03 o9 \0 @' r  |- a1 F$ A/ v+ r
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* F  Q0 Z% C4 k$ ?9 l! k! U        if (ret)/ M  M" I  E# H% ~
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# k7 }& {: b' B3 v' S0 {                                "%d\n", ret);
' j$ G! Q1 n! F; E#endif; |: |$ G: Z4 H9 T! ^8 u, {0 _
        ret = platform_device_register(&da850_evm_tl_leds_device);
' G! J* K0 H. m; N        if (ret)
0 ~  P  ?& }1 u# W                pr_warning("Could not register som GPIO expander LEDS");) e+ h/ s/ g" Z( D3 Z( ^: W
        else$ z& G6 q# C8 V) k% K) i
                printk(KERN_INFO "LED register sucessful!\n");1 e# |2 N, c3 J* q, q" Z- g2 u

+ f2 y: ]% u' d; K2 ^" u        return ret;2 X* l, R8 `  C, K  K% `
}; d7 x+ ^  q$ ]" w3 i" D; @3 @9 Z
% s0 m, P* l% E  ^
static void __exit led_platform_exit(void)
4 q  x4 J5 v4 Y. H{
+ \, n' f" F2 X        platform_device_unregister(&da850_evm_tl_leds_device);
% O- E  \! @. U2 [  O# o3 S5 e
        printk(KERN_INFO "LED unregister!\n");, F# J$ B3 p6 ~3 S
}4 z+ Q; v% ]5 l5 `1 y$ s8 m$ ]
- Y2 Y9 ^& u0 }8 B( }# t
module_init(led_platform_init);
- C# v* u+ Y' z/ J/ x1 P3 E! S4 D$ ?module_exit(led_platform_exit);( J9 @& Q" `$ n) I- [, ?
" v' [. `$ ?' c+ e) r2 G! H
MODULE_DESCRIPTION("Led platform driver");7 i* x; h4 }+ C1 z8 i+ T( C
MODULE_AUTHOR("Tronlong");2 E4 G) |7 z4 g7 z. A* v0 V
MODULE_LICENSE("GPL");
) l$ O8 r& b) {$ E. \2 z: r, {
$ Z: i8 v* L5 |- W. u7 v" [1 p0 G
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-9 07:35 , Processed in 0.038471 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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