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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。9 J% X7 `, t* [$ e
#include <linux/init.h>
) c# M7 I4 R& V5 s0 @! d2 r#include <linux/module.h>
. H% A! i: }6 m6 t#include <linux/kernel.h>
0 S; l6 m8 \: G7 v+ ]) N#include <linux/types.h>
) g2 h; u  Q  Q, J#include <linux/gpio.h>  i# L  d" L0 a; ?2 S6 C
#include <linux/leds.h>  M8 N- K1 V1 A( ~1 N7 W+ Z$ y
#include <linux/platform_device.h>% \: A/ Z  J4 L0 K* @
4 T# X3 ]) K1 d3 s
#include <asm/mach-types.h>+ C# ]1 r5 y9 {5 [
#include <asm/mach/arch.h>
2 [+ ]6 J) `2 [$ y#include <mach/da8xx.h>9 }2 d/ M9 Q3 B. |6 H& C
#include <mach/mux.h>
8 b2 I& s, M  K$ p
' A* @# o0 V) M$ a& n5 t" ?: Z#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)! }9 R" v/ W, c, l+ w
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
6 ?% U2 P7 f6 L2 _' q1 e#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)" j+ S/ L8 |3 `  }% ?! b
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2): ?# e0 G3 e. Q* k% E

- G3 u8 k7 I2 ~% L3 m& f* X/* assign the tl som board LED-GPIOs*/: o% f. i3 \- A6 j* Y! g
static const short da850_evm_tl_user_led_pins[] = {3 Z6 O. g! ~! v) G$ k' |% }
        /* These pins are definition at <mach/mux.h> file */5 Y8 g' Q/ Z9 x& l" `% Y
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 O% ?% Y5 `; B- T9 n+ _/ f# O6 }
        -17 X/ n$ K: g) r6 E+ @8 _5 ~
};2 [# u7 {5 D6 V* J# W2 Y

& E4 W' k: q2 k, n4 rstatic struct gpio_led da850_evm_tl_leds[] = {. m, C) Y. V8 j( O' n
        {( C) W" e) p3 L4 Q1 c' c# I
                .active_low = 0,( r- a- H; X% H: C" c
                .gpio = DA850_USER_LED0,
1 r5 h7 e2 U7 k0 G: i% B, r                .name = "user_led0",
6 J  Q1 M) S& o8 s  ^4 g' ^! H                .default_trigger = "default-on",
. p9 T- D) k& w        },
& U0 y/ Q( z, D; q+ m        {7 h4 Q3 T% }' i. u' W: o# d
                .active_low = 0,
$ F; o0 Y) K7 @/ @' c9 _                .gpio = DA850_USER_LED1,
% L+ t( P- p/ ?# _! z                .name = "user_led1",7 A$ y# k  f2 a# F/ ]) T
                .default_trigger = "default-on",
  l  b; M: h) ~& T( F  H  U& P        },  d+ _: E/ i8 B2 {! }
        {6 S* Q( G1 M) I; N
                .active_low = 0,1 i9 A& w' R1 Q' o# R0 [) R& T
                .gpio = DA850_USER_LED2,
8 t6 A& P4 U% I# u6 v                .name = "user_led2",, u/ ?- h& x+ p
                .default_trigger = "default-on",9 P+ O) q3 r3 k8 R! p
        },# b% \2 [5 @/ O- ?) T
        {
# O2 a2 k! V" U+ x" `/ s" |                .active_low = 0,5 o5 r! q$ g3 C7 X4 @. c
                .gpio = DA850_USER_LED3,
