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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
( W+ f3 {5 f! S#include <linux/init.h>
: H" Y4 A# e; ^#include <linux/module.h>
4 Q8 z1 h. s+ |* h4 x#include <linux/kernel.h>
% L7 L! |0 g7 O  n3 ]0 x5 l2 S#include <linux/types.h>' c+ l- t4 [  X4 T& Y: Q, u
#include <linux/gpio.h>/ r6 ~' g% g' i& E, t% A
#include <linux/leds.h>+ M+ l8 O, W, o, ^1 J8 B
#include <linux/platform_device.h>6 z4 d/ I( _9 v  R7 ^7 R+ y
# m; E- F8 ?- e$ g9 I8 ?$ z
#include <asm/mach-types.h>
# i0 U- j& `3 j% z#include <asm/mach/arch.h>
" ?7 |7 t4 K" F, [3 v#include <mach/da8xx.h>
( t6 c! ?/ D% s$ K5 m9 @#include <mach/mux.h>
/ t6 x" `& P" b6 l4 a
( A( r$ n" l) Q; o) M#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
. [# i+ t1 b9 D#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)8 m$ k: m; [5 t8 k& b: H
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)) A: O7 d$ i) v  M1 H/ h
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
* A* ^% Q! ^7 a5 ?0 V/ m, y; a
4 ?! l# X' R3 G2 x/* assign the tl som board LED-GPIOs*/! u) ~$ D$ X7 E+ F- T2 C
static const short da850_evm_tl_user_led_pins[] = {
' n; C# D5 O3 W8 J4 J% J& p6 C8 X+ G        /* These pins are definition at <mach/mux.h> file */9 G! X0 E# n" A7 Z8 y. y: {1 w, N: R/ b
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 e, @6 Y" ~1 s6 v
        -1
; q# n8 ~( z: c' k& H. n};- V9 e( |2 w* G* Y
: Q9 z2 Q5 b* f0 S/ t& j; t
static struct gpio_led da850_evm_tl_leds[] = {
$ i# j$ F0 C5 r7 F        {
+ _) E7 ]' i% V5 D6 D7 P                .active_low = 0,
8 G( T- r7 S; y) P/ I                .gpio = DA850_USER_LED0," d5 `. L8 @! Z0 g6 Z
                .name = "user_led0",1 W% x' U& b# I; ^9 B
                .default_trigger = "default-on",$ r3 }* _" `" f& A/ J4 I& N
        },
; g8 N$ W2 t' X! u8 l        {
. S/ n6 l/ @$ \2 f1 u" l+ W                .active_low = 0,
3 P7 A3 E+ N0 [3 h$ J9 g3 q; E3 e                .gpio = DA850_USER_LED1,
4 m$ f  c3 S$ r& k8 ]                .name = "user_led1",
6 }' J4 @2 U. O" h0 R! @& M                .default_trigger = "default-on",
. ]& V  t$ l/ u* K2 ~        },4 {. a% x/ y9 i3 h
        {
$ E& [/ [; Y- ~* F                .active_low = 0,/ }4 m, l) q6 U0 S& r) G: c+ v! o
                .gpio = DA850_USER_LED2,* H+ C: A* [' [$ E  P4 R
                .name = "user_led2",; g. y% z( T! u$ W+ N- U
                .default_trigger = "default-on",0 ]: [# O# Z. I0 S! w/ L
        },
2 [' s0 _' V2 s9 T' s: X$ V        {
) s- C8 S. d1 }# A                .active_low = 0,2 o) z  C) B% L1 Y# }( @7 c: c
                .gpio = DA850_USER_LED3,6 ~4 G# ~, F$ n. p
                .name = "user_led3",
; j+ i3 s+ N( O/ L                .default_trigger = "default-on",
6 j3 e4 }3 Q1 c/ A7 c6 M! F        },$ ^; p  c; ]' q- n5 E5 a; C- M) S
};
1 z8 ~! Y; s1 ]9 g/ ~7 c( n# G+ _7 h" N2 ^% o4 C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, o2 R1 N$ q/ E' ^: J        .leds = da850_evm_tl_leds," w1 D: E( s2 G' k5 o! f
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& s5 Q1 w- s) J. K};& r6 M. b0 ^) v4 l. f" N" [) ?

+ d* Y% Z$ P! U5 astatic void led_dev_release(struct device *dev)
$ s2 T" L2 P; E' c{, t' G; u5 Z4 A* V; J
};& ^9 ~$ P4 b  Y$ W

, C6 c- M3 O; r$ O2 f& x. }static struct platform_device da850_evm_tl_leds_device = {
5 j4 |! i: _: }" R( c6 v# z        .name                = "leds-gpio",
; Q& |, r- s! {9 |$ }        .id                = 1,
6 h- q5 D  Z+ l) R        .dev = {
  g/ R, Z  M& i' t% |# R                .platform_data = &da850_evm_tl_leds_pdata,! w( L! O- L- Y3 j& w1 m% l2 R
                .release = led_dev_release,+ F) z: ^, g$ g
        }  n% N& r5 v2 G1 L
};
1 O6 r" }' M0 z  t: s; g. u  G5 R# I7 ?8 i& L( i
static int __init led_platform_init(void)1 c  U2 n! Q4 t* Y. P; U. o, k* s
{
$ |$ B4 |6 E# a& h& G" m, s3 D. L        int ret;& f+ s5 i: e& O, g( s! w
#if 0
/ m* O; N9 w- R5 z* J& K        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 w( ]0 H1 Q( f/ B% }        if (ret)* ]& V+ t: x+ w' K
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 ^. c, e8 s2 U& ~3 @1 m' g- J
                                "%d\n", ret);/ U& V1 B4 M& r) g
#endif7 ^/ A7 ?* X" L$ N
        ret = platform_device_register(&da850_evm_tl_leds_device);
, F9 P+ r+ p  w6 l, m" q) M        if (ret)0 p1 s. O: Q3 d* @
                pr_warning("Could not register som GPIO expander LEDS");
% T1 i  g" K3 P0 T1 ^6 M4 ^( }        else
7 H! ?: r* i7 @                printk(KERN_INFO "LED register sucessful!\n");
% p0 {! z3 S. U# e! N% t/ A- A1 ]4 ]" Q' ^: b2 E4 V0 \
        return ret;; c: w# U' C2 z7 C( t
}
9 Z& `5 S& a9 w8 T
# I& N: s# E$ N& Q: Xstatic void __exit led_platform_exit(void)
+ j9 g9 G: l) H3 ?/ ~{+ |* j5 |  o1 D! ]7 E7 k' V
        platform_device_unregister(&da850_evm_tl_leds_device);) r& r* ~. p# s, V) G# C

  h2 p" g/ V" P% U" ]: w" ^        printk(KERN_INFO "LED unregister!\n");
1 s/ ~5 ?1 r. o. j3 s8 N  c) O8 t}
* y5 |6 [& s5 F% ^, \7 q/ ~
; v( g5 C* U3 i5 I1 m) F% gmodule_init(led_platform_init);
2 T- L2 t+ h# `& k$ smodule_exit(led_platform_exit);
. K2 p- d& t  x
6 |# s$ |6 C; d3 M5 J5 y+ [+ ^MODULE_DESCRIPTION("Led platform driver");
3 C. p% T; a9 @/ m/ aMODULE_AUTHOR("Tronlong");
2 {1 ]6 v4 v/ K. P$ Z% j) ~: `MODULE_LICENSE("GPL");; }; J  c. F0 h" p) t

4 w1 L. r. R& a9 A  t4 S
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-5 06:20 , Processed in 0.044048 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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