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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
& d; K" v' E7 x; C#include <linux/init.h>
/ V+ N  V+ o* t& S' x#include <linux/module.h>
. h2 q5 U0 D1 P/ q# B#include <linux/kernel.h>% m+ S; t! n0 D2 f1 K
#include <linux/types.h>
2 v' O6 l7 s! q5 y+ e#include <linux/gpio.h>' d! e4 v/ a' V; S" j5 @
#include <linux/leds.h>
4 V7 C6 H# }: y( C! y#include <linux/platform_device.h>
3 Q5 l" T3 ^8 }
) Y) s0 v2 s5 L  Z* f  V- W#include <asm/mach-types.h>
4 o* B) @* ?/ L* ?6 o#include <asm/mach/arch.h>
/ d8 e; C& h) a, ^: K#include <mach/da8xx.h>' w1 F5 g  T6 U8 d
#include <mach/mux.h>
  J; y3 }1 s: \/ X8 T
. S# [) d$ W3 N' S7 I; n: ~6 n6 n4 y#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
1 g6 E) A8 k: U; O#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
" O  o9 }# F+ @* w#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)! m; P3 E* @0 u. T
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
( B  v) Y  q* @  e8 I3 V  M# e' |5 N( _. {! U5 O* E( o, n
/* assign the tl som board LED-GPIOs*/
. {9 }( I) s' ?3 E0 T6 A0 I: V( lstatic const short da850_evm_tl_user_led_pins[] = {* V: Q$ d% J  B" L
        /* These pins are definition at <mach/mux.h> file */
( c3 i( |; g. j        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ u  B; J+ b7 {        -13 B+ ]- H2 o/ ~$ T& X. E
};
7 P+ S* t# [1 h7 z$ ^8 ]: V  c
+ ?/ |- b6 P6 U- {static struct gpio_led da850_evm_tl_leds[] = {
4 R7 m) u, Y$ Z  k( {# K% c        {$ I2 A# h7 m9 O$ ?* ~/ M' t
                .active_low = 0,
4 L0 W2 w' k$ V# z- z                .gpio = DA850_USER_LED0,8 D- K) R1 Y) b; |3 `
                .name = "user_led0",
# A: x: x% S( `' t' e! n                .default_trigger = "default-on",
5 C( Q  C( u; V        },
3 [! T+ d+ a' s+ r        {7 \( K) ]: D, g" `0 c9 H- I" H
                .active_low = 0,
. ^+ `# j8 A! ?5 q6 \! U0 Y; C                .gpio = DA850_USER_LED1,
9 y, k$ M5 s. O/ K3 J% ]                .name = "user_led1",- h" i* j; @+ G1 B; U; T8 D
                .default_trigger = "default-on",& ^0 D/ U$ x1 ?8 P
        },
2 G' L4 ^9 S6 O' ^! W- B& O1 `' T3 j        {
+ G: Y) I1 V8 i" }0 Z" B                .active_low = 0,' c- U( i/ d3 o  ~, q3 z
                .gpio = DA850_USER_LED2,
6 u- B1 r: D' m: B; z                .name = "user_led2",) w) B! }7 G, r; |8 E
                .default_trigger = "default-on",
1 T, g. _( f, x9 b9 W! o        },
1 H# z: w3 k( m- y7 l: O        {
$ w: }2 O; X# w3 _& B0 e                .active_low = 0,, x: A# Z+ }, h7 y; k
                .gpio = DA850_USER_LED3,: R9 |+ a6 i+ P3 h- d& k6 B
                .name = "user_led3",/ c3 Z. T! m8 I# W  v
                .default_trigger = "default-on",
$ V5 L/ r, V3 b" i; S; n1 X        },
; g1 K1 g7 j7 X/ p};
+ E. T! `: i! }' K1 C; ^, N1 C
5 n+ v8 P- n3 b* X. L3 hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. M' W) E- y# `7 g) F: c4 T        .leds = da850_evm_tl_leds,) W$ q7 h+ P1 f$ h
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: |( `1 n* {: ~" |};
: G, k; B5 V, N" n
& i5 |9 @4 c1 l0 p/ fstatic void led_dev_release(struct device *dev)* n3 h) o( p* i, i
{6 g& Z4 X% O  w; D
};
5 s6 |# q9 z' O: j2 _: U, I" ?1 G. f
, H4 V! o8 B6 g& |  r9 Tstatic struct platform_device da850_evm_tl_leds_device = {4 i' v( Z" h% g  ^
        .name                = "leds-gpio",% n9 H+ ?& }, j0 I
        .id                = 1,. s# U# o# Z: ]- T8 E
        .dev = {
6 \7 C$ w3 S8 p+ J& [; u3 k                .platform_data = &da850_evm_tl_leds_pdata,9 @2 _$ V2 h2 X" n, v0 q: N
                .release = led_dev_release,
( f" m( l5 V7 t& j1 a9 z. i8 \        }
! C# Y# f9 U5 \( L5 V6 }7 n};$ ?. T) @7 L) O8 r% x
. m+ M. q$ n) v* t# T+ g( C- ?5 q
static int __init led_platform_init(void)
5 S) D9 ?4 P7 ^7 \3 l{" U, C6 T! y* x8 j- |
        int ret;8 L) f/ [$ w1 e1 j% y4 Y8 Z0 C
#if 0
0 x3 q$ h3 _; r2 q        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 a% {" }- y' k9 H3 E
        if (ret)
4 }" S* f/ F/ |! W8 M                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# n3 Y; z( A* @4 ]% k' x
                                "%d\n", ret);" }' P1 H9 M7 R, ^: W6 h9 X8 s* W
#endif! Z) o, N1 Q% x& T9 ~5 A
        ret = platform_device_register(&da850_evm_tl_leds_device);
  r. l: ]& x& z' g+ B        if (ret)! N  O" l8 B: H
                pr_warning("Could not register som GPIO expander LEDS");8 G  U; e$ h' d2 V
        else
7 C8 g* ~/ l. u8 I+ D$ X; U                printk(KERN_INFO "LED register sucessful!\n");4 i9 b) D( J2 K+ G
# K0 m) Y; O, |) \
        return ret;; _; r, L0 @. n8 Q, |% G5 m
}
! O0 A. A/ c$ U' r/ d; N
2 w- D9 D& ~4 ]) w" \; s' I4 x3 tstatic void __exit led_platform_exit(void)! H* I; ~4 V0 i" p- y
{+ C1 T7 M7 W: p2 x. a' F5 d
        platform_device_unregister(&da850_evm_tl_leds_device);
9 N; X( W5 R) B& ^
6 }0 ]' Q7 S! y' C% |3 J        printk(KERN_INFO "LED unregister!\n");+ G8 o/ l( ^, v( f1 Y
}7 W' x4 F1 U8 g* p3 _

+ ?/ [9 i1 q3 ~0 ]module_init(led_platform_init);8 `' [+ `* o+ f
module_exit(led_platform_exit);+ w& w! P% p2 C  j

; ]3 r* J$ Y# j6 J% K- [7 b; W! }MODULE_DESCRIPTION("Led platform driver");
* H( ^4 H. e1 _4 k' E5 sMODULE_AUTHOR("Tronlong");
8 J" L, {; A7 L6 i. {8 KMODULE_LICENSE("GPL");; e: F9 g! \3 A3 ~( N0 }

, K  U8 q9 V/ a6 M2 Q- R: d
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-5 16:36 , Processed in 0.039331 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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