/ Q' U2 a4 N, X0 p% T* l& P2 f                .name = "user_led3",
. A- G) t( _# ]1 I                .default_trigger = "default-on",
% M1 t, e! W8 b" K( X% ]! I        },
( C" ^- j  q" a- N) }" i0 s& e};
6 D4 o( Z9 G0 X5 V0 ^) w. F3 P6 ^, z" S' c- s( e; G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 A4 G: x+ x. P5 [# Q& A9 m& {
        .leds = da850_evm_tl_leds,1 o# S# @2 N$ h, R+ V! E0 p. N
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 J% d7 ~  v: m};. S/ E4 b  p2 I0 y# b5 @
( c) Y1 l. w& U- `! k. E
static void led_dev_release(struct device *dev)
, R0 F$ F# o! p2 q" w- o8 v- y0 i{+ ?  z! e# t6 x; Z* |
};& J, h$ q" X! g; u1 Z1 D. y8 l

. K9 Y! d) W6 M" k* K/ _static struct platform_device da850_evm_tl_leds_device = {
! B4 H  X% `. Y, ~4 l5 X7 Z        .name                = "leds-gpio",% z1 H  `* x5 O& y8 W. F" L8 y
        .id                = 1,9 c  p# b/ A  }( V$ F
        .dev = {
& J3 c; @1 W9 C. t7 c* w% G: o5 N                .platform_data = &da850_evm_tl_leds_pdata,
' N' a+ c+ N$ p+ Z6 e, R                .release = led_dev_release,) I3 b, R( ]. c& `" }2 m" d) C( t
        }
+ p; M4 t9 d! Z0 n! }};; f3 o# @4 n9 n/ L6 n/ G; G
" ^, X5 r- G5 q( @; ~
static int __init led_platform_init(void)
- G% o* Z- k1 v5 z2 y{' g  c% Y( `0 F6 `0 s
        int ret;
/ Y) n3 p6 `; a% ]6 D8 h9 J, Y' _#if 0
+ H4 Y- A  h2 N6 H/ ~% \$ G        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# U) I: i' D) {6 K0 \8 X) M
        if (ret)
: L, l0 I' h! x6 e0 p                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ T6 e) \' F' F1 K, a- }: a& P9 b                                "%d\n", ret);4 W+ I) L4 S/ k7 R
#endif
0 M: ]5 e3 n3 P, @        ret = platform_device_register(&da850_evm_tl_leds_device);8 y* L/ J/ \8 P) y
        if (ret)8 x& {4 i6 ]7 ?4 Y& ^1 h5 O- V
                pr_warning("Could not register som GPIO expander LEDS");4 y+ h! W: T& D0 Z& u0 A6 _! u# z- K
        else. h0 f3 A( y' [. ^4 [
                printk(KERN_INFO "LED register sucessful!\n");
; N4 A3 X1 h/ E+ j0 d# `# b3 A
+ F5 J# A4 v7 R4 M/ d/ F. f        return ret;
7 x; {0 V* B/ b) {2 u1 |* P% i}" A; d# t8 O8 K# q6 M
( P; O8 c  h- G4 v
static void __exit led_platform_exit(void)& T" Q3 |# i. B0 w6 ^$ O% a- I
{
* _* z/ K6 I2 @/ F        platform_device_unregister(&da850_evm_tl_leds_device);
1 K, l2 M2 i. ^' m, i
+ z: v0 E8 D. R- `5 L- N  W        printk(KERN_INFO "LED unregister!\n");+ m0 B9 F  t3 v
}' d/ `6 M! M9 ^2 w- f+ c2 k+ b

/ r( S: ?1 [4 l& M0 v2 j% xmodule_init(led_platform_init);8 X: @4 K. \& C, V
module_exit(led_platform_exit);
( Z/ o( l# h2 y( @1 |9 m
& @$ }2 O4 G- rMODULE_DESCRIPTION("Led platform driver");
. l8 v4 q  ]9 H- L7 w  ]- d- }MODULE_AUTHOR("Tronlong");  M" w9 }# k7 q7 Q& n
MODULE_LICENSE("GPL");
5 m) A: x  c3 T$ h* z( B% c
% U, E$ _* S- g. _$ b4 q; F
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-19 21:06 , Processed in 0.055174 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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