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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。& X* X0 w! h" d& e, u. g
#include <linux/init.h>
; v) v2 f8 l1 P2 \% D( b/ g0 C) {#include <linux/module.h>
# P, b/ Q, J& B* {7 E  g#include <linux/kernel.h>
! f: B! W/ m0 P#include <linux/types.h>2 [* e6 B1 B# e6 S) g& V
#include <linux/gpio.h>
' \4 t* ^' _# e5 z4 X* k#include <linux/leds.h>2 s) n0 Q1 C3 x1 O7 h
#include <linux/platform_device.h>2 @7 X% j3 H: e' p0 s% M

$ W. T: x% P- l: c2 S  e! b. e& M#include <asm/mach-types.h>
0 m& \3 K" L: v+ Y! k* P4 e#include <asm/mach/arch.h>
( s" z6 g8 l+ \. W* ]#include <mach/da8xx.h>
. `$ L. J3 m' F7 j* M/ m#include <mach/mux.h>& A8 A# }6 h6 f+ `( F+ k: H% T

/ f1 a& \' `+ ~$ L* ]#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)% n; ]  t0 ^5 C* w2 q- f0 Q0 r& ]5 V3 a
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)$ E/ R/ ~. B$ @. |9 a  j& t* G! }
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
) l: i$ P' v# Q8 n#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)/ d( Z# Z! r( O" ~% g: |# \

5 n1 I  b. B* F6 I/* assign the tl som board LED-GPIOs*/; s0 E$ A2 ?& {) e
static const short da850_evm_tl_user_led_pins[] = {: R: d5 [" y1 u) F7 M" J6 P4 A7 f
        /* These pins are definition at <mach/mux.h> file */
1 t6 Q( R5 i& r: \1 s        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. E+ ?9 i! Z0 N3 c/ M! I' A5 {        -1  }" x1 b. C2 Y! \5 n6 i; y
};- q3 y8 t5 Q2 _& U* m
6 g8 |! N  e$ Z* r) \
static struct gpio_led da850_evm_tl_leds[] = {- |5 d# r. Y0 a  g  i
        {
- N1 J1 h/ \9 B  S6 n                .active_low = 0,) s$ h9 [2 f; i2 z! J) H+ w
                .gpio = DA850_USER_LED0,& K2 f3 E4 {  K6 n' i3 F
                .name = "user_led0",5 t; z  v( C6 g2 [
                .default_trigger = "default-on",, R+ h0 k' }5 f  g; `: n! w
        },
8 s5 G. N4 G$ r        {0 U. K9 v9 r- w% X6 A$ ~
                .active_low = 0,# G# l9 R& K& f+ d$ O
                .gpio = DA850_USER_LED1,; r* Z+ o& W7 B! D
                .name = "user_led1",
6 Y5 _1 v( F; J7 S8 }                .default_trigger = "default-on",
; H( v9 d2 M; @& n. R+ |        },5 Y- F* r! P5 a* ^# ^  o' V
        {3 g+ ?+ F1 s, D* E1 G: Q2 ^$ b
                .active_low = 0,
( T8 _' t+ l; x! F3 ]/ s+ t, e- I, I                .gpio = DA850_USER_LED2,
, E6 n7 S, o" n                .name = "user_led2",3 n' f, a; K2 a% I/ E1 I/ }  d8 m; ?
                .default_trigger = "default-on",
! n2 Y" {9 B5 A$ r& L) H        },* g0 p8 N- @  s4 o  y
        {
/ I6 ?) Z& A% s0 {                .active_low = 0,
+ a+ z" u" f# P( N$ F                .gpio = DA850_USER_LED3,
- t  z" |  ~& w5 X$ d. L* L9 o2 Q( @$ C                .name = "user_led3",1 U  v! N* U3 n: ?2 a5 _
                .default_trigger = "default-on",# @1 U7 d" N9 g0 x
        },
# M7 z/ @1 q! `% |, q: x7 f1 W6 U};! b3 ^) O1 [+ F+ {: H

) a5 g' J5 I/ w5 N) Xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 W5 d7 R6 A+ O- s; x2 j" s        .leds = da850_evm_tl_leds,3 j' g/ q4 |; k5 ?) v  e5 o+ _
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 n2 _  K4 o: f4 Q2 W! v
};; R, w, D- j: q' \$ `
$ I, {& ~+ U* v) ]
static void led_dev_release(struct device *dev)
! |) E  J6 Y4 N7 U$ T; |$ S{* M3 X9 M- p8 n8 y! B5 T) ^' q
};5 b# |# K& d$ n& J) a
- ?! T7 O# ^1 u: n& O) L7 E/ j6 i. [
static struct platform_device da850_evm_tl_leds_device = {8 W& h0 V: e4 N, D
        .name                = "leds-gpio",
, m( u9 i0 R0 D( n8 I5 o        .id                = 1,
3 s, i* Y( T  I% g" v        .dev = {' u3 T6 E- b* ~% e
                .platform_data = &da850_evm_tl_leds_pdata,6 V0 |2 f- ]0 Q% r+ x. ~
                .release = led_dev_release,
' y" E6 r/ ]: z! j        }
& \7 D; i5 r% ^) x7 P};
, R% A* v7 \0 N* ]  B
% D4 H3 U+ N# vstatic int __init led_platform_init(void)  D5 n6 P0 k6 _( Q' k8 D
{8 \# I3 U2 z; f8 u
        int ret;  @' D$ m$ Q* [( t+ F! N' ?/ F
#if 0% N& ]) @6 @1 u7 ~+ c1 m3 b
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: c. ]& Y3 q2 C# ^; d: ^4 k
        if (ret)
. m: t2 h1 [% T7 k0 R. i( e8 G                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* \7 z9 R6 J$ b( m1 i/ t# [                                "%d\n", ret);
0 G6 j# u( z2 r1 ^3 A/ x#endif
9 i1 n7 i/ o+ C        ret = platform_device_register(&da850_evm_tl_leds_device);' d4 d, x6 U4 r- ?, [8 J  I
        if (ret)
6 ~- U8 S- t: s/ w- |                pr_warning("Could not register som GPIO expander LEDS");) r" q9 K# q# O' N0 ~$ g
        else! ?! I/ `+ s0 \- r9 P! j
                printk(KERN_INFO "LED register sucessful!\n");
. I) L3 Q- k& d- a( k& e) Z
! p# ?: Q3 X5 z) ~# s0 D) Z        return ret;3 ^" i- l% B  _. m
}
+ d. X* ~7 E1 o4 I  d2 M3 ]8 Q5 s
$ g7 s1 l4 y4 V3 L! X! ustatic void __exit led_platform_exit(void)
9 p0 a6 B9 \; D! W1 _{
9 l8 X! J, W3 Y        platform_device_unregister(&da850_evm_tl_leds_device);
7 o: H$ B9 @: ?4 ^# q
8 ?8 W* B* u: M; E. {        printk(KERN_INFO "LED unregister!\n");6 V, c. X1 `0 W5 B5 A5 |
}5 _; u. a* J  D9 J! {8 t

  R" m  O4 y3 A% @" C$ Umodule_init(led_platform_init);
8 h5 F& i  l( s5 w) f3 `( Kmodule_exit(led_platform_exit);
3 `# B: x  Q" x; O( q( D
1 O+ }8 [; A' n9 b  T9 {  gMODULE_DESCRIPTION("Led platform driver");% _4 `& R1 D; k
MODULE_AUTHOR("Tronlong");0 M& m: [9 v( j
MODULE_LICENSE("GPL");- D3 G. N0 m5 J: A) M  Z

/ g* f3 k3 R$ i9 p, ^: N7 V- Q# c
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-30 02:24 , Processed in 0.040959 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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